/* Dashboard Monitoring Stock — design tokens + components.
   Every component references tokens only; raw colour literals live in the
   :root blocks below so light/dark stay in sync. */

:root {
    /* Type scale */
    --text-xs: 11px;
    --text-sm: 12px;
    --text-md: 13px;
    --text-base: 14px;
    --text-lg: 16px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 30px;

    /* Surfaces & text */
    --color-bg: #f3f6fb;
    --color-surface: #ffffff;
    --color-surface-subtle: #f8fafc;
    --color-border: #e3e9f2;
    --color-border-strong: #cbd5e1;
    --color-text: #0f172a;
    /* #64748b measured 4.47:1 on --color-bg — just under AA for 13px text.
       This lands at 5.08:1 while still reading as muted. */
    --color-muted: #5e6b7e;

    /* Brand */
    --color-primary: #245cce;
    --color-primary-dark: #1d4ed8;
    --color-button-primary: #245cce;
    --color-button-primary-hover: #1d4ed8;
    --color-on-primary: #ffffff;

    /* Feedback cards stay white in both themes. */
    --color-feedback-surface: #ffffff;
    --color-feedback-text: #17243e;
    --color-feedback-muted: #58657a;
    --color-feedback-border: #e3e9f2;
    --color-feedback-tint: #eaf1ff;
    --color-feedback-success: #15803d;
    --color-feedback-success-bg: #ecfdf3;

    /* Destructive */
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-error-tint: #fef2f2;

    /* Semantic pairs */
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-error-bg: #fee2e2;
    --color-error-text: #991b1b;
    --color-warning-bg: #fef3c7;
    --color-warning-text: #92400e;
    --color-info-bg: #dbeafe;
    --color-info-text: #1e40af;

    /* Sidebar */
    --color-sidebar: #ffffff;
    --color-sidebar-text: #526078;
    --color-sidebar-active: #eaf1ff;
    --color-sidebar-strong: #1e4fb6;
    --color-sidebar-heading: #627087;

    /* Shape & elevation */
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .03);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
}

:root[data-theme="dark"] {
    --color-bg: #0b1220;
    --color-surface: #151d2e;
    --color-surface-subtle: #1a2334;
    --color-border: #2a3446;
    --color-border-strong: #3b4759;
    --color-text: #e2e8f0;
    --color-muted: #94a3b8;

    --color-primary: #8cb4ff;
    --color-primary-dark: #60a5fa;
    --color-button-primary: #245cce;
    --color-button-primary-hover: #1d4ed8;
    --color-on-primary: #ffffff;

    --color-danger: #ef4444;
    --color-danger-dark: #dc2626;
    --color-error-tint: rgba(239, 68, 68, .08);

    /* Translucent so semantic chips sit on any surface */
    --color-success-bg: rgba(34, 197, 94, .15);
    --color-success-text: #4ade80;
    --color-error-bg: rgba(239, 68, 68, .15);
    --color-error-text: #f87171;
    --color-warning-bg: rgba(245, 158, 11, .15);
    --color-warning-text: #fbbf24;
    --color-info-bg: rgba(59, 130, 246, .15);
    --color-info-text: #60a5fa;

    --color-sidebar: #111827;
    --color-sidebar-text: #cbd5e1;
    --color-sidebar-active: #1f2937;
    --color-sidebar-strong: #f8fafc;
    --color-sidebar-heading: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, .45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The UA rule for [hidden] is display:none at the weakest possible specificity,
   so ANY component rule that sets display beats it — .btn's inline-block and
   .action-strip's flex both did, leaving #scope-reset and the pending-distribution
   strip permanently visible however carefully the JS set el.hidden. Toggling
   .hidden state is the app's main show/hide idiom, so it gets to win. */
[hidden] { display: none !important; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    /* Scoped to body only — a global transition makes theme switching feel laggy */
    transition: background-color .15s, color .15s;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== App layout: sidebar + content ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar stays put while the content area scrolls */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 252px;
    height: 100vh;
    flex-shrink: 0;
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-sidebar-strong);
    border-bottom: 1px solid var(--color-border);
}

/* Only the menu scrolls on short screens; the workspace and account stay visible. */
.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 4px; }

.sidebar-brand,
.sidebar-footer { flex-shrink: 0; }

/* Icons and fixed row spacing keep navigation predictable between pages. */
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 12px;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: var(--text-md);
    line-height: 1.35;
    color: var(--color-sidebar-text);
    text-decoration: none;
}

.sidebar-nav a:hover { background: var(--color-surface-subtle); color: var(--color-text); }
.sidebar-nav a.active {
    background: var(--color-sidebar-active);
    color: var(--color-sidebar-strong);
    font-weight: 600;
}

