/* ============================================================
   ShopSaathi — Modern Design System
   Mobile-first, card-based, with light + dark theme.
   Used by all shop-facing pages via templates/shop/base.html
   ============================================================ */

:root {
    /* Brand — trustworthy retail green + amber accent */
    --brand:        #16a34a;
    --brand-dark:   #15803d;
    --brand-light:  #dcfce7;
    --accent:       #f59e0b;
    --accent-light: #fef3c7;

    /* Status colors */
    --green:  #16a34a;
    --blue:   #2563eb;
    --purple: #7c3aed;
    --red:    #dc2626;
    --orange: #ea580c;
    --teal:   #0d9488;

    /* Surfaces & text (light theme) */
    --bg:        #f1f5f9;
    --surface:   #ffffff;
    --surface-2: #f8fafc;
    --border:    #e2e8f0;
    --text:      #0f172a;
    --text-soft: #64748b;
    --text-mute: #94a3b8;

    /* Shape & motion */
    --radius:    16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --shadow:    0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md: 0 4px 12px rgba(15,23,42,.10);
    --shadow-lg: 0 12px 32px rgba(15,23,42,.16);
    --ease: cubic-bezier(.4,0,.2,1);

    --topbar-h: 58px;
    --bottomnav-h: 64px;
    --maxw: 1180px;
}

[data-theme="dark"] {
    --bg:        #0b1120;
    --surface:   #131c2e;
    --surface-2: #1b2740;
    --border:    #28344e;
    --text:      #e8edf6;
    --text-soft: #9aa8c0;
    --text-mute: #64748b;
    --brand-light: #143524;
    --accent-light:#3a2d09;
    --shadow:    0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

html { -webkit-text-size-adjust:100%; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
    padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    transition: background .25s var(--ease), color .25s var(--ease);
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ================= TOP APP BAR ================= */
.topbar {
    position: sticky; top: 0; z-index: 60;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.topbar .menu-btn,
.topbar .icon-btn {
    width: 40px; height: 40px; flex: 0 0 40px;
    display: grid; place-items: center;
    border: none; background: transparent;
    border-radius: 12px; font-size: 20px; color: var(--text);
    transition: background .15s var(--ease);
}
.topbar .menu-btn:active,
.topbar .icon-btn:active { background: var(--surface-2); }
.topbar .sync-btn {
    position: relative;
    font-size: 13px;
    font-weight: 800;
}
.topbar .sync-btn.has-pending {
    color: var(--orange);
}
#offlinePendingCount {
    position: absolute;
    top: 4px;
    right: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    font-weight: 800;
}
#offlinePendingCount:empty { display: none; }
.offline-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
}
.offline-tabs button {
    min-height: 42px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    font-weight: 800;
    font-size: 13px;
}
.offline-tabs button.active {
    border-color: var(--brand);
    background: var(--brand-light);
    color: var(--brand-dark);
}
.offline-notice {
    border-color: var(--orange);
}
@media (max-width: 380px) {
    .offline-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.topbar .shop-title {
    flex: 1; min-width: 0;
    display: flex; align-items: center; gap: 9px;
}
.topbar .shop-title .logo-dot {
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 9px; display: grid; place-items: center;
    background: var(--brand); color: #fff; font-weight: 800; font-size: 15px;
}
.topbar .shop-title b {
    font-size: 16px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 2px; }

/* ================= SIDE DRAWER ================= */
.drawer-scrim {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(2,6,23,.5); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    width: 290px; max-width: 84vw;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .28s var(--ease);
    display: flex; flex-direction: column;
    overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
    padding: 20px 18px; background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
}
.drawer-head .logo-dot {
    width: 44px; height: 44px; border-radius: 13px; background: rgba(255,255,255,.2);
    display: grid; place-items: center; font-size: 22px; font-weight: 800; margin-bottom: 10px;
}
.drawer-head b { font-size: 18px; display: block; }
.drawer-head small { opacity: .85; font-size: 12.5px; }
.drawer-head .plan-pill {
    display: inline-block; margin-top: 10px; padding: 3px 11px;
    background: rgba(255,255,255,.22); border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .5px;
}
.drawer-nav { padding: 10px 0; flex: 1; }
.drawer-nav .section-label {
    padding: 14px 20px 6px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px; color: var(--text-mute);
}
.drawer-nav a {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 20px; font-size: 15px; font-weight: 500; color: var(--text);
    transition: background .15s var(--ease);
}
.drawer-nav a .di { font-size: 19px; width: 24px; text-align: center; }
.drawer-nav a:active { background: var(--surface-2); }
.drawer-nav a.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 700; }
.drawer-nav a.danger { color: var(--red); }

/* ================= BOTTOM NAV (mobile) ================= */
.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex; align-items: stretch;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(15,23,42,.06);
}
.bottomnav a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    font-size: 10.5px; font-weight: 600; color: var(--text-mute);
    transition: color .15s var(--ease);
}
.bottomnav a .bi { font-size: 21px; line-height: 1; }
.bottomnav a.active { color: var(--brand); }
.bottomnav a.fab-slot { position: relative; }
.bottomnav .fab {
    width: 56px; height: 56px; margin-top: -22px;
    border-radius: 18px; background: var(--brand); color: #fff;
    display: grid; place-items: center; font-size: 26px;
    box-shadow: 0 6px 16px rgba(22,163,74,.45);
    border: 4px solid var(--surface);
}
.bottomnav a.fab-slot span.lbl { color: var(--brand); margin-top: 1px; }

