:root {
    /* Color scale — richer, more legible than the old flat #666/#777/#888/#999 grays */
    --text: #0F172A;
    --text-body: #334155;
    --text-muted: #64748B;
    --text-faint: #94A3B8;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --surface: #fff;
    --bg: #F6F7F9;

    --brand: #F26B1D;
    --brand-dark: #C9530E;
    --brand-soft: #FDECDF;

    --success: #1E9E5A;
    --success-dark: #16794A;
    --success-soft: #EAF7F0;

    --danger: #DC2626;
    --danger-dark: #B91C1C;
    --danger-soft: #FEF2F2;

    --warn: #D97706;
    --warn-soft: #FFFBEB;

    --info: #3A7BD5;
    --info-soft: #EEF4FD;

    --header-blue: #5DADE2;

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
    --shadow-md: 0 8px 24px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text-body); }

h1, h2, h3 { color: var(--text); }

.loading-shell { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--text-muted); }

#blazor-error-ui {
    display: none;
    background: #fffae6; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    left: 0; padding: 0.75rem 2.5rem 0.75rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
    font-size: 0.95rem; color: var(--text-body, #334155);
}
#blazor-error-ui .reload {
    display: inline-block; margin-left: 1rem;
    background: var(--brand, #F26B1D); color: #fff; border-radius: 6px;
    padding: 0.35rem 0.9rem; text-decoration: none; font-weight: 600; white-space: nowrap;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.app-topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--brand); }
.brand-mark { width: 24px; height: 24px; object-fit: contain; }
.business-pill, .user-pill { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--text-body); }
.topbar-right { margin-left: auto; }
.user-pill em { font-style: normal; color: var(--text-muted); margin-left: 4px; }

.app-body { display: flex; flex: 1; min-width: 0; }

/* ---------- Navigation: mobile-first = fixed bottom bar, collapsed to a
   few "primary" items + a More toggle that expands the rest in place. ---------- */
.app-nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    display: flex; justify-content: space-around; align-items: stretch; gap: 0;
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    z-index: 900; padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 8px 2px; text-decoration: none; color: var(--text-muted); font-size: .64rem; font-weight: 600;
    border: none; background: none; text-align: center; cursor: pointer; width: auto;
}
.nav-item .ico { font-size: 1.2rem; line-height: 1; }
.nav-item:hover, .nav-item.active { color: var(--brand); }
.nav-item.signout { margin-top: 0; }

/* Collapsed (default) mobile bar: only primary items + the More/Close toggle show */
.nav-item:not(.primary):not(.nav-more-toggle) { display: none; }

.app-nav.expanded {
    display: grid; grid-template-columns: repeat(4, 1fr);
    height: auto; max-height: 70vh;
    overflow-y: auto; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.15);
    padding: 12px 8px;
}
.app-nav.expanded .nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 4px; font-size: .68rem; text-align: center; border-radius: 12px;
}
.app-nav.expanded .nav-item .ico { font-size: 1.5rem; }
.app-nav.expanded .nav-item:hover, .app-nav.expanded .nav-item.active { background: var(--bg); }

/* padding-bottom must clear the fixed .app-nav bar below it. .app-nav pads itself by
   env(safe-area-inset-bottom) (line 84) to dodge the home-indicator on notched phones, which
   makes its real rendered height taller than the ~66px base case on those devices — but this
   was a bare 76px, so on any phone with a non-zero safe-area inset the bar grew past that
   clearance and could sit over the bottom of the page's content. That's exactly where the
   Inventory "Add item" form's Next/Save button lives, with "Home" as the nav's first (leftmost)
   item right under it — a tap aimed at the button could land on Home instead, on those devices.
   Add the same safe-area term here so the two paddings track each other. */
.app-content { flex: 1; min-width: 0; padding: 16px; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0)); overflow-x: auto; }

