/* Claude Relay console: quiet workspace UI with detail on demand. */

:root {
  color-scheme: light dark;

  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #f9fbfb;
  --surface-3: #eef2f2;
  --line: #e1e7e8;
  --line-strong: #cbd5d6;
  --text: #192528;
  --muted: #68777b;
  --faint: #96a3a6;
  --accent: #176b52;
  --accent-strong: #0f5a43;
  --accent-text: #ffffff;
  --accent-soft: #e5f3ec;
  --ok: #1b7a58;
  --ok-soft: #e3f3eb;
  --warn: #a15f16;
  --warn-soft: #fff1dc;
  --danger: #ae4036;
  --danger-soft: #fbe7e4;
  --chart-1: #2563eb;
  --chart-2: #c2410c;
  --chart-3: #7c3aed;
  --chart-4: #0f766e;
  --chart-5: #be185d;
  --chart-6: #4d7c0f;
  --chart-7: #92400e;
  --chart-8: #0369a1;
  --shadow: 0 1px 2px rgba(21, 35, 38, .04), 0 12px 32px rgba(21, 35, 38, .06);
  --shadow-soft: 0 1px 2px rgba(21, 35, 38, .04);

  --radius: 14px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13191b;
    --surface: #1b2325;
    --surface-2: #202a2c;
    --surface-3: #293436;
    --line: #2e3b3d;
    --line-strong: #415154;
    --text: #e7eeee;
    --muted: #a2b0b2;
    --faint: #788789;
    --accent: #54b38c;
    --accent-strong: #6ac69d;
    --accent-text: #102019;
    --accent-soft: #1b3a30;
    --ok: #67c99d;
    --ok-soft: #1b3a30;
    --warn: #e3ad65;
    --warn-soft: #3d2e1c;
    --danger: #ed8b82;
    --danger-soft: #442724;
    --chart-1: #60a5fa;
    --chart-2: #fb923c;
    --chart-3: #c084fc;
    --chart-4: #2dd4bf;
    --chart-5: #f472b6;
    --chart-6: #a3e635;
    --chart-7: #fbbf24;
    --chart-8: #38bdf8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 32px rgba(0, 0, 0, .24);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #13191b;
  --surface: #1b2325;
  --surface-2: #202a2c;
  --surface-3: #293436;
  --line: #2e3b3d;
  --line-strong: #415154;
  --text: #e7eeee;
  --muted: #a2b0b2;
  --faint: #788789;
  --accent: #54b38c;
  --accent-strong: #6ac69d;
  --accent-text: #102019;
  --accent-soft: #1b3a30;
  --ok: #67c99d;
  --ok-soft: #1b3a30;
  --warn: #e3ad65;
  --warn-soft: #3d2e1c;
  --danger: #ed8b82;
  --danger-soft: #442724;
  --chart-1: #60a5fa;
  --chart-2: #fb923c;
  --chart-3: #c084fc;
  --chart-4: #2dd4bf;
  --chart-5: #f472b6;
  --chart-6: #a3e635;
  --chart-7: #fbbf24;
  --chart-8: #38bdf8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 32px rgba(0, 0, 0, .24);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea, select { color: inherit; font: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.02em; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 14px; }
code, pre, .mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.note code { padding: 1px 4px; border-radius: 4px; background: var(--surface-3); font-size: 11px; }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }

/* ---------- identity and controls ---------- */

.logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s, transform .14s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { border-color: var(--line); background: var(--surface-3); color: var(--text); }
.btn-quiet[aria-pressed="true"] { border-color: var(--accent-soft); background: var(--accent-soft); color: var(--accent); }
.btn-inline { height: 29px; padding: 0 10px; font-size: 11px; }
.btn-block { width: 100%; height: 38px; margin-top: 14px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-close { width: 30px; height: 30px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 19px; }
.btn-close:hover { background: var(--surface-3); }
.plus { margin-top: -1px; font-size: 18px; font-weight: 400; line-height: 1; }
.action-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

label { display: block; margin: 15px 0 6px; font-size: 12px; font-weight: 650; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="datetime-local"], textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: 0;
  transition: border-color .14s, box-shadow .14s;
}
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="datetime-local"], select { height: 36px; padding: 0 10px; }
textarea { padding: 9px 10px; font-family: var(--mono); font-size: 12px; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check-row { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-weight: 500; line-height: 1.5; }
.check-row input { margin-top: 2px; accent-color: var(--accent); }
.secret-field { position: relative; }
.secret-field input { padding-right: 68px; }
.secret-field .btn-inline { position: absolute; top: 4px; right: 4px; }

/* ---------- sign in ---------- */

.signin {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 42%), var(--bg);
}
.signin-card {
  width: min(400px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.signin-head { display: flex; align-items: center; gap: 12px; }
.signin-head h1 { font-size: 19px; }
.signin-head p { margin: 3px 0 0; font-size: 12px; }
.signin-note { margin: 16px 0 0; color: var(--faint); font-size: 11px; line-height: 1.65; }

/* ---------- application shell ---------- */

.app { width: min(1220px, 100%); margin: 0 auto; padding: 0 28px 64px; }
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-product { display: flex; align-items: baseline; gap: 8px; }
.topbar-name { font-size: 13px; font-weight: 700; }
.topbar-context { color: var(--muted); font-size: 12px; }
.tag {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
}
.topbar-status { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-bad { background: var(--danger-soft); color: var(--danger); }
.chip-unknown { background: var(--surface-3); color: var(--muted); }

.workspace { padding-top: 0; }
.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 38px 2px 24px;
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.page-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; }

/* ---------- overview ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 30px;
}
.stat {
  min-height: 122px;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.stat-primary { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.stat-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.stat-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 750;
}
.stat-icon-ok { background: var(--ok-soft); color: var(--ok); }
.stat-icon-warn { background: var(--warn-soft); color: var(--warn); }
.stat-value-row { display: flex; align-items: baseline; gap: 3px; margin: 9px 0 2px; }
.stat > strong, .stat-value-row > strong { display: block; font-size: 31px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.04em; line-height: 1; }
.stat-suffix { color: var(--faint); font-size: 15px; font-variant-numeric: tabular-nums; }
.stat > small { display: block; color: var(--faint); font-size: 11px; }
.stat > strong { margin: 13px 0 7px; }
.stat.is-warn > strong, .stat.is-warn .stat-value-row > strong { color: var(--warn); }
.stat.is-bad > strong, .stat.is-bad .stat-value-row > strong { color: var(--danger); }
.stat-success { color: var(--ok); font-size: 10px; }
.stat-success b { font-size: 12px; font-weight: 700; }
.stat-detail { margin-top: 3px; color: var(--faint) !important; }

/* ---------- workspace tabs and panels ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 37px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { border-color: var(--accent); color: var(--text); }
.tab em { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-style: normal; font-variant-numeric: tabular-nums; }
.tab.is-active em { background: var(--accent-soft); color: var(--accent); }
.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 23px 17px;
}
.section-title h2 { margin-top: -2px; }
.section-title > span { display: block; margin-top: 5px; font-size: 11px; }
.account-tools { display: flex; align-items: center; gap: 8px; }
.search-field { position: relative; width: 228px; margin: 0; }
.search-field input { padding-left: 31px; background: var(--surface-2); font-size: 12px; }
.search-icon { position: absolute; top: 6px; left: 11px; z-index: 1; color: var(--faint); font-size: 19px; line-height: 1; pointer-events: none; transform: rotate(-20deg); }
.select-field { width: 116px; margin: 0; }
.select-field select { font-size: 12px; }
/* ---------- account list ---------- */

/* Every row, header included, shares one fixed column template so columns line up. */
.account-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 2.2fr) minmax(0, .6fr) minmax(0, .75fr) minmax(0, 1.1fr) 112px;
  align-items: center;
  gap: 20px;
  padding: 12px 22px;
}
.account-head {
  padding-top: 8px;
  padding-bottom: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
.account-list > .account-row { border-bottom: 1px solid var(--line); transition: background .14s; }
.account-list > .account-row:last-child { border-bottom: 0; }
.account-list > .account-row:hover { background: var(--surface-2); }
.account-row.account-warn { box-shadow: inset 3px 0 0 var(--warn); }
.account-row.account-bad { box-shadow: inset 3px 0 0 var(--danger); }
.account-row.account-off { color: var(--muted); }
.account-row.account-off .account-avatar { background: var(--surface-3); color: var(--faint); }

.account-identity { display: flex; align-items: center; min-width: 0; gap: 11px; }
.account-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .03em;
}
/* The chips carry their own padding, so the block is pulled back by that inset
   to keep the alias text optically aligned with the avatar. */
