/* Food truck dashboard: cool paper, ink-green text, one accent (salsa verde),
   mustard only for "needs attention". The headline numbers sit on a dark band
   set like the truck's menu board; everything else stays quiet. */

:root {
    --paper: #F6F7F5;
    --surface: #FFFFFF;
    --ink: #1D2B2A;
    --muted: #5F6D69;
    --rule: #DCE2DE;
    --accent: #0E7C66;
    --accent-soft: #D5ECE5;
    --warn: #C98F0A;
    --warn-soft: #FBF1D6;
    --danger: #A83A2C;
    --board: #1D2B2A;
    --board-ink: #F2F5F3;
    --board-muted: #A9BAB4;
    --board-accent: #7FD1B9;

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
    --radius-s: 4px;
    --radius-m: 8px;

    --font: "Avenir Next", "Avenir", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.07rem; font-weight: 650; }
h3 { font-size: 0.98rem; font-weight: 650; }
h1:focus { outline: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-s); }

.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Shell ------------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.side {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 2px;
    padding: var(--s5) var(--s3);
    border-right: 1px solid var(--rule);
    background: var(--surface);
}
.brand {
    display: flex; align-items: center; gap: var(--s2);
    padding: 0 var(--s3) var(--s5);
    font-weight: 700; font-size: 1.05rem;
}
.brand svg { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.nav-item {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s2) var(--s3);
    border-radius: var(--radius-m);
    color: var(--ink);
    font-weight: 500;
}
.nav-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: var(--paper); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.side-foot { margin-top: auto; padding: 0 var(--s3); font-size: 0.8rem; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; justify-content: flex-end; align-items: center;
    padding: var(--s3) var(--s6);
    min-height: 48px;
}
main { padding: 0 var(--s6) var(--s7); max-width: 1440px; width: 100%; }

.live { display: inline-flex; align-items: center; gap: var(--s2); font-size: 0.85rem; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: var(--accent); }
.live.off .dot { background: var(--warn); }
.live .dot.pulse { animation: pulse 1.4s ease-out; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(14, 124, 102, 0.45); }
    100% { box-shadow: 0 0 0 10px rgba(14, 124, 102, 0); }
}

/* ---- Page head and the board -------------------------------------------------- */
.page-head { margin: var(--s2) 0 var(--s5); }
.lede { margin: var(--s2) 0 0; color: var(--muted); font-size: 1.02rem; max-width: 70ch; }

.board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    background: var(--board);
    color: var(--board-ink);
    border-radius: var(--radius-m);
    padding: var(--s5) var(--s2);
    margin-bottom: var(--s6);
}
.kpi {
    display: flex; flex-direction: column;
    padding: var(--s1) var(--s4);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    min-width: 0;
}
.kpi:first-child { border-left: 0; }
.kpi-value {
    font-size: 1.75rem; font-weight: 650; line-height: 1.15;
    font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-value.ghost { background: rgba(255, 255, 255, 0.08); border-radius: var(--radius-s); width: 70%; }
.kpi-label { margin-top: var(--s1); font-size: 0.86rem; color: var(--board-accent); font-weight: 600; }
.kpi-note { font-size: 0.8rem; color: var(--board-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.warn .kpi-value { color: #F2C14E; }
.kpi.warn .kpi-label { color: #F2C14E; }

/* ---- Grid, panels, charts ----------------------------------------------------- */
.grid { display: grid; gap: var(--s5); margin-bottom: var(--s5); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.panel, .chart {
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-m);
    padding: var(--s5);
    min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); margin-bottom: var(--s4); }
.panel-head a { font-size: 0.88rem; font-weight: 600; }
.panel > h2 { margin-bottom: var(--s4); }

.chart figcaption { margin-bottom: var(--s4); }
.chart figcaption p { margin: 2px 0 0; font-size: 0.85rem; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.bars li { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: var(--s3); }
.bar-label { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--paper); border-radius: 2px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width 400ms ease; }
.bars.warn .bar-fill { background: var(--warn); }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.9rem; text-align: right; white-space: nowrap; }
.bar-value small { display: block; font-weight: 400; color: var(--muted); font-size: 0.76rem; }

.empty { color: var(--muted); margin: 0; padding: var(--s3) 0; }
.skeleton { height: 120px; border-radius: var(--radius-s); background: linear-gradient(90deg, var(--paper), #ECEFEC, var(--paper)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton.tall { height: 220px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---- Tables ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
    text-align: left; font-weight: 600; color: var(--muted); font-size: 0.82rem;
    padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}
td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFBFA; }
td .muted { font-size: 0.85rem; }
.warn-row td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.stock-low { color: var(--danger); font-weight: 650; }
.stock-near { color: var(--warn); font-weight: 650; }

.tag {
    display: inline-block; padding: 1px var(--s2);
    border-radius: var(--radius-s);
    background: var(--paper); border: 1px solid var(--rule);
    font-size: 0.8rem; white-space: nowrap;
}
.tag.yes { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tag.attn { background: var(--warn-soft); border-color: transparent; color: #7A5600; }

.more {
    margin-top: var(--s4);
    font: inherit; font-weight: 600; font-size: 0.9rem;
    color: var(--accent); background: var(--surface);
    border: 1px solid var(--rule); border-radius: var(--radius-m);
    padding: var(--s2) var(--s4); cursor: pointer;
}
.more:hover { border-color: var(--accent); }
.more:disabled { color: var(--muted); cursor: progress; }

.section-title { margin: var(--s6) 0 var(--s4); }
.count { color: var(--muted); font-weight: 500; font-size: 0.9rem; margin-left: var(--s2); }

/* ---- Feed and toasts ---------------------------------------------------------- */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li { display: grid; grid-template-columns: 74px 1fr; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--rule); font-size: 0.9rem; }
.feed-list li:last-child { border-bottom: 0; }
.feed-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed-list small { display: block; color: var(--muted); }
.feed-list li.op-deleted span { color: var(--muted); }

.toasts { position: fixed; right: var(--s5); bottom: var(--s5); display: flex; flex-direction: column; gap: var(--s2); z-index: 10; max-width: 380px; }
.toast {
    background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent);
    border-radius: var(--radius-m); padding: var(--s3) var(--s4);
    box-shadow: 0 6px 20px rgba(29, 43, 42, 0.12);
    font-size: 0.9rem;
    animation: toast-in 220ms ease-out;
}
.toast strong { display: block; font-weight: 600; }
.toast span { color: var(--muted); font-size: 0.85rem; }
.toast.op-deleted { border-left-color: var(--muted); }
.toast.op-updated { border-left-color: var(--warn); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.error {
    display: flex; flex-direction: column; gap: 2px;
    background: var(--warn-soft); border: 1px solid #EBD394; color: #5C4300;
    border-radius: var(--radius-m); padding: var(--s3) var(--s4); margin-bottom: var(--s5);
}

#blazor-error-ui { display: none; }

/* ---- Responsive and motion ---------------------------------------------------- */
@media (max-width: 1100px) {
    .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: var(--s3); border-right: 0; border-bottom: 1px solid var(--rule); }
    .brand { padding: var(--s2) var(--s3); }
    .side-foot { display: none; }
    main, .topbar { padding-left: var(--s4); padding-right: var(--s4); }
    .grid.two, .grid.three { grid-template-columns: 1fr; }
    .kpi { border-left: 0; padding: var(--s2) var(--s4); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
