/* ============================================================
   ELLYMAR Bakery · obsidian marble skin  (app-wide)
   ------------------------------------------------------------
   Loaded once for every page that uses views/layout/header.php,
   right after style.css. Purely presentational: it re-maps colour
   tokens and restyles shared chrome/components. No markup, routes,
   queries, forms or permissions are touched.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ---- 1. Tokens -------------------------------------------------------
   Re-map the app's brand variables instead of fighting individual rules,
   so shared chrome (topbar, ribbon, buttons, cards) inherits the skin. */
body.dark-mode {
    --tx-bg: #06051a;
    --tx-ink: #efeeff;
    --tx-mute: #9a96c4;
    --tx-amber: #ffb23e;
    --tx-glass: rgb(28 22 66 / .52);
    --tx-rim-top: rgb(255 255 255 / .2);
    --tx-rim: rgb(255 255 255 / .08);
    --tx-shadow: rgb(0 0 0 / .45);
    --tx-chip: #ffffff12;

    --sweet-harmony-gold: #ffb23e;
    --sweet-harmony-gold-dark: #e0782a;
    --sweet-harmony-crust: #0b0a20;
    --sweet-harmony-crust-dark: #06051a;
    --sweet-harmony-cream: #12102e;
    --sweet-harmony-cream-deep: #0d0b24;
    --sweet-harmony-ink: #efeeff;
    --sweet-harmony-muted: #9a96c4;
    --sweet-harmony-red: #ff6b6b;
    --sweet-harmony-red-dark: #d93a3a;
    --sweet-harmony-ai: #a78bfa;
    --sweet-harmony-ai-light: #2a2350;

    --glass-bg: var(--tx-glass);
    --glass-bg-strong: rgb(22 17 52 / .78);
    --glass-border: var(--tx-rim);
    --shadow-soft: 0 4px 24px rgb(0 0 0 / .35);
    --shadow-lift: 0 18px 44px rgb(0 0 0 / .55);
    --radius: 20px;
    --btn-gradient: linear-gradient(#ffd27a, #ff9f2a);
    --btn-shadow: 0 6px 18px #ff9f2a44;
    --btn-shadow-hover: 0 12px 28px #ffb23e66;

    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--tx-ink);
    background:
        radial-gradient(58% 46% at 12% 4%, #125b514d, transparent 72%),
        radial-gradient(48% 46% at 100% 94%, #9a512c3d, transparent 72%),
        radial-gradient(38% 34% at 88% 18%, #165c6652, transparent 74%),
        linear-gradient(145deg, #070a0d, #0b1115 54%, #101216);
    background-attachment: fixed;
}

/* Fine mineral veining behind the shared app shell. */
body.dark-mode::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(ellipse 70% 50% at 12% 26%, transparent 54%, rgb(90 215 194 / .12) 54.3%, transparent 54.7%, transparent 68%, rgb(90 215 194 / .08) 68.3%, transparent 68.7%),
        radial-gradient(ellipse 64% 48% at 88% 72%, transparent 58%, rgb(207 145 95 / .1) 58.3%, transparent 58.7%, transparent 73%, rgb(90 215 194 / .07) 73.3%, transparent 73.7%);
    background-size: 980px 720px, 840px 680px;
    opacity: .52;
    animation: tx-twinkle 9s ease-in-out infinite alternate;
}
@keyframes tx-twinkle {
    from { opacity: .5; }
    to   { opacity: .88; }
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
    font-family: "Space Grotesk", Inter, sans-serif;
}

/* ---- 2. Chrome: topbar + ribbon -------------------------------------- */
body.dark-mode .topbar {
    /* the base rule parks an !important white wash here, so match it */
    background: rgb(9 7 28 / .66) !important;
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    border-bottom: 1px solid rgb(255 255 255 / .08);
    border-image: none;
    box-shadow: 0 12px 34px rgb(0 0 0 / .35);
}
body.dark-mode .logo-wordmark {
    font-family: "Space Grotesk", Inter, sans-serif;
    font-weight: 700;
    letter-spacing: .2px;
    background: linear-gradient(120deg, #ffd27a, #ffb23e 45%, #ff8a3d);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
body.dark-mode .logo-tagline {
    color: var(--tx-mute);
    letter-spacing: .18em;
}
body.dark-mode .glass-clock {
    padding: 6px 14px;
    border-radius: 99px;
    background: var(--tx-chip);
    box-shadow: inset 0 1px 0 var(--tx-rim-top), inset 0 0 0 1px var(--tx-rim);
    color: var(--tx-ink);
}
body.dark-mode .user-info { color: var(--tx-mute); }
body.dark-mode .user-info strong { color: var(--tx-ink); }
body.dark-mode .topbar-avatar-initials {
    background: linear-gradient(#ffb23e, #e0782a);
    color: #2a1700;
}
body.dark-mode .logout-link { color: #ff9d8a; border-radius: 99px; }
body.dark-mode .logout-link:hover { background: #ff8a3d1f; }

body.dark-mode .ribbon {
    /* NOTE: no backdrop-filter here — it would become the containing block for
       the position:fixed .ribbon-panel dropdowns and break their placement. */
    background: rgb(11 9 32 / .92) !important;
    border-bottom: 1px solid rgb(255 255 255 / .06);
}
body.dark-mode .ribbon-menu {
    background: linear-gradient(180deg, #181233, #0a0820) !important;
    border: 1px solid #ffffff1f;
    box-shadow: 0 18px 40px #000a;
}
body.dark-mode .ribbon-tabs { align-items: center; padding: 2px 0; }
body.dark-mode .ribbon-tab {
    margin: 7px 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 99px;
    color: var(--tx-mute);
    font-family: inherit;
}
body.dark-mode .ribbon-tab:hover {
    color: var(--tx-ink);
    background: var(--tx-chip);
}
body.dark-mode .ribbon-tab.active {
    color: #2a1700;
    background: linear-gradient(#ffd27a, #ff9f2a);
    box-shadow: 0 6px 16px #ff9f2a44, inset 0 1px 0 #ffffff99;
}
/* Marble indicator layers onto existing ribbon controls; links and dropdowns stay intact. */
body.dark-mode .ribbon-tabs.marble-ready {
    position: relative;
    isolation: isolate;
    align-items: center;
    padding: 2px 0 34px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border: 1px solid #ffffff16;
    border-radius: 20px;
    background: linear-gradient(180deg, #1b1b1e 0%, #0c0c0e 100%);
    box-shadow: 0 10px 28px #0007, 0 14px 38px #f5a62312;
}
body.dark-mode .ribbon-tabs.marble-ready::-webkit-scrollbar { display: none; }
body.dark-mode .ribbon-tabs .marble-track,
body.dark-mode .ribbon-tabs .marble-ball { position: absolute; pointer-events: none; }
body.dark-mode .ribbon-tabs .marble-track {
    z-index: 0; bottom: 7px; height: 23px; border-radius: 20px;
    background: #050506; box-shadow: inset 0 2px 5px #000, 0 1px 0 #ffffff0a;
}
body.dark-mode .ribbon-tabs .marble-ball {
    z-index: 0; bottom: 3px; width: 32px; height: 32px; border-radius: 50%;
    will-change: transform;
    filter: drop-shadow(0 5px 5px #000b) drop-shadow(0 0 7px #35dbc477) drop-shadow(0 0 11px #f5a62366);
}
body.dark-mode .ribbon-tabs .marble-ball::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: url("./marble-orb.png") center / 100% 100% no-repeat;
    animation: marble-orb-spin 5s linear infinite;
}
@keyframes marble-orb-spin { to { transform: rotate(360deg); } }
body.dark-mode .ribbon-tabs .ribbon-tab { position: relative; z-index: 1; }
body.dark-mode .ribbon-tabs .ribbon-tab.active {
    color: #fff2dc; background: transparent; box-shadow: none; border-bottom-color: transparent;
}
body.dark-mode .ribbon-tabs .ribbon-tab.marble-lit { color: #fff2dc; text-shadow: 0 0 12px #f5a62366; }
body.dark-mode .ribbon-tabs .ribbon-tab:hover { background: #ffffff0d; }
body.dark-mode .store-eta-editor { display: grid; gap: 6px; min-width: 205px; margin: 6px 0; }
body.dark-mode .store-eta-editor small { color: var(--tx-mute); }
body.dark-mode .store-eta-editor .eta-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
body.dark-mode .store-eta-editor input { min-width: 0; max-width: 190px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
/* Public storefront navigation uses the same animated marble indicator. */
body.dark-mode .store-nav.marble-ready {
    position: relative;
    isolation: isolate;
    padding: 6px 12px 28px;
    margin-bottom: -20px;
    border: 1px solid rgb(145 219 204 / .18);
    border-radius: 18px;
    background: linear-gradient(145deg, rgb(25 39 40 / .88), rgb(13 18 23 / .94));
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 8px 24px rgb(0 0 0 / .28);
}
body.dark-mode .store-nav .marble-track,
body.dark-mode .store-nav .marble-ball { position: absolute; pointer-events: none; }
body.dark-mode .store-nav .marble-track {
    z-index: 0; bottom: 5px; height: 18px; border-radius: 20px;
    background: #050607; box-shadow: inset 0 2px 5px #000, 0 1px 0 #ffffff0a;
}
body.dark-mode .store-nav .marble-ball {
    z-index: 0; bottom: 0; width: 28px; height: 28px; border-radius: 50%;
    filter: drop-shadow(0 4px 5px #000b) drop-shadow(0 0 7px #35dbc477) drop-shadow(0 0 10px #f5a62366);
}
body.dark-mode .store-nav .marble-ball::before {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    background: url("./marble-orb.png") center / 100% 100% no-repeat;
    animation: marble-orb-spin 5s linear infinite;
}
body.dark-mode .store-nav > a { position: relative; z-index: 1; }
body.dark-mode .store-nav > a.marble-lit { color: #fff2dc; text-shadow: 0 0 12px #f5a62366; }
@media (max-width: 760px) {
    body.dark-mode .store-nav.marble-ready { gap: 10px; padding: 5px 9px 25px; }
}
@media (max-width: 700px) {
    body.dark-mode .ribbon-tabs.marble-ready { padding-bottom: 32px; border-radius: 17px; }
}
@media (prefers-reduced-motion: reduce) {
    body.dark-mode .ribbon-tabs .marble-ball { will-change: auto; }
    body.dark-mode .ribbon-tabs .marble-ball::before { animation: none; }
    body.dark-mode .ribbon-tabs .ribbon-tab { transition: none; }
}

body.dark-mode .ribbon-depot-picker {
    border-color: #ffb23e59;
    background: linear-gradient(120deg, #2a1c46, #171034);
    box-shadow: inset 0 1px 0 #ffffff1f;
    color: #ffd9a0;
}
body.dark-mode .ribbon-depot-picker select {
    border-color: #ffffff26;
    background: #0d0a24;
    color: var(--tx-ink);
}
body.dark-mode .ribbon-depot-picker option { color: #17213b; background: #fff; }

/* dropdown groups: light panel -> glass panel */
body.dark-mode .ribbon-panel {
    background: linear-gradient(180deg, #181233, #0a0820);
    border-top: 1px solid #ffb23e66;
    box-shadow: 0 28px 60px #000b;
}
body.dark-mode .ribbon-btn { color: #e6e3ff; border-radius: 14px; }
body.dark-mode .ribbon-btn:hover { background: #ffb23e1f; }
body.dark-mode .ribbon-group-caption { color: #8f8ab8; border-top-color: #ffffff12; }
body.dark-mode .ribbon-group-divider { background: #ffffff14; }

/* ---- 3. Page shell ---------------------------------------------------- */
body.dark-mode .container {
    position: relative;
    z-index: 1;
    /* the base layout shrinks .container to its content because of margin:auto
       inside a column flex body — force the full column so every dashboard
       role gets the same canvas */
    width: 100%;
    max-width: 1180px;
    padding: 30px 22px 70px;
}
body.dark-mode .container > * {
    animation: tx-rise .55s cubic-bezier(.22, .7, .28, 1) backwards;
}
body.dark-mode .container > *:nth-child(2) { animation-delay: .04s; }
body.dark-mode .container > *:nth-child(3) { animation-delay: .08s; }
body.dark-mode .container > *:nth-child(4) { animation-delay: .12s; }
body.dark-mode .container > *:nth-child(5) { animation-delay: .16s; }
body.dark-mode .container > *:nth-child(6) { animation-delay: .2s; }
@keyframes tx-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

body.dark-mode .app-footer {
    position: relative;
    z-index: 1;
    background: rgb(9 7 28 / .72);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
    border-top: 1px solid #ffffff0f;
    color: var(--tx-mute);
    font-size: .75rem;
}

/* ---- 4. Hero --------------------------------------------------------- */
body.dark-mode .dashboard-hero {
    align-items: flex-end;
    gap: 26px;
    isolation: isolate;
    padding: clamp(26px, 3.2vw, 40px);
    border: 1px solid var(--tx-rim);
    border-radius: 26px;
    background:
        radial-gradient(120% 120% at 88% -20%, #ffb23e33, transparent 62%),
        radial-gradient(100% 120% at 4% 120%, #8f5bff38, transparent 60%),
        linear-gradient(160deg, rgb(33 24 72 / .78), rgb(11 9 32 / .82));
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
    box-shadow:
        inset 0 1px 0 var(--tx-rim-top),
        inset 0 0 0 1px var(--tx-rim),
        0 26px 60px rgb(0 0 0 / .5);
}
/* soft amber nebula + a single moon: never a hard edge over the copy */
body.dark-mode .dashboard-hero::before {
    content: "";
    position: absolute;
    z-index: -1;
    right: -170px;
    top: -230px;
    width: 640px;
    height: 640px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 62% 45%, #fff6e2 0 2.5px, transparent 4px),
        radial-gradient(circle at 62% 45%, #ffb23eaa, transparent 46px),
        radial-gradient(circle at 50% 50%, #ffb23e4d, #ffb23e17 40%, transparent 68%);
    filter: blur(6px);
    pointer-events: none;
}
body.dark-mode .dashboard-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    right: -120px;
    top: -34px;
    width: 540px;
    height: 200px;
    border: 1px solid #ffffff26;
    border-radius: 50%;
    transform: rotate(-14deg);
    pointer-events: none;
}
body.dark-mode .dashboard-hero h1 {
    font-size: clamp(1.9rem, 3.1vw, 2.7rem);
    font-weight: 700;
    letter-spacing: -.025em;
    color: #fff;
}
body.dark-mode .dashboard-hero p { color: #b7b1dd; font-size: .92rem; max-width: 58ch; }
body.dark-mode .dashboard-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #ffd9a0;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .19em;
}
body.dark-mode .dashboard-eyebrow::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tx-amber);
    box-shadow: 0 0 12px var(--tx-amber);
}
body.dark-mode .dashboard-date {
    padding: 6px 13px;
    border-radius: 99px;
    background: var(--tx-chip);
    color: #cfc9ee;
    font-size: .76rem;
    box-shadow: inset 0 1px 0 var(--tx-rim-top), inset 0 0 0 1px var(--tx-rim);
}

/* ---- 5. Metric tiles -------------------------------------------------- */
body.dark-mode .dashboard-metrics { gap: 14px; margin-bottom: 32px; }
body.dark-mode .dashboard-metric {
    padding: 18px 18px 16px;
    border: 1px solid var(--tx-rim);
    border-radius: 20px;
    background: var(--tx-glass);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow:
        inset 0 1px 0 var(--tx-rim-top),
        inset 0 0 0 1px var(--tx-rim),
        0 14px 34px var(--tx-shadow);
}
/* turn the old left colour bar into a status light */
body.dark-mode .dashboard-metric::before {
    inset: 16px 16px auto auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--metric-color);
    opacity: 1;
    box-shadow: 0 0 14px var(--metric-color);
}
body.dark-mode .dashboard-metric:hover {
    border-color: var(--tx-rim);
    box-shadow:
        inset 0 1px 0 var(--tx-rim-top),
        0 0 0 1px color-mix(in srgb, var(--metric-color) 40%, transparent),
        0 22px 46px #000a;
}
body.dark-mode .dashboard-metric strong {
    color: #fff;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}
body.dark-mode .dashboard-metric small { color: #8c86b4; }
body.dark-mode .card-label {
    color: #a8a2ce;
    font-size: .68rem;
    letter-spacing: .11em;
}
body.dark-mode .metric-icon {
    width: 34px;
    height: 34px;
    border: 1px solid var(--tx-rim);
    border-radius: 50%;
    background: var(--tx-chip);
    box-shadow: inset 0 1px 0 var(--tx-rim-top);
}

/* ---- 6. Section heading + depot cards -------------------------------- */
body.dark-mode .dashboard-section-heading h2 { font-size: 1.4rem; letter-spacing: -.02em; }
body.dark-mode .depot-overview-card {
    position: relative;
    overflow: hidden;
    padding: 18px;
    border: 1px solid var(--tx-rim);
    border-radius: 20px;
    background: var(--tx-glass);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow:
        inset 0 1px 0 var(--tx-rim-top),
        inset 0 0 0 1px var(--tx-rim),
        0 14px 34px var(--tx-shadow);
    transition: transform .2s ease, box-shadow .2s ease;
}
/* faint orbit line per depot */
body.dark-mode .depot-overview-card::after {
    content: "";
    position: absolute;
    right: -46px;
    top: -34px;
    width: 140px;
    height: 56px;
    border: 1px solid #ffffff21;
    border-radius: 50%;
    transform: rotate(-18deg);
    pointer-events: none;
}
body.dark-mode .depot-overview-card:hover {
    transform: translateY(-3px);
    box-shadow: inset 0 1px 0 var(--tx-rim-top), 0 24px 50px #000a;
}
body.dark-mode .depot-overview-head { border-bottom: 1px solid var(--tx-rim); }
body.dark-mode .depot-overview-foot { border-top: 1px solid var(--tx-rim); }
body.dark-mode .depot-overview-stats strong,
body.dark-mode .depot-overview-foot strong { color: #f4f2ff; }
body.dark-mode .depot-overview-foot a { color: #ffc978; }
body.dark-mode .depot-pin {
    border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, #ffe9bd, #ffb23e 55%, #e0782a);
    color: #2a1700;
    box-shadow: 0 0 20px #ffa94d66;
}

/* ---- 7. Buttons, alerts, empties ------------------------------------- */
body.dark-mode .btn {
    padding: 12px 20px;
    border-radius: 99px;
    background: linear-gradient(#ffd27a, #ff9f2a);
    color: #2a1700;
    font-family: Inter, sans-serif;
    font-size: .86rem;
    font-weight: 600;
    box-shadow: 0 6px 18px #ff9f2a44, inset 0 1px 0 #ffffff80;
}
body.dark-mode .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px #ffb23e66, inset 0 1px 0 #ffffff99;
}
body.dark-mode .btn-secondary {
    background: var(--tx-chip);
    color: var(--tx-ink);
    box-shadow: inset 0 0 0 1px var(--tx-rim), inset 0 1px 0 var(--tx-rim-top);
}
body.dark-mode .btn-secondary:hover { box-shadow: inset 0 0 0 1px #ffffff2b, 0 10px 24px #0008; }
/* the base .btn parks a white 35% stripe over the left third at rest;
   turn it into a sheen that only sweeps across on hover */
body.dark-mode .btn::before {
    left: -80%;
    width: 70%;
    background: linear-gradient(90deg, transparent, #ffffff4d, transparent);
}
body.dark-mode .btn:hover::before { left: 130%; }
body.dark-mode .btn-ai {
    background: linear-gradient(135deg, #b79cff, #7a70e6);
    color: #fff;
    box-shadow: 0 6px 18px #7a70e655;
}
body.dark-mode .btn-danger {
    background: linear-gradient(135deg, #ff8a80, #d93a3a);
    color: #fff;
    box-shadow: 0 6px 18px #d93a3a55;
}

/* generic .card (plain-salesperson dashboard) */
body.dark-mode .card {
    border: 1px solid var(--tx-rim);
    border-image: none;
    border-radius: 20px;
    background: var(--tx-glass);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow: inset 0 1px 0 var(--tx-rim-top), 0 14px 34px var(--tx-shadow);
}
body.dark-mode .card-value { color: #fff; font-family: "Space Grotesk", Inter, sans-serif; }
body.dark-mode .card-warning .card-value { color: #ffb39b; }

body.dark-mode .alert {
    margin: 0 0 22px;
    padding: 13px 18px;
    border-radius: 14px;
    background: #ffb23e14;
    border: 1px solid #ffb23e40;
    color: #ffe0ae;
    box-shadow: inset 0 1px 0 #ffffff14;
}
body.dark-mode .alert-success {
    border-color: #3fd9a04d;
    background: #3fd9a014;
    color: #b6f5d8;
}
body.dark-mode .alert-error,
body.dark-mode .alert-danger {
    border-color: #ff6b6b4d;
    background: #ff6b6b14;
    color: #ffc2c2;
}
body.dark-mode .empty-state {
    padding: 26px;
    border: 1px dashed #ffffff26;
    border-radius: 18px;
    background: var(--tx-chip);
    color: var(--tx-mute);
    text-align: center;
}
body.dark-mode .muted { color: var(--tx-mute); }
body.dark-mode .alert-warning { border-color: #ffb23e4d; background: #ffb23e14; color: #ffe0ae; }
body.dark-mode .alert-info { border-color: #8ab4ff4d; background: #8ab4ff12; color: #c9dcff; }
body.dark-mode .btn-sm { padding: 7px 14px; font-size: .76rem; border-radius: 99px; }

/* ---- 8. Page headings ------------------------------------------------ */
body.dark-mode h1 {
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    font-weight: 700;
    letter-spacing: -.02em;
    color: #fff;
}
body.dark-mode h2 { font-size: 1.15rem; letter-spacing: -.015em; color: #f2f0ff; }
body.dark-mode h4 { letter-spacing: -.01em; }

/* ---- 9. Panels + forms ----------------------------------------------- */
body.dark-mode .form-box,
body.dark-mode .chart-box,
body.dark-mode .settlement-lines,
body.dark-mode .crate-workflow-card {
    border: 1px solid var(--tx-rim);
    border-radius: 20px;
    background: var(--tx-glass);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow: inset 0 1px 0 var(--tx-rim-top), 0 14px 34px var(--tx-shadow);
}
body.dark-mode .ai-panel {
    border: 1px solid #a78bfa33;
    border-radius: 20px;
    background: linear-gradient(145deg, #2a235099, #12102e99);
    box-shadow: inset 0 1px 0 #ffffff1f, 0 14px 34px var(--tx-shadow);
}
body.dark-mode .section-actions { gap: 10px; }
body.dark-mode .setup-banner,
body.dark-mode .notice-box { border: 1px solid #ffb23e3d; border-radius: 16px; background: #ffb23e12; color: #ffe0ae; }

body.dark-mode .form-row label { color: #cfc9ee; font-size: .78rem; letter-spacing: .03em; }
body.dark-mode .form-row input:not([type=checkbox]):not([type=radio]),
body.dark-mode .form-row select,
body.dark-mode .form-row textarea {
    padding: 11px 13px;
    border: 1px solid #ffffff1f;
    border-radius: 12px;
    background: #ffffff0a;
    color: #f4f2ff;
    font-size: .9rem;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
body.dark-mode .form-row input:not([type=checkbox]):not([type=radio])::placeholder,
body.dark-mode .form-row textarea::placeholder { color: #7d78a6; }
body.dark-mode .form-row input:not([type=checkbox]):not([type=radio]):focus,
body.dark-mode .form-row select:focus,
body.dark-mode .form-row textarea:focus {
    border-color: var(--tx-amber);
    background: #ffffff12;
    box-shadow: 0 0 0 3px #ffb23e2e;
}
body.dark-mode .form-row select option { color: #17213b; background: #fff; }
body.dark-mode .form-row input[type=file]::file-selector-button {
    margin-right: 12px;
    padding: 7px 12px;
    border: 1px solid #ffb23e45;
    border-radius: 9px;
    background: #ffb23e1f;
    color: #ffd9a0;
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

/* ---- 10. Tables + badges --------------------------------------------- */
body.dark-mode .data-table {
    border: 1px solid var(--tx-rim);
    border-radius: 18px;
    background: var(--tx-glass);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow: inset 0 1px 0 var(--tx-rim-top), 0 14px 34px var(--tx-shadow);
}
body.dark-mode .data-table th {
    background: #ffffff0a;
    color: #b7b1dd;
    font-size: .68rem;
    letter-spacing: .1em;
    border-bottom: 1px solid var(--tx-rim);
}
body.dark-mode .data-table th,
body.dark-mode .data-table td { border-bottom: 1px solid #ffffff0d; }
body.dark-mode .data-table td { color: #ddd9f5; }
body.dark-mode .data-table tbody tr:hover { background: #ffffff08; }
body.dark-mode .data-table tr.status-out { background: #ffb23e10; }
body.dark-mode .data-table tr.status-variance { background: #ff6b6b0d; }
/* action buttons inside dense tables stay compact */
body.dark-mode .data-table .btn {
    padding: 6px 11px;
    border-radius: 9px;
    font-size: .74rem;
    box-shadow: none;
    border: 1px solid #ffffff1f;
    white-space: nowrap;
}
body.dark-mode .data-table .btn:hover { transform: none; filter: brightness(1.06); }

body.dark-mode .badge {
    border: 1px solid #ffffff1a;
    background: #ffffff10;
    color: #ddd9f5;
    font-weight: 600;
    white-space: nowrap;
}
body.dark-mode .badge-out,
body.dark-mode .badge-moderate,
body.dark-mode .badge-medium,
body.dark-mode .badge-pending { background: #ffb23e1c; border-color: #ffb23e42; color: #ffd9a0; }
body.dark-mode .badge-settled,
body.dark-mode .badge-approved,
body.dark-mode .badge-active,
body.dark-mode .badge-low { background: #3fd9a017; border-color: #3fd9a040; color: #a8f0ce; }
body.dark-mode .badge-variance,
body.dark-mode .badge-high,
body.dark-mode .badge-critical,
body.dark-mode .badge-rejected { background: #ff6b6b1a; border-color: #ff6b6b42; color: #ffb3b3; }
body.dark-mode .badge-ai { background: #a78bfa1c; border-color: #a78bfa42; color: #d3c4ff; }

/* ---- 11. Orbit board (dashboard network map) -------------------------- */
.orbit-board.company-orbit-board { margin-bottom: 18px; }
.company-orbit-subtitle { margin: 5px 0 0; color: var(--tx-mute); font-size: .78rem; }
.company-orbit-guide { fill: none; stroke: #ffffff16; stroke-width: 1; stroke-dasharray: 2 8; }
.company-orbit-node { cursor: default; }
.company-orbit-node .orbit-planet { filter: drop-shadow(0 0 10px #ffb23e); }
.orbit-live-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--tx-mute); font-size: .65rem; letter-spacing: .1em; }
.orbit-live-indicator i { width: 7px; height: 7px; border-radius: 50%; background: #3fd9a0; box-shadow: 0 0 10px #3fd9a0; }
.orbit-board {
    position: relative;
    margin: 0 0 30px;
    padding: 20px 22px 14px;
    border: 1px solid var(--tx-rim);
    border-radius: 22px;
    background:
        radial-gradient(90% 120% at 50% 120%, #8f5bff26, transparent 60%),
        var(--tx-glass);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow: inset 0 1px 0 var(--tx-rim-top), 0 16px 38px var(--tx-shadow);
    overflow: hidden;
}
.orbit-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 2px;
}
.orbit-head h2 { margin: 4px 0 0; }
.orbit-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--tx-mute);
    font-size: .7rem;
}
.orbit-legend span { display: inline-flex; align-items: center; gap: 6px; }
.orbit-legend i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tx-amber);
    box-shadow: 0 0 10px var(--tx-amber);
}
.orbit-legend i.ring {
    background: transparent;
    border: 1.5px solid #ffffff88;
    box-shadow: none;
}
.orbit-canvas { position: relative; }
.orbit-canvas svg { display: block; width: 100%; height: auto; overflow: visible; }
.orbit-sun-core {
    fill: #ffb23e;
    filter: drop-shadow(0 0 18px #ffb23eaa);
}
.orbit-guide { fill: none; stroke: #ffffff14; stroke-width: 1; stroke-dasharray: 3 7; }
.orbit-sun-label { fill: #ffd9a0; font: 600 9px/1 "Space Grotesk", Inter, sans-serif; letter-spacing: .22em; }
.orbit-sun-halo { animation: orbit-sun 6s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes orbit-sun { from { opacity: .35; } to { opacity: .6; } }
.orbit-planet { transition: transform .25s ease; transform-box: fill-box; transform-origin: center; }
.orbit-node:hover .orbit-planet { transform: scale(1.14); }
.orbit-node:hover .orbit-label { fill: #fff; }
.orbit-label { fill: #d9d4f7; font: 600 12px/1 "Space Grotesk", Inter, sans-serif; }
.orbit-sub { fill: #8c86b4; font: 500 10px/1 Inter, sans-serif; }
.orbit-moon { fill: #ffffff; }
.orbit-moon.out { fill: none; stroke: #ffffffa6; stroke-width: 1.2; }
.orbit-orbit { fill: none; stroke: #ffffff26; stroke-width: 1; }
.orbit-spark { fill: #fff1c9; filter: drop-shadow(0 0 4px #ffb23e); pointer-events: none; }
.orbit-empty { color: var(--tx-mute); font-size: .85rem; padding: 18px 0; }

/* ---- 12. Responsive / motion ------------------------------------------ */
/* Dashboard entrance follows the soft, staggered reveal used by Transom.
   These animations are presentation only; links, data and controls retain
   their existing behavior. */
@keyframes tx-dashboard-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
body.dark-mode .dashboard-hero,
body.dark-mode .orbit-board,
body.dark-mode .dashboard-section-heading,
body.dark-mode .dashboard-quick-actions {
    animation: tx-dashboard-rise .48s cubic-bezier(.2,.75,.25,1) both;
}
body.dark-mode .dashboard-metric,
body.dark-mode .depot-overview-card {
    animation: tx-dashboard-rise .48s cubic-bezier(.2,.75,.25,1) both;
}
body.dark-mode .dashboard-metric:nth-child(1) { animation-delay: .04s; }
body.dark-mode .dashboard-metric:nth-child(2) { animation-delay: .08s; }
body.dark-mode .dashboard-metric:nth-child(3) { animation-delay: .12s; }
body.dark-mode .dashboard-metric:nth-child(4) { animation-delay: .16s; }
body.dark-mode .dashboard-metric:nth-child(5) { animation-delay: .20s; }
body.dark-mode .dashboard-metric:nth-child(6) { animation-delay: .24s; }
body.dark-mode .dashboard-metric:nth-child(7) { animation-delay: .28s; }
body.dark-mode .dashboard-metric:nth-child(8) { animation-delay: .32s; }
body.dark-mode .depot-overview-card:nth-child(1) { animation-delay: .05s; }
body.dark-mode .depot-overview-card:nth-child(2) { animation-delay: .10s; }
body.dark-mode .depot-overview-card:nth-child(3) { animation-delay: .15s; }
body.dark-mode .depot-overview-card:nth-child(4) { animation-delay: .20s; }
body.dark-mode .depot-overview-card:nth-child(5) { animation-delay: .25s; }
body.dark-mode .depot-overview-card:nth-child(6) { animation-delay: .30s; }
body.dark-mode .depot-overview-card:nth-child(n+7) { animation-delay: .34s; }

@media (max-width: 760px) {
    body.dark-mode .dashboard-hero {
        align-items: flex-start;
        gap: 18px;
    }
    body.dark-mode .dashboard-hero::before {
        right: -230px;
        top: -260px;
        width: 460px;
        height: 460px;
    }
    body.dark-mode .dashboard-hero::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    body.dark-mode .dashboard-hero,
    body.dark-mode .orbit-board,
    body.dark-mode .dashboard-section-heading,
    body.dark-mode .dashboard-quick-actions,
    body.dark-mode .dashboard-metric,
    body.dark-mode .depot-overview-card {
        animation: none !important;
    }
}
@media (max-width: 640px) {
    body.dark-mode .container { padding: 20px 14px 54px; }
    body.dark-mode .dashboard-hero { padding: 22px 18px; border-radius: 22px; }
    body.dark-mode .dashboard-hero h1 { font-size: 1.75rem; }
    body.dark-mode .dashboard-metric { padding: 14px 13px; }
    body.dark-mode .dashboard-metric::before { top: 12px; right: 12px; width: 8px; height: 8px; }
    body.dark-mode .btn { padding: 11px 16px; font-size: .8rem; }

    /* topbar: keep the same links, reclaim the vertical space */
    body.dark-mode .topbar { padding: 9px 12px; gap: 7px; }
    body.dark-mode .logo-wordmark { font-size: 1.1rem; }
    body.dark-mode .logo-tagline { display: none; }
    body.dark-mode .user-info { font-size: .72rem; gap: 6px; }
    body.dark-mode .user-info > span { display: none; }   /* the "(role)" hint */
    body.dark-mode .user-info > strong {
        max-width: 96px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    body.dark-mode .logout-link { padding: 4px 7px; }
    body.dark-mode .glass-clock { padding: 5px 11px; }
    body.dark-mode .glass-clock .clock-date { display: none; }

    /* ribbon: one swipeable row instead of four wrapped ones */
    body.dark-mode .ribbon { padding: 0 10px; background: rgb(9 7 28 / .72); }
    body.dark-mode .ribbon-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    body.dark-mode .ribbon-tabs::-webkit-scrollbar { display: none; }
    body.dark-mode .ribbon-tab,
    body.dark-mode .ribbon-depot-picker { flex: 0 0 auto; }
    body.dark-mode .ribbon-tab { margin: 6px 2px; padding: 7px 11px; font-size: .76rem; }

    /* orbit board: shorter canvas, smaller type */
    .orbit-board { padding: 16px 14px 8px; border-radius: 18px; }
    .orbit-head { flex-direction: column; align-items: flex-start; gap: 6px; }
    .orbit-legend { font-size: .64rem; gap: 10px; }
    .orbit-label { font-size: 10px; }
    .orbit-sub { font-size: 8.5px; }
}
@media (prefers-reduced-motion: reduce) {
    body.dark-mode::before { animation: none; }
    body.dark-mode .container > * { animation: none; }
    .orbit-sun-halo { animation: none; }
    .orbit-planet { transition: none; }
}

/* ---- Marble finish: shared high-detail, raised card surfaces --------- */
body.dark-mode .topbar {
    background: rgb(8 13 15 / .88) !important;
    border-bottom-color: rgb(111 216 197 / .15);
    box-shadow: 0 12px 34px rgb(0 0 0 / .42);
}
body.dark-mode .ribbon {
    background: rgb(9 15 17 / .96) !important;
    border-bottom-color: rgb(111 216 197 / .13);
}
body.dark-mode .ribbon-panel,
body.dark-mode .ribbon-menu {
    background: linear-gradient(145deg, #192728, #0d1217 62%, #171512);
    border-color: rgb(111 216 197 / .22);
    box-shadow: 0 24px 58px rgb(0 0 0 / .72), inset 0 1px 0 rgb(255 255 255 / .1);
}
body.dark-mode :is(
    .card, .dashboard-metric, .depot-overview-card, .crate-workflow-card,
    .form-box, .chart-box, .settlement-lines, .ai-panel, .orbit-board,
    .dashboard-hero, .dashboard-quick-actions, .pos-card,
    .store-product-card, .store-cart-summary, .store-form-card, .store-status-card
) {
    background:
        radial-gradient(ellipse 90% 75% at 8% 5%, rgb(39 203 179 / .13), transparent 68%),
        radial-gradient(ellipse 75% 90% at 96% 100%, rgb(194 112 59 / .12), transparent 68%),
        repeating-linear-gradient(132deg, transparent 0 43px, rgb(139 239 220 / .025) 44px, transparent 46px 91px),
        linear-gradient(145deg, rgb(25 39 40 / .97), rgb(13 18 23 / .985) 58%, rgb(18 20 24 / .98));
    border-color: rgb(145 219 204 / .19);
    box-shadow:
        inset 0 1px 0 rgb(255 255 255 / .15),
        inset 0 -1px 0 rgb(61 191 174 / .09),
        0 16px 36px rgb(0 0 0 / .45),
        0 2px 6px rgb(0 0 0 / .3);
    transform-style: preserve-3d;
    transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease;
}
@media (hover: hover) and (pointer: fine) {
    body.dark-mode :is(
        .card, .dashboard-metric, .depot-overview-card, .crate-workflow-card,
        .form-box, .chart-box, .settlement-lines, .ai-panel, .orbit-board,
        .dashboard-hero, .dashboard-quick-actions, .pos-card,
        .store-product-card, .store-cart-summary, .store-form-card, .store-status-card
    ):hover {
        transform: perspective(1000px) translateY(-4px) rotateX(.7deg);
        border-color: rgb(119 230 209 / .38);
        box-shadow:
            inset 0 1px 0 rgb(255 255 255 / .2),
            inset 0 -1px 0 rgb(61 191 174 / .13),
            0 24px 48px rgb(0 0 0 / .54),
            0 0 24px rgb(31 188 169 / .08);
    }
}
@media (prefers-reduced-motion: reduce) {
    body.dark-mode :is(
        .card, .dashboard-metric, .depot-overview-card, .crate-workflow-card,
        .form-box, .chart-box, .settlement-lines, .ai-panel, .orbit-board,
        .dashboard-hero, .dashboard-quick-actions, .pos-card,
        .store-product-card, .store-cart-summary, .store-form-card, .store-status-card
    ) { transition: none; }
}

/* ---- Navigation menu readability and alignment ---------------------- */
body.dark-mode .ribbon { padding-inline: 18px; }
body.dark-mode .ribbon-tabs { gap: 6px; }
body.dark-mode .ribbon-tab {
    font-family: Inter, "Segoe UI", sans-serif;
    font-size: .82rem;
    font-weight: 650;
    letter-spacing: .01em;
    padding: 9px 13px;
}
body.dark-mode .ribbon-panel {
    align-items: flex-start;
    gap: 26px;
    padding: 20px clamp(18px, 2.6vw, 38px) 22px;
    max-height: min(72vh, 680px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgb(111 216 197 / .42) rgb(8 13 15 / .32);
}
body.dark-mode .ribbon-group { flex: 0 0 auto; }
body.dark-mode .ribbon-group-items {
    grid-auto-columns: 142px;
    gap: 9px 10px;
    align-items: stretch;
}
body.dark-mode .ribbon-group-items--wide { grid-template-rows: repeat(2, minmax(92px, auto)); }
body.dark-mode .ribbon-btn {
    box-sizing: border-box;
    width: 142px;
    min-height: 92px;
    padding: 12px 10px 11px;
    gap: 8px;
    border: 1px solid rgb(145 219 204 / .13);
    background: rgb(255 255 255 / .025);
    font-family: Inter, "Segoe UI", sans-serif;
}
body.dark-mode .ribbon-btn-icon { font-size: 1.42rem; }
body.dark-mode .ribbon-btn-label {
    display: -webkit-box;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    min-height: 2.6em;
    max-height: 2.6em;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .005em;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
}
body.dark-mode .ribbon-btn:hover {
    border-color: rgb(111 216 197 / .34);
    background: rgb(111 216 197 / .1);
}
body.dark-mode .ribbon-group-caption {
    margin-top: 10px;
    padding-top: 8px;
    font-size: .71rem;
    line-height: 1.35;
    letter-spacing: .065em;
}

@media (max-width: 760px) {
    body.dark-mode .ribbon { padding-inline: 10px; }
    body.dark-mode .ribbon-tabs { gap: 4px; }
    body.dark-mode .ribbon-tab { font-size: .78rem; padding: 8px 10px; }
    body.dark-mode .ribbon-panel { gap: 16px; padding: 14px 14px 18px; }
    body.dark-mode .ribbon-group-items { grid-auto-columns: 132px; gap: 8px; }
    body.dark-mode .ribbon-btn { width: 132px; min-height: 86px; padding: 10px 9px; }
    body.dark-mode .ribbon-btn-label { font-size: .77rem; }
}

/* ---- Phone layout: calmer chrome, roomy controls, and no page-wide drift ---- */
@media (max-width: 640px) {
    html { scroll-padding-top: 12px; }
    body.dark-mode { overflow-x: hidden; }

    body.dark-mode .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
        padding: 10px 14px 8px;
    }
    body.dark-mode .logo-mark { min-width: 0; gap: 9px; }
    body.dark-mode .logo-wordmark { font-size: 1rem; line-height: 1.2; }
    body.dark-mode .logo-tagline { display: none; }
    body.dark-mode .glass-clock {
        grid-column: 2;
        grid-row: 1;
        padding: 7px 10px;
        font-size: .76rem;
        white-space: nowrap;
    }
    body.dark-mode .glass-clock .clock-date { display: none; }
    body.dark-mode .user-info {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 7px;
        overflow-x: auto;
        padding: 7px 0 2px;
        border-top: 1px solid rgb(255 255 255 / .08);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    body.dark-mode .user-info::-webkit-scrollbar { display: none; }
    body.dark-mode .user-info > strong,
    body.dark-mode .user-info > a { flex: 0 0 auto; white-space: nowrap; }
    body.dark-mode .user-info > strong { max-width: 120px; font-size: .76rem; }
    body.dark-mode .user-info > span { display: none; }
    body.dark-mode .user-info .logout-link {
        padding: 6px 9px;
        border: 1px solid rgb(255 255 255 / .09);
        background: rgb(255 255 255 / .035);
        font-size: .7rem;
    }

    body.dark-mode .ribbon {
        position: relative;
        z-index: 30;
        padding: 0 10px;
        border-bottom: 1px solid rgb(111 216 197 / .16);
        box-shadow: 0 8px 24px rgb(0 0 0 / .18);
    }
    body.dark-mode .ribbon-tabs {
        flex-wrap: nowrap;
        gap: 5px;
        overflow-x: auto;
        padding: 5px 0;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }
    body.dark-mode .ribbon-tabs::-webkit-scrollbar { display: none; }
    body.dark-mode .ribbon-tab {
        flex: 0 0 auto;
        min-height: 40px;
        margin: 0;
        padding: 8px 11px;
        border: 1px solid transparent;
        border-radius: 13px;
        font-size: .76rem;
        scroll-snap-align: start;
    }
    body.dark-mode .ribbon-tab.active {
        border-color: rgb(255 178 62 / .2);
        background: linear-gradient(135deg, rgb(255 178 62 / .12), rgb(111 216 197 / .08));
    }
    body.dark-mode .ribbon-depot-picker { flex: 0 0 auto; margin: 2px 0; }

    body.dark-mode .ribbon-dropdown.open .ribbon-panel {
        left: 8px;
        right: 8px;
        width: auto;
        max-height: 72vh;
        max-height: min(72dvh, 620px);
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        overflow-x: hidden;
        overflow-y: auto;
        border: 1px solid rgb(111 216 197 / .22);
        border-top: 3px solid #65d9c1;
        border-radius: 0 0 18px 18px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
    body.dark-mode .ribbon-group { width: 100%; min-width: 0; }
    body.dark-mode .ribbon-group-items,
    body.dark-mode .ribbon-group-items--wide {
        grid-auto-flow: row;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: none;
        grid-auto-columns: auto;
        gap: 7px;
    }
    body.dark-mode .ribbon-btn {
        width: 100%;
        min-width: 0;
        min-height: 62px;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 9px;
        padding: 9px;
        border-radius: 12px;
        text-align: left;
    }
    body.dark-mode .ribbon-btn-icon { width: 24px; flex: 0 0 24px; font-size: 1.2rem; text-align: center; }
    body.dark-mode .ribbon-btn-label {
        min-height: 0;
        max-height: 2.6em;
        font-size: .72rem;
        line-height: 1.3;
    }
    body.dark-mode .ribbon-group-caption { text-align: left; }

    body.dark-mode .container { padding: 22px 14px 42px; }
    body.dark-mode .container h1 { margin-bottom: 16px; font-size: clamp(1.55rem, 7vw, 2rem); line-height: 1.16; }
    body.dark-mode .container h2 { font-size: 1.14rem; line-height: 1.25; }
    body.dark-mode .dashboard-hero {
        gap: 15px;
        padding: 21px 18px;
        border-radius: 21px;
    }
    body.dark-mode .dashboard-hero h1 { font-size: clamp(1.65rem, 7vw, 2rem); }
    body.dark-mode .dashboard-hero p { font-size: .86rem; line-height: 1.55; }
    body.dark-mode .dashboard-metrics { gap: 9px; margin-bottom: 24px; }
    body.dark-mode .dashboard-metric { min-width: 0; padding: 13px 12px; border-radius: 16px; }
    body.dark-mode .dashboard-metric strong { font-size: clamp(1.05rem, 5vw, 1.3rem); }
    body.dark-mode .dashboard-metric small { font-size: .68rem; }
    body.dark-mode .dashboard-section-heading { gap: 10px; }
    body.dark-mode .form-box,
    body.dark-mode .chart-box,
    body.dark-mode .crate-workflow-card,
    body.dark-mode .pos-card,
    body.dark-mode .dashboard-quick-actions { padding: 16px; border-radius: 18px; }
    body.dark-mode .form-grid { grid-template-columns: minmax(0, 1fr); gap: 11px; }
    body.dark-mode .form-grid > *,
    body.dark-mode .form-row,
    body.dark-mode .form-box { min-width: 0; }
    body.dark-mode .container input:not([type="checkbox"]):not([type="radio"]),
    body.dark-mode .container select,
    body.dark-mode .container textarea {
        max-width: 100%;
        min-height: 44px;
        border-radius: 12px;
        font-size: 16px;
    }
    body.dark-mode .container textarea { min-height: 92px; }
    body.dark-mode .container .btn { min-height: 42px; touch-action: manipulation; }
    body.dark-mode .section-actions { gap: 8px; }

    body.dark-mode .container table.data-table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        border-radius: 15px;
        -webkit-overflow-scrolling: touch;
    }
    body.dark-mode .data-table th,
    body.dark-mode .data-table td { padding: 10px 9px; font-size: .76rem; line-height: 1.4; }
    body.dark-mode .data-table th { font-size: .63rem; letter-spacing: .07em; }
    body.dark-mode .data-table .btn { min-height: 36px; padding: 7px 9px; font-size: .7rem; }
    body.dark-mode .table-scroll { margin-bottom: 22px; border-radius: 15px; }
    body.dark-mode .table-scroll .data-table { min-width: 600px; }
    body.dark-mode .crate-filter-bar { padding: 13px; border-radius: 15px; }
    body.dark-mode .crate-filter-form { align-items: stretch; }
    body.dark-mode .crate-filter-form select { width: 100%; }
    body.dark-mode .app-footer { padding: 20px 14px; }
    body.dark-mode .footer-inner { font-size: .72rem; line-height: 1.7; overflow-wrap: anywhere; }
}

@media (max-width: 380px) {
    body.dark-mode .container { padding-inline: 11px; }
    body.dark-mode .topbar { padding-inline: 11px; }
    body.dark-mode .ribbon { padding-inline: 7px; }
    body.dark-mode .ribbon-group-items,
    body.dark-mode .ribbon-group-items--wide { grid-template-columns: minmax(0, 1fr); }
}

/* Stock counts are a frequent phone task: show compact product cards and keep
   the count/reconcile/delete controls comfortably tappable. */
@media (max-width: 640px) {
    body.dark-mode #central-stock,
    body.dark-mode #depot-stock {
        position: relative;
        overflow: hidden;
        border: 1px solid rgb(111 216 197 / .15);
        background:
            radial-gradient(ellipse at 100% 0%, rgb(111 216 197 / .09), transparent 48%),
            linear-gradient(155deg, rgb(24 29 43 / .98), rgb(18 21 32 / .98));
        box-shadow: 0 18px 42px rgb(0 0 0 / .2), inset 0 1px rgb(255 255 255 / .035);
    }
    body.dark-mode #central-stock h2,
    body.dark-mode #depot-stock h2 { margin-bottom: 8px; font-size: 1.22rem; letter-spacing: -.02em; }
    body.dark-mode #central-stock > p.muted,
    body.dark-mode #depot-stock > p.muted { color: #aaa9bc; font-size: .81rem; line-height: 1.55; }
    body.dark-mode #central-stock > p:has(> .btn),
    body.dark-mode #depot-stock > p:has(> .btn) { margin: 14px 0; }
    body.dark-mode #central-stock > p > .btn,
    body.dark-mode #depot-stock > p > .btn { width: 100%; justify-content: center; min-height: 44px; }
    body.dark-mode #central-stock .table-scroll,
    body.dark-mode #depot-stock .table-scroll { overflow: visible; margin: 12px 0 0; }
    body.dark-mode #central-stock .table-scroll .data-table,
    body.dark-mode #depot-stock .table-scroll .data-table {
        display: block;
        min-width: 0;
        overflow: visible;
        background: transparent;
    }
    body.dark-mode #central-stock .data-table thead,
    body.dark-mode #depot-stock .data-table thead { display: none; }
    body.dark-mode #central-stock .data-table tbody,
    body.dark-mode #depot-stock .data-table tbody { display: grid; gap: 10px; }
    body.dark-mode #central-stock .data-table tbody tr,
    body.dark-mode #depot-stock .data-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding: 3px 13px;
        border: 1px solid rgb(255 255 255 / .075);
        border-radius: 15px;
        background: linear-gradient(130deg, rgb(255 255 255 / .045), rgb(255 255 255 / .018));
        box-shadow: 0 8px 20px rgb(0 0 0 / .12);
    }
    body.dark-mode #central-stock .data-table td,
    body.dark-mode #depot-stock .data-table td {
        display: grid;
        grid-template-columns: minmax(92px, .42fr) minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        min-width: 0;
        padding: 10px 0;
        border-bottom: 1px solid rgb(255 255 255 / .055);
        overflow-wrap: anywhere;
    }
    body.dark-mode #central-stock .data-table td:last-child,
    body.dark-mode #depot-stock .data-table td:last-child { border-bottom: 0; }
    body.dark-mode #central-stock .data-table td:nth-child(1)::before { content: "Product"; }
    body.dark-mode #central-stock .data-table td:nth-child(2)::before { content: "Balance"; }
    body.dark-mode #central-stock .data-table td:nth-child(3)::before { content: "Actions"; }
    body.dark-mode #depot-stock .data-table td:nth-child(1)::before { content: "Depot"; }
    body.dark-mode #depot-stock .data-table td:nth-child(2)::before { content: "Product"; }
    body.dark-mode #depot-stock .data-table td:nth-child(3)::before { content: "Balance"; }
    body.dark-mode #depot-stock .data-table td:nth-child(4)::before { content: "Actions"; }
    body.dark-mode #central-stock .data-table td::before,
    body.dark-mode #depot-stock .data-table td::before {
        color: #9291a7;
        font-size: .65rem;
        font-weight: 750;
        letter-spacing: .075em;
        text-transform: uppercase;
    }
    body.dark-mode #central-stock .data-table td strong,
    body.dark-mode #depot-stock .data-table td strong { color: #76e0c6; font-size: 1rem; }
    body.dark-mode #central-stock .data-table td:has(details),
    body.dark-mode #depot-stock .data-table td:has(details) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
    body.dark-mode #central-stock .data-table details,
    body.dark-mode #depot-stock .data-table details { flex: 0 0 100%; }
    body.dark-mode #central-stock .data-table details summary,
    body.dark-mode #depot-stock .data-table details summary { display: inline-flex; justify-content: center; min-width: 88px; }
    body.dark-mode #central-stock .data-table details[open] summary,
    body.dark-mode #depot-stock .data-table details[open] summary { margin-bottom: 9px; }
    body.dark-mode #central-stock .data-table details form,
    body.dark-mode #depot-stock .data-table details form,
    body.dark-mode #central-stock .data-table td > form,
    body.dark-mode #depot-stock .data-table td > form { display: grid !important; grid-template-columns: minmax(0, 1fr); width: 100%; gap: 9px; margin: 0 !important; }
    body.dark-mode #central-stock .data-table td > a.btn,
    body.dark-mode #depot-stock .data-table td > a.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; max-width: 100%; white-space: normal; }
    body.dark-mode #central-stock .data-table label,
    body.dark-mode #depot-stock .data-table label { display: grid; gap: 5px; color: #b8b7c9; font-size: .72rem; }
    body.dark-mode #central-stock .data-table td[colspan],
    body.dark-mode #depot-stock .data-table td[colspan] { display: block; }
}
