/*
 * Godisbiten store dashboard.
 * Palette: liquorice aubergine ink, raspberry accent, a lilac-white paper.
 * The one loud element is the polkagris stripe (the red-and-white Swedish
 * peppermint stick): on the brand mark and on the active page in the menu.
 */
:root {
  --paper: #faf7fb;
  --panel: #ffffff;
  --ink: #24133a;
  --ink-2: #4d4060;
  --muted: #6e6380;
  --line: #e8e0ee;
  --line-strong: #d6cade;
  --accent: #c8185f;
  --accent-soft: #fbe7ef;
  --nav-bg: #24133a;
  --nav-ink: #e9e1f3;
  --nav-muted: #a798ba;

  --critical: #b3261e;
  --critical-soft: #fde9e7;
  --warning: #8a5300;
  --warning-soft: #fdf1dc;
  --good: #1f6f35;
  --good-soft: #e5f4e8;

  --stripe: repeating-linear-gradient(-45deg, #e01f4f 0 6px, #fff 6px 12px);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius: 10px;
  --font: "Bricolage Grotesque Variable", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

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

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

.nav {
  background: var(--nav-bg);
  color: var(--nav-ink);
  padding: var(--s5) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: grid; grid-template-columns: 34px 1fr; column-gap: var(--s3); align-items: center; padding: 0 var(--s2); }
.brand-mark {
  grid-row: span 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--stripe);
  box-shadow: inset 0 0 0 2px #fff;
}
.brand-name { font-size: 20px; font-weight: 750; font-stretch: 90%; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-size: 13px; color: var(--nav-muted); }

.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-list a {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s3);
  border-radius: 8px;
  color: var(--nav-ink);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}
.nav-list a:hover { background: rgba(255, 255, 255, 0.07); }
.nav-list a[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 650; }
.nav-list a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 6px;
  border-radius: 0 4px 4px 0;
  background: var(--stripe);
}
.nav-list svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-foot { margin-top: auto; padding: 0 var(--s2); font-size: 12px; color: var(--nav-muted); }

/* ---------- Main ---------- */
.main { padding: var(--s6) var(--s6) var(--s7); min-width: 0; outline: none; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s5); margin-bottom: var(--s5); }
h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 800;
  font-stretch: 85%;
  letter-spacing: -0.025em;
}
.subtitle { margin: var(--s2) 0 0; color: var(--muted); max-width: 64ch; }
.head-tools { display: flex; align-items: center; gap: var(--s4); flex: none; padding-top: var(--s2); }
.updated { margin: 0; display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--muted); }
.updated.flash #updated-text { animation: flash 1.2s ease-out; }
@keyframes flash { from { color: var(--accent); } to { color: var(--muted); } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.dot.live { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.reconnecting { background: #c98500; box-shadow: 0 0 0 3px var(--warning-soft); }
.dot.offline { background: var(--critical); }

.feed-btn {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
  display: inline-flex; align-items: center; gap: var(--s2);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 6px 14px 6px 10px; cursor: pointer;
}
.feed-btn:hover { border-color: var(--ink-2); }
.feed-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; line-height: 18px; }

/* ---------- KPI strip ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--s5);
}
.kpi { padding: var(--s4) var(--s5); border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 13px; color: var(--muted); margin: 0; }
.kpi-value { font-size: 30px; font-weight: 700; font-stretch: 90%; letter-spacing: -0.02em; margin: 2px 0 0; line-height: 1.2; white-space: nowrap; }
.kpi-hint { font-size: 12px; color: var(--muted); margin: 0; }
.kpi.critical .kpi-value { color: var(--critical); }
.kpi.warning .kpi-value { color: var(--warning); }
.kpi-tone { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; margin: 0; }
.kpi.critical .kpi-tone { color: var(--critical); }
.kpi.warning .kpi-tone { color: var(--warning); }
.kpi.good .kpi-tone { color: var(--good); }

/* ---------- Panels ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s4) var(--s5) var(--s5);
  min-width: 0;
  display: flex; flex-direction: column;
}
.panel.wide { grid-column: 1 / -1; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.panel h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.005em; }
.panel-note { margin: 0 0 var(--s3); font-size: 13px; color: var(--muted); }
.view-toggle {
  font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 2px 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.view-toggle:hover { color: var(--ink); }
.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 220px; }
.empty, .error {
  flex: 1; display: grid; place-items: center; text-align: center;
  min-height: 140px; color: var(--muted); font-size: 14px; padding: var(--s4);
  border: 1px dashed var(--line-strong); border-radius: 8px;
}
.error { color: var(--critical); border-color: #f1c4c0; background: var(--critical-soft); }

.skeleton { min-height: 260px; border-radius: 8px; background: linear-gradient(90deg, #f4eff7 0 40%, #faf6fc 50%, #f4eff7 60% 100%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s5) * -1); padding: 0 var(--s5); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 6px var(--s3) 8px 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 9px var(--s3) 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.when { white-space: nowrap; color: var(--ink-2); }
.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 9px; border-radius: 999px; background: #f1ecf5; color: var(--ink-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.critical { background: var(--critical-soft); color: var(--critical); }
.qty-low { color: var(--critical); font-weight: 650; }

/* ---------- Activity feed ---------- */
.feed {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line-strong);
  box-shadow: -12px 0 32px rgba(36, 19, 58, 0.12);
  padding: var(--s5); overflow-y: auto; z-index: 20;
}
.feed-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); }
.feed-head h2 { margin: 0; font-size: 20px; }
.feed-close { font: inherit; background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.feed-empty { color: var(--muted); font-size: 14px; }
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }

.note-top { display: flex; justify-content: space-between; gap: var(--s3); font-size: 12.5px; color: var(--muted); }
.note-op { font-weight: 650; }
.note-op.Created, .note-op.Linked { color: var(--good); }
.note-op.Deleted, .note-op.Unlinked { color: var(--critical); }
.note-op.Updated { color: var(--accent); }
.note-text { margin: 2px 0 0; font-weight: 550; }
.note-changes { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.note-changes li { padding: 0; border: 0; }
.note-changes b { font-weight: 600; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); display: grid; gap: var(--s2); z-index: 30; width: min(360px, calc(100vw - 32px)); }
.toast {
  background: var(--ink); color: #f4eefa; border-radius: var(--radius);
  padding: var(--s3) var(--s4); box-shadow: 0 10px 30px rgba(36, 19, 58, 0.28);
  animation: toast-in 0.25s ease-out;
}
.toast .note-top { color: #bfb1d1; }
.toast .note-op.Created, .toast .note-op.Linked { color: #8fe0a6; }
.toast .note-op.Deleted, .toast .note-op.Unlinked { color: #ff9c95; }
.toast .note-op.Updated { color: #ff9cc3; }
.toast .note-changes { color: #ddd3ea; }
.toast.leaving { opacity: 0; transition: opacity 0.3s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; height: auto; z-index: 15; padding: var(--s3); gap: var(--s2); flex-direction: row; align-items: center; overflow-x: auto; }
  .brand-sub, .brand-name, .nav-foot { display: none; }
  .brand { grid-template-columns: 30px; padding: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .nav-list { display: flex; gap: 2px; }
  .nav-list a span { display: none; }
  .nav-list a[aria-current="page"]::before { left: 6px; right: 6px; top: auto; bottom: -6px; width: auto; height: 4px; border-radius: 2px; }
  .main { padding: var(--s5) var(--s4) var(--s7); }
  h1 { font-size: 32px; }
  .head { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
