/* ==========================================================================
   Resonate Cloud Control Plane — "Studio" admin theme
   Inset-panel layout · warm neutrals · hairlines · tabular numerals
   ========================================================================== */

:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "PingFang SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  /* surfaces — warm stone neutrals */
  --app-bg: #efefec;
  --panel: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #f0f0ed;
  --hover: rgba(28, 25, 23, 0.04);
  --pressed: rgba(28, 25, 23, 0.07);
  --overlay: rgba(20, 18, 16, 0.36);

  --line: #e8e7e3;
  --line-strong: #d9d8d3;
  --line-subtle: #f1f0ed;

  --ink: #1c1b19;
  --ink-2: #57554f;
  --ink-3: #8a8880;
  --ink-4: #b5b3ac;
  --ink-inverse: #ffffff;

  /* brand (logo mid-stop) — used sparingly */
  --brand: #d6336c;
  --brand-soft: rgba(214, 51, 108, 0.08);
  --brand-grad: linear-gradient(135deg, #ff2d55 0%, #e03e7e 52%, #6366f1 100%);
  --focus-ring: 0 0 0 3px rgba(214, 51, 108, 0.16);
  --focus-border: rgba(214, 51, 108, 0.55);

  /* semantic */
  --green: #1f9d55;   --green-ink: #18794a;  --green-soft: rgba(31, 157, 85, 0.09);
  --amber: #d9860b;   --amber-ink: #a85d00;  --amber-soft: rgba(217, 134, 11, 0.1);
  --red: #dc3b3b;     --red-ink: #c02626;    --red-soft: rgba(220, 59, 59, 0.08);
  --blue: #2f6fdb;    --blue-ink: #2559b8;   --blue-soft: rgba(47, 111, 219, 0.08);
  --violet: #7c4ddb;  --violet-ink: #6537c4; --violet-soft: rgba(124, 77, 219, 0.08);
  --teal: #0f9488;    --teal-ink: #0b7469;   --teal-soft: rgba(15, 148, 136, 0.09);

  /* chart series (validated: blue / aqua / critical-red) */
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --series-err: #d03b3b;
  --chart-grid: #efeeea;

  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-card: 0 1px 2px rgba(28, 25, 23, 0.035);
  --shadow-panel: 0 1px 3px rgba(28, 25, 23, 0.05), 0 0 0 1px rgba(28, 25, 23, 0.03);
  --shadow-pop: 0 14px 36px -10px rgba(28, 25, 23, 0.2), 0 2px 6px rgba(28, 25, 23, 0.05);
  --shadow-modal: 0 30px 80px -16px rgba(28, 25, 23, 0.34), 0 4px 14px rgba(28, 25, 23, 0.06);

  --sidebar-w: 236px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #09090a;
  --panel: #111112;
  --surface: #161617;
  --surface-2: #1b1b1d;
  --surface-3: #222224;
  --hover: rgba(255, 255, 255, 0.045);
  --pressed: rgba(255, 255, 255, 0.08);
  --overlay: rgba(0, 0, 0, 0.6);

  --line: #252527;
  --line-strong: #333336;
  --line-subtle: #1e1e20;

  --ink: #ededec;
  --ink-2: #a9a9a4;
  --ink-3: #7d7d78;
  --ink-4: #56564f;
  --ink-inverse: #111112;

  --brand: #f0679a;
  --brand-soft: rgba(240, 103, 154, 0.12);
  --focus-ring: 0 0 0 3px rgba(240, 103, 154, 0.2);
  --focus-border: rgba(240, 103, 154, 0.6);

  --green: #3ecf7a;   --green-ink: #5ad98e;  --green-soft: rgba(62, 207, 122, 0.11);
  --amber: #f2a93b;   --amber-ink: #f5b95e;  --amber-soft: rgba(242, 169, 59, 0.12);
  --red: #f06a6a;     --red-ink: #ff8a8a;    --red-soft: rgba(240, 106, 106, 0.12);
  --blue: #5b93f0;    --blue-ink: #86aff5;   --blue-soft: rgba(91, 147, 240, 0.13);
  --violet: #a786f5;  --violet-ink: #bea6fa; --violet-soft: rgba(167, 134, 245, 0.13);
  --teal: #34d3c0;    --teal-ink: #6ee0d2;   --teal-soft: rgba(52, 211, 192, 0.11);

  --series-1: #3987e5;
  --series-2: #199e70;
  --series-err: #e66767;
  --chart-grid: #222224;

  --shadow-card: none;
  --shadow-panel: 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-pop: 0 18px 44px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-modal: 0 30px 90px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--app-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand-soft); }

