/* ThetaRho Console — rebuilt on the shadcn/ui new-york-v4 `dashboard-01` block.
   Layout: inset sidebar (page bg = --sidebar, main = rounded card), 48px header, 4 section cards,
   one chart card, one tabbed data table. Tokens mirror shadcn's oklch neutral theme, radius 0.625rem. */
:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --brand: #7ebf42;            /* ThetaRho green (tailwind thetarhoGreen) */
  --brand-deep: #528828;       /* brand 700: text/buttons on light */
  --brand-soft: #f3faeb;       /* brand 50 */
  --brand-border: #cce8ae;     /* brand 200 */
  --brand-blue: #3cb4e5;       /* ThetaRho blue, used sparingly */
  --primary: var(--brand-deep);
  --primary-foreground: #ffffff;
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: var(--brand-soft);
  --accent-foreground: #2f4720;
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: var(--brand);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-accent: var(--brand-soft);
  --sidebar-accent-foreground: #2f4720;
  --sidebar-border: oklch(0.922 0 0);
  --chart-1: var(--brand);
  --ok: var(--brand-deep);
  --warn: oklch(0.769 0.188 70.08);
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0);
    --card: oklch(0.205 0 0); --card-foreground: oklch(0.985 0 0); --popover: oklch(0.205 0 0);
    --brand-soft: rgb(126 191 66 / 0.14); --brand-border: rgb(126 191 66 / 0.35); --brand-deep: #aad87e;
    --primary: var(--brand); --primary-foreground: #16260d;
    --secondary: oklch(0.269 0 0); --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.269 0 0); --muted-foreground: oklch(0.708 0 0);
    --accent: var(--brand-soft); --accent-foreground: #cce8ae;
    --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(1 0 0 / 10%); --input: oklch(1 0 0 / 15%); --ring: var(--brand);
    --sidebar: oklch(0.205 0 0); --sidebar-foreground: oklch(0.985 0 0);
    --sidebar-accent: var(--brand-soft); --sidebar-accent-foreground: #cce8ae; --sidebar-border: oklch(1 0 0 / 10%);
    --chart-1: var(--brand);
    --ok: var(--brand); --warn: oklch(0.828 0.189 84.429);
    --shadow-xs: none; --shadow-sm: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0); --card-foreground: oklch(0.985 0 0); --popover: oklch(0.205 0 0);
  --brand-soft: rgb(126 191 66 / 0.14); --brand-border: rgb(126 191 66 / 0.35); --brand-deep: #aad87e;
  --primary: var(--brand); --primary-foreground: #16260d;
  --secondary: oklch(0.269 0 0); --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0); --muted-foreground: oklch(0.708 0 0);
  --accent: var(--brand-soft); --accent-foreground: #cce8ae;
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%); --input: oklch(1 0 0 / 15%); --ring: var(--brand);
  --sidebar: oklch(0.205 0 0); --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-accent: var(--brand-soft); --sidebar-accent-foreground: #cce8ae; --sidebar-border: oklch(1 0 0 / 10%);
  --chart-1: var(--brand);
  --ok: var(--brand); --warn: oklch(0.828 0.189 84.429);
  --shadow-xs: none; --shadow-sm: none;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; border-color: var(--border); }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--sidebar); color: var(--foreground);
  font: 14px/1.45 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in oklab, var(--ring) 50%, transparent); outline-offset: 0; border-radius: calc(var(--radius) - 2px); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.text-muted { color: var(--muted-foreground); }
.text-sm { font-size: 14px; } .text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.icon { width: 16px; height: 16px; }

