:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color-scheme: light;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --mono:
    ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas,
    monospace;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --head: #f9fafb;
  --hover: #f6f7f9;
  --field: #ffffff;
  --line: #e4e6ea;
  --line-soft: #eef0f2;
  --line-strong: #d0d4da;
  --text: #1f2328;
  --muted: #646b76;
  --faint: #959ba5;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --focus: #2563eb;
  --select: #eff4ff;
  --ok: #16a34a;
  --off: #a3a9b2;
  --danger: #c62828;
  --danger-line: #f3c7c3;
  --danger-wash: #fdf2f1;
  --warn: #b45309;
  --warn-dot: #d97706;
  --warn-wash: #fffaeb;
  --button-bg: var(--link);
  --button-hover: var(--link-hover);
  --button-ink: #ffffff;
  --hover-line: #b9bec6;
  --danger-hover-line: #e9a9a3;
  --meter-track: #e9ebef;
  --dialog-shadow: 0 16px 48px #0f172a2e;
  --backdrop: #0f172a52;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23646b76' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #242628;
  --panel: #2d3033;
  --head: #33363a;
  --hover: #383c40;
  --field: #282b2e;
  --line: #42464c;
  --line-soft: #3b3f44;
  --line-strong: #5d636b;
  --text: #e7e9ed;
  --muted: #b4bac4;
  --faint: #939ba8;
  --link: #8bb7ff;
  --link-hover: #bad2ff;
  --focus: #9ec2ff;
  --select: #36455d;
  --ok: #63c58c;
  --off: #828c98;
  --danger: #ff9b93;
  --danger-line: #6e4947;
  --danger-wash: #412f30;
  --warn: #eac17b;
  --warn-dot: #e4ac54;
  --warn-wash: #3e3629;
  --button-bg: #3b6fc4;
  --button-hover: #477fdb;
  --hover-line: #818a96;
  --danger-hover-line: #b7756f;
  --meter-track: #464c54;
  --dialog-shadow: 0 16px 48px #00000066;
  --backdrop: #00000080;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b4bac4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.top-controls {
  position: absolute;
  top: 10px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}
.top-controls .icon-button {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
}
.top-controls svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-theme-icon] {
  display: none;
}
[data-theme-mode="system"] [data-theme-icon="system"],
[data-theme-mode="light"] [data-theme-icon="light"],
[data-theme-mode="dark"] [data-theme-icon="dark"] {
  display: block;
}
.signin {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 64px 24px;
}
.signin-content {
  width: 100%;
  max-width: 320px;
}
.signin-content .brand {
  margin-bottom: 32px;
  text-align: center;
}
#signin-form {
  display: grid;
  gap: 10px;
}
#signin-form label {
  color: var(--muted);
}
#signin-form input {
  min-height: 36px;
}
#signin-feedback:empty {
  display: none;
}
#signin-submit {
  margin-top: 4px;
  min-height: 36px;
}

/* Shell: centered wordmark and tabs over a full-width workspace. */
.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 10px 0;
}
.brand {
  margin-bottom: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.26em;
  padding-left: 0.26em;
}
.tabs {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 2px;
  max-width: 100%;
  margin-bottom: -1px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs a {
  flex: none;
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px 9px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
}
.tabs a:hover {
  color: var(--text);
}
.tabs a[aria-current="page"] {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  font-weight: 600;
}
.workspace {
  min-height: calc(100vh - 80px);
  margin: 0 10px;
  padding: 20px 24px 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}
.workspace > :is(.page, .error-banner) {
  max-width: 1440px;
  margin-inline: auto;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 30px;
  margin-bottom: 14px;
}
.page-heading:has(.view-switch) {
  align-items: center;
}
.view-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.view-switch button {
  border: 0;
  border-radius: 4px;
  padding: 5px 10px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.view-switch button[aria-pressed="true"] {
  color: var(--text);
  background: var(--hover);
}
h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}
h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}
p {
  margin: 0;
}
a {
  color: var(--link);
}
a:hover {
  color: var(--link-hover);
}