.hidden { display: none !important; }
.muted { color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.tnum, .num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}
.id-text { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.token-cell { display: flex; align-items: center; gap: 2px; min-width: 0; }
.token-cell .id-text { overflow: hidden; text-overflow: ellipsis; max-width: 220px; margin-right: 4px; }
.token-cell .id-text.revealed { color: var(--ink-1); user-select: all; max-width: none; overflow: visible; }
.token-input { position: relative; display: flex; align-items: center; }
.token-input input { flex: 1; padding-right: 40px; }
.token-input .btn-icon { position: absolute; right: 4px; }

.ico {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px;
}
.ico-sm { width: 14px; height: 14px; vertical-align: -2px; }
.ico-xs { width: 12px; height: 12px; vertical-align: -1px; stroke-width: 1.9; }
.ico-lg { width: 22px; height: 22px; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   Unlock
   -------------------------------------------------------------------------- */
.unlock-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(500px 260px at 30% 10%, rgba(255, 45, 85, 0.08), transparent 70%),
    radial-gradient(500px 260px at 70% 0%, rgba(99, 102, 241, 0.08), transparent 70%),
    var(--app-bg);
}
.unlock-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-pop);
}
.unlock-card .brand-lockup { flex-direction: column; align-items: flex-start; gap: 18px; }
.unlock-card h1 { font-size: 20px; }
.unlock-card .muted { margin-top: 4px; font-size: 13px; }
.brand-icon svg { display: block; border-radius: 12px; }
.unlock-desc { color: var(--ink-2); font-size: 13px; line-height: 1.7; margin: 18px 0 20px; }
.unlock-form { display: flex; flex-direction: column; gap: 10px; }
.unlock-form .btn { width: 100%; }
.inline-error {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 14px; padding: 9px 12px;
  color: var(--red-ink); background: var(--red-soft);
  border-radius: var(--radius-md); font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   Shell: sidebar on app background, main content as an inset panel
   -------------------------------------------------------------------------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  height: 100vh;
  background: var(--app-bg);
  z-index: 40;
}
.sidebar-header { padding: 18px 18px 8px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-svg { border-radius: 7px; flex-shrink: 0; display: block; box-shadow: 0 2px 8px -2px rgba(224, 62, 126, 0.45); }
.brand-title { font-size: 14px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ver-tag { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }

.nav-scroll { flex: 1; overflow-y: auto; padding: 8px 10px 16px; display: flex; flex-direction: column; }
.nav-group-label { font-size: 11px; font-weight: 500; color: var(--ink-4); padding: 16px 10px 6px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative;
  width: 100%; height: 32px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  border: 0; background: transparent;
  color: var(--ink-2);
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer; text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item .nav-ico { display: inline-flex; color: var(--ink-3); transition: color 0.12s ease; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 0 0 1px var(--line);
}
html[data-theme="dark"] .nav-item.active { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
.nav-item.active .nav-ico { color: var(--brand); }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.sidebar-status {
  margin: auto 4px 0;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line-strong);
  font-size: 12px;
}
.sidebar-status-row { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.sidebar-status-meta { color: var(--ink-3); margin-top: 3px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.live-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.live-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid var(--green); opacity: 0; animation: pulse-ring 2.4s var(--ease) infinite;
}

.sidebar-footer { padding: 8px 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.identity-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-md); min-width: 0; }
.identity-meta { min-width: 0; flex: 1; }
.identity-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-2);
  font-weight: 600; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#whoami-avatar { background: var(--brand-grad); color: #fff; }
.identity-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.identity-role { margin-top: 3px; }
.footer-actions { display: flex; gap: 2px; }
.footer-actions .btn { flex: 1; justify-content: flex-start; color: var(--ink-3); }

.sidebar-backdrop { display: none; }

.main-area {
  flex: 1; min-width: 0;
  margin: 8px 8px 8px 0;
  height: calc(100vh - 16px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  border: 1px solid var(--line);
  position: relative;
}

/* Topbar (inside the panel) */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 52px;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: color-mix(in srgb, var(--panel) 84%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
.main-area.is-scrolled .topbar { border-bottom-color: var(--line); }
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; white-space: nowrap; }
.crumb-root { color: var(--ink-3); }
.crumb-sep { color: var(--ink-4); }
.crumb-current { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn.menu-btn { display: none; }

.auto-poll-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500;
  color: var(--ink-2);
  cursor: pointer; user-select: none;
  transition: background 0.12s ease;
}
.auto-poll-chip:hover { background: var(--hover); }
.auto-poll-chip input { position: absolute; opacity: 0; pointer-events: none; }
.auto-poll-chip:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.pulse-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex-shrink: 0; }
.auto-poll-chip:has(input:checked) .pulse-dot { background: var(--green); }
.auto-poll-chip:has(input:checked) .pulse-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid var(--green); opacity: 0; animation: pulse-ring 2s var(--ease) infinite;
}
.auto-poll-chip:not(:has(input:checked)) { color: var(--ink-3); }
@keyframes pulse-ring { 0% { transform: scale(0.6); opacity: 0.7; } 100% { transform: scale(1.9); opacity: 0; } }

.content-canvas { padding: 8px 32px 56px; max-width: 1360px; width: 100%; margin: 0 auto; }

.page-head { padding: 18px 0 24px; }
.page-title { font-family: var(--font-display); font-size: 24px; font-weight: 650; letter-spacing: -0.022em; line-height: 1.25; }
.page-subtitle { font-size: 13.5px; color: var(--ink-3); margin-top: 6px; }

.tab-panel { animation: panel-in 0.24s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Grid & cards
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.grid-hero { grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack > .card { margin-bottom: 0; }
.stack > .card-fill { flex: 1; display: flex; flex-direction: column; }
.card-fill > .table-wrap { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
  min-width: 0;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; margin-bottom: 16px;
}
.card-head > div:first-child { min-width: 0; }
.card-head h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head .muted { margin-top: 3px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 12px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.section-title .ico { color: var(--ink-3); }
.section-label {
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.eyebrow { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.count-tag {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11.5px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Hero card (traffic) */
.hero-card { padding: 22px 24px 18px; display: flex; flex-direction: column; position: relative; }
.hero-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 140px;
  background: radial-gradient(360px 120px at 0% 0%, rgba(42, 120, 214, 0.07), transparent 70%);
  pointer-events: none;
}
.hero-top { position: relative; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.hero-figure { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; }
.hero-number {
  font-family: var(--font-display);
  font-size: 44px; font-weight: 650;
  letter-spacing: -0.035em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.hero-unit { font-size: 15px; color: var(--ink-3); font-weight: 500; }
.hero-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* Stat list (traffic side) */
.stat-list-card { display: flex; flex-direction: column; }
.stat-list { display: flex; flex-direction: column; flex: 1; justify-content: space-between; }
.stat-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line-subtle); }
.stat-item:first-child { border-top: 0; padding-top: 2px; }
.stat-item:last-child { padding-bottom: 0; }
.stat-item-main { min-width: 0; }
.stat-item-lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat-item-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-item-val {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stat-item-val .unit { font-size: 12px; color: var(--ink-3); font-weight: 500; margin-left: 2px; letter-spacing: 0; }
.stat-item.is-alert .stat-item-val { color: var(--red-ink); }
.kpi-dot { width: 6px; height: 6px; border-radius: 2px; background: var(--accent-color, var(--ink-4)); flex-shrink: 0; }

/* Stat row (users / audit) — borderless hero figures */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
  padding: 4px 0;
}
.stat-row:empty { display: none; }
.stat-cell { padding: 2px 24px; border-left: 1px solid var(--line); min-width: 0; }
.stat-cell:first-child { padding-left: 2px; border-left: 0; }
.stat-cell-lbl { font-size: 12.5px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.stat-cell-val {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15;
  margin-top: 6px; font-variant-numeric: tabular-nums;
}
.stat-cell-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-cell.is-alert .stat-cell-val { color: var(--red-ink); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 1px rgba(28, 25, 23, 0.03);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, opacity 0.12s, transform 0.06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-sm); gap: 5px; }
.btn-lg { height: 40px; padding: 0 16px; font-size: 13.5px; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--ink-inverse); box-shadow: 0 1px 2px rgba(28, 25, 23, 0.18); }
.btn-primary:hover { background: var(--ink); opacity: 0.86; }
.btn-secondary { background: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-danger { color: var(--red-ink); }
.btn-ghost.btn-danger { color: var(--ink-3); }
.btn-danger:hover, .btn-ghost.btn-danger:hover { background: var(--red-soft); border-color: transparent; color: var(--red-ink); }
.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .ico { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-close {
  border: 0; background: transparent; color: var(--ink-3);
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.icon-close:hover { background: var(--hover); color: var(--ink); }
.icon-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
input[type="text"], input[type="password"], input[type="url"], input[type="email"],
input[type="number"], input[type="search"], .select-ctrl {
  width: 100%; height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s;
}
input::placeholder { color: var(--ink-4); }
input:hover, .select-ctrl:hover { border-color: color-mix(in srgb, var(--line-strong) 55%, var(--ink-4)); }
input:focus, .select-ctrl:focus { border-color: var(--focus-border); box-shadow: var(--focus-ring); }
input:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input.mono { font-family: var(--font-mono); font-size: 12px; }

.select-ctrl {
  appearance: none; -webkit-appearance: none;
  padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8880' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
  text-overflow: ellipsis;
}
.select-ctrl.select-inline { width: auto; min-width: 120px; max-width: 300px; height: 32px; }

.search-field { position: relative; display: inline-flex; align-items: center; width: 260px; max-width: 100%; }
.search-field .ico { position: absolute; left: 11px; color: var(--ink-4); pointer-events: none; }
.search-field .search-input { padding-left: 32px; width: 100%; height: 32px; background: var(--surface-2); border-color: transparent; }
.search-field .search-input:hover { border-color: var(--line); }
.search-field .search-input:focus { background: var(--surface); border-color: var(--focus-border); }

label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; margin: 0 0 6px; }
label .opt { color: var(--ink-4); font-weight: 400; margin-left: 4px; font-size: 11.5px; }
.inline-lbl { display: inline-block; margin: 0 8px 0 0; font-size: 12px; color: var(--ink-3); }
.field { display: flex; flex-direction: column; min-width: 0; }
.field-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-narrow { max-width: none; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-row-2 > div { min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.form-foot { padding-top: 6px; flex-wrap: wrap; }
.form-section-title {
  font-size: 11.5px; font-weight: 600; color: var(--ink-3);
  letter-spacing: 0.02em;
  margin-top: 2px; margin-bottom: -4px;
}
.pane-intro { font-size: 12.5px; color: var(--ink-3); margin: -4px 0 18px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-weight: 400; }
.checkbox-row input { width: 15px; height: 15px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.row-gap { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }

/* Segmented */
.segmented {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--radius-md);
  padding: 3px; gap: 2px;
  max-width: 100%;
  overflow-x: auto; scrollbar-width: none;
  flex-shrink: 0;
}
.segmented::-webkit-scrollbar { display: none; }
.seg-btn {
  border: 0; background: transparent;
  color: var(--ink-3);
  font-size: 12px; font-weight: 500;
  height: 26px; padding: 0 11px;
  border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color 0.12s, background 0.12s, box-shadow 0.12s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(28, 25, 23, 0.08), 0 0 0 0.5px rgba(28, 25, 23, 0.06); }
html[data-theme="dark"] .seg-btn.active { background: var(--line-strong); box-shadow: none; }
.seg-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.seg-count { font-variant-numeric: tabular-nums; color: var(--ink-4); font-size: 11px; }
.seg-btn.active .seg-count { color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Pills — soft, borderless; status shown as dot + text
   -------------------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.pill .ico { width: 11px; height: 11px; stroke-width: 2.1; vertical-align: 0; }
.pill.pill-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-round { border-radius: 999px; }
.pill-neutral { background: var(--surface-3); color: var(--ink-2); }
.pill-green { background: var(--green-soft); color: var(--green-ink); }
.pill-amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill-coral, .pill-red { background: var(--red-soft); color: var(--red-ink); }
.pill-indigo { background: var(--blue-soft); color: var(--blue-ink); }
.pill-purple { background: var(--violet-soft); color: var(--violet-ink); }
.pill-blue { background: var(--blue-soft); color: var(--blue-ink); }
.pill-teal { background: var(--teal-soft); color: var(--teal-ink); }
.pill-outline { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.pill-mono { font-family: var(--font-mono); font-size: 10.5px; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--st, var(--ink-4)); flex-shrink: 0; }
.status.ok { --st: var(--green); }
.status.warn { --st: var(--amber); }
.status.bad { --st: var(--red); }
.status.off { --st: var(--ink-4); color: var(--ink-3); }
.status.info { --st: var(--blue); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--ink-4); }

.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.cap-text { color: var(--ink-2); font-size: 12px; line-height: 1.6; }
.cap-text .sep { color: var(--ink-4); margin: 0 5px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -22px -22px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-subtle);
  font-size: 12.5px;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
th {
  position: sticky; top: 0;
  background: var(--surface);
  color: var(--ink-3);
  font-weight: 500; font-size: 12px;
  white-space: nowrap;
  height: 36px; padding-top: 0; padding-bottom: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
th.num, td.num { text-align: right; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable-row { cursor: pointer; }
td .muted { font-size: 11.5px; margin-top: 2px; }
td .cell-title, td.nowrap, td.muted, td.num { white-space: nowrap; }
.table-scroll { max-height: 620px; overflow: auto; }

.table-plain th { border-top: 0; height: 30px; font-size: 11.5px; }
.table-plain td { padding-top: 9px; padding-bottom: 9px; }

.sticky-actions td:last-child, .sticky-actions th:last-child { position: sticky; right: 0; background: var(--surface); }
.sticky-actions th:last-child { z-index: 2; }
.sticky-actions tbody tr:hover td:last-child { background: var(--surface-2); }

.cell-user { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-user .identity-avatar { width: 30px; height: 30px; font-size: 12px; }
.cell-title { font-weight: 500; color: var(--ink); }
.cell-actions { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.cell-path { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 300px; }
.cell-path .path { font-family: var(--font-mono); font-size: 12px; color: var(--ink); }
.method { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--ink-3); width: 36px; flex-shrink: 0; }
.method-POST { color: var(--blue-ink); }
.method-PATCH, .method-PUT { color: var(--amber-ink); }
.method-DELETE { color: var(--red-ink); }
.status-code { font-family: var(--font-mono); font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.status-code::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--st, var(--green)); }
.status-code.c3 { --st: var(--blue); }
.status-code.c4 { --st: var(--amber); color: var(--amber-ink); }
.status-code.c5 { --st: var(--red); color: var(--red-ink); }
.latency-slow { color: var(--amber-ink); font-weight: 500; }
.latency-bad { color: var(--red-ink); font-weight: 600; }
.rank { width: 18px; color: var(--ink-4); font-size: 12px; font-variant-numeric: tabular-nums; display: inline-block; flex-shrink: 0; }

.meter { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.meter-track { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--ink-2); transition: width 0.4s var(--ease); }
.meter-fill.warn { background: var(--amber); }
.meter-fill.crit { background: var(--red); }
.meter-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.meter-label strong { color: var(--ink); font-weight: 500; }

/* --------------------------------------------------------------------------
   Chart
   -------------------------------------------------------------------------- */
.chart-card { display: flex; flex-direction: column; }
.chart-summary { position: relative; display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 18px 0 6px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.legend-item strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.swatch-area { background: var(--series-1); }
.swatch-line { height: 2px; border-radius: 2px; width: 12px; background: repeating-linear-gradient(90deg, var(--series-2) 0 4px, transparent 4px 6px); }
.swatch-bar { background: var(--series-err); width: 6px; }

.chart-stage { position: relative; min-height: 240px; width: 100%; flex: 1; display: flex; align-items: flex-end; }
.traffic-svg { width: 100%; height: 240px; display: block; overflow: visible; user-select: none; }
.traffic-svg text { font-family: var(--font-sans); font-variant-numeric: tabular-nums; fill: var(--ink-4); font-size: 10.5px; }
.chart-crosshair { stroke: var(--ink-4); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-tooltip {
  position: absolute; top: 0;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 12px; line-height: 1.55;
  box-shadow: var(--shadow-pop);
  white-space: nowrap;
  z-index: 5; min-width: 184px;
}
.tip-title { font-size: 11.5px; color: var(--ink-3); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row .tip-lbl { color: var(--ink-2); flex: 1; }
.tip-row .tip-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-sep { height: 1px; background: var(--line); margin: 6px 0; }

.breakdown-stack { display: flex; flex-direction: column; gap: 22px; }
.status-hero { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.status-hero .v { font-family: var(--font-display); font-size: 28px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.status-hero .k { font-size: 12px; color: var(--ink-3); }
.stacked-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface-3); }
.stacked-bar > span { height: 100%; min-width: 3px; }
.seg-2xx { background: var(--green); }
.seg-302 { background: var(--blue); }
.seg-4xx { background: var(--amber); }
.seg-5xx { background: var(--red); }
.status-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.status-legend-item .k { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); }
.status-legend-item .k .swatch { width: 7px; height: 7px; border-radius: 50%; }
.status-legend-item .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bar-meta .bar-name { color: var(--ink); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.bar-meta strong { color: var(--ink); font-weight: 600; }
.bar-track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--series-1); transition: width 0.4s var(--ease); }

/* --------------------------------------------------------------------------
   Music accounts (hero)
   -------------------------------------------------------------------------- */
/* One platform per row: the account pool table needs the full width. */
.hero-accounts-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.pool-table .id-text { max-width: 260px; }
.music-hero-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 20px;
  min-width: 0; overflow: hidden;
}
.music-hero-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 120px;
  background: radial-gradient(380px 120px at 0% 0%, var(--brand-tint), transparent 72%);
  pointer-events: none;
}
.music-hero-card.qq { --brand-c: #1fb46a; --brand-tint: rgba(31, 180, 106, 0.1); }
.music-hero-card.netease { --brand-c: #e3262e; --brand-tint: rgba(227, 38, 46, 0.08); }
.music-hero-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.music-hero-id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.music-hero-id h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.music-hero-id .muted { margin-top: 2px; }
.music-brand-badge {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #fff;
  background: var(--brand-c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 6px 14px -6px var(--brand-c);
}
.music-brand-badge .ico { width: 22px; height: 22px; stroke-width: 1.8; }
.music-hero-facts { position: relative; display: flex; flex-wrap: wrap; gap: 8px 26px; }
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact .k { font-size: 11.5px; color: var(--ink-3); }
.music-hero-form { position: relative; }
.pool-panel { position: relative; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.pool-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.pool-strategy { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.pool-panel .table-wrap { margin: 0; }
.pool-strategy .pool-select { width: auto; height: 30px; font-size: 12px; padding: 0 8px; }
.pool-table { width: 100%; font-size: 12px; }
.pool-table td, .pool-table th { padding: 6px 6px; vertical-align: middle; }
.pool-table .id-text { max-width: 180px; }
.pool-table input.pool-num { width: 42px; height: 28px; font-size: 12px; padding: 2px 4px; text-align: center; font-family: var(--font-mono); }
.pool-table input.pool-num-wide { width: 56px; }
.pool-table .pool-vip { font-size: 10px; padding: 0 5px; margin-left: 4px; vertical-align: 1px; }
.pool-table td:last-child { width: 1%; white-space: nowrap; }
.pool-table .cell-actions { gap: 4px; flex-wrap: nowrap; }
.pool-add { display: flex; gap: 8px; flex-wrap: wrap; }
.pool-add[hidden] { display: none; }
.pool-add input { flex: 1; min-width: 140px; font-size: 12px; }
.pool-add input[type="url"] { font-family: var(--font-mono); flex: 2; }
.pool-empty { font-size: 12px; margin: 0; }
.input-group { display: flex; align-items: stretch; gap: 8px; }
.input-group input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; }

.source-form-pane { animation: panel-in 0.2s var(--ease); }

/* --------------------------------------------------------------------------
   Now playing / handoff
   -------------------------------------------------------------------------- */
.handoff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; margin-bottom: 24px; }
.np-card {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  padding: 18px 20px;
  min-width: 0;
  box-shadow: var(--shadow-card);
  isolation: isolate;
}
.np-bg {
  position: absolute; inset: -40px;
  background-size: cover; background-position: center;
  filter: blur(42px) saturate(1.5);
  opacity: 0.32;
  z-index: -1;
  transform: scale(1.1);
}
html[data-theme="dark"] .np-bg { opacity: 0.38; }
.np-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--surface) 70%, transparent) 100%);
}
.np-device { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.np-device-name { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--ink-2); font-weight: 500; }
.np-device-name .ico { color: var(--ink-3); }
.np-main { display: flex; align-items: center; gap: 16px; margin: 16px 0 18px; min-width: 0; }
.np-cover {
  width: 84px; height: 84px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--surface-3);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex; align-items: center; justify-content: center; color: var(--ink-4);
}
.np-cover .ico { width: 26px; height: 26px; }
.np-title { font-family: var(--font-display); font-size: 19px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; }
.np-artist { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.np-tags { display: flex; gap: 6px; margin-top: 9px; align-items: center; flex-wrap: wrap; }
.np-tags .np-note { font-size: 12px; }
.np-progress { height: 4px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; }
.np-progress > div { height: 100%; background: var(--ink); border-radius: 99px; }
.np-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.eq-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.eq-bars i { width: 2px; background: currentColor; border-radius: 1px; animation: eq 1s ease-in-out infinite; }
.eq-bars i:nth-child(2) { animation-delay: -0.4s; }
.eq-bars i:nth-child(3) { animation-delay: -0.7s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 10px; } }
.handoff-empty { border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); grid-column: 1 / -1; }

.art-thumb {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4);
}
.art-thumb.sm { width: 38px; height: 38px; }
.art-thumb .ico { width: 16px; height: 16px; }

.library-toolbar { margin-bottom: 0; padding-bottom: 16px; }
.track-grid-list { display: flex; flex-direction: column; margin: 0 -22px -22px; border-top: 1px solid var(--line); }
.lib-track-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line-subtle);
  min-width: 0;
  transition: background 0.1s ease;
}
.lib-track-row:last-child { border-bottom: 0; }
.lib-track-row:hover { background: var(--surface-2); }
.lib-track-main { flex: 1; min-width: 0; }
.lib-track-index { width: 18px; text-align: right; color: var(--ink-4); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.lib-track-dur { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.lib-row-actions { opacity: 0; transition: opacity 0.12s; }
.lib-track-row:hover .lib-row-actions, details.playlist-row > summary:hover .lib-row-actions, .lib-row-actions:focus-within { opacity: 1; }

details.playlist-row { border-bottom: 1px solid var(--line-subtle); }
details.playlist-row:last-child { border-bottom: 0; }
details.playlist-row > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 22px;
  transition: background 0.1s ease;
}
details.playlist-row > summary::-webkit-details-marker { display: none; }
details.playlist-row > summary:hover { background: var(--surface-2); }
details.playlist-row .chev { color: var(--ink-4); transition: transform 0.16s var(--ease); }
details.playlist-row[open] .chev { transform: rotate(90deg); }
.playlist-tracks { padding: 0 22px 12px 86px; display: flex; flex-direction: column; }
.playlist-track { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line-subtle); font-size: 12.5px; min-width: 0; }

/* --------------------------------------------------------------------------
   RBAC
   -------------------------------------------------------------------------- */
.rbac-matrix { margin: 0 -22px -22px; overflow-x: auto; }
.matrix-table th { vertical-align: bottom; padding-top: 14px; padding-bottom: 14px; height: auto; white-space: normal; }
.matrix-table th.role-col { text-align: center; min-width: 160px; }
.matrix-table .role-head { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.matrix-table .role-head .id-text { font-size: 11px; }
.matrix-table .role-desc { font-weight: 400; color: var(--ink-3); font-size: 11.5px; line-height: 1.5; max-width: 210px; text-align: center; }
.matrix-table td.cap-cell { text-align: center; }
.matrix-table .cap-name { display: flex; flex-direction: column; gap: 1px; }
.matrix-table tfoot td { font-size: 12px; color: var(--ink-3); text-align: center; border-top: 1px solid var(--line); border-bottom: 0; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.matrix-table tfoot td:first-child { text-align: left; }
.cap-yes { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--green-soft); color: var(--green-ink); }
.cap-yes .ico { width: 12px; height: 12px; stroke-width: 2.6; }
.cap-no { display: inline-block; width: 10px; height: 1.5px; background: var(--line-strong); border-radius: 2px; vertical-align: middle; }
.cap-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }

.inspect-result { margin-top: 16px; border-radius: var(--radius-md); border: 1px solid var(--line); overflow: hidden; }
.inspect-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.inspect-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.inspect-placeholder {
  margin-top: 16px; padding: 40px 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--ink-3); font-size: 12.5px;
}
.inspect-placeholder .ico { width: 22px; height: 22px; color: var(--ink-4); }
.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.kv-grid .k { font-size: 11.5px; color: var(--ink-3); }
.kv-grid .v { font-size: 13px; font-weight: 500; margin-top: 3px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in 0.16s ease;
}
.modal-card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px);
  animation: modal-in 0.22s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 920px; }
.sources-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sources-note { font-size: 12px; margin: 10px 0 12px; }
.source-btn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; background: none; border: 0; padding: 2px 4px; margin: -2px -4px; border-radius: 6px; cursor: pointer; color: inherit; font: inherit; text-align: left; }
.source-btn:hover { background: var(--line); }
.source-btn .bad { color: var(--red, #dc2626); font-weight: 600; }
.client-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.modal-head { padding: 18px 16px 6px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.modal-head h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.modal-body { padding: 14px 24px 24px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  margin: 8px -24px -24px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky; bottom: -24px;
}

.qr-modal-body .row-gap { flex-wrap: nowrap; }
.qr-modal-body .row-gap input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; }
.qr-stage {
  margin: 20px auto 14px;
  width: 232px; height: 232px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 14px; color: #6e6e78;
}
.qr-stage img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-stage .empty-hint { padding: 0; color: #6e6e78; }
.qr-result { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; color: #18794a; }
.qr-result .ico { width: 38px; height: 38px; padding: 9px; border-radius: 50%; background: rgba(31, 157, 85, 0.1); stroke-width: 2.2; }
.qr-error { color: #c02626; font-size: 12.5px; text-align: center; line-height: 1.5; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-status-text { font-size: 12.5px; color: var(--ink-2); margin: 0; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; }
.qr-status-text::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--qr-dot, var(--amber)); flex-shrink: 0; }

.token-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font-family: var(--font-mono); font-size: 12.5px;
  word-break: break-all; color: var(--ink);
  user-select: all;
}
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  font-size: 12.5px; line-height: 1.65;
  background: var(--amber-soft);
  color: var(--ink-2);
}
.callout .ico { color: var(--amber-ink); margin-top: 2px; }

.audit-detail-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.audit-detail-summary { font-size: 15px; font-weight: 500; line-height: 1.55; letter-spacing: -0.01em; }
.code-pre {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-2);
  overflow: auto; line-height: 1.65;
  max-height: 42vh;
}

