/* Cykelbutiken staff dashboard.
   One accent (city-bike green), cool paper-white surfaces, one type family.
   Light is the default; [data-theme="dark"] on <html> switches every token. */

:root {
    color-scheme: light;
    --bg: #f2f4f1;
    --surface: #ffffff;
    --surface-2: #eef1ed;
    --line: #dde3dd;
    --ink: #18211d;
    --ink-2: #4b5852;
    --ink-3: #6f7b75;
    --accent: #1e6b52;
    --accent-ink: #ffffff;
    --accent-soft: #dcede5;
    --bar: #2a7a5f;
    --track: #e9eee9;
    --warn: #9a6200;
    --warn-soft: #fbf0d9;
    --critical: #b3372f;
    --critical-soft: #fbe3e0;
    --done-soft: #e3efe8;
    --shadow: 0 1px 2px rgba(24, 33, 29, .06);

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
    --radius: 10px;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Ubuntu, Cantarell, Arial, sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1412;
    --surface: #161d1a;
    --surface-2: #1d2622;
    --line: #2a3530;
    --ink: #e3eae6;
    --ink-2: #a9b6b0;
    --ink-3: #87948e;
    --accent: #56b791;
    --accent-ink: #0d1411;
    --accent-soft: #1d3a2f;
    --bar: #4fae89;
    --track: #222c28;
    --warn: #e2a948;
    --warn-soft: #3a2e17;
    --critical: #ec7a70;
    --critical-soft: #3f2220;
    --done-soft: #1c3029;
    --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
code { font-size: .9em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.rail {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: var(--s4) var(--s3);
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: var(--s5);
}

.brand {
    display: flex; align-items: center; gap: var(--s2);
    color: var(--accent); text-decoration: none;
    font-weight: 700; font-size: 17px; letter-spacing: -.01em;
    padding: var(--s1) var(--s2);
}
.brand span { color: var(--ink); }

.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.nav-link {
    display: flex; align-items: center; gap: var(--s3);
    padding: 9px var(--s3);
    border-radius: 8px;
    color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .icon { flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
    padding: var(--s3) var(--s6);
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(6px);
    position: sticky; top: 0; z-index: 5;
    font-size: 13px; color: var(--ink-2);
}
.topbar-right { display: flex; align-items: center; gap: var(--s4); }

.live { display: flex; align-items: center; gap: var(--s2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.live-live .live-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.live-reconnecting .live-dot, .live-connecting .live-dot { background: var(--warn); }
.live-offline .live-dot { background: var(--ink-3); }
.live-time { color: var(--ink-3); transition: color .4s; }
.live-time.flash { color: var(--accent); }

.theme-toggle {
    display: inline-flex; align-items: center; gap: var(--s2);
    font: inherit; font-size: 13px; color: var(--ink-2);
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
    padding: 5px var(--s3) 5px 10px; cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.theme-toggle .icon { width: 16px; height: 16px; }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline-flex; }
:root[data-theme="dark"] .when-light { display: none; }

.content { padding: var(--s6); max-width: 1440px; width: 100%; }

/* ---------- Page heads ---------- */

.page-title { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.page-lead { color: var(--ink-2); margin: var(--s2) 0 var(--s5); max-width: 70ch; }
.muted { color: var(--ink-2); }

/* The overview opens on today, written out: the shop's first question. */
.today { margin-bottom: var(--s5); }
.today-date { font-size: clamp(32px, 4vw, 46px); font-weight: 700; letter-spacing: -.03em; }
.today-line { margin: var(--s2) 0 0; font-size: 18px; color: var(--ink-2); max-width: 75ch; }
.today-line span + span::before { content: " "; }
.today-line strong { color: var(--ink); }

/* ---------- Stats ---------- */

.stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1px; background: var(--line);
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
    margin-bottom: var(--s5);
}
.stat { background: var(--surface); padding: var(--s4) var(--s5); }
.stat-label { font-size: 13px; color: var(--ink-2); }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; }
.stat-sub { font-size: 13px; color: var(--ink-3); }
.stat-warn .stat-value { color: var(--warn); }
.stat-critical .stat-value { color: var(--critical); }

/* ---------- Panels & grid ---------- */

.grid { display: grid; gap: var(--s5); margin-bottom: var(--s5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--s5);
    box-shadow: var(--shadow);
    min-width: 0;
}
.panel-head { margin-bottom: var(--s4); }
.panel-head h2 { font-size: 16px; font-weight: 650; }
.panel-note { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }

.section-title { font-size: 19px; font-weight: 650; margin: var(--s6) 0 var(--s4); letter-spacing: -.01em; }

/* ---------- Bars ---------- */

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bar-row {
    display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto;
    align-items: center; gap: var(--s3); font-size: 14px;
}
.bar-label { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--track); border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
.bar-row:hover .bar-fill { background: var(--accent); }
.bar-row:hover .bar-label { font-weight: 600; }
.bar-value { color: var(--ink-2); text-align: right; white-space: nowrap; min-width: 3ch; }

/* ---------- Columns ---------- */

.cols { width: 100%; height: auto; display: block; overflow: visible; }
.cols .gridline { stroke: var(--line); stroke-width: 1; }
.cols .axis { stroke: var(--ink-3); stroke-width: 1; }
.cols .tick { fill: var(--ink-3); font-size: 11px; }
.cols .col-fill { fill: var(--bar); }
.cols .hit { fill: transparent; }
.cols .col:hover .col-fill { fill: var(--accent); }
.cols .col:hover .hit { fill: var(--surface-2); }

/* ---------- Tables & lists ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; font-weight: 500; font-size: 13px; color: var(--ink-3);
    padding: 0 var(--s3) var(--s2) 0; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px var(--s3) 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; padding-right: 0; }
.strong { font-weight: 600; }
.sub { display: block; font-size: 12.5px; color: var(--ink-3); font-weight: 400; }
.nowrap { white-space: nowrap; }

.stock-list { list-style: none; margin: 0; padding: 0; }
.stock-list li {
    display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3);
    padding: 10px 0; border-bottom: 1px solid var(--line);
}
.stock-list li:last-child { border-bottom: 0; }
.stock-main { min-width: 0; }
.stock-qty { text-align: right; white-space: nowrap; }
.stock-qty .qty { font-weight: 650; color: var(--warn); }
.stock-qty.zero .qty { color: var(--critical); }

.pill {
    display: inline-block; font-size: 12.5px; font-weight: 550; white-space: nowrap;
    padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
}
.pill-done { background: var(--done-soft); color: var(--accent); }
.pill-wait { background: var(--warn-soft); color: var(--warn); }
.pill-stop { background: var(--critical-soft); color: var(--critical); }
.pill-active { background: var(--surface-2); color: var(--ink); }

.empty { color: var(--ink-3); margin: var(--s2) 0; font-size: 14px; }

/* ---------- Feed ---------- */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
    display: grid; grid-template-columns: 110px 1fr; gap: var(--s4);
    padding: var(--s3) 0; border-bottom: 1px solid var(--line);
}
.feed li:last-child { border-bottom: 0; }
.feed-time { color: var(--ink-3); font-size: 13px; padding-top: 2px; }
.feed-op { font-weight: 600; }
.feed-op.op-create { color: var(--accent); }
.feed-op.op-delete { color: var(--critical); }

/* ---------- States ---------- */

.loading { display: flex; align-items: center; gap: var(--s3); color: var(--ink-2); padding: var(--s6) 0; }
.spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--line); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s4); border-radius: var(--radius); margin-bottom: var(--s5);
}
.notice-error { background: var(--critical-soft); color: var(--critical); }
.notice-error span { color: var(--ink); }