/* Buttons and focus. Every control has one visible focus treatment. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--button-bg);
  background: var(--button-bg);
  color: var(--button-ink);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover:not(:disabled) {
  background: var(--button-hover);
  border-color: var(--button-hover);
}
.button:disabled {
  opacity: 0.5;
  cursor: default;
}
.button.secondary {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line-strong);
}
.button.secondary:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--hover-line);
}
.button.danger.secondary {
  border-color: var(--danger-line);
  color: var(--danger);
}
.button.danger.secondary:hover:not(:disabled) {
  background: var(--danger-wash);
  border-color: var(--danger-hover-line);
}
.button.small {
  min-height: 26px;
  padding: 3px 10px;
  font-size: 12px;
}
.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--link);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.link-button:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}
:is(
  .button,
  .link-button,
  .icon-button,
  a,
  input[type="checkbox"],
  input[type="radio"]
):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.tabs a:focus-visible {
  outline-offset: -2px;
}

/* Fields have a single border that turns blue on focus, without a ring. */
input:not([type="checkbox"], [type="radio"]),
select,
textarea {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
input:not([type="checkbox"], [type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: var(--hover-line);
}
input:not([type="checkbox"], [type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--focus);
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
}
input::placeholder {
  color: var(--faint);
}
input[type="checkbox"],
input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--link);
}
input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* Text roles. */
.muted {
  color: var(--muted);
}
.hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.mono {
  font-family: var(--mono);
  font-size: 12px;
}
.tabular,
.num {
  font-variant-numeric: tabular-nums;
}
.nowrap {
  white-space: nowrap;
}
.problem {
  color: var(--danger);
  font-weight: 600;
}
.good {
  font-weight: 600;
}
/* Inline, so the word shares the row baseline and still ellipsizes. */
.status {
  white-space: nowrap;
}
.status::before {
  content: "";
  display: inline-block;
  margin: 0 6px 1px 0;
  vertical-align: middle;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.status.warn {
  color: var(--warn);
}
.status.warn::before {
  background: var(--warn-dot);
}
.status.bad {
  color: var(--danger);
}
.status.bad::before {
  background: var(--danger);
}
.status.off {
  color: var(--muted);
}
.status.off::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--off);
}