.identity-copy { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; margin-left: -7px; gap: 1px; }
.identity-line { display: flex; align-items: center; min-width: 0; max-width: 100%; gap: 6px; }
.identity-line > .alias-chip, .identity-line > .badge { flex: 0 0 auto; }
.identity-line > small { min-width: 0; overflow: hidden; margin-left: 7px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.copy-chip {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 3px 7px;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s, color .12s;
}
.copy-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.copy-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-chip-icon { display: flex; flex: 0 0 auto; }
.copy-chip-icon svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.alias-chip {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.alias-chip .copy-chip-icon, .contact-chip .copy-chip-icon { opacity: 0; color: var(--faint); transition: opacity .12s; }
.account-row:hover .copy-chip-icon, .copy-chip:focus-visible .copy-chip-icon { opacity: 1; }
.alias-chip:hover { border-color: var(--accent-soft); background: var(--accent-soft); color: var(--accent); }
.alias-chip:hover .copy-chip-icon { color: inherit; }

.contact-chip { padding-top: 1px; padding-bottom: 1px; color: var(--muted); font-size: 12px; }
.contact-chip:hover { background: var(--surface-3); color: var(--text); }

.copy-chip.is-copied, .copy-chip.is-copied:hover { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }

.account-usage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; min-width: 0; gap: 18px; }
.usage-notice { grid-column: 1 / 3; min-width: 0; overflow: hidden; color: var(--faint); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.usage-notice.is-bad { color: var(--danger); }
.usage-side { display: flex; align-items: center; gap: 4px; }
.usage-more { color: var(--faint); font-size: 11px; cursor: help; }
.usage-refresh { width: 28px; height: 28px; padding: 0; border-color: transparent; background: transparent; color: var(--faint); font-size: 15px; }
.usage-refresh:hover { border-color: var(--line); color: var(--text); }
.usage-refresh.is-warn { color: var(--warn); }
.quota-meter { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.quota-meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.quota-meter-head strong { color: var(--text); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.quota-track { height: 6px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.quota-track span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .25s ease; }
.quota-track span.quota-mid { background: var(--warn); }
.quota-track span.quota-low { background: var(--danger); }
.quota-reset { overflow: hidden; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.account-cell { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.account-cell > strong { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; }
.account-cell > small { overflow: hidden; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.account-cell > .is-warn { color: var(--warn); }
.account-cell-label { display: none; }
.account-cell > .account-idle { font-size: 12px; }
.activity-list { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--muted); font-size: 12px; }
.activity-list strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.account-actions { display: inline-flex; justify-content: flex-end; gap: 6px; }
.account-off .btn-toggle, .account-bad .btn-toggle { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.account-off .btn-toggle:hover, .account-bad .btn-toggle:hover { background: var(--accent-strong); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.badge::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.badge-off { background: var(--surface-3); color: var(--muted); }
.badge-plain::before { display: none; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.stack small { color: var(--muted); font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }

.empty { padding: 52px 20px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 23px; font-weight: 350; }
.empty h3 { font-size: 14px; }
.empty p { max-width: 460px; margin: 7px auto 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.empty-compact { padding: 36px 20px; }

/* ---------- request table ---------- */

.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); font-size: 12px; }
.bar-actions { display: flex; gap: 6px; }
.filters { display: flex; gap: 12px; }
.field { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.field span { color: var(--muted); font-size: 11px; }
.field select { width: auto; min-width: 120px; height: 30px; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.grid { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 13px; }
.grid th { padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 650; text-align: left; white-space: nowrap; }
.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--surface-2); }
.col-actions { text-align: right; }
.col-number { text-align: right; }
.grid td.col-number { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.col-actions { text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 4px; }

/* ---------- connection workspace ---------- */
.usage-dashboard { display: grid; gap: 14px; padding: 16px; }
.usage-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.usage-summary-grid .card { display: flex; min-height: 108px; flex-direction: column; }
.usage-summary-grid small { color: var(--muted); font-size: 11px; }
.usage-summary-grid strong { margin: 9px 0 3px; font-size: 25px; font-variant-numeric: tabular-nums; }
.usage-summary-grid span { color: var(--faint); font-size: 10px; }
.usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.usage-card { min-width: 0; padding: 0; overflow: hidden; background: var(--surface); }
.usage-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px 12px; padding: 15px 17px 10px; }
.usage-card-head > div:first-child { min-width: 0; }
.usage-card-head h3 { margin: 0 0 2px; }
.usage-card-head small { color: var(--muted); font-size: 10px; }
.usage-table { min-width: 860px; font-size: 11px; }
.usage-table th, .usage-table td { padding: 9px 11px; }
.usage-estimate-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: inherit; background: none; font: inherit; font-weight: 600; cursor: pointer; }
.usage-estimate-indicator { display: inline-block; color: var(--muted); font-size: 16px; line-height: 1; transition: transform 120ms ease; }
.usage-estimate-toggle[aria-expanded="true"] .usage-estimate-indicator { transform: rotate(90deg); }
.usage-estimate-details > td { padding: 0 !important; background: var(--surface-2); }
.usage-estimate-models { padding: 8px 12px 12px 28px; overflow-x: auto; }
.usage-estimate-model-table { min-width: 850px; margin: 0; table-layout: fixed; background: var(--surface); }
.usage-estimate-model-table th:first-child, .usage-estimate-model-table td:first-child { width: 24%; overflow-wrap: anywhere; }
.usage-estimate-model-table th:nth-child(2), .usage-estimate-model-table td:nth-child(2) { width: 7%; }
.usage-estimate-model-table th:nth-child(3), .usage-estimate-model-table td:nth-child(3) { width: 9%; }
.usage-estimate-model-table th:nth-child(4), .usage-estimate-model-table td:nth-child(4) { width: 10%; }
.usage-estimate-model-table th:nth-child(5), .usage-estimate-model-table td:nth-child(5) { width: 10%; }
.usage-estimate-model-table th:nth-child(6), .usage-estimate-model-table td:nth-child(6) { width: 10%; }
.usage-estimate-model-table th:nth-child(7), .usage-estimate-model-table td:nth-child(7) { width: 9%; }
.usage-estimate-model-table th:nth-child(8), .usage-estimate-model-table td:nth-child(8) { width: 12%; }
.usage-estimate-model-table th:nth-child(9), .usage-estimate-model-table td:nth-child(9) { width: 9%; }
.five-hour-chart { padding: 2px 17px 15px; }
.five-hour-chart-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 18px; margin-bottom: 9px; }
.five-hour-chart-toolbar > div:first-child { display: flex; min-width: 170px; flex-direction: column; gap: 1px; }
.five-hour-chart-toolbar strong { font-size: 11px; }
.five-hour-chart-toolbar small { color: var(--faint); font-size: 10px; }
.five-hour-chart-controls { display: flex; max-width: min(620px, 70%); flex-direction: column; align-items: flex-end; gap: 6px; }
.five-hour-chart-legend { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.five-hour-chart-legend-item { display: inline-flex; min-height: 32px; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 10px; cursor: pointer; }
.five-hour-chart-legend-item:hover { border-color: var(--line-strong); background: var(--surface-3); color: var(--text); }
.five-hour-chart-legend-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.five-hour-chart-legend-line { stroke: var(--series-color); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.five-hour-account-picker { width: min(310px, 100%); }
.five-hour-account-picker > summary { display: flex; min-height: 32px; align-items: center; justify-content: flex-end; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 650; cursor: pointer; list-style: none; }
.five-hour-account-picker > summary::-webkit-details-marker { display: none; }
.five-hour-account-picker > summary::after { font-size: 14px; line-height: 1; content: "⌄"; transition: transform 120ms ease; }
.five-hour-account-picker[open] > summary::after { transform: rotate(180deg); }
.five-hour-account-picker > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.five-hour-account-picker > summary span { color: var(--faint); font-weight: 500; }
.five-hour-account-picker-panel { display: grid; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); box-shadow: var(--shadow-soft); }
.five-hour-account-picker-panel input { height: 32px; font-size: 11px; }
.five-hour-account-list { max-height: 238px; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.five-hour-account-option { display: flex; min-height: 42px; align-items: center; gap: 8px; margin: 0; padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.five-hour-account-option:last-child { border-bottom: 0; }
.five-hour-account-option:hover { background: var(--surface-2); }
.five-hour-account-option input { width: 15px; height: 15px; flex: 0 0 auto; margin: 0; }
.five-hour-account-option > span { display: flex; min-width: 0; flex-direction: column; }
.five-hour-account-option strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.five-hour-account-option small { overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.five-hour-account-picker-panel > small { color: var(--faint); font-size: 9px; line-height: 1.45; }
.five-hour-chart-frame { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.five-hour-chart-plot { display: block; width: 100%; min-width: 680px; height: auto; }
.five-hour-chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.five-hour-chart-grid-vertical { stroke-dasharray: 2 5; }
.five-hour-chart-axis-label, .five-hour-chart-axis-title, .five-hour-chart-empty { fill: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 10px; }
.five-hour-chart-axis-title { font-size: 10px; font-weight: 650; }
.five-hour-chart-empty { font-size: 12px; }
.five-hour-chart-line { fill: none; stroke: var(--series-color); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.25; vector-effect: non-scaling-stroke; }
.five-hour-chart-point { fill: var(--surface); stroke: var(--series-color); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.five-hour-chart-point.is-unpriced { fill: var(--warn-soft); }
.five-hour-chart-point-hit { fill: transparent; stroke: transparent; stroke-width: 16; cursor: pointer; pointer-events: all; }
.five-hour-chart-point-group.is-active .five-hour-chart-point, .five-hour-chart-point-group:focus-within .five-hour-chart-point { fill: var(--series-color); r: 6px; }
.five-hour-chart-point-hit:focus { outline: none; }
.five-hour-chart-tooltip { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; max-width: min(290px, calc(100% - 20px)); flex-direction: column; gap: 2px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: var(--shadow-soft); font-size: 10px; pointer-events: none; }
.five-hour-chart-tooltip strong { font-size: 11px; }
.five-hour-chart-tooltip span { color: var(--muted); }
.five-hour-chart-tooltip .five-hour-chart-tooltip-warn { color: var(--warn); }
.five-hour-chart-note { margin: 7px 1px 0; color: var(--faint); font-size: 10px; }
.five-hour-window-details { border-top: 1px solid var(--line); }
.five-hour-window-details summary { display: flex; align-items: center; gap: 5px; padding: 10px 17px; color: var(--muted); font-size: 11px; font-weight: 650; cursor: pointer; list-style: none; }
.five-hour-window-details summary::-webkit-details-marker { display: none; }
.five-hour-window-details summary::before { display: inline-block; font-size: 16px; font-weight: 400; line-height: 1; content: "›"; transition: transform 120ms ease; }
.five-hour-window-details[open] summary::before { transform: rotate(90deg); }
.five-hour-window-details summary:hover { background: var(--surface-2); color: var(--text); }
.five-hour-window-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.five-hour-window-details summary span { color: var(--faint); font-weight: 500; }
.usage-warning { padding: 10px 13px; border: 1px solid var(--warn); border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 11px; }
.cache-stats-note { margin: -2px 1px 12px; color: var(--faint); font-size: 10px; line-height: 1.6; }
.usage-empty-note { padding: 12px 17px 17px; color: var(--faint); font-size: 11px; }
.price-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }

.connect-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; padding: 16px; align-items: start; }
.card { padding: 17px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.card h3 { margin-bottom: 12px; }
.kv { margin-bottom: 12px; }
.kv > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.value-row { display: flex; align-items: center; gap: 6px; }
.value-row code { flex: 1; min-width: 0; padding: 6px 8px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.snippet { margin-bottom: 13px; }
.snippet:last-child { margin-bottom: 0; }
.snippet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.snippet pre { margin: 0; padding: 10px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: 11.5px; line-height: 1.65; }
.runtime { display: grid; gap: 7px; margin: 0; }
.runtime > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; }
.runtime dt { color: var(--muted); white-space: nowrap; }
.runtime dd { margin: 0; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.official-version-card .note { margin: 0 0 13px; }
.official-version-card .form-grid, .refusal-billing-card .form-grid { display: grid; grid-template-columns: 1fr 1.4fr; align-items: center; gap: 9px 10px; margin-bottom: 13px; }
.official-version-card .form-grid label, .refusal-billing-card .form-grid label { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.refusal-billing-card .check-row { margin-bottom: 13px; }
.official-version-card input { width: 100%; }
.routing-policy-card, .model-list-card { grid-column: 1 / -1; }
.routing-policy-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.routing-policy-head > div { display: flex; align-items: center; gap: 9px; }
.routing-policy-head h3 { margin: 0; }
.routing-policy-card .note { margin: 13px 0 6px; }
.model-list { margin-top: 10px; }
.model-list-details summary { padding: 9px 2px; }
.model-list-details summary.model-list-error { color: var(--danger); }
.model-list-details .grid { min-width: 560px; font-size: 12px; }
.model-list-details .grid th, .model-list-details .grid td { padding: 8px 10px; }
.routing-policy-warning { margin: 0; color: var(--warn); font-size: 11px; }

/* ---------- dialogs ---------- */

.dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#actionsDialog { width: min(630px, calc(100% - 28px)); }
.dialog::backdrop { background: rgba(10, 16, 18, .52); }
.dialog-body { padding: 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.dialog textarea { font-size: 12px; }
#actionsDetail { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
#actionsDetail > div { min-width: 0; }
#actionsDetail dt { color: var(--muted); font-size: 10px; }
#actionsDetail dd { margin-top: 2px; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.steps { display: flex; gap: 6px; margin: 16px 0 4px; padding: 0; list-style: none; }
.steps li { flex: 1; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--faint); font-size: 11px; font-weight: 650; text-align: center; }
.steps li.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.step label:first-child { margin-top: 11px; }
.success-note { margin: 15px 0 0; color: var(--ok); font-size: 13px; font-weight: 650; }
.action-list { display: grid; gap: 7px; margin-top: 17px; }
.action-list .btn { width: 100%; height: 36px; justify-content: flex-start; }
.action-list .action-note { margin: -2px 0 6px; color: var(--faint); font-size: 11px; }
.confirm-body { margin: 13px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.confirm-body strong { color: var(--text); }
.confirm-body ul { margin: 8px 0 0; padding-left: 18px; }
.confirm-body li { margin-bottom: 4px; font-size: 12px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }

/* ---------- toast ---------- */

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: 340px; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .16s, transform .16s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .app { padding-right: 20px; padding-left: 20px; }
}

/* Below this width a row becomes a two-line card: identity + actions, quota, then labelled stats. */
@media (max-width: 1040px) {
  .account-head { display: none; }
  .account-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    grid-template-areas: "identity identity identity actions" "usage usage usage usage" "requests activity refusal refusal";
    gap: 12px 18px;
    padding: 14px 18px;
  }
  .account-identity { grid-area: identity; }
  .account-usage { grid-area: usage; }
  .account-row > .account-cell:nth-child(3) { grid-area: requests; }
  .account-row > .account-cell:nth-child(4) { grid-area: activity; }
  .account-row > .account-cell:nth-child(5) { grid-area: refusal; }
  .account-actions { grid-area: actions; }
  .account-cell { align-self: start; }
  .account-cell > .account-cell-label { display: block; color: var(--muted); }
}

@media (max-width: 720px) {
  .app { padding: 0 13px 40px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 0; }
  .topbar-status { order: 3; width: 100%; margin-right: 0; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .btn-quiet:nth-child(3) { display: none; }
  .page-intro { align-items: flex-start; flex-direction: column; padding: 29px 2px 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .stats { grid-template-columns: 1fr; gap: 8px; margin-bottom: 23px; }
  .stat { min-height: 0; padding: 14px 16px; }
  .stat > strong { margin: 9px 0 5px; }
  .tabs { overflow-x: auto; }
  .panel-heading { align-items: stretch; flex-direction: column; padding: 18px 16px 15px; }
  .account-tools { align-items: stretch; }
  .search-field { flex: 1; width: auto; }
  .select-field { width: 122px; }
  .account-row { padding: 14px; }
  .account-usage { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .account-usage .quota-meter { grid-column: 1; }
  .account-usage .usage-notice { grid-column: 1; }
  .account-usage > span:empty { display: none; }
  .usage-side { grid-column: 2; grid-row: 1; }
  .panel-bar { align-items: flex-start; flex-direction: column; padding: 13px 15px; }
  .filters { width: 100%; gap: 7px; }
  .field { flex: 1; }
  .field select { width: 100%; min-width: 0; }
  .connect-grid { grid-template-columns: 1fr; padding: 10px; }
  .routing-policy-head { align-items: flex-start; flex-direction: column; }
  .usage-summary-grid, .usage-grid { grid-template-columns: 1fr; }
  .usage-dashboard { padding: 10px; }
  .five-hour-chart-toolbar { align-items: stretch; flex-direction: column; }
  .five-hour-chart-controls { width: 100%; max-width: none; align-items: stretch; }
  .five-hour-chart-legend { justify-content: flex-start; }
  .five-hour-account-picker { width: 100%; }
  .five-hour-account-picker > summary { justify-content: flex-start; }
  #actionsDetail { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  h1 { font-size: 25px; }
  .topbar-product { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.15; }
  .topbar-actions .btn { padding: 0 8px; }
  .topbar-actions .btn:nth-child(2) { display: none; }
  .account-tools { flex-direction: column; }
  .select-field { width: 100%; }
  .account-row { grid-template-areas: "identity identity identity identity" "usage usage usage usage" "requests activity refusal refusal" "actions actions actions actions"; }
  .account-actions .btn { flex: 1; }
  .empty { padding: 40px 15px; }
  .dialog-body { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