/* ================= LAYOUT ================= */
.page { max-width: var(--maxw); margin: 0 auto; padding: 16px 14px 8px; }
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-head h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-soft); font-size: 13.5px; margin-top: 2px; }

/* ================= CARDS ================= */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px;
}
.card.pad-0 { padding: 0; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display:flex; align-items:center; gap:8px; }

/* ================= STAT TILES ================= */
.stat-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 18px;
}
@media(min-width:640px){ .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media(min-width:980px){ .stat-grid { grid-template-columns: repeat(6, 1fr); } }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 15px 15px 16px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
    background: var(--c, var(--brand));
}
.stat .ic {
    width: 38px; height: 38px; border-radius: 11px; margin-bottom: 10px;
    display: grid; place-items: center; font-size: 19px;
    background: color-mix(in srgb, var(--c, var(--brand)) 14%, transparent);
    color: var(--c, var(--brand));
}
.stat .k { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--text-mute); }

/* color helpers */
.c-green  { --c: var(--green); }
.c-blue   { --c: var(--blue); }
.c-purple { --c: var(--purple); }
.c-red    { --c: var(--red); }
.c-orange { --c: var(--orange); }
.c-teal   { --c: var(--teal); }
.c-accent { --c: var(--accent); }

/* ================= BUTTONS ================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
    font-size: 14.5px; font-weight: 700; color: #fff; background: var(--brand);
    transition: transform .08s var(--ease), filter .15s var(--ease), background .15s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.05); }
.btn.lg { padding: 15px 26px; font-size: 16px; border-radius: var(--radius); }
.btn.block { width: 100%; }
.btn.blue   { background: var(--blue); }
.btn.red    { background: var(--red); }
.btn.teal   { background: var(--teal); }
.btn.wa     { background: #25D366; }
.btn.ghost  { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.soft   { background: var(--brand-light); color: var(--brand-dark); }
.btn.sm     { padding: 7px 12px; font-size: 12.5px; }

/* ================= FORMS ================= */
.field { margin-bottom: 14px; }
.field label, .lbl {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--text-soft); margin-bottom: 6px;
}
input, select, textarea {
    width: 100%; padding: 12px 14px;
    background: var(--surface); color: var(--text);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
input::placeholder { color: var(--text-mute); }
.input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input-row > * { flex: 1; min-width: 130px; }

/* ================= TABLE ================= */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 14px; text-align: left; font-size: 13.5px; }
table.data thead th {
    background: var(--surface-2); color: var(--text-soft);
    font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* ================= BADGES & CHIPS ================= */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.badge.green  { background: var(--brand-light); color: var(--brand-dark); }
.badge.blue   { background: #dbeafe; color: #1d4ed8; }
.badge.red    { background: #fee2e2; color: #b91c1c; }
.badge.amber  { background: var(--accent-light); color: #b45309; }
.badge.gray   { background: var(--surface-2); color: var(--text-soft); }
[data-theme="dark"] .badge.blue { background:#1e3a5f; color:#93c5fd; }
[data-theme="dark"] .badge.red  { background:#451a1a; color:#fca5a5; }

/* ================= EMPTY STATE ================= */
.empty {
    text-align: center; padding: 48px 20px; color: var(--text-mute);
}
.empty .e-ic { font-size: 46px; margin-bottom: 12px; opacity: .6; }
.empty p { font-size: 14px; }

/* ================= TOASTS ================= */
#toast-host {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--bottomnav-h) + 18px); z-index: 200;
    display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: 90vw;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 18px; border-radius: var(--radius);
    background: #0f172a; color: #fff; box-shadow: var(--shadow-lg);
    font-size: 14px; font-weight: 600;
    animation: toast-in .3s var(--ease);
}
.toast.ok  { background: var(--brand-dark); }
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity:0; transform: translateY(14px) scale(.96);} to {opacity:1; transform:none;} }

/* ================= MISC ================= */
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 22px 0 6px; }
.pagination a { padding: 9px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
.pagination span { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.muted { color: var(--text-soft); }
.text-red { color: var(--red); font-weight: 700; }
.text-green { color: var(--green); font-weight: 700; }
.grid-2 { display: grid; gap: 16px; }
@media(min-width:900px){ .grid-2 { grid-template-columns: 1fr 1fr; } }
.flex-between { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.hide-mobile { display: none; }
@media(min-width:760px){ .hide-mobile { display: revert; } .only-mobile { display:none !important; } }

/* Language sheet */
.lang-sheet-scrim { position: fixed; inset: 0; z-index: 110; background: rgba(2,6,23,.5); opacity:0; pointer-events:none; transition: opacity .2s; }
.lang-sheet-scrim.open { opacity:1; pointer-events:auto; }
.lang-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
    background: var(--surface); border-radius: 22px 22px 0 0;
    padding: 10px 14px calc(20px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg); transform: translateY(105%);
    transition: transform .28s var(--ease); max-width: 520px; margin: 0 auto;
}
.lang-sheet.open { transform: translateY(0); }
.lang-sheet h3 { text-align:center; font-size:15px; padding: 12px 0 6px; }
.lang-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding: 8px 0; }
.lang-grid button {
    padding: 14px 8px; border: 1.5px solid var(--border); background: var(--surface);
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--text);
}
.lang-grid button.active { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }

/* ============================================================
   2026 SaaS polish layer
   Non-destructive overrides for a unified analytics workspace.
   ============================================================ */
:root {
    --brand: #0f9f6e;
    --brand-dark: #08734f;
    --brand-light: #ddf8ed;
    --accent: #c47b0b;
    --accent-light: #fff4d6;
    --green: #0f9f6e;
    --blue: #2563eb;
    --purple: #6d5dfc;
    --red: #dc2626;
    --orange: #d97706;
    --teal: #0f766e;
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-2: #f7fafc;
    --surface-3: #edf3f8;
    --border: #dce5ef;
    --border-2: #cbd8e6;
    --text: #111827;
    --text-soft: #526173;
    --text-mute: #8a98a9;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 8px;
    --shadow: 0 1px 2px rgba(17,24,39,.06), 0 1px 1px rgba(17,24,39,.04);
    --shadow-md: 0 8px 22px rgba(17,24,39,.08);
    --shadow-lg: 0 18px 44px rgba(17,24,39,.16);
    --topbar-h: 64px;
    --bottomnav-h: 66px;
    --sidebar-w: 292px;
    --maxw: 1240px;
}

[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #121b2b;
    --surface-2: #182235;
    --surface-3: #202b40;
    --border: #263348;
    --border-2: #34435a;
    --text: #edf2f8;
    --text-soft: #a8b5c7;
    --text-mute: #748297;
}

body {
    font-size: 15px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--bg) 86%, #fff), var(--bg) 240px),
        var(--bg);
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--brand) 34%, transparent);
    outline-offset: 2px;
}