/* Sections and tables. Rows stay on one line; a note follows the value. */
.section {
  margin: 0 0 24px;
  min-width: 0;
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.section-meta {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.section-link {
  margin-left: auto;
  font-size: 12px;
  text-decoration: none;
}
.section-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 0 24px;
  align-items: start;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.data-table th,
.data-table td {
  line-height: 18px;
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  vertical-align: middle;
}
.data-table th {
  background: var(--head);
  border-bottom-color: var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}
.data-table td.wrap {
  white-space: normal;
}
.data-table tbody tr:hover td {
  background: var(--hover);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table td.actions {
  width: 1%;
  padding-block: 4px;
  text-align: right;
}
.data-table .num {
  text-align: right;
}
.data-table .center {
  text-align: center;
}
.primary {
  color: var(--text);
}
.primary.muted {
  color: var(--muted);
}
.sub {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
}
.problem-text {
  color: var(--danger);
}
.empty-row {
  text-align: center !important;
  color: var(--muted);
  padding: 22px 12px !important;
}

/* Dashboard metrics: one row of labelled values with dividers. */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.pool-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.pool-control-label {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
}
.section-head:has(.pool-controls) {
  flex-wrap: wrap;
  row-gap: 8px;
}
.pool-groups {
  display: grid;
  gap: 16px;
}
.pool {
  --pool: var(--link);
  min-width: 0;
  padding: 14px 16px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.pool-anthropic {
  --pool: #d9693f;
}
.pool-openai {
  --pool: #2f6fe0;
}
.pool-gemini {
  --pool: #7c5cd6;
}
:root[data-theme="dark"] .pool-anthropic {
  --pool: #ee8d68;
}
:root[data-theme="dark"] .pool-openai {
  --pool: #6ea2ff;
}
:root[data-theme="dark"] .pool-gemini {
  --pool: #a48dff;
}
.pool-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}
.pool-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.pool-title h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 2px;
  background: var(--pool);
}
.pool-accounts {
  color: var(--muted);
  white-space: nowrap;
}
.pool-missing {
  color: var(--warn);
}
.pool-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 4px;
}
.pool-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.pool-total strong {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.pool-total span {
  color: var(--muted);
}
.pool-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 32px;
  margin: 0;
  text-align: right;
}
.pool-stat dt {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.pool-stat dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pool-stat dd strong {
  margin-right: 6px;
  color: var(--pool);
}
.pool-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 4px;
  overflow: visible;
}
.pool-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}
.pool-grid.hour {
  stroke-dasharray: 1 5;
}
.pool-grid.base {
  stroke: var(--line-strong);
}
.pool-axis,
.pool-note,
.pool-empty-label {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.pool-empty-label {
  fill: var(--text);
}
.pool-note,
.pool-empty-label {
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.pool-total strong.unknown {
  color: var(--faint);
}
.pool-stop-top {
  stop-color: var(--pool);
  stop-opacity: 0.16;
}
.pool-stop-bottom {
  stop-color: var(--pool);
  stop-opacity: 0.02;
}
.pool-line {
  fill: none;
  stroke: var(--pool);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.pool-line.projected {
  stroke-width: 1.6;
  stroke-dasharray: 6 4;
}
.pool-dot {
  fill: var(--pool);
}
.pool-now {
  stroke: var(--faint);
  stroke-width: 1;
}
.pool-reset {
  stroke: var(--faint);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.pool-now-point,
.pool-empty-point {
  fill: var(--panel);
  stroke: var(--pool);
  stroke-width: 2;
}
.pool-now-point {
  fill: var(--pool);
  stroke: var(--panel);
}
.pool-legend {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.pool-legend > span:first-child {
  margin-right: 4px;
}
.pool-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.pool-key i {
  width: 18px;
  border-top: 2px solid var(--pool);
}
.pool-key.projected i {
  border-top-style: dashed;
}
.metric {
  min-width: 0;
  padding: 9px 14px 10px;
  box-shadow: 1px 0 0 var(--line);
}
.metric dt {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.metric dd {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Settings: title column on the left, fields on the right. */
.settings-section {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 28px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.settings-section:first-child {
  padding-top: 4px;
  border-top: 0;
}
.settings-section > h2 {
  padding-top: 4px;
}
.settings-body {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 1040px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px;
  align-items: start;
}
.field {
  min-width: 0;
}
.field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
}
.field input:not([type="checkbox"], [type="radio"]),
.field select,
.field textarea {
  display: block;
  width: 100%;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1/-1;
  min-height: 22px;
}
.inline-check label {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
}
.field-wide {
  grid-column: 1/-1;
}
.field-group h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  margin-bottom: 6px;
}
.config-key-list {
  display: grid;
  gap: 6px;
  max-width: 820px;
}
.key-head,
.key-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(200px, 1.6fr) 84px;
  gap: 8px;
  align-items: center;
}
.key-head {
  color: var(--faint);
  font-size: 12px;
}
.key-row input {
  width: 100%;
}
.field-group > .hint {
  margin: 6px 0 10px;
}
.form-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.feedback {
  font-size: 13px;
  color: var(--muted);
}
.feedback.error {
  color: var(--danger);
}
.feedback.success {
  color: var(--ok);
}
.warning {
  border-left: 3px solid var(--warn-dot);
  border-radius: 4px;
  background: var(--warn-wash);
  padding: 8px 12px;
  color: var(--warn);
  font-size: 13px;
}
.error-banner {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--danger-wash);
  color: var(--danger);
  border: 1px solid var(--danger-line);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
}

/* Quota table. Each active window is one compact line. */
input.table-input {
  width: 76px;
  max-width: 100%;
  min-height: 26px;
  padding: 2px 8px;
  text-align: right;
}
.quota-accounts .data-table {
  min-width: 1000px;
}
.quota-account {
  min-width: 180px;
  max-width: 250px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.quota-account .primary,
.quota-account .sub,
.quota-reset .primary,
.quota-reset .sub {
  display: block;
  margin-left: 0;
  white-space: normal;
}
.quota-reset {
  min-width: 145px;
  white-space: normal;
}
input[type="checkbox"].account-switch {
  appearance: none;
  position: relative;
  width: 32px;
  height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--meter-track);
  vertical-align: middle;
  cursor: pointer;
}
.account-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--button-ink);
}
input[type="checkbox"].account-switch:checked {
  border-color: var(--button-bg);
  background: var(--button-bg);
}
.account-switch:checked::before {
  left: 16px;
}
.usage-cell {
  min-width: 280px;
  max-width: 360px;
  white-space: normal;
}
.usage-list {
  display: grid;
  gap: 6px;
}
.usage-row {
  display: grid;
  grid-template-columns: 56px minmax(72px, 140px) 64px;
  gap: 2px 10px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.usage-label {
  font-weight: 550;
}
.usage-left {
  text-align: right;
}
.usage-reset,
.usage-stamp {
  color: var(--muted);
  font-size: 12px;
}
.usage-reset {
  grid-column: 1 / -1;
  white-space: normal;
  overflow-wrap: anywhere;
}
.meter {
  height: 5px;
  border-radius: 3px;
  background: var(--meter-track);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--ok);
}
.meter.mid .meter-fill {
  background: var(--warn-dot);
}
.meter.low .meter-fill {
  background: var(--danger);
}

/* Quota timeline. The table stays mounted while users switch account views. */
.quota-timeline {
  margin-bottom: 18px;
}
.timeline-toolbar,
.timeline-controls,
.range-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.timeline-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.timeline-controls {
  flex-wrap: wrap;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
}
.segmented button {
  min-height: 28px;
  padding: 4px 9px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.segmented button:last-child {
  border-right: 0;
}
.segmented button:hover {
  color: var(--text);
  background: var(--hover);
}
.segmented button.selected {
  background: var(--select);
  color: var(--text);
  font-weight: 600;
}
.range-nav .button {
  min-height: 28px;
  padding: 4px 9px;
}
.range-label {
  margin-right: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timeline-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  scrollbar-width: thin;
}
.timeline-grid {
  min-width: 1120px;
  font-variant-numeric: tabular-nums;
}
.timeline-axis,
.timeline-row {
  display: grid;
  grid-template-columns: 210px minmax(900px, 1fr);
  align-items: center;
}
.timeline-axis {
  min-height: 40px;
  background: var(--head);
  border-bottom: 1px solid var(--line);
}
.timeline-identity-head {
  position: sticky;
  left: 0;
  z-index: 5;
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--head);
  border-right: 1px solid var(--line-soft);
  font-weight: 600;
}
.timeline-plot {
  position: relative;
  height: 56px;
  min-width: 900px;
  overflow: hidden;
}
.timeline-axis-plot {
  height: 40px;
  overflow: visible;
}
.timeline-day {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}
.timeline-day.today {
  color: var(--text);
  font-weight: 600;
}
.timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--link) 6%, transparent);
}
.timeline-tick-label {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.timeline-tick-label.start {
  transform: translate(0, -50%);
}
.timeline-tick-label.end {
  transform: translate(-100%, -50%);
}
.timeline-gridline {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line-soft);
}
.timeline-provider {
  grid-column: 1 / -1;
  position: sticky;
  left: 0;
  z-index: 4;
  padding: 5px 12px;
  background: var(--head);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.timeline-row {
  grid-template-rows: 56px auto;
  min-height: 56px;
  border-bottom: 1px solid var(--line-soft);
}
.timeline-row:last-child {
  border-bottom: 0;
}
.timeline-identity {
  grid-row: 1 / 3;
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: stretch;
  min-width: 0;
  padding: 4px 12px;
  background: var(--panel);
  border-right: 1px solid var(--line-soft);
}
.timeline-account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}
.timeline-disabled {
  color: var(--muted);
  font-size: 11px;
}
.timeline-row.disabled .timeline-identity {
  color: var(--muted);
}
.timeline-window-label {
  display: block;
  grid-column: 2;
  align-self: start;
  padding: 0 10px 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timeline-bar {
  position: absolute;
  z-index: 2;
  top: 8px;
  height: 40px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line));
  background: color-mix(in srgb, var(--ok) 8%, var(--panel));
}
.timeline-bar-label {
  display: block;
  padding: 4px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.timeline-bar-fill {
  position: absolute;
  left: 0;
  bottom: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--ok);
}
.timeline-bar.mid {
  border-color: color-mix(in srgb, var(--warn-dot) 45%, var(--line));
  background: color-mix(in srgb, var(--warn-dot) 8%, var(--panel));
}
.timeline-bar.mid .timeline-bar-fill {
  background: var(--warn-dot);
}
.timeline-bar.low {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 8%, var(--panel));
}
.timeline-bar.low .timeline-bar-fill {
  background: var(--danger);
}
.timeline-bar.ended {
  border-color: var(--line);
  background: var(--head);
  color: var(--muted);
}
.timeline-bar.ended .timeline-bar-fill {
  background: var(--off);
}
.timeline-bar.next {
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
}
.timeline-idle {
  position: absolute;
  top: 26px;
  left: 10px;
  width: 140px;
  height: 5px;
  border-radius: 3px;
  background: var(--meter-track);
}
.timeline-now {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--link);
}
.timeline-now span {
  display: none;
}
.timeline-axis-plot .timeline-now span {
  display: block;
  position: absolute;
  top: 0;
  left: 3px;
  padding: 1px 3px;
  border-radius: 3px;
  background: var(--link);
  color: var(--button-ink);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}