/* 16px above keeps the group break visible next to the taller rows */
.sidebar-section {
    padding: 16px 24px 6px;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-sidebar-heading);
}

/* The first group needs no extra gap above it */
.sidebar-nav > .sidebar-section:first-child { padding-top: 6px; }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
}

.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.sidebar-user-name { font-weight: 600; font-size: var(--text-md); color: var(--color-sidebar-strong); }

.sidebar-user-branch { font-size: var(--text-xs); color: var(--color-sidebar-heading); }

.sidebar-account-link {
    display: block;
    margin: 0 -8px 8px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: var(--text-xs);
    color: var(--color-sidebar-text);
    text-decoration: none;
}

.sidebar-account-link:hover,
.sidebar-account-link.active {
    background: var(--color-sidebar-active);
    color: var(--color-sidebar-strong);
}

/* Offset by the fixed sidebar's width */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: 252px;
}

/* ===== Topbar / page header ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 76px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-heading { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.page-title {
    font-size: var(--text-lg);
    font-weight: 600;
    line-height: 1.3;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--color-muted);
    line-height: 1.3;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.content { padding: 28px 32px; flex: 1; }

/* ===== Workspace navigation and shortcuts ===== */
.ui-icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.sidebar-brand-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    background: var(--color-button-primary);
    color: var(--color-on-primary);
}
.sidebar-brand-icon .ui-icon { width: 24px; height: 24px; }
.sidebar-brand-text { color: var(--color-text); line-height: 1.35; }
.sidebar-brand-caption { display: block; margin-top: 4px; color: var(--color-muted); font-size: 10px; font-weight: 400; }
.sidebar-nav a .ui-icon { width: 18px; height: 18px; }
.sidebar-nav a.active::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-left: auto; }
.sidebar-avatar { display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: var(--color-sidebar-active); color: var(--color-sidebar-strong); font-weight: 700; }
.sidebar-user-name { color: var(--color-text); }
.sidebar-user > div { min-width: 0; }
.sidebar-user-name, .sidebar-user-branch { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .btn { justify-content: center; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); padding: 10px 16px; border-radius: var(--radius); background: var(--color-surface); color: var(--color-text); }
.skip-link:focus { transform: translateY(0); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.transaction-menu { position: relative; }
.transaction-menu summary { list-style: none; }
.transaction-menu summary::-webkit-details-marker { display: none; }
.transaction-menu summary .ui-icon { width: 17px; height: 17px; }
.transaction-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 292px;
    max-width: calc(100vw - 32px);
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
}
.transaction-menu-label { padding: 6px 10px 10px; color: var(--color-muted); font-size: var(--text-sm); }
.transaction-menu-panel a { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 8px; color: var(--color-text); text-decoration: none; }
.transaction-menu-panel a:hover { background: var(--color-surface-subtle); }
.transaction-menu-panel a > .ui-icon { color: var(--color-primary); }
.transaction-menu-panel strong, .transaction-menu-panel small { display: block; }
.transaction-menu-panel strong { font-size: var(--text-md); font-weight: 600; }
.transaction-menu-panel small { font-size: var(--text-sm); color: var(--color-muted); margin-top: 2px; }
.workflow-nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.workflow-label { font-size: var(--text-sm); color: var(--color-muted); }
.workflow-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.workflow-links a { padding: 6px 10px; border-radius: 7px; font-size: var(--text-md); color: var(--color-muted); text-decoration: none; }
.workflow-links a:hover { background: var(--color-surface); color: var(--color-text); }
.workflow-links a.is-active { background: var(--color-sidebar-active); color: var(--color-sidebar-strong); font-weight: 600; }
.workflow-arrow { display: inline-flex; color: var(--color-border-strong); }
.workflow-arrow .ui-icon { width: 14px; height: 14px; }
.dashboard-intro { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.eyebrow { font-size: var(--text-xs); color: var(--color-primary); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 7px; }
.dashboard-intro h1 { font-size: clamp(22px, 2vw, 28px); font-weight: 650; letter-spacing: -.035em; line-height: 1.3; }
.dashboard-intro-description { color: var(--color-muted); margin-top: 8px; }
.workspace-badge { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 7px 12px; border: 1px solid var(--color-border); border-radius: 999px; font-size: var(--text-sm); background: var(--color-surface); }
.workspace-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary); }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 14px; margin-bottom: 24px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 17px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); text-decoration: none; }
.quick-action:hover { border-color: var(--color-primary); text-decoration: none; box-shadow: var(--shadow-md); }
.quick-action-icon { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; background: var(--color-sidebar-active); color: var(--color-sidebar-strong); border-radius: 11px; }
.quick-action-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.quick-action-body strong { font-size: var(--text-md); font-weight: 600; }
.quick-action-body > span { font-size: var(--text-sm); color: var(--color-muted); }
.quick-action > .ui-icon { width: 16px; height: 16px; color: var(--color-muted); }
.sidebar-close { display: none !important; }

