/* =====================================================================
   TERMINAL ONE — design system v2
   Restyled to match the LEGEND family look: classic retro admin-panel
   aesthetic (black borders, green/navy/amber, 3D outset/inset buttons,
   Tahoma), with a light/dark toggle via [data-theme="dark"] on <html>.

   Class names are unchanged from v1 on purpose — every admin/branch page
   still works untouched; only the rules under each selector changed.
   ===================================================================== */

:root {
    /* --- brand / semantic colors (constant across light & dark) --- */
    --green: #004d00;
    --green-light: #008000;
    --green-dark: #003300;
    --navy: #000080;
    --red: #b30000;
    --red-light: #cc0000;
    --amber: #d4880f;
    --amber-light: #e6a017;
    --grey-btn: #c0c0c0;

    /* --- surfaces / text (flip in dark mode below) --- */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #e8e8e8;
    --text: #000000;
    --text-dim: #333333;
    --text-faint: #666666;
    --border: #000000;
    --table-even: #fafafa;
    --hover-bg: #f0f0f0;
    --input-bg: #ffffff;
    --input-border: #999999;
    --modal-bg: #ececec;
    --modal-footer: #dcdcdc;
    --scrollbar-track: #e0e0e0;
    --scrollbar-thumb: #666666;
    --scrollbar-border: #444444;
    --shadow-color: rgba(0, 0, 0, 0.3);

    --font-body: Tahoma, Arial, sans-serif;
    --font-mono: "Courier New", monospace;
    --sidebar-w: 220px;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --surface: #1a1a1a;
    --surface-alt: #2a2a2a;
    --text: #e8e8e8;
    --text-dim: #cfcfcf;
    --text-faint: #999999;
    --border: #ffffff;
    --table-even: #222222;
    --hover-bg: #2a2a2a;
    --input-bg: #111111;
    --input-border: #555555;
    --modal-bg: #1a1a1a;
    --modal-footer: #2a2a2a;
    --scrollbar-track: #2a2a2a;
    --scrollbar-thumb: #666666;
    --scrollbar-border: #444444;
    --shadow-color: rgba(255, 255, 255, 0.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.45;
}

body { height: 100vh; overflow: hidden; }

h1, h2, h3, h4 {
    font-family: var(--font-body);
    font-weight: bold;
    color: var(--text);
    margin: 0 0 0.5em 0;
}

h1 { font-size: 1.35rem; text-transform: uppercase; letter-spacing: 0.3px; }
h2 { font-size: 1.05rem; text-transform: uppercase; padding-bottom: 6px; border-bottom: 2px solid var(--border); margin-bottom: 12px; }
h3 { font-size: 0.92rem; text-transform: uppercase; color: var(--text-dim); letter-spacing: 0.3px; }

a { color: var(--navy); text-decoration: none; }
[data-theme="dark"] a { color: #6db3ff; }
a:hover { text-decoration: underline; }

p { margin: 0 0 1em 0; color: var(--text-dim); }

.num, input[type="number"], td.num, .money { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---------------------------------------------------------------------
   Accessibility utilities
   --------------------------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 10px;
    z-index: 100;
    background: var(--amber);
    color: #000000;
    padding: 10px 18px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85rem;
    border: 2px solid #000000;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: 10px;
    outline: 3px solid #000000;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ---------------------------------------------------------------------
   App shell — fixed full-height "terminal application" feel
   --------------------------------------------------------------------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Topbar: always visible (was mobile-only in v1) */
.topbar {
    display: flex !important;
    align-items: center;
    height: 42px;
    flex-shrink: 0;
    background: var(--green);
    color: #ffffff;
    border-bottom: 3px solid var(--border);
    padding: 0 12px;
    gap: 12px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
}

.topbar .brand-name {
    font-size: 1.05rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ffffff;
}
.topbar .brand-name::before { content: "\2726  "; }

.topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-toggle {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    padding: 4px 12px;
    cursor: pointer;
    font-weight: bold;
    font-size: 11px;
    font-family: var(--font-body);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.theme-toggle:active { border-style: inset; }

.topbar-status {
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.3px;
    display: none;
}
.topbar-status .status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: #00ff00;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.menu-toggle {
    background: #ffffff;
    border: 2px solid #000000;
    color: #000000;
    padding: 5px 9px;
    font-size: 1rem;
    cursor: pointer;
}

/* Sidebar (left panel) */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--green);
    border-right: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 42px; bottom: 0; left: 0;
    z-index: 40;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    background: var(--green-dark);
    padding: 9px 16px;
    border-bottom: 2px solid var(--border);
}
.sidebar-brand .brand-name {
    font-size: 0.82rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
    font-weight: bold;
}
.sidebar-brand .brand-tag {
    font-size: 0.66rem;
    color: var(--amber-light);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: block;
    margin-top: 2px;
}

.sidebar-user {
    padding: 10px 16px;
    border-bottom: 1px solid var(--green-dark);
    font-size: 0.78rem;
}
.sidebar-user .u-name { color: #ffffff; font-weight: bold; display: block; }
.sidebar-user .u-role { color: var(--amber-light); text-transform: uppercase; letter-spacing: 0.4px; font-size: 0.68rem; font-weight: bold; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 16px;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: bold;
    text-decoration: none;
    border-bottom: 1px solid var(--green-dark);
    border-left: 4px solid transparent;
}
.sidebar-nav a:hover { background: var(--green-light); text-decoration: none; }
.sidebar-nav a i { width: 18px; text-align: center; margin-right: 4px; opacity: 0.85; }
.sidebar-nav a.active { background: #ffffff; color: #000000; border-left-color: var(--amber); }

.sidebar-nav .nav-badge {
    margin-left: auto;
    background: var(--red);
    color: #ffffff;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.62rem;
    font-weight: bold;
    border: 1px solid var(--border);
}
.sidebar-nav a.active .nav-badge { background: var(--red); color: #ffffff; }

.sidebar-nav .nav-section {
    padding: 12px 16px 5px 16px;
    font-size: 0.64rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--amber-light);
    font-weight: bold;
}

.sidebar-foot { padding: 10px 16px; border-top: 2px solid var(--border); background: var(--green-dark); }
.sidebar-foot a { color: #ffffff; font-size: 0.8rem; font-weight: bold; }
.sidebar-foot a:hover { color: var(--red-light); }

/* Main / right panel */
.main {
    margin-left: var(--sidebar-w);
    margin-top: 42px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 42px);
    overflow: hidden;
}

.panel-title-bar {
    background: var(--navy);
    color: #ffffff;
    padding: 9px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 50px 24px;
    background: var(--surface);
}

/* v1 page-head is now a toolbar strip; the big <h1> is redundant with
   panel-title-bar above, so it's visually suppressed rather than ripped
   out of 30 PHP files. Eyebrow (real context) and actions stay visible. */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--surface-alt);
    border: 2px solid var(--border);
    padding: 10px 14px;
    margin-bottom: 16px;
}
.page-head h1 { display: none; }
.page-head .eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: bold;
    display: block;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Cards / panels
   --------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 2px solid var(--border);
    padding: 16px;
    margin-bottom: 18px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 10px;
    flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; border: none; padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------
   Stat tiles — matches reference .stat-card: centered, top accent bar
   --------------------------------------------------------------------- */
.stat-tile {
    background: var(--surface-alt);
    border: 2px solid var(--border);
    border-top: 4px solid var(--green);
    padding: 14px;
    text-align: center;
}
.stat-tile.positive { border-top-color: var(--green); }
.stat-tile.warning { border-top-color: var(--red); }
[data-theme="dark"] .stat-tile.positive { border-top-color: #6fdc6f; }
[data-theme="dark"] .stat-tile.warning { border-top-color: #ff7777; }
[data-theme="dark"] .stat-tile { border-top-color: #6fdc6f; }

.stat-tile .stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-dim);
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    opacity: 0.85;
}
.stat-tile .stat-value {
    font-size: 1.7rem;
    font-weight: bold;
    color: var(--text);
}
.stat-tile .stat-sub { font-size: 0.74rem; color: var(--text-faint); margin-top: 3px; }

/* ---------------------------------------------------------------------
   Buttons — classic 3D outset/inset press effect
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-body);
    font-weight: bold;
    font-size: 0.8rem;
    padding: 7px 16px;
    border: 3px outset #ffffff;
    background: var(--grey-btn);
    color: #000000;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { border-style: inset; }

.btn-primary { background: var(--green); color: #ffffff; border-color: var(--green-light); }
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary { background: var(--grey-btn); color: #000000; border-color: #999999; }
.btn-secondary:hover { background: #d0d0d0; }

.btn-danger { background: var(--red); color: #ffffff; border-color: #800000; }
.btn-danger:hover { background: var(--red-light); }

.btn-warning { background: var(--amber); color: #000000; border-color: #b0760a; }
.btn-warning:hover { background: var(--amber-light); }

.btn-success { background: #0a6f0a; color: #ffffff; border-color: #005500; }
.btn-success:hover { background: #0c8a0c; }

.btn-sm { padding: 3px 10px; font-size: 0.7rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Forms — inset (sunken) fields, uppercase bold labels
   --------------------------------------------------------------------- */
label {
    display: block;
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.field { margin-bottom: 14px; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="email"], input[type="month"], select, textarea {
    width: 100%;
    background: var(--input-bg);
    border: 3px inset var(--input-border);
    color: var(--text);
    padding: 7px 10px;
    font-size: 0.88rem;
    font-family: var(--font-body);
}
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: none; }
input::placeholder { color: var(--text-faint); }

.help-text { font-size: 0.74rem; color: var(--text-faint); margin-top: 4px; }

.checkbox-row { display: flex; align-items: center; gap: 7px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; text-transform: none; letter-spacing: normal; color: var(--text); font-weight: normal; }

fieldset { border: 2px solid var(--border); padding: 14px; margin: 0 0 14px 0; }
legend { padding: 0 6px; font-weight: bold; text-transform: uppercase; font-size: 0.78rem; color: var(--green); }
[data-theme="dark"] legend { color: #6fdc6f; }

/* ---------------------------------------------------------------------
   Tables — dark navy sticky header, hard grid borders
   --------------------------------------------------------------------- */
.table-wrap { overflow: auto; border: 2px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

thead th {
    background: var(--navy);
    color: #ffffff;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.3px;
    text-align: left;
    padding: 8px 10px;
    border: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

tbody td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:nth-child(even) { background: var(--table-even); }
tbody tr:hover { background: var(--hover-bg); }

td.num, th.num { text-align: right; }

/* computed (system-calculated) cells */
td.computed { background: rgba(0, 128, 0, 0.12); font-weight: bold; color: var(--green); }
[data-theme="dark"] td.computed { background: rgba(0, 255, 0, 0.12); color: #6fdc6f; }
td.computed.negative { background: #f8d7da; color: #721c24; }
[data-theme="dark"] td.computed.negative { background: #3a1a1a; color: #ff7777; }

.sheet-table input[type="number"] {
    width: 78px;
    text-align: right;
    padding: 4px 6px;
    border: 2px inset var(--input-border);
}
.sheet-table input[type="number"]:focus { border-color: var(--green); }

tfoot td {
    padding: 10px;
    font-weight: bold;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-top: 2px solid var(--navy);
    color: var(--text);
}

/* ---------------------------------------------------------------------
   Badges (v1 name) = Tags (reference styling): rounded, semantic colors,
   with distinct brighter tones in dark mode.
   --------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 3px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: bold;
    border: 1px solid var(--border);
}
.badge-open { background: #fff3cd; color: #856404; }
.badge-submitted { background: #d4edda; color: #155724; }
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #eeeeee; color: #555555; }
.badge-admin { background: #d1ecf1; color: #0c5460; }
.badge-branch { background: #eeeeee; color: #555555; }

[data-theme="dark"] .badge-open { background: #3a3a1a; color: #ffdd77; border-color: #ffdd77; }
[data-theme="dark"] .badge-submitted { background: #1a3a1a; color: #77dd77; border-color: #77dd77; }
[data-theme="dark"] .badge-active { background: #1a3a1a; color: #77dd77; border-color: #77dd77; }
[data-theme="dark"] .badge-inactive { background: #2a2a2a; color: #aaaaaa; border-color: #aaaaaa; }
[data-theme="dark"] .badge-admin { background: #1a2a3a; color: #77ddff; border-color: #77ddff; }
[data-theme="dark"] .badge-branch { background: #2a2a2a; color: #aaaaaa; border-color: #aaaaaa; }

/* ---------------------------------------------------------------------
   Alerts (inline flash banners — kept inline rather than corner toasts,
   so error/success feedback can't be missed after a redirect)
   --------------------------------------------------------------------- */
.alert {
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 2px solid;
}
.alert-success { background: #d4edda; border-color: var(--green); color: #155724; }
.alert-error { background: #f8d7da; border-color: var(--red); color: #721c24; }
.alert-warning { background: #fff3cd; border-color: var(--amber); color: #856404; }
.alert-info { background: #d1ecf1; border-color: var(--navy); color: #0c5460; }
[data-theme="dark"] .alert-success { background: #1a3a1a; color: #77dd77; }
[data-theme="dark"] .alert-error { background: #3a1a1a; color: #ff7777; }
[data-theme="dark"] .alert-warning { background: #3a3a1a; color: #ffdd77; }
[data-theme="dark"] .alert-info { background: #1a2a3a; color: #77ddff; }

/* ---------------------------------------------------------------------
   Toolbar + search (products, stock sheet grid, sheets list)
   --------------------------------------------------------------------- */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    align-items: center;
    background: var(--surface-alt);
    padding: 9px;
    border: 2px solid var(--border);
}
.toolbar .search-box-wrap { position: relative; flex: 1; min-width: 180px; }
.toolbar .search-box-wrap .search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-faint); pointer-events: none; font-size: 0.85rem;
}
.toolbar .search-box-wrap .search-box-inline { width: 100%; min-width: 0; padding-left: 30px; }
.toolbar .search-box-inline {
    padding: 6px 10px;
    border: 3px inset var(--input-border);
    font-size: 0.85rem;
    font-weight: bold;
    flex: 1;
    min-width: 180px;
    background: var(--input-bg);
    color: var(--text);
}
.toolbar .search-box-inline:focus { border-color: var(--green); outline: none; }
.toolbar .search-count { font-size: 0.72rem; font-weight: bold; color: var(--text-dim); white-space: nowrap; }
.toolbar .search-hint { font-size: 0.66rem; color: var(--text-faint); white-space: nowrap; }
.search-no-match { text-align: center; padding: 30px; font-style: italic; font-weight: bold; color: var(--text-faint); }

/* ---------------------------------------------------------------------
   Login page
   --------------------------------------------------------------------- */
.login-body { overflow-y: auto !important; height: auto !important; min-height: 100vh; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-dark);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 3px solid var(--border);
    padding: 30px 28px;
    box-shadow: 8px 8px 0px var(--shadow-color);
}
.login-card .brand-name {
    font-size: 1.3rem;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    display: block;
    letter-spacing: 0.5px;
}
.login-card .brand-name::before { content: "\2726  "; }
.login-card .brand-tag {
    text-align: center;
    display: block;
    color: var(--green-dark);
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 24px;
    font-weight: bold;
}
[data-theme="dark"] .login-card .brand-tag { color: #6fdc6f; }

/* ---------------------------------------------------------------------
   Status bar (bottom, terminal-style)
   --------------------------------------------------------------------- */
.status-bar {
    height: 24px;
    background: #000000;
    color: #00ff00;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    padding: 0 10px;
    flex-shrink: 0;
    border-top: 2px solid var(--green);
    letter-spacing: 0.3px;
}
.status-bar .status-indicator {
    display: inline-block;
    width: 6px; height: 6px;
    background: #00ff00;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse-dot 1.5s infinite;
}

/* ---------------------------------------------------------------------
   Scrollbar
   --------------------------------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border: 2px solid var(--scrollbar-border); }
::-webkit-scrollbar-thumb:hover { background: #888888; }

/* ---------------------------------------------------------------------
   Misc utility
   --------------------------------------------------------------------- */
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-brass, .text-amber { color: #8a5c0a; }
[data-theme="dark"] .text-brass, [data-theme="dark"] .text-amber { color: var(--amber-light); }
.text-bottle, .text-green { color: var(--green); }
[data-theme="dark"] .text-bottle, [data-theme="dark"] .text-green { color: #6fdc6f; }
.text-rust, .text-red { color: var(--red); }
[data-theme="dark"] .text-rust, [data-theme="dark"] .text-red { color: #ff7777; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.divider { border: none; border-top: 2px solid var(--border); margin: 18px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-faint); font-style: italic; font-weight: bold; }
.empty-state h3 { color: var(--text-dim); margin-bottom: 8px; border: none; padding: 0; }
.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .field { margin-bottom: 0; min-width: 150px; }

/* ---------------------------------------------------------------------
   Chart panels (admin analytics dashboard)
   --------------------------------------------------------------------- */
.chart-card { background: var(--surface); border: 2px solid var(--border); padding: 14px; margin-bottom: 18px; }
.chart-card h3 { margin-bottom: 10px; }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap.h-260 { height: 260px; }
.chart-wrap.h-220 { height: 220px; }
.period-tabs { display: flex; gap: 6px; }
.period-tabs a {
    padding: 5px 12px;
    border: 2px solid var(--border);
    background: var(--surface-alt);
    color: var(--text);
    font-size: 0.7rem;
    font-weight: bold;
    text-decoration: none;
}
.period-tabs a:hover { background: var(--hover-bg); text-decoration: none; }
.period-tabs a.active { background: var(--green); color: #ffffff; }
.variance-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.variance-row:last-child { border-bottom: none; }

/* ---------------------------------------------------------------------
   Sticky-list layout — for long editable grids (the 100+ row stock
   sheet). Keeps the page head, cash/profit summary, and Save controls
   always in view; only the product rows scroll. Wrap a page's body in
   <div class="sticky-list-page"> with a <div class="sticky-list-scroll">
   around the table portion; everything else (page-head, save bars,
   cash/profit cards) stays put.
   On short viewports where even the fixed chrome doesn't fit, .content's
   own scrollbar still works as a fallback — nothing is ever unreachable.
   --------------------------------------------------------------------- */
.sticky-list-page {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}
.sticky-list-top,
.sticky-list-bottom { flex: 0 0 auto; }

.sticky-list-scroll {
    flex: 1 1 auto;
    min-height: 180px;
    overflow: auto;
    margin: 0 0 14px 0;
    border: 2px solid var(--border);
}
/* The table's own wrapper no longer needs its own scrollbar/border —
   .sticky-list-scroll is now the single scrolling ancestor, so the
   sticky thead (thead th { position: sticky; top: 0; }) sticks to it. */
.sticky-list-scroll .table-wrap { overflow: visible; border: none; }

.save-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface);
    border: 2px solid var(--border);
    position: sticky;
    z-index: 4;
}
.save-bar-top { top: 0; margin-bottom: 14px; }
.save-bar-bottom { bottom: 0; margin-top: 0; }
.save-bar .save-bar-hint {
    font-size: 0.74rem;
    color: var(--text-dim, var(--text));
    opacity: 0.8;
    margin-left: auto;
}
@media (max-width: 880px) {
    .save-bar .save-bar-hint { display: none; }
}
/* Unsaved-changes indicator (app.js toggles this) — kept subtle and
   text-based, not color-only, so it doesn't rely on color perception. */
.save-bar[data-dirty="true"] .save-bar-status::before { content: "\25CF "; color: var(--amber); }
.save-bar-status { font-size: 0.78rem; font-weight: bold; }

@media (max-width: 880px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 6px 0 0 var(--shadow-color); }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 14px 12px 40px 12px; }
    .topbar-status { display: none !important; }
    /* On phones the fixed chrome (head + two save bars + cash/profit
       cards) can exceed the viewport on its own — let the whole page
       scroll instead of forcing a cramped mid-page scroll box. */
    .sticky-list-page { height: auto; }
    .sticky-list-scroll { flex: none; max-height: 50vh; }
    .save-bar-top { position: static; }
}
@media (min-width: 881px) {
    .menu-toggle { display: none; }
    .topbar-status { display: flex; align-items: center; }
}

/* ---------------------------------------------------------------------
   POS terminal — product grid + running cart + payment panel. A cashier
   workflow, so touch targets are large and the layout is thumb-friendly
   on a tablet as well as usable with mouse/keyboard on a desktop.
   --------------------------------------------------------------------- */
.pos-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 4px;
    margin-bottom: 14px;
    font-size: 0.85rem;
}
.pos-summary-bar i { margin-right: 4px; color: var(--green); }

.pos-main { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.pos-products { min-width: 0; }
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.pos-product-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px;
    min-height: 90px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: transform 0.08s ease, border-color 0.15s ease;
}
.pos-product-card:hover:not(:disabled) { border-color: var(--green); transform: translateY(-2px); }
.pos-product-card:disabled { opacity: 0.45; cursor: not-allowed; }
.pos-product-name { font-weight: bold; font-size: 0.9rem; }
.pos-product-price { color: var(--green); font-family: var(--font-mono); font-weight: bold; }
.pos-product-stock { font-size: 0.72rem; color: var(--text-faint); }
.pos-product-stock.negative { color: var(--red); font-weight: bold; }

.pos-cart {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    position: sticky;
    top: 14px;
}
.pos-cart h2 { font-size: 1rem; margin: 0 0 12px 0; display: flex; align-items: center; gap: 8px; }
.pos-cart-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.pos-cart-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-qty-controls { display: flex; align-items: center; gap: 6px; }
.pos-qty-btn {
    width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.pos-qty-value { min-width: 20px; text-align: center; font-weight: bold; }
.pos-cart-line-total { font-family: var(--font-mono); white-space: nowrap; }
.pos-remove-btn { background: none; border: none; color: var(--red); cursor: pointer; padding: 4px; }
.pos-cart-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; margin-top: 8px; border-top: 2px solid var(--border);
    font-size: 1.1rem;
}
.pos-cart-footer strong { font-family: var(--font-mono); color: var(--green); }
.btn-lg { padding: 14px; font-size: 1.05rem; width: 100%; margin-top: 10px; }

.pos-panel { max-width: 560px; margin: 0 auto; }
.pos-payment-methods { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.pos-payment-method {
    background: var(--surface); border: 2px solid var(--border); border-radius: 6px; padding: 16px;
}
.pos-payment-method h3 { margin: 0 0 10px 0; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.pos-payment-method input { margin-bottom: 10px; }

.pos-receipt { text-align: center; padding: 30px 20px; }
.pos-receipt-icon { font-size: 3rem; color: var(--green); margin-bottom: 10px; }
.pos-receipt-total-line { font-size: 1.2rem; margin: 14px 0; }
.pos-receipt-mpesa-code { font-family: var(--font-mono); background: var(--surface); display: inline-block; padding: 6px 12px; border-radius: 4px; }

@media (max-width: 880px) {
    .pos-main { grid-template-columns: 1fr; }
    .pos-cart { position: static; }
}

.pos-branch-override {
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 10px;
}
.pos-branch-override summary {
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}
.pos-branch-override summary i { color: var(--green); }

.onboarding-steps { display: flex; gap: 18px; justify-content: center; margin: 14px 0 22px 0; font-size: 0.82rem; }
.onboarding-step { color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.onboarding-step.active { color: var(--green); font-weight: bold; }
.onboarding-step.done { color: var(--green); }

/* Small utility classes for tinting an inline Font Awesome icon to match
   the app's palette, used next to form labels/headings for a more
   polished, professional look without relying on emoji. */
.icon-green { color: var(--green); }
.icon-amber { color: var(--amber); }
.icon-red { color: var(--red); }
.icon-faint { color: var(--text-faint); }