@media (min-width: 768px) {
    .app-nav, .app-nav.expanded {
        position: static; width: 180px; flex-shrink: 0; height: auto; max-height: none;
        background: var(--surface); border-top: none; border-right: 1px solid var(--border); box-shadow: none;
        border-radius: 0; padding: 12px 0; flex-direction: column; align-items: stretch;
        justify-content: flex-start; gap: 2px; overflow-y: visible;
    }
    .nav-item:not(.primary):not(.nav-more-toggle),
    .nav-item.primary,
    .app-nav.expanded .nav-item {
        display: flex; flex: none; flex-direction: row; justify-content: flex-start; gap: 10px;
        padding: 10px 16px; font-size: .9rem; text-align: left;
    }
    .nav-item .ico { font-size: 1.05rem; }
    .nav-item:hover, .nav-item.active { background: var(--bg); }
    .nav-item.signout { margin-top: auto; color: var(--danger); }
    .nav-more-toggle { display: none; }

    .app-content { padding: 24px; padding-bottom: 24px; }
}

.ico { font-size: 1.05rem; line-height: 1; }
.lbl { }

/* =========================================================================
   Tabs — combine closely-related pages into one hub instead of separate nav items
   ========================================================================= */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab-bar .tab-item {
    padding: 10px 16px; border: none; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-family: inherit;
    font-weight: 600; font-size: .88rem; color: var(--text-muted);
    margin-bottom: -1px; white-space: nowrap; border-radius: 0;
}
.tab-bar .tab-item:hover { color: var(--text); background: none; }
.tab-bar .tab-item.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* =========================================================================
   Page header — every page starts with one of these instead of a bare <h1>
   ========================================================================= */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
    flex-wrap: wrap; margin-bottom: var(--space-5); padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}
.page-header h1 { margin: 0; font-size: 1.4rem; font-weight: 800; color: var(--text); }
.page-header .page-subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: .86rem; max-width: 640px; line-height: 1.5; }
.page-header .page-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* =========================================================================
   Card — the base surface for grouping content
   ========================================================================= */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm); padding: var(--space-5); margin-bottom: var(--space-5);
}
.card:last-child { margin-bottom: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card h2 { font-size: 1.02rem; }
.card h3 { font-size: .92rem; }

/* Quick-action cards (Home landing page) */
.action-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-4); }
.action-card {
    display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: var(--space-4); box-shadow: var(--shadow-sm); text-decoration: none;
    color: inherit; transition: box-shadow .15s, border-color .15s;
}
.action-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.action-card .action-ico { font-size: 1.5rem; }
.action-card .action-title { font-weight: 700; color: var(--text); font-size: .95rem; }
.action-card .action-desc { color: var(--text-muted); font-size: .82rem; line-height: 1.4; }

/* =========================================================================
   Forms — label-above-field, fixes the inline label/input wrapping bug
   ========================================================================= */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 var(--space-5); }
.form-grid .field-full { grid-column: 1 / -1; }
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); min-width: 0; }
.field > label { font-size: .8rem; font-weight: 600; color: var(--text-body); }
.field .field-hint { font-size: .76rem; color: var(--text-muted); margin-top: -2px; }
.field-check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.field-check label { font-size: .86rem; font-weight: 500; color: var(--text-body); }
.field-check input[type="checkbox"], .field-check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand); }

.form-actions { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-2); flex-wrap: wrap; }

/* =========================================================================
   Buttons — consistent hierarchy everywhere
   ========================================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 700;
    cursor: pointer; border: 1px solid transparent; font-family: inherit; line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text-body); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-ghost { background: none; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text-body); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #F3C7C7; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-block { width: 100%; }

/* Icon-only buttons — table-row actions (Edit/Deactivate/Remove/etc.) show a single
   glyph instead of a text label; the title attribute carries the accessible name.
   No fill/border regardless of the btn-primary/secondary/danger modifier it's paired
   with — just the glyph on a transparent background. */
.app-content .btn-icon { padding: 6px 8px; font-size: .95rem; line-height: 1; background: transparent; border-color: transparent; }
.app-content .btn-icon:hover:not(:disabled) { background: var(--bg); }
.btn-icon.btn-sm { padding: 4px 7px; font-size: .88rem; }