/* Hamburger and overlay are display-controlled at the end of this file, after
   .btn-icon — otherwise .btn-icon's display:inline-flex wins on source order
   and the hamburger shows up on desktop too. */

@media (max-width: 768px) {
    /* Previously the sidebar became a full-width static block, so all 14 menu
       items, the profile block and Log Out stacked above the content and the
       first KPI was a long scroll away on every page. It is a drawer now. */
    .sidebar {
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .nav-open .sidebar { transform: translateX(0); }

    .nav-overlay {
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(15, 23, 42, .5);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .nav-open .nav-overlay { opacity: 1; pointer-events: auto; }

    .main-area { margin-left: 0; }
}

/* A drawer that only opens with JS would be a nav nobody can reach if the
   script fails, so without JS it falls back to the old stacked layout. */
@media (max-width: 768px) {
    .no-js .sidebar {
        position: static;
        width: 100%;
        max-width: none;
        height: auto;
        transform: none;
    }

    .no-js .sidebar-nav { overflow-y: visible; }
    .no-js .sidebar-close { display: none !important; }
    .no-js .nav-toggle { display: none; }
    .no-js .nav-overlay { display: none; }
}

/* ===== Centered confirmation and success cards ===== */
body.feedback-is-open { overflow: hidden; }
.feedback-dialog {
    position: fixed;
    inset: 0;
    width: min(440px, calc(100% - 32px));
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 32px;
    overflow-y: auto;
    border: 1px solid var(--color-feedback-border);
    border-radius: 20px;
    background: var(--color-feedback-surface);
    color: var(--color-feedback-text);
    box-shadow: 0 24px 80px rgba(15, 23, 42, .22);
    text-align: center;
    color-scheme: light;
}
.feedback-dialog[open] { animation: feedback-card-in .22s ease-out; }
.feedback-dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); }
.feedback-dialog h2 { margin: 18px 0 10px; font-size: 23px; line-height: 1.3; letter-spacing: -.025em; }
.feedback-dialog p { color: var(--color-feedback-muted); font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.feedback-symbol { width: 76px; height: 76px; margin: 0 auto; align-items: center; justify-content: center; }
.feedback-symbol-confirm { display: flex; border-radius: 50%; background: var(--color-feedback-tint); color: var(--color-button-primary); }
.feedback-symbol-success, .feedback-symbol-loading { display: none; }
.feedback-dialog[data-state="success"] .feedback-symbol-confirm,
.feedback-dialog[data-state="loading"] .feedback-symbol-confirm { display: none; }
.feedback-dialog[data-state="success"] .feedback-symbol-success { display: flex; }
.feedback-dialog[data-state="loading"] .feedback-symbol-loading { display: flex; }
.feedback-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }
.feedback-button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 11px 20px; border: 1px solid var(--color-feedback-border); border-radius: 10px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.feedback-button-cancel { background: var(--color-feedback-surface); color: var(--color-feedback-muted); }
.feedback-button-cancel:hover { background: var(--color-feedback-tint); }
.feedback-button-primary { background: var(--color-button-primary); border-color: var(--color-button-primary); color: var(--color-on-primary); }
.feedback-button-primary:hover { background: var(--color-button-primary-hover); }
.feedback-dialog[data-state="success"] .feedback-button { min-width: 160px; }
.feedback-symbol-success { position: relative; width: 84px; height: 84px; }
.feedback-checkmark { position: relative; color: var(--color-feedback-success); animation: feedback-check-pop .4s .45s ease-out both; }
.feedback-checkmark-circle { fill: var(--color-feedback-success-bg); stroke: currentColor; stroke-dasharray: 214; stroke-dashoffset: 214; animation: feedback-check-draw .5s .1s ease-out forwards; }
.feedback-checkmark-tick { stroke: currentColor; stroke-dasharray: 50; stroke-dashoffset: 50; animation: feedback-check-draw .35s .5s ease-out forwards; }
.feedback-success-pulse { position: absolute; inset: 8px; border: 2px solid var(--color-feedback-success); border-radius: 50%; opacity: 0; animation: feedback-success-pulse .9s .6s ease-out 2; }
.feedback-spinner { width: 42px; height: 42px; border: 3px solid var(--color-feedback-tint); border-top-color: var(--color-button-primary); border-radius: 50%; animation: feedback-spin .7s linear infinite; }
@keyframes feedback-card-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes feedback-check-draw { to { stroke-dashoffset: 0; } }
@keyframes feedback-check-pop { 0% { transform: scale(.85); } 65% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes feedback-success-pulse { 0% { opacity: .3; transform: scale(1); } 100% { opacity: 0; transform: scale(1.45); } }
@keyframes feedback-spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) {
    .feedback-dialog { padding: 28px 22px; }
    .feedback-dialog h2 { font-size: 21px; }
    .feedback-actions { gap: 8px; }
    .feedback-actions .feedback-button { flex: 1; padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .feedback-dialog[open], .feedback-checkmark, .feedback-spinner { animation: none; }
    .feedback-checkmark-circle, .feedback-checkmark-tick { animation: none; stroke-dashoffset: 0; }
    .feedback-success-pulse { display: none; }
}

/* ===== Guest layout ===== */
.guest-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.guest-container { width: 100%; max-width: 460px; }

.guest-card { text-align: center; padding: 36px 32px; }

.guest-title { font-size: var(--text-xl); margin-bottom: 8px; }

.guest-subtitle { color: var(--color-muted); margin-bottom: 16px; }

.error-code {
    font-size: 56px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}

/* Stack trace on the 500 page; only ever rendered when APP_DEBUG=true */
.error-detail {
    text-align: left;
    font-size: 12px;
    line-height: 1.5;
    max-height: 320px;
    overflow: auto;
    padding: 12px;
    margin-bottom: 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ===== Cards ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: 14px; }

/* ===== KPI cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
    padding: 18px 20px 16px 22px;
    overflow: hidden;
}

/* Thin left accent bar — the one decorative element the design calls for */
.kpi::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--color-border-strong);
    border-radius: var(--radius) 0 0 var(--radius);
}

