/* Design tokens follow docs/ui-build-spec.md §2: teal primary, dark sidebar,
   OKLCH. Dark values are declared twice: once for the OS setting, once for the
   in-app toggle (data-theme), which wins both ways. */
:root {
  color-scheme: light;
  --bg: oklch(0.985 0.003 248);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.968 0.007 247.9);
  --fg: oklch(0.2 0.03 258);
  --fg-2: oklch(0.42 0.03 257);
  --fg-3: oklch(0.555 0.03 257);
  --border: oklch(0.925 0.01 255);
  --border-strong: oklch(0.86 0.012 255);
  --primary: oklch(0.654 0.094 205.6);
  --primary-strong: oklch(0.52 0.085 207);
  --primary-soft: oklch(0.654 0.094 205.6 / 0.12);
  --danger: oklch(0.55 0.2 25);
  --danger-soft: oklch(0.637 0.208 25.33 / 0.12);
  --warn: oklch(0.55 0.12 70);
  --warn-soft: oklch(0.8 0.14 80 / 0.22);
  --ok: oklch(0.5 0.12 155);
  --ok-soft: oklch(0.65 0.14 155 / 0.16);
  --info-soft: oklch(0.6 0.12 250 / 0.13);
  --info: oklch(0.48 0.13 255);
  --sidebar: oklch(0.208 0.04 265.73);
  --sidebar-fg: oklch(0.86 0.01 250);
  --sidebar-muted: oklch(0.62 0.02 255);
  --sidebar-accent: oklch(0.28 0.037 259.97);
  --shadow: 0 1px 2px oklch(0.2 0.03 258 / 0.06), 0 4px 16px oklch(0.2 0.03 258 / 0.06);
  --shadow-lg: 0 12px 40px oklch(0.2 0.03 258 / 0.22);
  --radius: 0.5rem;
  /* chart roles (validated palette, see dataviz reference) */
  --series-1: #2a78d6;
  --series-muted: #c9ccd3;
  --grid: oklch(0.93 0.008 255);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: oklch(0.155 0.03 258.5);
    --surface: oklch(0.2 0.032 259);
    --surface-2: oklch(0.245 0.034 259.5);
    --fg: oklch(0.96 0.005 248);
    --fg-2: oklch(0.8 0.02 255);
    --fg-3: oklch(0.68 0.03 256);
    --border: oklch(0.29 0.035 260);
    --border-strong: oklch(0.36 0.035 260);
    --primary-strong: oklch(0.6 0.09 206);
    --primary-soft: oklch(0.654 0.094 205.6 / 0.2);
    --danger: oklch(0.7 0.17 25);
    --warn: oklch(0.82 0.13 80);
    --ok: oklch(0.78 0.14 155);
    --info: oklch(0.78 0.1 250);
    --sidebar: oklch(0.13 0.028 262);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 4px 16px oklch(0 0 0 / 0.25);
    --series-1: #3987e5;
    --series-muted: #4a5163;
    --grid: oklch(0.27 0.03 260);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: oklch(0.155 0.03 258.5);
  --surface: oklch(0.2 0.032 259);
  --surface-2: oklch(0.245 0.034 259.5);
  --fg: oklch(0.96 0.005 248);
  --fg-2: oklch(0.8 0.02 255);
  --fg-3: oklch(0.68 0.03 256);
  --border: oklch(0.29 0.035 260);
  --border-strong: oklch(0.36 0.035 260);
  --primary-strong: oklch(0.6 0.09 206);
  --primary-soft: oklch(0.654 0.094 205.6 / 0.2);
  --danger: oklch(0.7 0.17 25);
  --warn: oklch(0.82 0.13 80);
  --ok: oklch(0.78 0.14 155);
  --info: oklch(0.78 0.1 250);
  --sidebar: oklch(0.13 0.028 262);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 4px 16px oklch(0 0 0 / 0.25);
  --series-1: #3987e5;
  --series-muted: #4a5163;
  --grid: oklch(0.27 0.03 260);
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font:
    14px/1.5 Inter,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--primary-strong);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
}
svg.icon {
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-fg);
  padding: 1rem 0.75rem;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.5rem 1rem;
  color: white;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 700;
}
.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--sidebar-muted);
}
.nav-group {
  margin: 0.9rem 0.6rem 0.3rem;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--sidebar-fg);
  transition:
    background 120ms ease,
    color 120ms ease;
}
.nav a:hover {
  background: var(--sidebar-accent);
  color: white;
  text-decoration: none;
}
.nav a[aria-current='page'] {
  background: var(--sidebar-accent);
  color: white;
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav .count {
  margin-left: auto;
  min-width: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-accent);
}
.me {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
}
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--sidebar-accent);
  color: white;
  font-weight: 600;
  font-size: 12px;
}
.me-text {
  min-width: 0;
  flex: 1;
  font-size: 12px;
  line-height: 1.3;
}
.me-text strong {
  display: block;
  color: white;
  font-weight: 600;
}
.me-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sidebar-muted);
}
.sidebar .icon-btn {
  color: var(--sidebar-fg);
}
.sidebar .icon-btn:hover {
  background: var(--sidebar-accent);
  color: white;
}