.empty-hint { color: var(--ink-3); text-align: center; padding: 32px 12px; font-size: 12.5px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 16px; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.empty-state .ico { width: 22px; height: 22px; color: var(--ink-4); margin-bottom: 4px; }
.empty-state .ttl { font-size: 13px; font-weight: 500; color: var(--ink-2); }

.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--radius-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.4s infinite; transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80;
  transform: translate(-50%, 8px);
  opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ink-inverse);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  box-shadow: var(--shadow-pop);
  max-width: min(440px, calc(100vw - 32px));
  display: flex !important; align-items: center; gap: 8px;
  transition: opacity 0.18s ease, transform 0.18s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .ico { flex-shrink: 0; color: #4ade80; }
html[data-theme="dark"] .toast .ico { color: #18794a; }
.toast.is-error .ico { color: #ff8a8a; }
html[data-theme="dark"] .toast.is-error .ico { color: #c02626; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child { grid-column: 1 / -1; }
  .grid-1-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1100px) {
  .grid-hero, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stat-list { flex-direction: row; flex-wrap: wrap; gap: 14px 0; }
  .stat-item { flex: 1 1 180px; border-top: 0; padding: 0 16px 0 0; flex-direction: column; align-items: flex-start; gap: 4px; }
  .stat-item:first-child { padding-top: 0; }
  .stat-item .stat-item-val { order: -1; }
}

@media (max-width: 960px) {
  .app-shell { height: auto; overflow: visible; display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100%;
    transform: translateX(-100%);
    transition: transform 0.26s var(--ease);
    background: var(--panel);
    border-right: 1px solid var(--line);
  }
  .app-shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-modal); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: var(--overlay);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .app-shell.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .btn.menu-btn { display: inline-flex; margin-left: -6px; }
  .main-area { margin: 0; height: auto; min-height: 100vh; overflow: visible; border-radius: 0; border: 0; box-shadow: none; }
  .topbar { padding: 0 16px; border-bottom-color: var(--line); }
  .content-canvas { padding: 4px 16px 48px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
  .stat-cell:nth-child(3) { padding-left: 2px; border-left: 0; }
  .hide-md { display: none; }
}

@media (max-width: 720px) {
  .page-head { padding: 14px 0 18px; }
  .page-title { font-size: 21px; }
  .page-subtitle { font-size: 12.5px; }
  .crumb-root, .crumb-sep, #auth-pill, .topbar-actions .btn-label, .auto-poll-chip .chip-label { display: none; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn { width: 32px; padding: 0; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px 16px 18px; }
  .hero-card { padding: 18px 16px 14px; }
  .hero-number { font-size: 36px; }
  .table-wrap, .track-grid-list, .rbac-matrix { margin: 0 -16px -18px; }
  th:first-child, td:first-child { padding-left: 16px; }
  th:last-child, td:last-child { padding-right: 16px; }
  .table-wrap > table { min-width: 520px; }
  .table-plain > table { min-width: 0; }
  .stat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
  .stat-item { padding: 0; }
  .lib-track-row, details.playlist-row > summary { padding-left: 16px; padding-right: 16px; }
  .playlist-tracks { padding-left: 16px; padding-right: 16px; }
  .form-row-2 { grid-template-columns: minmax(0, 1fr); }
  .search-field { width: 100%; }
  .card-head > .row-gap { width: 100%; }
  .select-ctrl.select-inline { flex: 1; max-width: none; }
  .hero-accounts-grid, .handoff-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-cell { padding: 2px 14px; }
  .stat-cell-val { font-size: 26px; }
  .traffic-svg { height: 200px; }
  .chart-stage { min-height: 200px; }
  .status-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .np-cover { width: 68px; height: 68px; }
  .np-title { font-size: 17px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-card { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 92vh; }
  .modal-sm, .modal-md { max-width: none; }
  .lib-row-actions { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   Motion & interaction layer
   ========================================================================== */

/* Card hover: hairline strengthens, soft lift for navigable cards */
.card, .music-hero-card, .np-card {
  transition: border-color 0.2s ease, box-shadow 0.28s ease, transform 0.28s var(--ease);
}
.card:hover { border-color: var(--line-strong); }
html:not([data-theme="dark"]) .card:hover { box-shadow: 0 10px 28px -20px rgba(28, 25, 23, 0.28); }

.card-link { cursor: pointer; outline: none; }
.card-link:hover, .card-link:focus-visible,
.music-hero-card:hover, .np-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 36px -22px rgba(28, 25, 23, 0.34), 0 2px 6px -2px rgba(28, 25, 23, 0.06);
}
html[data-theme="dark"] .card-link:hover, html[data-theme="dark"] .card-link:focus-visible,
html[data-theme="dark"] .music-hero-card:hover, html[data-theme="dark"] .np-card:hover {
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.card-link:focus-visible { box-shadow: var(--focus-ring); }
.card-link:active { transform: translateY(0); }

.music-brand-badge { transition: transform 0.35s var(--ease); }
.music-hero-card:hover .music-brand-badge { transform: rotate(-6deg) scale(1.06); }
.np-cover { transition: transform 0.4s var(--ease), box-shadow 0.4s ease; }
.np-card:hover .np-cover { transform: scale(1.04); box-shadow: 0 16px 30px -12px rgba(0, 0, 0, 0.5); }
.np-bg { transition: opacity 0.4s ease, transform 0.8s var(--ease); }
.np-card:hover .np-bg { opacity: 0.45; transform: scale(1.18); }

.stat-item { transition: background 0.15s ease; border-radius: var(--radius-sm); }
.stat-item-val { transition: transform 0.25s var(--ease); }
.stat-item:hover .stat-item-val { transform: translateX(-2px); }

.nav-item .nav-ico .ico { transition: transform 0.2s var(--ease); }
.nav-item:hover .nav-ico .ico { transform: scale(1.08); }

.btn-primary:hover { box-shadow: 0 6px 16px -8px rgba(28, 25, 23, 0.5); }

/* Entrance choreography (tab switch / first load only — not on silent polling) */
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.995); } to { opacity: 1; transform: none; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.is-entering .card, .is-entering .music-hero-card, .is-entering .np-card, .is-entering .stat-cell, .pop-in {
  animation: card-in 0.55s var(--ease) both;
}
.is-entering .bar-fill, .is-entering .meter-fill, .is-entering .np-progress > div, .is-entering .stacked-bar > span {
  transform-origin: left center;
  animation: grow-x 0.9s var(--ease) both;
  animation-delay: 0.15s;
}

/* Chart polish */
.chart-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; stroke-dasharray: 3 5; }
.chart-base { stroke: var(--line-strong); stroke-width: 1; }
.chart-band { fill: color-mix(in srgb, var(--ink) 3.2%, transparent); transition: x 0.08s linear; }
.chart-line { filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--line-color, var(--series-1)) 32%, transparent)); }
.chart-pulse { transform-box: fill-box; transform-origin: center; animation: chart-pulse 2.2s ease-out infinite; pointer-events: none; }
@keyframes chart-pulse { 0% { transform: scale(1); opacity: 0.55; } 100% { transform: scale(3.4); opacity: 0; } }
.chart-tooltip { transition: left 0.1s var(--ease), top 0.1s var(--ease); }
.swatch-lat { background: var(--violet); }
.hero-card::before { transition: opacity 0.4s ease; }
.hero-card:hover::before { opacity: 1.6; }

/* Overview quick cards */
.overview-cards:empty { display: none; }
.ov-card { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 14px; min-height: 138px; }
.ov-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--ink); }
.ov-meta { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.ov-arrow { color: var(--ink-4); transition: transform 0.25s var(--ease), color 0.2s; }
.card-link:hover .ov-arrow { transform: translateX(3px); color: var(--ink-2); }
.ov-rows { display: flex; flex-direction: column; gap: 11px; }
.ov-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ov-brand { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.ov-brand.qq { background: #1fb46a; }
.ov-brand.netease { background: #e3262e; }
.ov-brand .ico { width: 12px; height: 12px; stroke-width: 2; }
.ov-name { flex: 1; font-weight: 500; min-width: 0; }
.ov-np { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ov-np .art-thumb { width: 46px; height: 46px; border-radius: 9px; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.45); }
.ov-eq { color: var(--green); display: inline-flex; }
.ov-empty { color: var(--ink-3); font-size: 12.5px; margin: auto 0; }
.ov-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: auto; }
.ov-num { font-family: var(--font-display); font-size: 26px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ov-num.is-alert { color: var(--red-ink); }

@media (max-width: 720px) {
  .chart-controls { width: 100%; }
  .chart-controls .segmented { flex: 1; }
  .chart-controls .seg-btn { flex: 1; justify-content: center; }
}

/* ==========================================================================
   302 cache page
   (validated palette: HIT aqua / MISS blue / BYPASS orange — slots 3·1·2)
   ========================================================================== */
:root { --c-hit: #1baf7a; --c-miss: #2a78d6; --c-bypass: #eb6834; }
html[data-theme="dark"] { --c-hit: #199e70; --c-miss: #3987e5; --c-bypass: #d95926; }
span.seg-hit, .swatch.seg-hit { background: var(--c-hit); }
span.seg-miss, .swatch.seg-miss { background: var(--c-miss); }
span.seg-bypass, .swatch.seg-bypass { background: var(--c-bypass); }
rect.seg-hit { fill: var(--c-hit); }
rect.seg-miss { fill: var(--c-miss); }
rect.seg-bypass { fill: var(--c-bypass); }

.cache-hero::before { background: radial-gradient(360px 120px at 0% 0%, color-mix(in srgb, var(--c-hit) 9%, transparent), transparent 70%); }
.cache-composition { position: relative; margin: 20px 0 22px; }
.cache-stack { height: 10px; }
.cache-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.cache-legend-item .k { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.cache-legend-item .k .mono { font-size: 11px; color: var(--ink-3); }
.cache-legend-item .k .swatch { width: 8px; height: 8px; border-radius: 2px; }
.cache-legend-item .v { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; font-family: var(--font-display); font-size: 22px; font-weight: 650; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.cache-legend-item .v .pct { font-family: var(--font-sans); font-size: 12px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.cache-legend-item .d { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.cache-trend-label { margin-bottom: 4px; }
.cache-chart { min-height: 196px; }
.cache-svg { height: 196px; }
.bars-reveal > g { transform-box: fill-box; transform-origin: 50% 100%; animation: bar-grow 0.6s var(--ease) both; }
@keyframes bar-grow { from { transform: scaleY(0); opacity: 0.3; } to { transform: scaleY(1); opacity: 1; } }

.cache-sources-label { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-subtle); }
.cache-sources { display: flex; flex-direction: column; gap: 2px; }
.cache-source-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; min-width: 0; }
.cache-source-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.cache-source-meta { font-size: 12px; color: var(--ink-3); }

.ttl-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.ttl-cell .meter-track { flex: 1; min-width: 70px; }
.ttl-fill { background: var(--c-hit); transition: width 1s linear; }
.ttl-fill.warn { background: var(--amber); }
.ttl-text { font-size: 12px; color: var(--ink-2); width: 56px; text-align: right; }
tr.is-expired td { opacity: 0.45; }
tr.is-expired .ttl-text { color: var(--red-ink); }

@media (max-width: 720px) {
  .cache-legend { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cache-legend-item .d { display: none; }
}
#cache-facts { flex: 0 0 auto; justify-content: flex-start; }
.cache-sources-label { margin-top: auto; }
@media (max-width: 1100px) { .cache-sources-label { margin-top: 18px; } }

/* ==========================================================================
   Traffic volume page
   (audio measured blue / audio estimated hatched blue / API out aqua / API in orange)
   ========================================================================== */
:root { --c-vm: #2a78d6; --c-ve: #7fb0ea; --c-vo: #1baf7a; --c-vi: #eb6834; }
html[data-theme="dark"] { --c-vm: #3987e5; --c-ve: #5d8fcc; --c-vo: #199e70; --c-vi: #d95926; }
span.seg-vm, .swatch.seg-vm { background: var(--c-vm); }
span.seg-ve, .swatch.seg-ve {
  background: repeating-linear-gradient(135deg, var(--c-ve) 0 4px, color-mix(in srgb, var(--c-ve) 55%, transparent) 4px 7px);
}
span.seg-vo, .swatch.seg-vo { background: var(--c-vo); }
span.seg-vi, .swatch.seg-vi { background: var(--c-vi); }
rect.seg-vm { fill: var(--c-vm); }
rect.seg-ve { fill: var(--c-ve); opacity: 0.85; }
rect.seg-vo { fill: var(--c-vo); }
rect.seg-vi { fill: var(--c-vi); }

.volume-hero::before { background: radial-gradient(360px 120px at 0% 0%, color-mix(in srgb, var(--c-vm) 9%, transparent), transparent 70%); }
.volume-legend { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.volume-track { display: flex; gap: 2px; background: var(--surface-3); }
.volume-track > span { height: 100%; border-radius: 99px; min-width: 3px; transition: width 0.4s var(--ease); }
.volume-row-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tab-volume .bar-list { gap: 14px; }
#volume-facts { flex: 0 0 auto; justify-content: flex-start; }

@media (max-width: 1100px) {
  .volume-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .volume-legend { grid-template-columns: minmax(0, 1fr); }
  .volume-row-name { max-width: 140px; }
}

/* Client usage (sources tab) */
.usage-subhead { margin: 30px 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-1); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.usage-subhead .muted { font-weight: 400; font-size: 12px; }
.usage-trail { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
#client-usage-card .stat-row { margin: 6px 0 18px; }
#client-usage-devices tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--amber-ink); }

/* Handoff: devices not seen for 5 minutes */
.np-card.is-offline { filter: saturate(0.25); opacity: 0.72; }
.np-card.is-offline .np-bg { opacity: 0.35; }

/* Playback priority (sources tab) */
.priority-list { list-style: none; margin: 4px 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.priority-item { display: grid; grid-template-columns: 28px 26px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.priority-item.dragging { opacity: 0.5; }
.priority-item.drop-target { box-shadow: inset 0 2px 0 var(--accent, var(--blue-ink)); }
.priority-item.is-excluded .priority-name { color: var(--ink-3); }
.priority-rank { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); text-align: center; }
.priority-handle { cursor: grab; color: var(--ink-3); text-align: center; user-select: none; }
.priority-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.priority-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.priority-actions { display: flex; gap: 6px; align-items: center; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) {
  .priority-item { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .priority-item .priority-handle, .priority-item .priority-meta { display: none; }
  .form-row-3 { grid-template-columns: minmax(0, 1fr); }
}
#matches-card .stat-row { margin: 6px 0 18px; }
#matches-card .form-foot, #priority-card .form-foot { margin-top: 16px; }