.kpi--primary::before { background: var(--color-primary); }
.kpi--warn::before    { background: var(--color-warning-text); }
.kpi--ok::before      { background: var(--color-success-text); }
.kpi--info::before    { background: var(--color-info-text); }

.kpi-label {
    font-size: var(--text-sm);
    color: var(--color-muted);
    font-weight: 500;
}

.kpi-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.1;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.kpi-meta { font-size: var(--text-sm); color: var(--color-muted); min-height: 1.2em; }

.kpi-meta--up { color: var(--color-success-text); }
.kpi-meta--down { color: var(--color-error-text); }

/* Clickable variant */
a.kpi { text-decoration: none; color: inherit; }

a.kpi:hover {
    text-decoration: none;
    box-shadow: var(--shadow-md);
    border-color: var(--color-border-strong);
}

a.kpi::after {
    content: '\203A';
    position: absolute;
    top: 12px;
    right: 16px;
    color: var(--color-muted);
    font-size: var(--text-lg);
    line-height: 1;
}

/* ===== Charts ===== */
.chart-box { position: relative; height: 300px; }

/* Shown instead of an axis-only chart when every value is zero */
.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 16px;
    font-size: var(--text-sm);
    color: var(--color-muted);
}

/* ===== Ranked list (top products) ===== */
.rank-list { display: flex; flex-direction: column; gap: 14px; }

.rank-item { display: flex; flex-direction: column; gap: 6px; }

.rank-row { display: flex; align-items: baseline; gap: 10px; }

.rank-num {
    flex-shrink: 0;
    width: 18px;
    font-size: var(--text-sm);
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

.rank-name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-value {
    flex-shrink: 0;
    font-size: var(--text-md);
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

.rank-bar {
    height: 4px;
    border-radius: 999px;
    background: var(--color-surface-subtle);
    overflow: hidden;
}

.rank-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--color-primary);
    opacity: .5;
}

/* ===== Activity feed ===== */
.activity { display: flex; flex-direction: column; }

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.activity-item:first-child { padding-top: 0; }
.activity-item:last-child { padding-bottom: 0; border-bottom: none; }

.activity-qty {
    flex-shrink: 0;
    min-width: 52px;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-muted);
}

.activity-qty--up { color: var(--color-success-text); }
.activity-qty--down { color: var(--color-error-text); }

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

.activity-main { font-weight: 500; }

.activity-branch { color: var(--color-muted); font-weight: 400; }

.activity-meta {
    font-size: var(--text-sm);
    color: var(--color-muted);
    margin-top: 2px;
}

.activity-empty { font-size: var(--text-sm); color: var(--color-muted); }