.main {
  min-width: 0;
  padding: 1.5rem 2rem 3rem;
  max-width: 1400px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head h1 {
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.page-head p {
  margin: 0.2rem 0 0;
  color: var(--fg-3);
}
.page-head .actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  font-size: 12px;
  color: var(--fg-3);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 34px;
  padding: 0 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 80ms ease;
}
.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: white;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.btn.danger-ghost {
  color: var(--danger);
}
.btn.danger-ghost:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.sm {
  height: 28px;
  padding: 0 0.6rem;
  font-size: 13px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--fg);
}
.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 1rem 1.1rem;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.card-head h3 {
  font-size: 0.95rem;
  font-weight: 600;
}
.card-head .sub {
  color: var(--fg-3);
  font-size: 12px;
}
.card-head .right {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.grid {
  display: grid;
  gap: 1rem;
}
.grid.kpis {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid.two {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}
.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.grid.detail {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}
.muted {
  color: var(--fg-3);
}
.small {
  font-size: 12px;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- KPI tiles ---------- */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 1.1rem;
  color: inherit;
}
a.kpi:hover {
  text-decoration: none;
  border-color: var(--primary);
}
.kpi .label {
  color: var(--fg-3);
  font-size: 12.5px;
}
.kpi .value {
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.kpi .foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 32px;
  color: var(--fg-3);
  font-size: 12px;
}
.kpi.attn {
  border-color: var(--primary);
  background: linear-gradient(0deg, var(--primary-soft), var(--primary-soft)), var(--surface);
}

/* ---------- status pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill.bad {
  background: var(--danger-soft);
  color: var(--danger);
}
.pill.info {
  background: var(--info-soft);
  color: var(--info);
}
.tag {
  display: inline-block;
  padding: 0 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--fg-2);
  white-space: nowrap;
}

/* ---------- toolbar, tabs ---------- */
.tabs {
  display: flex;
  gap: 0.15rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
  overflow-x: auto;
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--fg-3);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.tabs button:hover {
  color: var(--fg);
}
.tabs button[aria-selected='true'] {
  color: var(--fg);
  border-bottom-color: var(--primary);
}
.tabs .n {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--fg-2);
}
.tabs button[aria-selected='true'] .n {
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.search {
  position: relative;
  flex: 1 1 240px;
  max-width: 360px;
}
.search svg {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-3);
}
.search input[type='search'] {
  padding-left: 2rem;
}
.bulkbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-soft);
}

/* ---------- forms ---------- */
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='url'],
input[type='search'],
input:not([type]),
select,
textarea {
  width: 100%;
  height: 34px;
  padding: 0 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}
select {
  width: auto;
  padding-right: 1.6rem;
}
textarea {
  height: auto;
  min-height: 6rem;
  padding: 0.5rem 0.65rem;
  resize: vertical;
  line-height: 1.5;
}
textarea.code {
  font:
    12.5px/1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  min-height: 22rem;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--surface-2);
  color: var(--fg-2);
}
input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-strong);
  cursor: pointer;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.field > label,
.field > .label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
}
.field .help {
  font-size: 12px;
  color: var(--fg-3);
}
.form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem;
  min-height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.chips:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.2rem 0 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px;
}
.chip.block {
  background: var(--danger-soft);
}
.chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--fg-3);
  cursor: pointer;
}
.chip button:hover {
  background: var(--border-strong);
  color: var(--fg);
}
.chips input {
  flex: 1 1 80px;
  width: auto;
  height: 24px;
  border: 0;
  padding: 0 0.3rem;
  box-shadow: none !important;
  background: transparent;
}
.rule {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.5rem;
}
.rule .num {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 600;
}
.rule textarea {
  min-height: 34px;
  height: 34px;
  field-sizing: content;
}
.rule .ops {
  display: flex;
}

/* ---------- tables ---------- */
.table-wrap {
  overflow: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th,
table.data td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}
table.data th.sortable {
  cursor: pointer;
}
table.data th.sortable:hover {
  color: var(--fg);
}
table.data th .arrow {
  display: inline-block;
  width: 1em;
  color: var(--primary-strong);
}
table.data tbody tr {
  transition: background 100ms ease;
}
table.data tbody tr.clickable {
  cursor: pointer;
}
table.data tbody tr:hover {
  background: var(--primary-soft);
}
table.data tbody tr.selected {
  background: var(--primary-soft);
  box-shadow: inset 2px 0 0 var(--primary);
}
table.data tbody tr:focus-visible {
  outline: none;
  box-shadow: inset 2px 0 0 var(--primary);
  background: var(--primary-soft);
}
table.data tbody tr:last-child td {
  border-bottom: 0;
}
table.data td.check,
table.data th.check {
  width: 36px;
  padding-right: 0;
}
table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-main {
  font-weight: 500;
  color: var(--fg);
}
.cell-sub {
  color: var(--fg-3);
  font-size: 12px;
}
.cell-clip {
  max-width: 420px;
}
.table-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--border);
  color: var(--fg-3);
  font-size: 12.5px;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--fg-3);
}
.empty .ring {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--fg-2);
}
.empty strong {
  color: var(--fg);
  font-size: 0.95rem;
}

