/* ============================================================
   Sterling Meats admin theme
   Design system from the Claude Design handoff (maroon + IBM Plex).
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    --maroon: #9E2B33;
    --maroon-dark: #8A242B;
    --ink: #16191D;
    --ink-soft: #1A1D21;
    --text-secondary: #5B6470;
    --text-muted: #8A929C;
    --bg: #F5F6F7;
    --card: #ffffff;
    --border: #E7E9EC;
    --border-input: #E2E5E9;
    --row-border: #F0F1F3;
    --head-bg: #FAFBFB;
    --green: #2E9E63;
    --green-dark: #26824F;
    --red: #C24B53;
    --red-dark: #A83A42;
    --sidebar-bg: #14181D;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
    --radius: 12px;
    --radius-ctl: 9px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, .04);
}

html, body {
    font-family: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--ink-soft);
    background: var(--bg);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D4D8DD; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #C0C5CC; }

/* ---- Typography ---- */
h1, h2, h3, h4, h5 { color: var(--ink); font-weight: 600; letter-spacing: -.3px; }
h1 { font-size: 25px; margin-bottom: .25rem; }
h1:focus { outline: none; }
h3 { font-size: 18px; margin-top: 1.5rem; }
h5 { font-size: 14.5px; }
p { color: var(--text-secondary); font-size: 13.5px; }

a, .btn-link { color: var(--maroon); text-decoration: none; }
a:hover, .btn-link:hover { color: var(--maroon-dark); text-decoration: underline; }

code { color: var(--maroon); font-family: var(--mono); font-size: .85em; }

/* ---- Buttons ---- */
.btn {
    border-radius: var(--radius-ctl);
    font-weight: 600;
    font-size: 13.5px;
    padding: .5rem .95rem;
}

.btn-primary {
    color: #fff;
    background-color: var(--maroon);
    border-color: var(--maroon);
    box-shadow: 0 1px 2px rgba(158, 43, 51, .3);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--maroon-dark) !important;
    border-color: var(--maroon-dark) !important;
    color: #fff;
}

.btn-success { color: #fff; background-color: var(--green); border-color: var(--green); }
.btn-success:hover, .btn-success:focus, .btn-success:active {
    background-color: var(--green-dark) !important; border-color: var(--green-dark) !important; color: #fff;
}

.btn-danger { color: #fff; background-color: var(--red); border-color: var(--red); }
.btn-danger:hover, .btn-danger:focus, .btn-danger:active {
    background-color: var(--red-dark) !important; border-color: var(--red-dark) !important; color: #fff;
}

.btn-secondary {
    color: #3A4149; background-color: #fff; border-color: var(--border-input);
}
.btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active {
    background-color: #F4F5F6 !important; border-color: #D8DCE1 !important; color: #3A4149 !important;
}

.btn-sm { font-size: 12.5px; padding: .3rem .6rem; }

/* Table action links (Edit / Delete) */
.btn-link { font-weight: 600; padding: .2rem .4rem; }
.btn-link.text-danger { color: var(--maroon) !important; }

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(158, 43, 51, .15);
}

/* ---- Forms ---- */
.form-control, .form-select {
    border: 1px solid var(--border-input);
    border-radius: var(--radius-ctl);
    font-size: 13.5px;
    color: var(--ink);
    padding: .5rem .75rem;
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--maroon);
    box-shadow: 0 0 0 3px rgba(158, 43, 51, .12);
}

label, .form-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .4px;
    text-transform: uppercase;
    margin-bottom: 5px;
}
.form-check-label { text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--ink-soft); font-weight: 500; }

/* ---- Tables (pages render bare `.table`; give them the card look) ---- */
.table {
    --bs-table-bg: #fff;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    /* Not 'hidden': that clips the row-action (…) dropdown for the bottom row. Corners are
       rounded per-cell below (tr:first/last-child) so we don't need overflow to clip them. */
    overflow: visible;
    margin-bottom: 1.25rem;
    color: var(--ink-soft);
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background: var(--head-bg);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .4px;
    text-transform: uppercase;
    border-bottom: 1px solid #EEF0F2;
    padding: 11px 16px;
    white-space: nowrap;
}
.table tbody td {
    font-size: 13.5px;
    padding: 12px 16px;
    border-top: 1px solid var(--row-border);
    vertical-align: middle;
}
.table tbody tr:first-child td { border-top: none; }
.table tbody tr:hover { background: #FAFAFB; }
.table.table-bordered, .table.table-bordered td, .table.table-bordered th { border-color: var(--row-border); }

.table-responsive { border-radius: var(--radius); }

/* Round the card corners on the first/last cells (border-collapse: separate). */
.table thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
.table thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
.table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

/* Inline add/edit forms on data pages sit in their own card instead of spanning the page. */
.app-content form {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    margin-bottom: 1.25rem;
    max-width: 580px;
}

/* Generic white card panel (e.g. the Reports builder controls). */
.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    margin-bottom: 1.25rem;
}