/* Monthly recap (dasbor pusat): empty months stay listed but recede, so the
   months with activity are what the eye lands on */
.recap-row-empty td { color: var(--color-muted); }
.recap-note { font-size: var(--text-sm); color: var(--color-muted); }

/* ===== Skeleton loading ===== */
.skeleton {
    display: inline-block;
    background: var(--color-surface-subtle);
    border-radius: 4px;
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.skeleton-value { height: 30px; width: 90px; }
.skeleton-text { height: 12px; width: 100%; }

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
    body { transition: none; }
    .sidebar { transition: none; }
    .nav-overlay { transition: none; }
}

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
}

/* No global nowrap — columns opt in with .nowrap so long text can wrap */
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: var(--text-md);
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Footer totals keep normal casing (currency prefixes like "Rp") */
tfoot th {
    text-transform: none;
    font-size: var(--text-base);
    color: var(--color-text);
    font-weight: 700;
}

tr:hover td { background: var(--color-surface-subtle); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }

label { display: block; font-weight: 500; margin-bottom: 6px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
    border-color: var(--color-primary);
}

.form-error { color: var(--color-error-text); font-size: var(--text-md); margin-top: 4px; }

/* Element+class selectors so these beat the input[type="..."] base rules above */
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--color-danger);
    background: var(--color-error-tint);
}

input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    outline-color: var(--color-danger);
    border-color: var(--color-danger);
}

.form-hint { color: var(--color-muted); font-size: var(--text-md); margin-top: 4px; }

/* The per-row stock hint keeps .form-hint's spacing and only changes voice when
   the qty above it exceeds what is in stock — it is the same sentence either
   way, so restyling it in place reads better than swapping in a second element. */
.stock-hint.is-over { color: var(--color-error-text); font-weight: 500; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--color-button-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-button-primary-hover); }

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: var(--color-danger); color: var(--color-on-primary); }
.btn-danger:hover { background: var(--color-danger-dark); }

.btn-sm { padding: 5px 12px; font-size: var(--text-md); }

/* Borderless square button (theme toggle) */
.btn-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    font-size: var(--text-lg);
    line-height: 1;
    cursor: pointer;
}

.btn-icon:hover { background: var(--color-surface-subtle); border-color: var(--color-border); }

/* Glyph follows data-theme, so the correct one is painted on first render */
.theme-glyph-dark { display: none; }
:root[data-theme="dark"] .theme-glyph-dark { display: inline; }
:root[data-theme="dark"] .theme-glyph-light { display: none; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--text-sm);
    font-weight: 600;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-danger  { background: var(--color-error-bg); color: var(--color-error-text); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-info    { background: var(--color-info-bg); color: var(--color-info-text); }
/* --color-muted on --color-border measured 4.39:1 — under AA for a 12px/600
   badge. The chip already reads as muted from its grey ground, so the text
   itself doesn't need to be dimmed. Now 14.48:1 light / 10.15:1 dark. */
.badge-muted   { background: var(--color-border); color: var(--color-text); }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert-error   { background: var(--color-error-bg); color: var(--color-error-text); }

.alert-info    { background: var(--color-info-bg); color: var(--color-info-text); }

/* ===== Role & access editors ===== */
.role-name { font-weight: 600; }
.role-key { font-size: var(--text-sm); color: var(--color-muted); margin-right: 6px; }

.perm-group {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 6px 16px 8px;
    margin-bottom: 16px;
}

.perm-group-title { padding: 0 6px; margin-left: -6px; font-weight: 600; }

.perm-group-actions { display: flex; gap: 16px; margin-bottom: 4px; }

/* Two columns once there is room; each item is checkbox + its explanation */
.perm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0 20px;
}

/* label is display:block with a bold weight globally; an item is a row of text */
.perm-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
    margin-bottom: 0;
    font-weight: 400;
    cursor: pointer;
}

.perm-item input { margin-top: 3px; flex-shrink: 0; }
.perm-group:disabled .perm-item { cursor: default; }

.perm-label { display: block; font-weight: 500; }
.perm-desc { display: block; font-size: var(--text-md); color: var(--color-muted); }
.perm-req { display: block; font-size: var(--text-sm); color: var(--color-info-text); margin-top: 2px; }

.perm-module-title { font-size: var(--text-base); font-weight: 600; margin-bottom: 8px; }

/* Inline text action ("Pilih semua") that should not read as a full button */
.btn-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: var(--text-md);
    color: var(--color-primary);
    cursor: pointer;
}

.btn-link:hover { text-decoration: underline; }

/* ===== Dashboard secondary grid ===== */
.stat-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
}

