:root {
  --bg: #f6f3ee; --surface: #ffffff; --ink: #1d2a2a; --muted: #6b7774; --line: #e4dfd6;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e1f1ee; --side: #123b38; --side-ink: #cfe3df;
  --radius: 14px; --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px;
  --shadow: 0 1px 2px rgba(29,42,42,.05), 0 6px 18px rgba(29,42,42,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h3 { margin: 0; font-weight: 600; }
h1 { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; font-size: 2rem; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: var(--s1) 0 var(--s4); }

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s1);
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: var(--s2) var(--s2) var(--s4); }
.brand span { font-family: Georgia, serif; font-size: 1.15rem; line-height: 1.15; display: flex; flex-direction: column; }
.brand small { font: 11px/1.4 "Inter", system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #8fb5af; }
.nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
.nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav:hover { background: rgba(255,255,255,.07); }
.nav.active { background: var(--accent); color: var(--accent-ink); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8fb5af; padding: var(--s2); }
.live { width: 8px; height: 8px; border-radius: 50%; background: #7b8f8c; flex: none; }
.live.on { background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }

.main { padding: var(--s4) var(--s5) var(--s5); min-width: 0; }
.topbar { display: flex; justify-content: flex-end; height: 22px; margin-bottom: var(--s2); }
.refresh { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.refresh .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .5; }
.refresh.busy .dot { opacity: 1; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .15; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3); display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.stat-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stat-value { font-family: Georgia, serif; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--muted); }

.grid { display: grid; gap: var(--s3); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4) var(--s4); box-shadow: var(--shadow); min-width: 0; }
.card header { margin-bottom: var(--s3); }
.card h3 { font-size: 1rem; }
.card header p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.state { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; font-size: 14px; }
.state-error { color: #9a3412; background: #fff7ed; border-color: #fed7aa; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.barlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.barlist li { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 12px; align-items: center; font-size: 13.5px; }
.bl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-track { height: 12px; background: #f0ece5; border-radius: 6px; overflow: hidden; }
.bl-fill { display: block; height: 100%; border-radius: 6px; transition: width .5s ease; }
.bl-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3ch; text-align: right; }

.columns { width: 100%; height: auto; display: block; }
.columns .grid { stroke: #ece7de; stroke-width: 1; }
.columns .axis, .axis { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.columns rect { transition: height .4s ease, y .4s ease; }
.columns rect:hover { opacity: .8; }

.donut { display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap; }
.donut svg { width: 160px; height: 160px; flex: none; }
.donut-bg { fill: none; stroke: #f0ece5; stroke-width: 18; }
.donut-total { font-family: Georgia, serif; font-size: 22px; fill: var(--ink); }
.donut-cap { font-size: 9px; fill: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; min-width: 160px; font-size: 13.5px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.lg-value small { color: var(--muted); font-weight: 400; margin-left: 4px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 50; width: min(340px, calc(100vw - 40px)); }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 28px rgba(29,42,42,.18); animation: slide .25s ease; }
.toast.op-update { border-left-color: #d97706; } .toast.op-delete { border-left-color: #b91c1c; }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }
.toast-head { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.op-update .chip { background: #fef3c7; color: #92400e; } .op-delete .chip { background: #fee2e2; color: #991b1b; }
.x { margin-left: auto; border: 0; background: none; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; }
.toast-body { margin-top: 4px; font-size: 12.5px; color: var(--muted); word-break: break-word; }
.empty { padding: var(--s5); color: var(--muted); }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: var(--s2); } .side-foot { display: none; }
  .nav span { display: none; } .nav { padding: 10px; }
  .g2 { grid-template-columns: 1fr; }
  .main { padding: var(--s3); }
}
#blazor-error-ui { display: none; }
