/* Godisboden staff dashboard.
   Palette: licorice (ink + rail), raspberry (the one accent), sugar (page), lilac lines,
   mint for "fine", butterscotch for "act on this". One rounded type family throughout. */
:root {
    --licorice: #241c2e;
    --licorice-2: #3a2f47;
    --raspberry: #c8325e;
    --raspberry-soft: #fbe5ec;
    --sugar: #faf7fc;
    --paper: #ffffff;
    --line: #e9e2ef;
    --ink: #241c2e;
    --ink-2: #625872;
    --mint: #1f8a6d;
    --mint-soft: #e2f4ee;
    --butterscotch: #9a5b00;
    --butterscotch-soft: #fdf0d9;
    --muted-soft: #f0edf3;

    --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
    --r-lg: 18px; --r-sm: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--sugar);
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}
h1, h2, p { margin: 0; }
:focus-visible { outline: 3px solid var(--raspberry); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: var(--s2); background: var(--paper); padding: var(--s2) var(--s3); z-index: 10; }
.skip:focus { left: var(--s2); }

/* ---------- rail ---------- */
.rail {
    background: var(--licorice);
    color: #efe8f5;
    padding: var(--s5) var(--s3);
    display: flex;
    flex-direction: column;
    gap: var(--s6);
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: var(--s3); color: inherit; text-decoration: none; padding: 0 var(--s2); }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-mark circle { fill: var(--raspberry); }
.brand-mark path { stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.brand strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 12px; color: #b9aec6; }

.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a {
    position: relative;
    display: flex; align-items: center; gap: var(--s3);
    padding: 10px var(--s3) 10px 20px;
    border-radius: var(--r-sm);
    color: #d9cfe3;
    text-decoration: none;
    font-weight: 600;
}
.rail nav a:hover { background: var(--licorice-2); color: #fff; }
.rail nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
/* The active page is marked with a candy stick: a short raspberry-and-white striped bar. */
.rail nav a.active { background: var(--licorice-2); color: #fff; }
.rail nav a.active::before {
    content: "";
    position: absolute; left: 6px; top: 8px; bottom: 8px; width: 6px;
    border-radius: 3px;
    background: repeating-linear-gradient(135deg, var(--raspberry) 0 5px, #fff 5px 8px);
}
.rail-foot { margin-top: auto; font-size: 12px; color: #a99dba; padding: 0 var(--s2); }

/* ---------- top bar ---------- */
.shell { min-width: 0; }
.topbar {
    display: flex; justify-content: flex-end; align-items: center; gap: var(--s4);
    padding: var(--s4) var(--s6) 0;
}
.live { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--ink-2); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }
.live[data-state="reconnecting"] .dot, .live[data-state="connecting"] .dot { background: #d29a2c; }
.live[data-state="offline"] .dot { background: #a39bb0; }
.live .updated:not(:empty)::before { content: "· "; }
.live.pulse .updated { color: var(--raspberry); transition: color 0.2s; }

.activity-btn {
    display: inline-flex; align-items: center; gap: var(--s2);
    font: inherit; font-weight: 600; font-size: 14px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px var(--s4);
    cursor: pointer;
}
.activity-btn:hover { border-color: #d5c8e0; }
.activity-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.activity-btn .count { background: var(--raspberry); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; }

/* ---------- page ---------- */
main { padding: var(--s5) var(--s6) var(--s7); max-width: 1440px; }
main:focus { outline: none; }
.page-head { margin-bottom: var(--s5); max-width: 70ch; }
h1 { font-size: 34px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.lede { margin-top: var(--s2); color: var(--ink-2); font-size: 16px; }

.problem {
    background: var(--butterscotch-soft); color: #6d4100;
    border-radius: var(--r-sm); padding: var(--s3) var(--s4); margin-bottom: var(--s5);
}

/* Key figures sit on one band, split by thin rules, rather than in separate cards. */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    margin-bottom: var(--s5);
    overflow: hidden;
}
.kpi { padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 12.5px; color: var(--ink-2); }
.kpi.tone-accent .kpi-value { color: var(--raspberry); }
.kpi.tone-warn .kpi-value { color: var(--butterscotch); }
.kpi.tone-ok .kpi-value { color: var(--mint); }

.charts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: var(--s4);
    margin: 0 0 var(--s5);
}
.chart {
    margin: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s4) var(--s5) var(--s5);
    display: flex; flex-direction: column; gap: var(--s3);
}
.chart h2, .table-card h2 { font-size: 16px; font-weight: 700; }
.chart figcaption p, .table-card header p { font-size: 13px; color: var(--ink-2); }
.chart-body { position: relative; height: 260px; }
.chart .empty, .table-card .empty {
    display: grid; place-items: center; text-align: center;
    min-height: 120px; padding: var(--s4);
    color: var(--ink-2); font-size: 14px;
    background: repeating-linear-gradient(135deg, var(--sugar) 0 10px, #fff 10px 20px);
    border-radius: var(--r-sm);
}
.chart .empty { flex: 1; min-height: 200px; }

.tables { display: flex; flex-direction: column; gap: var(--s4); margin-bottom: var(--s5); }
.tables:empty { display: none; }
.table-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) 0 var(--s2); }
.table-card header { padding: 0 var(--s5) var(--s3); }
.table-card .empty { margin: 0 var(--s5) var(--s3); min-height: 64px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-2);
    padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { padding-left: var(--s5); }
th:last-child, td:last-child { padding-right: var(--s5); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfaFd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td time { white-space: nowrap; }

.badge {
    display: inline-block; padding: 1px 10px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
    background: var(--muted-soft); color: var(--ink-2);
}
.badge.ok { background: var(--mint-soft); color: var(--mint); }
.badge.warn { background: var(--butterscotch-soft); color: var(--butterscotch); }
.badge.muted { background: var(--muted-soft); color: #7d7489; }

/* ---------- activity drawer + toasts ---------- */
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw);
    background: var(--paper); border-left: 1px solid var(--line);
    box-shadow: -12px 0 32px rgba(36, 28, 46, 0.12);
    padding: var(--s5); overflow-y: auto; z-index: 20;
}
.drawer header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s4); }
.drawer h2 { font-size: 18px; font-weight: 800; }
.drawer .close { font: inherit; font-size: 24px; line-height: 1; border: 0; background: none; cursor: pointer; color: var(--ink-2); padding: var(--s1) var(--s2); }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) 0 var(--s3) var(--s4); border-bottom: 1px solid var(--line); position: relative; }
.feed li::before { content: ""; position: absolute; left: 0; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.feed li[data-op="removed"]::before { background: #a39bb0; }
.feed li[data-op="updated"]::before { background: var(--raspberry); }
.feed strong { font-size: 14px; }
.feed span, .feed time { font-size: 13px; color: var(--ink-2); }
.feed .changes { color: var(--ink); }
.feed-empty { color: var(--ink-2); font-size: 14px; }

.toasts { position: fixed; right: var(--s5); bottom: var(--s5); display: flex; flex-direction: column; gap: var(--s2); z-index: 30; max-width: min(360px, calc(100vw - 32px)); }
.toast {
    background: var(--licorice); color: #fff;
    border-radius: 14px; padding: var(--s3) var(--s4);
    box-shadow: 0 10px 30px rgba(36, 28, 46, 0.25);
    display: flex; flex-direction: column; gap: 2px;
    animation: toast-in 0.25s ease-out;
}
.toast strong { font-size: 14px; }
.toast span { font-size: 13px; color: #ddd3e8; }
.toast .changes { color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
    body { grid-template-columns: 1fr; }
    .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s3); }
    .rail nav { flex-direction: row; overflow-x: auto; width: 100%; }
    .rail nav a { padding: var(--s2) var(--s3); white-space: nowrap; }
    .rail nav a.active::before { left: 10px; right: 10px; top: auto; bottom: 2px; width: auto; height: 4px; }
    .rail-foot { display: none; }
    .topbar { padding: var(--s3) var(--s4) 0; }
    main { padding: var(--s4) var(--s4) var(--s6); }
    h1 { font-size: 28px; }
    .kpi { border-left: 0; border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; }
}