/* ===== Empty states ===== */
.empty-state {
    text-align: center;
    padding: 40px 24px;
}

.empty-state-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text);
}

.empty-state-message {
    color: var(--color-muted);
    max-width: 460px;
    margin: 0 auto 18px;
    line-height: 1.6;
}

.empty-state-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Onboarding checklist ===== */
.checklist { list-style: none; }

.checklist-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border);
}

.checklist-item:last-child { border-bottom: none; }

.checklist-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-button-primary);
    color: var(--color-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-md);
    font-weight: 700;
}

.checklist-num-done { background: var(--color-success-bg); color: var(--color-success-text); }

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

.checklist-label { display: block; font-weight: 600; }

.checklist-desc {
    display: block;
    font-size: var(--text-md);
    color: var(--color-muted);
    margin-top: 2px;
}

.checklist-done .checklist-label { color: var(--color-muted); }

.checklist-action { flex-shrink: 0; }

.alert-info-card { border-left: 4px solid var(--color-primary); }

/* ===== Unit Code =====
   Colours follow the team's own spreadsheet: PT. RUA red, PT. DAL and the
   blue (secondary) code blue, so the page reads like the sheet it replaces. */
.unit-alt-code { color: var(--color-primary); font-weight: 600; }
.company { font-weight: 700; }
.company-rua { color: var(--color-error-text); }
.company-dal { color: var(--color-primary); }

/* Sectioned form: quiet uppercase section labels instead of extra cards, so a
   long form reads as one sheet of paper rather than a stack of boxes */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
}
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.form-section { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-section-title {
    padding: 0;
    margin-bottom: 12px;
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-muted);
}

/* The Unit Code fields sit in their own box at the top of the form */
.unit-code-panel {
    min-width: 0;
    margin: 0 0 20px;
    padding: 16px 16px 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-subtle);
}
.unit-code-panel .form-section-title { float: left; width: 100%; }
.unit-code-panel .form-grid { clear: both; }

.label-optional { margin-left: 4px; font-size: var(--text-sm); font-weight: 400; color: var(--color-muted); }

/* Codes and serials are stored upper-case; show them that way while typing */
.input-code { text-transform: uppercase; letter-spacing: .02em; }
/* Element+class to outrank the input[type="text"] base colour */
input.input-alt-code { color: var(--color-primary); font-weight: 600; }

/* A native <select> draws ~2px taller than a text input at the same padding;
   pin both so the Perusahaan dropdown lines up with the code fields beside it */
.unit-form input[type="text"],
.unit-form input[type="number"],
.unit-form select { height: 38px; }

.form-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    margin-top: 4px;
    border-top: 1px solid var(--color-border);
}
.form-footer-note { font-size: var(--text-md); color: var(--color-muted); }

@media (max-width: 768px) {
    .topbar { padding: 12px 16px; gap: 8px; min-height: 68px; }
    .page-heading { flex: 1; }
    .page-title { font-size: var(--text-base); }
    .page-subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .content { padding: 20px 16px; }
    .transaction-menu summary { padding: 9px; }
    .transaction-menu summary span, .transaction-menu summary .ui-icon:last-child { display: none; }
    .transaction-menu-panel { right: -42px; }
    .dashboard-intro { flex-direction: column; align-items: flex-start; gap: 12px; }
    .dashboard-intro-description { font-size: var(--text-md); }
    .quick-actions { gap: 10px; }
    .quick-action { padding: 13px 15px; }
    .workflow-nav { gap: 8px; margin-bottom: 18px; }
    .workflow-label { width: 100%; }
    .workflow-links { gap: 3px; }
    .workflow-links a { font-size: var(--text-sm); padding: 5px 7px; }
    .workflow-arrow { display: none; }
    .sidebar-close { display: inline-flex !important; margin-left: auto; flex-shrink: 0; }
    body.nav-is-open { overflow: hidden; }
    .checklist-item { flex-wrap: wrap; align-items: flex-start; }
    .checklist-body { flex-basis: calc(100% - 42px); }
    .checklist-action { margin-left: 42px; }
    .form-grid,
    .form-grid-3 { grid-template-columns: 1fr; }
    .form-footer .btn { width: 100%; }
}

/* ===== Action strip =====
   An aging task is not a measurement: a KPI tile can state "3 pending" but not
   "the oldest has been sitting for 6 days", and the age is what decides whether
   anyone needs to act. Rendered only when there is something to act on — the
   absence of the strip is the all-clear. The 3px left rule deliberately echoes
   .kpi::before so the two read as one family. */
.action-strip {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--color-text);
    text-decoration: none;
}