/* ---------- sidebar provider (inset variant) ---------- */
.sidebar-wrapper { display: flex; min-height: 100svh; width: 100%; --sidebar-width: 18rem; --header-height: 3rem; }
.sidebar {
  position: sticky; top: 0; height: 100svh; width: var(--sidebar-width); flex: none;
  display: flex; flex-direction: column; padding: 8px; gap: 8px; color: var(--sidebar-foreground);
}
.sidebar-header, .sidebar-footer { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.sidebar-content { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: auto; gap: 8px; }
.sidebar-group { position: relative; display: flex; flex-direction: column; padding: 8px; gap: 8px; }
.sidebar-group.mt-auto { margin-top: auto; }
.sidebar-group + .sidebar-group { padding-top: 0; }
.sidebar-group-label { height: 28px; display: flex; align-items: center; padding: 0 8px; font-size: 12px; font-weight: 500; color: color-mix(in oklab, var(--sidebar-foreground) 70%, transparent); }
.sidebar-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sidebar-menu-button {
  display: flex; width: 100%; align-items: center; gap: 8px; height: 32px; padding: 8px; border: 0; border-radius: calc(var(--radius) - 2px);
  background: transparent; text-align: left; font-size: 14px; cursor: pointer; overflow: hidden; white-space: nowrap;
}
.sidebar-menu-button:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.sidebar-menu-button[aria-current="page"] { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 500; }
.sidebar-menu-button svg { width: 16px; height: 16px; }
.sidebar-menu-button .ml-auto { margin-left: auto; }
.sidebar-menu-button.brand { height: auto; padding: 6px; font-size: 16px; font-weight: 600; }
.sidebar-menu-button.brand svg { width: 20px; height: 20px; color: var(--brand); }
.sidebar-menu-button.brand img { height: 34px; width: auto; display: block; margin: 2px 0; }
.sidebar-menu-button.brand .logo-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sidebar-menu-button.brand .logo-light { display: none; } :root:not([data-theme="light"]) .sidebar-menu-button.brand .logo-dark { display: block; } }
:root[data-theme="dark"] .sidebar-menu-button.brand .logo-light { display: none; }
:root[data-theme="dark"] .sidebar-menu-button.brand .logo-dark { display: block; }
.sidebar-menu-button[aria-current="page"] svg { color: var(--brand-deep); }
.sidebar-menu-button.brand:hover { background: transparent; }
.sidebar-menu-button.primary { background: var(--primary); color: var(--primary-foreground); min-width: 32px; }
.sidebar-menu-button.primary:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); color: var(--primary-foreground); }
.sidebar-menu-button.lg { height: 48px; padding: 8px; }
.sidebar-menu-button .avatar { width: 32px; height: 32px; border-radius: calc(var(--radius) - 2px); background: var(--muted); color: var(--foreground); display: grid; place-items: center; font-size: 12px; font-weight: 500; filter: grayscale(1); }
.sidebar-menu-button .grid { display: grid; flex: 1; text-align: left; line-height: 1.25; min-width: 0; }
.sidebar-menu-button .grid span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-row { display: flex; align-items: center; gap: 8px; }
.scope-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; margin-left: 8px; padding: 0 8px 0 10px; border: 1px solid var(--brand-border, var(--border)); border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; max-width: 40vw; }
.scope-chip span { overflow: hidden; text-overflow: ellipsis; }
.scope-chip svg { width: 14px; height: 14px; flex: none; }
.scope-chip:hover { filter: brightness(.97); }
.scope-note { display: flex; align-items: center; gap: 10px; margin: 0 var(--px, 16px); padding: 10px 12px; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); background: var(--muted); font-size: 13px; color: var(--muted-foreground); }
.scope-note svg { width: 16px; height: 16px; flex: none; color: var(--brand-deep); }
.scope-note b { color: var(--foreground); font-weight: 500; }
tr.scope-row > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
tr.scope-empty td { padding: 24px 16px; text-align: center; color: var(--muted-foreground); }
.practice-switch .avatar { filter: none; background: var(--brand-soft, var(--muted)); color: var(--brand-deep); }
.practice-switch .avatar svg { width: 16px; height: 16px; }
.practice-switch .grid { min-width: 0; text-align: left; line-height: 1.25; }
.practice-switch .truncate, #practiceMenu .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#practiceMenu .pm-dot { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
#practiceMenu .pm-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-foreground); opacity: .4; }
#practiceMenu .pm-dot[data-st]::before { opacity: 1; }
#practiceMenu .pm-dot[data-st="ok"]::before { background: var(--ok); }
#practiceMenu .pm-dot[data-st="warn"]::before { background: var(--warn); }
#practiceMenu .pm-dot[data-st="bad"]::before { background: var(--destructive); }
#practiceMenu a svg { color: var(--brand-deep); }
.sidebar-badge { margin-left: auto; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

.sidebar-inset {
  position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; background: var(--background);
  margin: 8px; margin-left: 0; border-radius: calc(var(--radius) + 2px); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* usage card (sidebar footer) */
.usage-card { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--sidebar-border); border-radius: calc(var(--radius) - 2px); background: var(--background); box-shadow: var(--shadow-xs); font-size: 12px; color: var(--muted-foreground); }
.usage-card:hover { border-color: var(--brand-border); }
.usage-head { display: flex; align-items: center; gap: 6px; color: var(--foreground); font-weight: 500; font-size: 13px; margin-bottom: 2px; }
.usage-head svg { width: 14px; height: 14px; color: var(--brand-deep); }
.usage-row { display: flex; justify-content: space-between; margin-top: 2px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; color: var(--brand-deep); }
.live i { position: relative; width: 8px; height: 8px; border-radius: 999px; background: var(--brand); flex: none; }
.live i::after { content: ""; position: absolute; inset: 0; border-radius: 999px; background: var(--brand); animation: pulse 1.8s cubic-bezier(0, 0, .2, 1) infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: .7 } 100% { transform: scale(2.6); opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .live i::after { animation: none; } }
.usage-row .tabular { color: var(--foreground); }
.meter { height: 5px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--destructive); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .usage-card { background: var(--sidebar-accent); } }
:root[data-theme="dark"] .usage-card { background: oklch(1 0 0 / 4%); }