.topbar {
    height: var(--topbar-h);
    padding: 0 16px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(18px);
}

.topbar .menu-btn,
.topbar .icon-btn {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 18px;
    transition: background .15s var(--ease), border-color .15s var(--ease), transform .12s var(--ease);
}

.topbar .menu-btn:hover,
.topbar .icon-btn:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.topbar .menu-btn:active,
.topbar .icon-btn:active,
.btn:active {
    transform: translateY(1px);
}

.topbar .shop-title .logo-dot,
.bottomnav .fab,
.drawer-head {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}

.topbar .shop-title .logo-dot {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: var(--radius);
}

.drawer {
    width: var(--sidebar-w);
}

.drawer-head {
    padding: 22px 20px;
}

.drawer-head .logo-dot {
    border-radius: var(--radius);
}

.drawer-nav {
    padding: 12px 10px;
}

.drawer-nav .section-label {
    padding: 16px 10px 7px;
    font-weight: 800;
    letter-spacing: .08em;
}

.drawer-nav a {
    gap: 12px;
    padding: 10px 11px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 650;
}

.drawer-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.drawer-nav a.active {
    font-weight: 800;
}

.bottomnav {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 -8px 24px rgba(17,24,39,.08);
    backdrop-filter: blur(18px);
}

.bottomnav .fab {
    border-radius: var(--radius);
}