/* display:flex on a component beats the UA stylesheet's [hidden] rule, so every
   flex component that can be hidden needs this. Kept together so the next one
   added inherits the fix instead of rediscovering the bug. */
.action-strip[hidden],
.kpi[hidden],
.scope-bar[hidden] { display: none; }

.action-strip:hover {
    text-decoration: none;
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-md);
}

/* 3px rules on --color-surface: warning 7.09:1 light / 10.09:1 dark,
   danger 4.83:1 light / 4.47:1 dark — all past the 3:1 graphic minimum. */
.action-strip--warn   { border-left-color: var(--color-warning-text); }
.action-strip--danger { border-left-color: var(--color-danger); }

.action-strip-icon { flex-shrink: 0; font-size: var(--text-2xl); line-height: 1; }
.action-strip-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.action-strip-title { font-weight: 600; }
.action-strip-desc { font-size: var(--text-md); color: var(--color-muted); }
.action-strip-cta { flex-shrink: 0; align-self: center; }

/* Status chip leads the row, mirroring the signed qty in the activity feed, so
   the two side-by-side feeds read as different instruments at a glance. */
.activity-badge { flex-shrink: 0; min-width: 76px; }

/* ===== Page-level scope selector =====
   Not .toolbar: that treatment is a submitted filter form everywhere else in
   the app (fields + Terapkan/Reset), and this applies on change. Same chrome
   would promise a submit that never comes. */
.scope-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

/* label is display:block with a bottom margin globally; both are undone here */
.scope-bar-label {
    margin-bottom: 0;
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--color-muted);
}

.scope-bar-control { width: 240px; max-width: 100%; }
.scope-bar-status { font-size: var(--text-md); color: var(--color-muted); }

/* Pairs with .card-title.mb-0 — the title's bottom margin moves down here */
.card-subtitle {
    margin-bottom: 14px;
    font-size: var(--text-sm);
    color: var(--color-muted);
}

/* ===== Searchable dropdown (combobox) =====
   The native <select> stays in the DOM as the submitted control; JS hides it.
   Without JS none of these classes are applied and the select renders normally. */
.combobox { position: relative; }

/* element+class so it outranks utilities like .w-auto that the select may also
   carry — otherwise the hidden native control keeps its width and, being
   absolutely positioned, pushes the page into horizontal overflow. */
select.combobox-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Matches the native control's metrics so toolbars don't reflow when enhanced */
.combobox-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: text;
}

.combobox-input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
    border-color: var(--color-primary);
}

.combobox-input.is-invalid {
    border-color: var(--color-danger);
    background: var(--color-error-tint);
}

.combobox-list {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.combobox-option {
    padding: 7px 10px;
    border-radius: 6px;
    font-size: var(--text-md);
    color: var(--color-text);
    cursor: pointer;
}

/* Keyboard cursor */
.combobox-option.is-active {
    background: var(--color-surface-subtle);
    box-shadow: inset 2px 0 0 var(--color-primary);
}

/* The info pair is tuned per theme; solid --color-primary with white text only
   reaches 3.68:1 in dark mode, which fails AA. */
.combobox-option.is-selected {
    background: var(--color-info-bg);
    color: var(--color-info-text);
    font-weight: 600;
}

.combobox-option.is-placeholder { color: var(--color-muted); }
.combobox-option.is-selected.is-placeholder { color: var(--color-info-text); }

.combobox-empty {
    padding: 10px;
    font-size: var(--text-md);
    color: var(--color-muted);
}

/* ===== Page tabs =====
   Sibling pages behind one sidebar entry (Barang | Kategori). Underlined
   rather than boxed so they read as navigation, not as another button row
   competing with Terapkan/Reset just below. */
.page-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

/* -1px pulls the active underline over the strip's own border */
.page-tab {
    padding: 8px 14px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    color: var(--color-muted);
    text-decoration: none;
}

.page-tab:hover { color: var(--color-text); text-decoration: none; }

/* --color-primary on --color-bg: 4.8:1 light, 5.1:1 dark */
.page-tab.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ===== Filter toolbar =====
   A filter row is a control surface, not data. Giving it .card made it carry
   the same visual weight as the results below it. */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: var(--color-surface-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

/* Fields sit on one line inside the toolbar, so their stacking margin goes */
.toolbar .form-group { margin-bottom: 0; }

.toolbar label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Search-style field that should absorb the leftover width */
.toolbar-grow { flex: 1; min-width: 200px; }

/* ===== Utilities ===== */
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-muted { color: var(--color-muted); }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-md { font-size: var(--text-md); }

/* Two master lists on one page (Kategori | Brand). min() keeps a single
   column from overflowing a phone-width screen. */
.master-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr));
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.master-grid > .card { margin-bottom: 0; }