/* desktop collapse */
@media (min-width: 768px) {
  .sidebar-wrapper.collapsed .sidebar { display: none; }
  .sidebar-wrapper.collapsed .sidebar-inset { margin-left: 8px; }
}

/* ---------- header ---------- */
.site-header { display: flex; height: var(--header-height); flex: none; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.site-header .inner { display: flex; width: 100%; align-items: center; gap: 4px; padding: 0 16px; }
.site-header h1 { font-size: 16px; font-weight: 500; }
.site-header .ml-auto { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.separator-v { width: 1px; height: 16px; background: var(--border); margin: 0 8px; flex: none; }
@media (min-width: 1024px) { .site-header .inner { padding: 0 24px; gap: 8px; } }

/* ---------- main content rhythm ---------- */
.main { display: flex; flex: 1; flex-direction: column; container-type: inline-size; container-name: main; }
.stack { display: flex; flex-direction: column; gap: 16px; padding: 16px 0; }
.px { padding-left: 16px; padding-right: 16px; }
@media (min-width: 768px) { .stack { gap: 24px; padding: 24px 0; } }
@media (min-width: 1024px) { .px { padding-left: 24px; padding-right: 24px; } }

/* ---------- card ---------- */
.card {
  display: flex; flex-direction: column; gap: 24px; padding: 24px 0; border-radius: calc(var(--radius) + 2px);
  border: 1px solid var(--border); background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow-xs); min-width: 0;
  container-type: inline-size; container-name: card;
}
.card-header { display: grid; grid-template-rows: auto auto; grid-template-columns: 1fr auto; align-items: start; gap: 6px 0; padding: 0 24px; }
.card-header > * { grid-column: 1; }
.card-title { font-weight: 600; line-height: 1; }
.card-description { color: var(--muted-foreground); font-size: 14px; }
.card-action { grid-column: 2; grid-row: 1 / span 2; justify-self: end; align-self: start; }
.card-content { padding: 0 24px; }
.card-footer { display: flex; align-items: center; padding: 0 24px; }
.card.flush { gap: 0; padding: 0; }
.card.flush .card-header { padding: 20px 24px 16px; }

/* section cards */
.section-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.section-cards .card { background: linear-gradient(to top, color-mix(in oklab, var(--brand) 7%, transparent), var(--card)); }
.section-cards .card-title { font-size: 24px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.section-cards .card-footer { flex-direction: column; align-items: flex-start; gap: 6px; font-size: 14px; }
.section-cards .card-footer .line { display: flex; gap: 8px; font-weight: 500; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@container main (min-width: 36rem) { .section-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container main (min-width: 64rem) { .section-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@container card (min-width: 250px) { .section-cards .card-title { font-size: 30px; } }
:root[data-theme="dark"] .section-cards .card { background: var(--card); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .section-cards .card { background: var(--card); } }

/* ---------- badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent; font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1;
}
.badge svg { width: 12px; height: 12px; }
.badge.outline { border-color: var(--border); color: var(--foreground); }
.badge.secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge.outline .ok { color: var(--ok); } .badge.outline .warn { color: var(--warn); } .badge.outline .bad { color: var(--destructive); }
.badge.outline .ok, .badge.outline .warn, .badge.outline .bad { fill: currentColor; }
.badge.text-muted { color: var(--muted-foreground); }
.badge.count { height: 20px; min-width: 20px; padding: 0 4px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); justify-content: center; }

/* ---------- button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent; background: var(--primary); color: var(--primary-foreground); font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; box-shadow: var(--shadow-xs);
}
.btn:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); }
.btn.outline { background: var(--background); color: var(--foreground); border-color: var(--border); }
.btn.outline:hover { background: var(--accent); color: var(--accent-foreground); }
.btn.ghost { background: transparent; color: var(--foreground); box-shadow: none; }
.btn.ghost:hover { background: var(--accent); }
.btn.destructive { background: var(--destructive); color: #fff; }
.btn.destructive:hover { background: color-mix(in oklab, var(--destructive) 90%, transparent); }
.btn.sm { height: 32px; padding: 0 12px; gap: 6px; }
.btn.icon { width: 36px; padding: 0; } .btn.icon.sm { width: 32px; height: 32px; } .btn.icon.xs { width: 28px; height: 28px; }
.btn.size-7 { width: 28px; height: 28px; padding: 0; }
.btn svg { width: 16px; height: 16px; pointer-events: none; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- inputs ---------- */
.input, .select {
  display: flex; height: 36px; width: 100%; min-width: 0; padding: 4px 12px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input); background: transparent; box-shadow: var(--shadow-xs); font-size: 14px; outline: none;
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus-visible, .select:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.input[aria-invalid="true"] { border-color: var(--destructive); box-shadow: 0 0 0 3px color-mix(in oklab, var(--destructive) 20%, transparent); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
.select.sm, .input.sm { height: 32px; }
.select.w-fit { width: auto; }
.textarea { min-height: 72px; padding: 8px 12px; resize: vertical; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--input); background: transparent; width: 100%; font-size: 14px; }
.label { font-size: 14px; font-weight: 500; line-height: 1; }
.field { display: grid; gap: 8px; }
.field .hint { font-size: 12px; color: var(--muted-foreground); }
.field .error { font-size: 12px; color: var(--destructive); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.checkbox { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.switch { position: relative; display: inline-flex; width: 32px; height: 18.4px; border-radius: 999px; border: 1px solid transparent; background: var(--input); cursor: pointer; padding: 0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 1px; left: 1px; width: 14.4px; height: 14.4px; border-radius: 999px; background: var(--background); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(14px); background: var(--primary-foreground); }
.switch[disabled] { opacity: .5; cursor: not-allowed; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .switch::after { background: var(--foreground); } }
:root[data-theme="dark"] .switch::after { background: var(--foreground); }

/* ---------- toggle group / tabs ---------- */
.toggle-group { display: inline-flex; border-radius: calc(var(--radius) - 2px); box-shadow: var(--shadow-xs); }
.toggle-group button { height: 32px; padding: 0 16px; border: 1px solid var(--input); background: transparent; font-size: 14px; font-weight: 500; cursor: pointer; margin-left: -1px; color: var(--foreground); }
.toggle-group button:first-child { border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px); margin-left: 0; }
.toggle-group button:last-child { border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0; }
.toggle-group button[aria-pressed="true"] { background: var(--accent); color: var(--accent-foreground); border-color: var(--brand-border); position: relative; z-index: 1; }
.toggle-group button:hover { background: var(--accent); }

.tabs-list { display: inline-flex; height: 36px; align-items: center; gap: 0; padding: 3px; border-radius: calc(var(--radius) - 2px); background: var(--muted); color: var(--muted-foreground); }
.tabs-list button { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 4px 8px; border: 1px solid transparent; border-radius: calc(var(--radius) - 4px); background: transparent; font-size: 14px; font-weight: 500; color: var(--muted-foreground); cursor: pointer; white-space: nowrap; }
.tabs-list button[aria-selected="true"] { background: var(--background); color: var(--brand-deep); box-shadow: var(--shadow-sm); }
.tabs-list .badge.count { font-size: 11px; }
.link-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.link-tabs a { display: inline-flex; align-items: center; height: 100%; padding: 4px 10px; border: 1px solid transparent; border-radius: calc(var(--radius) - 4px); font-size: 14px; font-weight: 500; color: var(--muted-foreground); white-space: nowrap; }
.link-tabs a:hover { color: var(--foreground); }
.link-tabs a[aria-selected="true"] { background: var(--background); color: var(--brand-deep); box-shadow: var(--shadow-sm); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .link-tabs a[aria-selected="true"] { background: var(--input); } }
:root[data-theme="dark"] .link-tabs a[aria-selected="true"] { background: var(--input); }
/* clickable cards (dashboard) */
a.card { text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.card:hover { border-color: var(--brand-border); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 15%, transparent); }
a.card .go { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 500; color: var(--brand-deep); }
a.card .go svg { width: 14px; height: 14px; }
tr[data-href] { cursor: pointer; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs-list button[aria-selected="true"] { background: var(--input); border-color: var(--input); } }
:root[data-theme="dark"] .tabs-list button[aria-selected="true"] { background: var(--input); border-color: var(--input); }
.tabs-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tabs-bar .actions { display: flex; align-items: center; gap: 8px; }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }

/* ---------- table ---------- */
.table-shell { overflow: hidden; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }
table { width: 100%; caption-side: bottom; font-size: 14px; border-collapse: collapse; }
thead { background: var(--muted); }
thead tr { border-bottom: 1px solid var(--border); }
th { height: 40px; padding: 0 8px; text-align: left; font-weight: 500; color: var(--foreground); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 16px; } th:last-child, td:last-child { padding-right: 16px; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }
td { padding: 8px; vertical-align: middle; white-space: nowrap; }
td.wrap { white-space: normal; }
td .sub, th .sub { display: block; font-size: 12px; color: var(--muted-foreground); font-weight: 400; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
tbody tr.muted-row { color: var(--muted-foreground); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; font-size: 14px; flex-wrap: wrap; }
.table-foot .pages { display: flex; align-items: center; gap: 32px; margin-left: auto; }
.table-foot .pager { display: flex; align-items: center; gap: 8px; }
.rows-per-page { display: none; align-items: center; gap: 8px; }
@media (min-width: 1024px) { .rows-per-page { display: flex; } }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status svg { width: 16px; height: 16px; }
.status .ok { color: var(--ok); fill: currentColor; } .status .bad { color: var(--destructive); fill: currentColor; } .status .warn { color: var(--warn); fill: currentColor; }
.status .spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { text-decoration: none; color: var(--brand-deep); }
.link:hover { text-decoration: underline; }

/* ---------- chart ---------- */
.chart { position: relative; height: 250px; width: 100%; }
.chart svg { width: 100%; height: 100%; overflow: visible; display: block; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--muted-foreground); font-size: 12px; font-family: var(--font-sans); }
.chart .area { fill: url(#fillArea); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; }
.chart .area2 { fill: url(#fillArea2); mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chart .area2 { mix-blend-mode: normal; } }
:root[data-theme="dark"] .chart .area2 { mix-blend-mode: normal; }
.chart .line2 { fill: none; stroke: var(--brand-deep); stroke-width: 2; opacity: .8; }
.chart-tip { position: absolute; pointer-events: none; display: none; min-width: 128px; padding: 6px 10px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--border); background: var(--background); box-shadow: var(--shadow-sm); font-size: 12px; z-index: 5; }
.chart-tip.show { display: grid; gap: 6px; }
.chart-tip .row { display: flex; align-items: center; gap: 8px; }
.chart-tip .sw { width: 10px; height: 10px; border-radius: 2px; background: var(--brand); }
.chart-tip .v { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; }
.chart-cursor { stroke: var(--border); stroke-dasharray: 3 3; }

/* ---------- dialog / sheet ---------- */
dialog { border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); background: var(--background); color: var(--foreground); padding: 24px; width: min(32rem, calc(100vw - 32px)); box-shadow: 0 20px 50px rgb(0 0 0 / .25); display: grid; gap: 16px; }
dialog:not([open]) { display: none; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog-header { display: grid; gap: 8px; }
.dialog-title { font-size: 18px; font-weight: 600; line-height: 1; }
.dialog-desc { color: var(--muted-foreground); font-size: 14px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-body { display: grid; gap: 16px; }
.code-box { font-family: var(--font-mono); font-size: 13px; padding: 10px 12px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--border); background: var(--muted); word-break: break-all; }

.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 40; display: none; }
.sheet-backdrop.open { display: block; }
.sheet { position: fixed; inset: 0 0 0 auto; width: min(32rem, 100vw); background: var(--background); border-left: 1px solid var(--border); z-index: 50; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; box-shadow: -10px 0 40px rgb(0 0 0 / .15); }
.sheet.open { transform: none; }
.sheet-header { display: grid; gap: 6px; padding: 16px; }
.sheet-title { font-weight: 600; } .sheet-desc { color: var(--muted-foreground); font-size: 14px; }
.sheet-body { flex: 1; overflow: auto; padding: 0 16px 16px; display: grid; gap: 20px; align-content: start; }
.sheet-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 16px; border-top: 1px solid var(--border); }
.sheet .close { position: absolute; top: 12px; right: 12px; }

/* ---------- dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; z-index: 30; min-width: 14rem; padding: 4px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--border); background: var(--popover); box-shadow: 0 8px 24px rgb(0 0 0 / .12); display: none; }
.dropdown-menu.open { display: block; }
.dropdown-menu.right { right: 0; top: calc(100% + 4px); }
.dropdown-menu.up { bottom: calc(100% + 4px); left: 0; }
.dropdown-menu button, .dropdown-menu a { display: flex; width: 100%; align-items: center; gap: 8px; padding: 6px 8px; border: 0; border-radius: calc(var(--radius) - 4px); background: transparent; font-size: 14px; text-align: left; cursor: pointer; }
.dropdown-menu button:hover, .dropdown-menu a:hover { background: var(--accent); }
.dropdown-menu button svg, .dropdown-menu a svg { width: 16px; height: 16px; color: var(--muted-foreground); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 4px -4px; }
.dropdown-menu .label { padding: 6px 8px; font-size: 14px; }
.dropdown-menu button.danger { color: var(--destructive); }

/* ---------- misc ---------- */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 60; padding: 12px 16px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--border); background: var(--popover); box-shadow: 0 8px 24px rgb(0 0 0 / .12); font-size: 14px; display: none; max-width: 22rem; gap: 2px; }
.toast.show { display: grid; }
.toast b { font-weight: 500; }
.toast span { color: var(--muted-foreground); font-size: 13px; }
.alert { display: grid; grid-template-columns: 16px 1fr; gap: 4px 12px; padding: 12px 16px; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); font-size: 14px; }
.alert svg { width: 16px; height: 16px; margin-top: 1px; }
.alert .alert-title { font-weight: 500; grid-column: 2; }
.alert .alert-desc { color: var(--muted-foreground); grid-column: 2; }
.alert.destructive { color: var(--destructive); }
.alert.destructive .alert-desc { color: color-mix(in oklab, var(--destructive) 85%, transparent); }
.kv { display: grid; grid-template-columns: 11rem 1fr; gap: 12px 24px; font-size: 14px; align-items: baseline; }
.kv dt { color: var(--muted-foreground); } .kv dd { margin: 0; min-width: 0; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dt { margin-top: 10px; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px; }
.chip .name { font-family: var(--font-sans); color: var(--muted-foreground); }
.chip.default { border-style: dashed; color: var(--muted-foreground); }
.chip { background: var(--brand-soft); border-color: var(--brand-border); }
.site-header { position: relative; }
.site-header::before { content: ""; position: absolute; left: 24px; right: 24px; top: -1px; height: 2px; background: var(--brand); border-radius: 0 0 2px 2px; opacity: 0; }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted-foreground); display: inline-flex; }
.chip button svg { width: 12px; height: 12px; }
.null { font-family: var(--font-mono); font-size: 12px; color: var(--warn); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@container main (min-width: 56rem) { .two-col { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }
.timeline { display: grid; }
.timeline .item { display: grid; grid-template-columns: 9.5rem 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline .item:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted-foreground); font-size: 13px; display: grid; gap: 2px; }
.timeline .when b { color: var(--foreground); font-weight: 500; }
.diff { display: inline-flex; gap: 6px; align-items: center; font-family: var(--font-mono); font-size: 12px; flex-wrap: wrap; }
.diff .old { color: var(--muted-foreground); text-decoration: line-through; }
.diff .new { font-weight: 500; }
.reason { color: var(--muted-foreground); margin-top: 4px; }
@media (max-width: 640px) { .timeline .item { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- responsive sidebar (offcanvas on small screens) ---------- */
.sidebar-trigger { display: inline-flex; }
.sidebar-close { display: none; position: absolute; top: 10px; right: 10px; }
.sidebar-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 45; display: none; }
.sidebar-overlay.open { display: block; }
.sidebar-header { position: relative; }
body.sidebar-open { overflow: hidden; }
@media (max-width: 767px) {
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; background: var(--sidebar); transform: translateX(-100%); transition: transform .2s ease; border-right: 1px solid var(--sidebar-border); }
  .sidebar.open { transform: none; }
  .sidebar-close { display: inline-flex; }
  .sidebar-menu-button.brand { padding-right: 40px; }
  .sidebar-inset { margin: 0; border-radius: 0; border: 0; box-shadow: none; }
  .sidebar-wrapper { background: var(--background); }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::after { transition: none !important; animation: none !important; } }
/* secondary (in-page) segmented tabs, smaller than the section tab bar */
.tabs-list.seg { height: 32px; padding: 2px; }
.tabs-list.seg button { font-size: 13px; padding: 2px 10px; }