.timeline-empty {
  padding: 14px;
  color: var(--muted);
}
.timeline-grid.hours .timeline-gridline:nth-of-type(3n + 2) {
  background: var(--line-strong);
}
@media (max-width: 700px) {
  .timeline-toolbar {
    align-items: flex-start;
  }
  #timeline-range,
  .timeline-toolbar .range-nav {
    width: 100%;
  }
  .timeline-toolbar .range-nav .button {
    flex: 1;
  }
}

/* Requests and logs share a framed viewer: toolbar, scroll body, status. */
.viewer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.viewer-toolbar label {
  margin: 0;
}
.viewer-toolbar .search-field {
  flex: 1;
  max-width: 480px;
}
.viewer-toolbar .search-field input {
  display: block;
  width: 100%;
}
.viewer-toolbar select {
  min-width: 120px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 13px;
}
.viewer-body {
  position: relative;
  overflow: auto;
  overflow-anchor: none;
}
.viewer-body:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.viewer-status {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 12px;
  border-top: 1px solid var(--line);
  background: var(--head);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.viewer-status span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.viewer-status span::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--off);
}
.viewer-status span[data-live="true"]::before {
  background: var(--ok);
  box-shadow: none;
}
.viewer-status span:empty::before {
  display: none;
}

/* The request table cuts every cell to one line. Wide columns scroll inside
   the viewer rather than the page. */