.page {
    padding: 20px 14px 8px;
}

.page-head,
.toolbar {
    margin-bottom: 18px;
}

.page-head h1 {
    font-size: clamp(22px, 3vw, 30px);
    line-height: 1.15;
    letter-spacing: 0;
    font-weight: 850;
}

.page-head .sub {
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 14px;
}

.card,
.stat,
.analytics-card,
.section-card,
.kpi-card {
    border-radius: var(--radius);
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.card-title,
.section-title {
    letter-spacing: 0;
    font-weight: 850;
}

.stat {
    min-height: 130px;
    padding: 16px;
}

.stat::before {
    inset: 0 0 auto;
    width: auto;
    height: 3px;
    background: linear-gradient(90deg, var(--c, var(--brand)), transparent);
}

.stat .ic {
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.stat .k {
    font-weight: 750;
}

.stat .v {
    font-size: 24px;
    letter-spacing: 0;
    font-weight: 850;
}

.btn {
    min-height: 42px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    font-size: 14px;
    font-weight: 800;
    transition: transform .12s var(--ease), filter .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
}

.btn:hover {
    filter: brightness(1.03);
    box-shadow: var(--shadow);
}

.btn.lg {
    border-radius: var(--radius);
    padding: 14px 24px;
    font-size: 15.5px;
}

.btn.sm {
    min-height: 34px;
    padding: 7px 12px;
}

.btn.ghost {
    background: var(--surface);
    color: var(--text);
}

.btn.soft {
    background: var(--brand-light);
    color: var(--brand-dark);
}

input,
select,
textarea {
    min-height: 44px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
}

table.data th,
table.data td {
    padding: 13px 14px;
}

table.data tbody tr:hover {
    background: color-mix(in srgb, var(--brand-light) 28%, var(--surface));
}

.badge {
    padding: 4px 10px;
    font-weight: 800;
}

.toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

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

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--brand-dark);
    background: var(--brand-light);
    border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--border));
    padding: 5px 9px;
    border-radius: 999px;
    margin-bottom: 9px;
}

.hero-panel {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--surface) 94%, var(--brand-light)), var(--surface)),
        radial-gradient(circle at top right, color-mix(in srgb, var(--brand-light) 75%, transparent), transparent 42%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi-card {
    background: var(--surface);
    padding: 16px;
    min-height: 126px;
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: "";
    position: absolute;
    right: -28px;
    top: -34px;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--c, var(--brand)) 11%, transparent);
}