/* Page heading + optional maroon eyebrow (use <p class="eyebrow"> above an <h1>). */
.eyebrow {
    font-size: 12px;
    font-weight: 600;
    color: var(--maroon);
    letter-spacing: .4px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

/* ---- Alerts / validation ---- */
.alert-danger {
    background: #F8ECEC; border: 1px solid #EBD3D4; color: var(--maroon);
    border-radius: var(--radius-ctl); font-size: 13.5px; font-weight: 500;
}
.text-danger { color: var(--maroon) !important; }
.text-muted { color: var(--text-muted) !important; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--green); }
.invalid { outline: 1px solid var(--red); }
.validation-message { color: var(--maroon); font-size: 12px; }

/* ============================================================
   Framework / template chrome (kept, recoloured)
   ============================================================ */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #9E2B33;
    padding: 1rem 1rem 1rem 1rem;
    color: white;
    border-radius: var(--radius-ctl);
}
    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}
    .loading-progress circle {
        fill: none;
        stroke: #e7e9ec;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }
        .loading-progress circle:last-child {
            stroke: var(--maroon);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--text-secondary);
}
    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* ---- Page toolbar (search + actions) ---- */
.page-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-toolbar .search-input { max-width: 340px; flex: 1; min-width: 200px; }
.page-toolbar .spacer { flex: 1; }

/* ---- Page header: title on the left, search + actions on the right (same row) ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head h1 { margin-bottom: 0; }
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head-actions .search-input { width: 260px; flex: none; max-width: 100%; }

.actions-col { width: 56px; text-align: right; }

/* ---- Row action (…) menu ---- */
.rowmenu { position: relative; display: inline-block; }
.rowmenu-btn {
    background: none; border: 1px solid transparent; border-radius: 7px;
    width: 30px; height: 30px; font-size: 18px; line-height: 1;
    color: var(--text-muted); cursor: pointer;
}
.rowmenu-btn:hover { background: #F0F1F3; color: var(--ink); }
.rowmenu-overlay { position: fixed; inset: 0; z-index: 1000; }
.rowmenu-panel {
    position: absolute; right: 0; top: 34px; z-index: 1001;
    background: #fff; border: 1px solid var(--border); border-radius: 9px;
    box-shadow: 0 6px 20px rgba(16, 24, 40, .12); min-width: 150px; padding: 5px;
}
.rowmenu-panel button {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    background: none; border: none; padding: 8px 10px; border-radius: 6px;
    font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.rowmenu-panel button:hover { background: #F4F5F6; }
.rowmenu-panel button.danger { color: var(--maroon); }
/* Bottom row: open the menu upward so it's never clipped by / dangling below the grid. */
.table tbody tr:last-child .rowmenu-panel { top: auto; bottom: 34px; }

/* ---- Modal dialog ---- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 56px 16px; z-index: 1050; overflow-y: auto;
}
.modal-card {
    background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
    box-shadow: 0 16px 48px rgba(16, 24, 40, .22);
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-x { background: none; border: none; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 18px 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* A form inside a modal is not the page-level card. */
.modal-body form { background: none; border: none; box-shadow: none; padding: 0; margin: 0; max-width: none; }

/* ---- Dashboard ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 16px 0 18px; }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 17px 18px; box-shadow: var(--shadow-card); }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.kpi-value { font-family: var(--mono); font-size: 27px; font-weight: 600; color: var(--ink); margin-top: 9px; letter-spacing: -.5px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; align-items: stretch; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-grid .panel h5 { margin: 0; }
.dash-grid .panel > .text-muted { margin: 2px 0 14px; }

.trend { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.trend-bar { width: 100%; max-width: 34px; background: var(--maroon); border-radius: 6px 6px 3px 3px; min-height: 2px; }
.trend-label { font-size: 10.5px; color: var(--text-muted); }
.trend-val { font-size: 10.5px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }

.bar-row { margin-bottom: 13px; }
.bar-row-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: 13px; color: var(--ink-soft); }
.bar-track { height: 8px; background: #F0F1F3; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--maroon); border-radius: 5px; }

.mono { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }
.num { text-align: right; }

/* ---- Loading spinner ---- */
.spinner { display: flex; justify-content: center; padding: 32px 0; }
.spinner-ring {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid #E2E5E9; border-top-color: var(--maroon);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