.requests-output {
  height: clamp(320px, calc(100vh - 252px), 1100px);
}
.requests-table {
  min-width: 1320px;
  table-layout: fixed;
}
.requests-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.requests-table th,
.requests-table td {
  padding: 7px 8px;
}
.requests-table th:first-child,
.requests-table td:first-child {
  padding-left: 12px;
}
.requests-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}
.requests-table .c-time {
  width: 148px;
}
.requests-table .c-status {
  width: 156px;
}
.requests-table .c-device {
  width: 96px;
}
.requests-table .c-ip {
  width: 120px;
}
.requests-table .c-client {
  width: 92px;
}
.requests-table .c-duration {
  width: 72px;
}
.requests-table .c-ttft {
  width: 64px;
}
.requests-table .c-tokens {
  width: 108px;
}
.requests-table .c-cost {
  width: 72px;
}
.requests-table .c-id {
  width: 92px;
}
.requests-table td:first-child,
.requests-table td.mono {
  font-size: 12px;
}
.requests-table .sub {
  margin-left: 6px;
}
.request-id {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 12px;
}

.log-output {
  height: clamp(320px, calc(100vh - 252px), 1100px);
  padding: 4px 0;
  color: var(--text);
  font: 12px/1.6 var(--mono);
  font-variant-numeric: tabular-nums;
  tab-size: 2;
}
.log-line {
  display: flex;
  align-items: baseline;
  gap: 0 12px;
  width: max-content;
  min-width: 100%;
  padding: 1px 12px 1px 10px;
  border-left: 2px solid transparent;
  white-space: pre;
}
.log-line:hover {
  background: var(--hover);
}
.log-output.wrap .log-line {
  width: auto;
  white-space: pre-wrap;
}
.log-output.wrap .log-body {
  min-width: 0;
  overflow-wrap: anywhere;
}
.log-time {
  flex: none;
  color: var(--faint);
}
.log-line .level {
  flex: none;
  width: 5ch;
  color: var(--muted);
  font-weight: 600;
}
.log-line[data-level="trace"] .level,
.log-line[data-level="debug"] .level {
  color: var(--faint);
}
.log-line[data-level="warn"] {
  border-left-color: var(--warn-dot);
}
.log-line[data-level="warn"] .level {
  color: var(--warn);
}
.log-line[data-level="error"] {
  border-left-color: var(--danger);
  background: var(--danger-wash);
}
.log-line[data-level="error"] .level {
  color: var(--danger);
}
.log-request,
.log-fields {
  color: var(--muted);
}
.log-message {
  color: var(--text);
}