.kpi-card .kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.kpi-card .kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--c, var(--brand)) 13%, transparent);
    color: var(--c, var(--brand));
    font-size: 17px;
    position: relative;
    z-index: 1;
}

.kpi-card .kpi-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-soft);
}

.kpi-card .kpi-value {
    font-size: 25px;
    line-height: 1;
    font-weight: 900;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-note {
    margin-top: 7px;
    color: var(--text-mute);
    font-size: 12px;
}

.analytics-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 18px;
    grid-template-columns: 1fr;
}

.analytics-card {
    background: var(--surface);
    padding: 18px;
    min-height: 320px;
}

.analytics-card canvas {
    max-height: 260px;
}

.section-card {
    background: var(--surface);
    margin-bottom: 18px;
}

.section-card > .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.section-card > .section-body {
    padding: 18px;
}

.section-title {
    font-size: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-sub {
    color: var(--text-soft);
    font-size: 13px;
    margin-top: 3px;
}

.form-grid {
    display: grid;
    gap: 12px;
    align-items: end;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.span-2 {
    grid-column: span 2;
}

.action-row,
.inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-actions {
    justify-content: flex-end;
}

.metric-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 750;
}

.metric-pill b {
    color: var(--text);
}

.notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid color-mix(in srgb, var(--orange) 22%, var(--border));
    background: color-mix(in srgb, var(--accent-light) 64%, var(--surface));
    color: #7c4a03;
    margin-bottom: 18px;
}

[data-theme="dark"] .notice {
    color: #f6d99a;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--c, var(--green));
    display: inline-block;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--green)) 14%, transparent);
}

.desktop-table {
    display: block;
}

.mobile-card-list {
    display: none;
}

@media (min-width: 760px) {
    .kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 980px) {
    body {
        padding-bottom: 0;
    }

    .topbar {
        left: var(--sidebar-w);
        padding-left: 22px;
    }

    .topbar .menu-btn {
        display: none;
    }

    .drawer {
        transform: none;
        box-shadow: none;
        z-index: 65;
        border-right: 1px solid var(--border);
    }

    .drawer-scrim {
        display: none;
    }

    main {
        margin-left: var(--sidebar-w);
    }

    .page {
        padding: 28px 28px 36px;
    }

    .bottomnav {
        display: none;
    }

    .analytics-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    }

    .kpi-grid.cols-6 {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .page {
        padding: 18px 14px 8px;
    }

    .page-head h1 {
        font-size: 23px;
    }

    .span-2 {
        grid-column: auto;
    }

    .toolbar,
    .toolbar-actions {
        align-items: stretch;
    }

    .toolbar-actions > .btn,
    .toolbar-actions > form,
    .toolbar-actions > a {
        width: 100%;
    }

    .desktop-table.mobile-hide {
        display: none;
    }

    .mobile-card-list {
        display: grid;
        gap: 10px;
    }

    .card,
    .section-card > .section-body,
    .analytics-card {
        padding: 16px;
    }

    table.data th,
    table.data td {
        padding: 11px 12px;
    }
}

/* Billing and dense table refinements */
.bill-actionbar {
    background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
    backdrop-filter: blur(18px);
}
.bill-actionbar .btn {
    min-width: 132px;
}
#billTable input,
#billTable select {
    min-width: 0;
}
@media (min-width: 980px) {
    .bill-actionbar {
        left: var(--sidebar-w) !important;
        bottom: 0 !important;
        padding-left: 28px !important;
        padding-right: 28px !important;
    }
}
@media (max-width: 520px) {
    .bill-actionbar {
        gap: 8px !important;
        padding: 9px 12px !important;
    }
    .bill-actionbar .btn {
        min-width: 0;
        padding-left: 12px;
        padding-right: 12px;
    }
    .bill-actionbar .bab-total b {
        font-size: 17px !important;
    }
}
@media (min-width: 980px) {
    .topbar {
        left: 0 !important;
        width: calc(100% - var(--sidebar-w));
        margin-left: var(--sidebar-w);
    }
}