/* ---------- notices ---------- */
.notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--warn-soft);
  color: var(--fg);
}
.notice svg {
  margin-top: 2px;
  color: var(--warn);
}
.notice.bad {
  background: var(--danger-soft);
}
.notice.bad svg {
  color: var(--danger);
}
.notice.info {
  background: var(--info-soft);
}
.notice.info svg {
  color: var(--info);
}
.error-text {
  color: var(--danger);
}

/* ---------- detail bits ---------- */
dl.kv {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 0.45rem 0.75rem;
  margin: 0;
}
dl.kv dt {
  color: var(--fg-3);
  font-size: 12.5px;
}
dl.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.section-title {
  margin: 0 0 0.5rem;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.list {
  display: flex;
  flex-direction: column;
}
.list > a,
.list > .item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: inherit;
}
.list > :last-child {
  border-bottom: 0;
}
.list > a:hover {
  background: var(--primary-soft);
  text-decoration: none;
}
.list .grow {
  min-width: 0;
  flex: 1;
}
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.compare h4 {
  margin-bottom: 0.4rem;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.compare iframe {
  width: 100%;
  height: 68vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}
.health {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-3);
}
.dot.ok {
  background: oklch(0.65 0.16 155);
}
.dot.bad {
  background: oklch(0.63 0.21 25);
}
.dot.warn {
  background: oklch(0.78 0.15 80);
}

/* ---------- drawer & dialog ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: oklch(0.15 0.03 260 / 0.45);
  animation: fade 140ms ease;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  width: min(600px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: slide 180ms ease;
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 {
  font-size: 1.05rem;
  font-weight: 650;
}
.drawer-head .grow {
  min-width: 0;
  flex: 1;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.drawer-foot {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
dialog.modal {
  width: min(460px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop {
  background: oklch(0.15 0.03 260 / 0.5);
}
dialog.modal .body {
  padding: 1.25rem 1.25rem 0.5rem;
}
dialog.modal h3 {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}
dialog.modal .foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
}
@keyframes slide {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- toast ---------- */
#toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 380px;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: oklch(0.22 0.04 262);
  color: white;
  box-shadow: var(--shadow-lg);
  animation: slide 160ms ease;
}
.toast.error {
  background: oklch(0.45 0.17 25);
}

/* ---------- charts ---------- */
.chart {
  position: relative;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart text {
  fill: var(--fg-3);
  font-size: 11px;
}
.chart .grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}
.chart .hit {
  fill: transparent;
}
.chart .hit:hover,
.chart .hit:focus {
  fill: var(--primary-soft);
  outline: none;
}
.legend {
  display: flex;
  gap: 1rem;
  font-size: 12px;
  color: var(--fg-2);
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 0.35rem;
  border-radius: 2px;
}
.tip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
}
.tip .t {
  margin-bottom: 0.25rem;
  color: var(--fg-3);
}
.tip .r {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tip .r b {
  margin-left: auto;
  font-size: 13px;
}
.tip .key {
  width: 10px;
  height: 3px;
  border-radius: 2px;
}
.hbar {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 2.5rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
  font-size: 13px;
}
.hbar .track {
  height: 14px;
}
.hbar .fill {
  height: 100%;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
}
.hbar b {
  font-variant-numeric: tabular-nums;
}
details.tableview {
  margin-top: 0.5rem;
  font-size: 12px;
  color: var(--fg-3);
}
details.tableview summary {
  cursor: pointer;
}
details.tableview table {
  margin-top: 0.4rem;
  border-collapse: collapse;
}
details.tableview td,
details.tableview th {
  padding: 0.15rem 0.75rem 0.15rem 0;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

/* ---------- login & skeleton ---------- */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  background: radial-gradient(60rem 30rem at 50% -10%, var(--primary-soft), transparent), var(--bg);
}
.login {
  width: min(380px, 100%);
  padding: 1.75rem;
}
.login .brand {
  color: var(--fg);
  padding: 0 0 1.25rem;
}
.login .brand small {
  color: var(--fg-3);
}
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .main {
    padding: 1rem;
  }
  .grid.two,
  .grid.detail,
  .compare {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

.drawer:focus {
  outline: none;
}