/* =========================================================================
   Badges — colored status pills instead of plain text
   ========================================================================= */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
}
.badge-active { background: var(--success-soft); color: var(--success-dark); }
.badge-inactive { background: #F1F5F9; color: var(--text-muted); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* =========================================================================
   Tables — wrap the existing .staff-table markup in .table-card
   ========================================================================= */
.table-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm); overflow-x: auto; margin-bottom: var(--space-5);
}
.table-card .staff-table { margin-bottom: 0; }
.staff-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.staff-table th, .staff-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: .86rem; white-space: nowrap; }
.app-content .staff-table th { color: var(--header-blue); font-weight: 700; font-size: .8rem; background: var(--bg); }
.staff-table tbody tr:hover { background: var(--bg); }
.staff-table tbody tr:last-child td { border-bottom: none; }
.staff-table td.num, .staff-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Shared page-content components */
.filter-row { display: flex; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }
.filter-row .field { margin-bottom: 0; }
.card-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--bg); border-radius: 12px; padding: 12px 16px; min-width: 130px; }
.stat-label { display: block; font-size: .75rem; color: var(--text-muted); }
.stat-value { display: block; font-size: 1.3rem; font-weight: 800; color: var(--brand-dark); }
.two-col { display: flex; gap: 24px; flex-wrap: wrap; }
.late-row { background: var(--danger-soft) !important; }
.ledger-panel { padding: 12px; background: var(--bg); border-radius: 8px; }
.ledger-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }

/* Generic fallback styling for pages without their own form/table CSS */
.app-content input, .app-content select, .app-content textarea {
    padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: .9rem; font-family: inherit; color: var(--text); background: var(--surface);
    width: 100%;
}
.app-content input:focus, .app-content select:focus, .app-content textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.app-content input[type="checkbox"], .app-content input[type="radio"] { width: auto; accent-color: var(--brand); }
.app-content button {
    padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--brand); color: #fff;
    font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit;
}
.app-content button:disabled { opacity: .55; cursor: default; }
.app-content table { border-collapse: collapse; width: 100%; }
.app-content th, .app-content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: .88rem; }
.app-content th { color: var(--text-muted); font-weight: 600; }

.auth-shell { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; gap: 4px; }
.auth-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-md); }
.auth-card h1 { display: flex; align-items: center; gap: 8px; margin: 0 0 2px; color: var(--brand); }
.auth-card .sub { color: var(--text-muted); margin: 0 0 18px; font-size: .9rem; }
.auth-card label { display: block; font-size: .82rem; font-weight: 600; margin: 12px 0 4px; color: var(--text-body); }
.auth-card input, .staff-table + form input, .staff-table + form select {
    width: 100%; padding: 9px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: .95rem;
}
.auth-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.auth-card button, form button { margin-top: 18px; width: 100%; padding: 10px; border: none; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; }
.auth-card button:disabled, form button:disabled { opacity: .6; cursor: default; }
.auth-card .switch { margin-top: 14px; font-size: .85rem; text-align: center; color: var(--text-muted); }
.auth-card .switch a { color: var(--brand-dark); font-weight: 600; }
.form-error { color: var(--danger); font-size: .85rem; margin-top: 10px; }
.form-success { color: var(--success-dark); font-size: .9rem; font-weight: 600; margin-top: 10px; }

/* Terms/Privacy — wider than .auth-card since it's a long-form document, not a login form. */
.legal-page {
    width: 100%; max-width: 680px; background: var(--surface); border-radius: var(--radius-lg);
    padding: 28px 32px; box-shadow: var(--shadow-md); line-height: 1.6;
}
.legal-page h1 { color: var(--brand); margin: 0 0 4px; }
.legal-page h2 { font-size: 1.05rem; margin: 22px 0 6px; }
.legal-page .sub { color: var(--text-muted); margin: 0 0 18px; font-size: .85rem; }
.legal-page a { color: var(--brand-dark); }

.auth-footer { display: flex; justify-content: center; gap: 16px; margin-top: 16px; font-size: .8rem; }
.auth-footer a { color: var(--text-muted); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.hint { color: var(--text-muted); font-size: .8rem; margin: 2px 0 0; line-height: 1.5; }