/* Inline add form: the field takes the leftover width. Set from the parent so
   the input keeps a single class attribute for invalid_attrs() to own. */
.category-form input[type="text"] { flex: 1; }

.unit-category-rename { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.unit-category-rename input[type="text"] { flex: 1 1 180px; min-width: 0; }

@media (max-width: 640px) {
    .unit-category-table thead { display: none; }
    .unit-category-table tbody { display: grid; gap: 12px; }
    .unit-category-table tr { display: block; border: 1px solid var(--color-border); border-radius: 12px; padding: 14px; }
    .unit-category-table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; padding: 0; }
    .unit-category-table td + td { margin-top: 12px; }
    .unit-category-table td::before { content: attr(data-label); color: var(--color-muted); font-size: var(--text-sm); font-weight: 600; }
    .unit-category-table td:first-child { display: block; }
    .unit-category-table td:first-child::before { display: block; margin-bottom: 8px; }
}

/* Emoji marker on empty-state cards */
.empty-glyph { font-size: var(--text-2xl); line-height: 1; }

/* Signed stock movements — tokenised so they survive a theme switch */
.text-pos { color: var(--color-success-text); font-weight: 600; }
.text-neg { color: var(--color-error-text); font-weight: 600; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-start { align-items: flex-start; }
.flex-1 { flex: 1; }
.gap-sm { gap: 6px; }
.w-auto { width: auto; }
.w-full { width: 100%; }
.font-normal { font-weight: 400; }

/* Single-column forms read better constrained; wider variants for detail pages */
.max-w-sm { max-width: 560px; }
.max-w-md { max-width: 620px; }
.max-w-lg { max-width: 720px; }
.max-w-xl { max-width: 760px; }
.max-w-2xl { max-width: 860px; }
.purchase-form-card { max-width: 1100px; }

/* Keep each purchase item readable with its brand on narrow screens. */
@media (max-width: 768px) {
    .purchase-items-table thead { display: none; }
    .purchase-items-table tbody,
    .purchase-items-table tfoot { display: block; }
    .purchase-items-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 16px 0;
        border-bottom: 1px solid var(--color-border);
    }
    .purchase-items-table tbody td { min-width: 0; padding: 0; border: 0; }
    .purchase-items-table tbody td:nth-child(-n+2) { grid-column: 1 / -1; }
    .purchase-items-table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        color: var(--color-muted);
        font-size: var(--text-sm);
        font-weight: 600;
    }
    .purchase-items-table .subtotal-cell { text-align: left; }
    .purchase-items-table tbody td:last-child { align-self: end; justify-self: end; }
    .purchase-items-table tfoot tr { display: flex; justify-content: space-between; }
    .purchase-items-table tfoot th { border: 0; }
    .purchase-items-table tfoot th:last-child { display: none; }
}

/* Explicit column widths, previously inline on <th> */
.col-xs { width: 50px; }
.col-sm { width: 60px; }
.col-md { width: 100px; }
.col-lg { width: 120px; }
.col-xl { width: 140px; }
.col-2xl { width: 150px; }
.col-3xl { width: 180px; }
.col-4xl { width: 300px; }

/* ===== Mobile component overrides =====
   Deliberately last in the file: these target components declared further up
   (.kpi-grid, .chart-box, .stat-grid-2), and at equal specificity the later
   rule wins. Putting them in the layout media query near the top silently
   lost to the base declarations. */
@media (max-width: 768px) {
    /* Two-up, so four KPIs don't occupy a whole screen before any content */
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-value { font-size: var(--text-2xl); }

    /* 300px is tall and narrow once the viewport is 375px wide */
    .chart-box { height: 220px; }

    .stat-grid-2 { grid-template-columns: 1fr; }

    /* Filter fields stack rather than squeezing side by side */
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions { margin-left: 0; }

    /* Card headers with several actions (Export Excel, CSV, Penyesuaian Stok):
       the buttons drop below the title instead of crushing it or overflowing */
    .flex-between { flex-wrap: wrap; gap: 12px; }
    .flex-between > .flex { flex-wrap: wrap; }
}

/* Drawer chrome visibility — last, so it outranks .btn-icon's display */
.nav-toggle,
.nav-overlay { display: none; }

@media (max-width: 768px) {
    .nav-toggle { display: inline-flex; }
    .no-js .nav-toggle { display: none; }

    .nav-overlay { display: block; }
    .no-js .nav-overlay { display: none; }
}