/* Dialogs. */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--dialog-shadow);
}
dialog::backdrop {
  background: var(--backdrop);
}
.dialog-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.dialog-heading h2 {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.dialog-heading svg {
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#wizard-back {
  margin-left: -6px;
}
.icon-button {
  width: 28px;
  height: 28px;
  flex: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}
.icon-button:disabled {
  opacity: 0.4;
  cursor: default;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.dialog-actions:empty {
  display: none;
}
#wizard-feedback:not(:empty) {
  margin: 12px 0 0;
}
#wizard-feedback:empty {
  display: none;
}

/* Wizard choices: one row per option, with a short description below its name. */
.wizard-fields {
  display: grid;
  gap: 14px;
}
.choice-list {
  display: grid;
  max-height: min(380px, 55vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.choice:last-child {
  border-bottom: 0;
}
.choice::after {
  content: "›";
  color: var(--faint);
  font-size: 16px;
}
.choice:hover:not(:disabled) {
  background: var(--hover);
}
.choice:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.choice:disabled {
  opacity: 0.45;
  cursor: default;
}
.choice-text {
  display: grid;
  flex: 1;
  gap: 1px;
  min-width: 0;
}
.choice-label {
  font-weight: 550;
}
.choice-detail {
  color: var(--muted);
  font-size: 12px;
}
.choice-meta {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}
.option-list {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.option-list legend {
  margin-bottom: 4px;
  padding: 0;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
}
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--field);
  cursor: pointer;
}
.option + .option {
  border-top: 0;
}
.option:first-of-type {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}
.option:last-of-type {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}
.option:hover {
  background: var(--hover);
}
.option:has(:checked) {
  background: var(--select);
}
.option:has(:disabled) {
  cursor: default;
}
.login-status {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  line-height: 1.5;
}
.login-status .button,
.login-status a {
  align-self: flex-start;
}
.login-status code {
  display: block;
  overflow-wrap: anywhere;
  background: var(--head);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.login-status .user-code {
  align-self: flex-start;
  padding: 6px 12px;
  border-color: var(--line-strong);
  font-size: 18px;
  letter-spacing: 0.14em;
  user-select: all;
}
.login-status a {
  text-underline-offset: 3px;
}
.login-status .detail-list {
  grid-template-columns: 100px minmax(0, 1fr);
  margin: 0;
}

/* Request details. */
.detail-dialog {
  width: min(860px, calc(100vw - 24px));
}
.detail-list {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 5px 16px;
  margin: 0 0 18px;
  font-size: 13px;
}
.detail-list dt {
  color: var(--muted);
}
.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
/* Attempts are few, so their cells wrap at spaces instead of scrolling. */
.detail-dialog .data-table td {
  white-space: normal;
}
.request-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line-strong);
}
.request-timeline li {
  display: grid;
  grid-template-columns: 64px minmax(120px, 180px) minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  position: relative;
  padding: 5px 0 5px 12px;
  font-size: 12px;
}
.request-timeline li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}
.request-timeline li.bad::before {
  background: var(--danger);
}
.request-timeline li.warn::before {
  background: var(--warn-dot);
}
.request-timeline time,
.request-timeline span {
  color: var(--muted);
}
.request-timeline span {
  overflow-wrap: anywhere;
}
.timeline-detail {
  min-width: 0;
}
.timeline-detail .table-wrap {
  margin-top: 6px;
}
.detail-list .select {
  user-select: all;
}
@media (min-width: 760px) {
  .detail-list {
    grid-template-columns: 120px minmax(0, 1fr) 120px minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
  .settings-section {
    grid-template-columns: minmax(0, 1fr);
  }
  .settings-section > h2 {
    padding-top: 0;
  }
}
@media (max-width: 760px) {
  .pool-controls {
    flex-wrap: wrap;
    margin-left: 0;
    width: 100%;
  }
  .pool-stats {
    justify-content: flex-start;
    text-align: left;
    gap: 4px 20px;
  }
  .pool-total strong {
    font-size: 28px;
  }
}
@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .masthead {
    padding: 12px 6px 0;
  }
  .brand {
    margin-bottom: 8px;
  }
  .tabs {
    align-self: stretch;
  }
  .tabs a {
    padding: 8px 11px 9px;
    font-size: 12px;
  }
  .tabs a:first-child {
    margin-left: auto;
  }
  .tabs a:last-child {
    margin-right: auto;
  }
  .workspace {
    margin: 0 6px;
    padding: 16px 12px 28px;
  }
  h1 {
    font-size: 17px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric dd {
    font-size: 15px;
  }
  /* Narrow tables keep natural column widths and scroll sideways. */
  .table-wrap .data-table {
    width: max-content;
    min-width: 100%;
  }
  .metric {
    box-shadow:
      1px 0 0 var(--line),
      0 1px 0 var(--line);
  }
  .viewer-toolbar {
    flex-wrap: wrap;
  }
  .viewer-toolbar .search-field {
    flex-basis: 100%;
    max-width: none;
    order: -1;
  }
  .viewer-toolbar select {
    min-width: 0;
  }
  .requests-output,
  .log-output {
    height: calc(100vh - 330px);
    min-height: 260px;
  }
  .key-head {
    display: none;
  }
  .key-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name remove"
      "value value";
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line-soft);
  }
  .key-row input[name="client-key-name"] {
    grid-area: name;
  }
  .key-row input[name="client-key-value"] {
    grid-area: value;
  }
  .key-row .button {
    grid-area: remove;
  }
  .form-footer {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 10px;
  }
  .detail-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .detail-list dd {
    margin-bottom: 6px;
  }
  .request-timeline li {
    grid-template-columns: 64px minmax(0, 1fr);
  }
  .timeline-detail {
    grid-column: 2;
  }
  dialog {
    padding: 14px;
  }
}