.btn {
    font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
    background: var(--accent); color: var(--accent-ink);
    border: 0; border-radius: 8px; padding: 6px 14px;
}

/* ---------- Toasts ---------- */

.toasts {
    position: fixed; right: var(--s5); bottom: var(--s5); z-index: 20;
    display: flex; flex-direction: column; gap: var(--s2); width: min(360px, calc(100vw - 32px));
}
.toast {
    display: flex; gap: var(--s3); align-items: flex-start;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-left: 3px solid var(--accent);
    border-radius: 8px; padding: var(--s3) var(--s3) var(--s3) var(--s4);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
    animation: toast-in .25s ease-out;
}
.toast-delete { border-left-color: var(--critical); }
.toast-update { border-left-color: var(--ink-3); }
.toast-body { flex: 1; min-width: 0; font-size: 14px; }
.toast-head { font-weight: 650; }
.toast-title { color: var(--ink); }
.toast-changed { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.toast-link { font-size: 13px; }
.toast-close { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 2px; }
.toast-close .icon { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--warn-soft); color: var(--ink); padding: var(--s3) var(--s5);
}
#blazor-error-ui .reload { margin-left: var(--s2); }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .rail {
        position: sticky; top: 0; height: auto; z-index: 10;
        flex-direction: row; align-items: center; padding: var(--s2);
        overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line);
    }
    .brand span, .nav-link span { display: none; }
    .rail ul { display: flex; }
    .topbar { position: static; padding: var(--s2) var(--s4); flex-wrap: wrap; }
    .zone { display: none; }
    .content { padding: var(--s4); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .table .hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
.panel.mb { margin-bottom: var(--s5); }
