/* The theme tokens, sizes and component styles copy CLIProxyAPI Management Center (src/styles/*.scss,
   src/features/authFiles, src/features/quota, src/features/dashboard, src/components/ui/Table),
   MIT License, Copyright (c) 2026 Router-For.ME. Light uses its "white" theme, dark its "dark" theme. */

/* Theme: each token holds a light and a dark value. color-scheme picks one: the system setting, or the
   data-theme attribute on <html> that the toolbar sets. */
:root {
  color-scheme: light dark;
  --bg-secondary: light-dark(#ffffff, #151412);
  --bg-primary: light-dark(#ffffff, #1d1b18);
  --bg-tertiary: light-dark(#f6f6f6, #262320);
  --floating-surface: light-dark(#ffffff, #2a2723);
  --text-primary: light-dark(#2d2a26, #f6f4f1);
  --text-secondary: light-dark(#6d6760, #c9c3bb);
  --text-tertiary: light-dark(#a29c95, #9c958d);
  --text-quaternary: light-dark(#c0bab3, #6f6962);
  --border-color: light-dark(#e5e5e5, #3a3530);
  --border-hover: light-dark(#cccccc, #5a544d);
  --primary-color: #8b8680;
  --primary-hover: light-dark(#7f7a74, #9a948e);
  --primary-active: light-dark(#726d67, #a6a099);
  --error-color: #c65746;
  --quota-medium-color: light-dark(#e0aa14, #ffd862);
  --warning-bg: light-dark(rgb(198 87 70 / 0.12), rgb(198 87 70 / 0.22));
  --warning-border: light-dark(rgb(198 87 70 / 0.35), rgb(198 87 70 / 0.45));
  --warning-text: light-dark(#c65746, #f1b0a6);
  --success-badge-bg: light-dark(#d1fae5, rgb(6 78 59 / 0.3));
  --success-badge-text: light-dark(#065f46, #6ee7b7);
  --success-badge-border: light-dark(#6ee7b7, #059669);
  --failure-badge-bg: light-dark(rgb(198 87 70 / 0.14), rgb(198 87 70 / 0.24));
  --failure-badge-text: light-dark(#8a3a30, #f1b0a6);
  --failure-badge-border: light-dark(rgb(198 87 70 / 0.35), rgb(198 87 70 / 0.5));
  --count-badge-bg: light-dark(rgb(139 134 128 / 0.18), rgb(139 134 128 / 0.28));
  --amber-color: light-dark(#d97706, #f59e0b);
  --amber-text: light-dark(#92400e, #fcd34d);
  --viz-success: light-dark(#10b981, #0fae78);
  --viz-failure: light-dark(#c65746, #cf4b3a);
  --floating-shadow: 0 12px 26px light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.4));
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.08);
  /* Provider colors: the badge background and text of each subscription kind. */
  --claude: light-dark(#c05621, #e8a882);
  --claude-bg: light-dark(#fbece4, #5e2c14);
  --codex: light-dark(#3538d4, #b5b0ff);
  --codex-bg: light-dark(#eae7ff, #262395);
  /* Request squares: the ends of the success-rate color scale. */
  --block-ok: #22c55e;
  --block-err: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
    "Droid Sans", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, "Liberation Mono",
    monospace;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --fast: 150ms ease;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
/* light-dark() takes colors only, so the card shadow switches by theme here. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3); } }
:root[data-theme="dark"] { --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3); }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: background-color 300ms ease, color 300ms ease;
}
a { color: inherit; }
main a { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border-hover); }
main a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Shell: a sidebar, and a wrapped top bar under 768 px. The shell paints the sidebar column, so the column
   keeps its color below the sticky sidebar on a long page. */
.shell {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
  background: linear-gradient(
    to right,
    var(--bg-primary) 215px,
    color-mix(in srgb, var(--border-color) 78%, transparent) 0 216px,
    transparent 0
  );
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 14px 10px;
  border-right: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
  background: var(--bg-primary);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 2px 8px 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
  line-height: 1.15;
}
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: 15px; font-weight: 800; }
.brand small { margin-top: 1px; font-size: 10.5px; font-weight: 500; color: var(--text-secondary); }
.logo {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--viz-success), #7a9dff 55%, #d97757);
}
nav { display: flex; flex-direction: column; gap: 10px; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  padding: 0 10px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text-primary) 42%, transparent);
  user-select: none;
}
nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
nav a svg { flex: none; margin: 0 1px; color: color-mix(in srgb, var(--text-primary) 58%, transparent); transition: color var(--fast); }
nav a:hover {
  background: color-mix(in srgb, var(--text-primary) 7%, transparent);
  border-color: color-mix(in srgb, var(--border-color) 58%, transparent);
  transform: translateX(1px);
}
nav a:hover svg { color: color-mix(in srgb, var(--text-primary) 82%, transparent); }
nav a[aria-current="page"] {
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
  border-color: color-mix(in srgb, var(--border-hover) 70%, transparent);
}
nav a[aria-current="page"] svg { color: var(--primary-active); }

/* Floating toolbar: fixed at the top right of the window. */
.header-actions {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--border-color) 68%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-primary) 68%, transparent);
  box-shadow: 0 18px 44px rgb(0 0 0 / 0.17), inset 0 1px 0 rgb(255 255 255 / 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.header-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
}
.header-actions button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
  border-color: transparent;
  color: var(--text-primary);
}
.header-actions button.text { width: auto; padding: 0 10px; font-size: 12.5px; }
.header-actions .expiry { align-self: center; padding: 0 6px; font-size: 12.5px; white-space: nowrap; }

main { min-width: 0; max-width: 96rem; padding: 70px clamp(20px, 3vw, 48px) 40px; }
@media (max-width: 767.98px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar {
    z-index: 2;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
  }
  .brand { padding: 0; margin: 0; border: 0; }
  .brand small, .nav-label { display: none; }
  nav, .nav-group { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .header-actions { position: static; margin-left: auto; padding: 4px; gap: 2px; border-radius: 14px; box-shadow: none; }
  .header-actions button { width: 36px; height: 36px; }
  main { padding: 20px 16px 24px; }
}

/* Page header: title, a monospace count line after a green bar, and the main buttons on the right. */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px 24px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 7px; font-size: clamp(26px, 3.2vw, 30px); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.page-head .sub::before { content: "▍"; align-self: center; margin-right: 1px; font-size: 13px; line-height: 1; color: var(--viz-success); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
h2 { margin: 28px 0 8px; font-size: 18px; font-weight: 650; }
h3 { margin: 20px 0 6px; font-size: 14px; font-weight: 650; }
.muted { color: var(--text-tertiary); }
.small { font-size: 12px; }
.ok-text { color: var(--viz-success); }
.err-text { color: var(--viz-failure); }
.label { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-tertiary); }
code, .mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }

/* Tables sit in a bordered box and scroll inside it, so the page never scrolls sideways. */
/* position: relative keeps the absolute .sr-only text inside the box. */
.scroll {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  margin: 8px 0 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
}
table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; font-size: 13px; }
caption { padding: 10px 14px 6px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: top; line-height: 1.5; }
thead th { padding: 10px 14px; background: var(--bg-tertiary); white-space: nowrap; vertical-align: middle; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
tbody th { font-weight: 600; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr > * { transition: background-color var(--fast); }
tbody tr:hover > * { background: color-mix(in srgb, var(--bg-tertiary) 50%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.disabled { opacity: 0.55; }
.nowrap { white-space: nowrap; }

/* State pills: color helps, the text says it. */
.state {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-secondary);
}
.state.connected, .state.ok { background: var(--success-badge-bg); border-color: var(--success-badge-border); color: var(--success-badge-text); }
.state.needs_login, .state.warning {
  background: color-mix(in srgb, var(--amber-color) 10%, transparent);
  border-color: color-mix(in srgb, var(--amber-color) 30%, transparent);
  color: var(--amber-text);
}
.state.login_pending {
  background: color-mix(in srgb, var(--primary-color) 10%, transparent);
  border-color: color-mix(in srgb, var(--primary-color) 30%, transparent);
  color: var(--primary-active);
}
.state.error { background: var(--failure-badge-bg); border-color: var(--failure-badge-border); color: var(--failure-badge-text); }
.due { color: var(--warning-text); }
.error { color: var(--error-color); }
.notice {
  padding: 7px 9px;
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  background: var(--warning-bg);
  font-size: 12px;
  color: var(--warning-text);
}
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  background: color-mix(in srgb, var(--bg-primary) 70%, transparent);
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.pill b { font-family: var(--mono); font-weight: 600; color: var(--text-secondary); }

/* Buttons: quiet outlined pills; .primary is the ink pill, inverted in the dark theme. */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 200ms var(--ease), border-color 200ms var(--ease), background-color 200ms var(--ease),
    box-shadow 200ms var(--ease), transform 160ms var(--ease);
}
button:hover:not(:disabled) { border-color: var(--border-hover); color: var(--text-primary); }
button:active:not(:disabled) { transform: scale(0.96); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button svg { flex: none; }
button.primary {
  gap: 7px;
  padding: 10px 18px;
  border: 0;
  background: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--bg-secondary);
}
button.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--text-primary) 86%, var(--bg-secondary));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--text-primary) 22%, transparent);
  color: var(--bg-secondary);
}
button.danger:not(:disabled) { background: var(--error-color); border-color: var(--error-color); color: #fff; }
button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--error-color) 90%, #000); color: #fff; }
/* .solid is the filled gray button of the OAuth cards. */
button.solid {
  min-height: 0;
  padding: 10px 14px;
  border-color: var(--primary-color);
  border-radius: 8px;
  background: var(--primary-color);
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
button.solid:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); color: #fff; }
/* A link that looks like the outlined button. */
a.button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  background: var(--bg-secondary);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  color: var(--text-secondary);
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
a.button:hover { border-color: var(--border-hover); color: var(--text-primary); }
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  transition: border-color var(--fast), box-shadow var(--fast);
}
textarea { height: auto; padding: 10px 12px; }
:is(input:not([type="radio"]):not([type="checkbox"]), select, textarea):focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(139 134 128 / 0.18);
}
::placeholder { color: var(--text-tertiary); }
textarea, input:not([type]) { width: 100%; font-family: var(--mono); }
dialog {
  max-width: 36rem;
  padding: 20px 24px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin-top: 8px; font-weight: 600; }
dialog fieldset { border: 1px solid var(--border-color); border-radius: 10px; }
dialog fieldset label { margin: 4px 0; font-weight: 400; }
.buttons { display: flex; gap: 8px; margin-top: 16px; }
.usercode { font-size: 1.3rem; letter-spacing: 0.1em; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Segmented control: buttons with aria-pressed, or radios in labels. */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  background: var(--bg-tertiary);
}
.seg button, .seg label {
  min-height: 0;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 9999px;
  background: none;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 200ms var(--ease), background-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.seg button:hover:not(:disabled), .seg label:hover { border-color: transparent; color: var(--text-primary); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg button[aria-pressed="true"], .seg label:has(input:checked) {
  background: var(--floating-surface);
  font-weight: 650;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.08);
}
.seg label:has(input:focus-visible) { outline: 2px solid var(--primary-color); outline-offset: -1px; }
.seg button:disabled { opacity: 0.5; cursor: default; }

/* Card: a stat tile with a short accent bar. */
.card {
  display: flex;
  flex: 1 1 9rem;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  transition: border-color var(--fast);
}
.card::before { content: ""; width: 28px; height: 3px; margin-bottom: 2px; border-radius: 9999px; background: var(--border-hover); }
.card:hover { border-color: var(--border-hover); }

/* Overview */
.headline { font-weight: 600; }
.headline.ok { color: var(--viz-success); }
.headline.error { color: var(--viz-failure); }
.headline.warning { color: var(--amber-text); }
.attention { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-primary); font-size: 13px; }
.attention li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-color); }
.attention li:last-child { border-bottom: 0; }
.cards { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 16px; }
.cards .card { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.card b { font-family: var(--mono); font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.chart { padding: 16px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-primary); }
.chart svg { display: block; width: 100%; height: 9rem; }
.chart .bar-ok { fill: var(--viz-success); }
.chart .bar-err { fill: var(--viz-failure); }
.chart .bar-gap { fill: var(--amber-color); }
.axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; color: var(--text-tertiary); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: 12px; color: var(--text-secondary); }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; }
.swatch.ok { background: var(--viz-success); }
.swatch.err { background: var(--viz-failure); }
.swatch.gap { background: var(--amber-color); }

/* Requests */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 8px; }
.filters input[type="search"] { width: 13rem; }

/* Accounts */
.tabs {
  display: flex;
  gap: 2px;
  max-width: 100%;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-color);
}
.tabs button {
  position: relative;
  flex-shrink: 0;
  gap: 7px;
  min-height: 0;
  padding: 8px 12px 11px;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: none;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-secondary);
}
.tabs button::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 9999px; background: transparent; }
.tabs button:hover:not(:disabled) { background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent); color: var(--text-primary); }
.tabs button:active:not(:disabled) { transform: translateY(0.5px); }
.tabs button[aria-pressed="true"] { font-weight: 650; color: var(--text-primary); }
.tabs button[aria-pressed="true"]::after { background: var(--text-primary); }
.mark { display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; font-size: 10px; font-weight: 700; color: var(--text-tertiary); }
.tabs button[aria-pressed="true"] .mark { color: var(--text-primary); }
.count {
  padding: 0 6px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}
.tabs button[aria-pressed="true"] .count { background: color-mix(in srgb, var(--text-primary) 10%, transparent); color: var(--text-primary); }
.search { position: relative; display: block; max-width: 340px; margin-bottom: 16px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-quaternary); pointer-events: none; }
.search input:not([type="radio"]):not([type="checkbox"]) { width: 100%; padding-left: 36px; }
.acct-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) { .acct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .acct-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.acct {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  font-size: 12.5px;
  transition: border-color 160ms var(--ease);
}
.acct:hover { border-color: var(--border-hover); }
.acct p { margin: 0; }
.acct-head { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 28px; }
.acct-head h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.acct-head + .mono { margin-top: -4px; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; color: var(--text-tertiary); }
.badge {
  flex: none;
  padding: 4px 10px;
  border: 1px dashed var(--border-hover);
  border-radius: 12px;
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-secondary);
}
.badge.kind-anthropic_oauth { border: 0; background: var(--claude-bg); color: var(--claude); }
.badge.kind-openai_codex { border: 0; background: var(--codex-bg); color: var(--codex); }
.acct-state { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.acct .mono.small { font-size: 11.5px; color: var(--text-tertiary); }
.reqs { display: grid; gap: 7px; }
.reqs-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.reqs-head .mono { display: inline-flex; gap: 8px; font-size: 11.5px; font-weight: 600; }
.reqs-strip { display: flex; align-items: center; gap: 8px; }
.reqs-strip > .mono { min-width: 40px; margin-left: auto; text-align: right; font-size: 11.5px; font-weight: 650; color: var(--viz-success); }
.strip { display: grid; flex: 1; grid-template-columns: repeat(20, minmax(3px, 1fr)); gap: 2px; min-width: 0; }
.strip > span { height: 14px; border-radius: 2px; background: var(--block-ok); }
.strip > span.err { background: var(--block-err); }
.quota-box {
  display: grid;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-secondary) 55%, transparent);
  font-size: 11.5px;
}
.quota-box p { margin: 0; }
.quota-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; }
.limit { display: grid; gap: 4px; }
.limit-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 8px; }
.limit-head > span:first-child { font-weight: 600; color: var(--text-secondary); }
.limit-head .mono { font-size: 11.5px; }
.limit-head b { font-weight: 650; color: var(--text-primary); }
.limit-head .muted { color: var(--text-quaternary); }
.bar { height: 6px; overflow: hidden; border-radius: 9999px; background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
.bar > span { display: block; height: 100%; border-radius: 9999px; background: var(--viz-success); transition: width 360ms var(--ease); }
.bar.warn > span { background: var(--quota-medium-color); }
.bar.err > span { background: var(--viz-failure); }
.acct-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
}
/* Card buttons: the small quiet outlined pill. */
.acct-actions button, .quota-foot button {
  gap: 5px;
  min-height: 0;
  padding: 5px 11px;
  background: none;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}
.acct-actions button:hover:not(:disabled), .quota-foot button:hover:not(:disabled) { background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent); }
/* Square icon buttons and the enable switch, after the CPAMC auth file card. */
.acct-actions button.icon { width: 30px; height: 30px; padding: 0; border-radius: 8px; }
.acct-actions button.danger-line { border-color: color-mix(in srgb, var(--error-color) 28%, transparent); color: var(--error-color); }
.acct-actions button.danger-line:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--error-color) 45%, transparent);
  background: color-mix(in srgb, var(--error-color) 10%, transparent);
  color: var(--error-color);
}
.acct-actions button[aria-busy="true"] svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toggle { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 11px; white-space: nowrap; color: var(--text-tertiary); cursor: pointer; }
.acct-actions .toggle button {
  position: relative;
  width: 44px;
  height: 24px;
  padding: 0;
  border: 0;
  background: var(--border-color);
}
.acct-actions .toggle button[aria-checked="true"] { background: var(--primary-color); }
.acct-actions .toggle button:hover:not(:disabled) { background: var(--border-hover); }
.acct-actions .toggle button[aria-checked="true"]:hover:not(:disabled) { background: var(--primary-hover); }
.acct-actions .toggle button:active:not(:disabled) { transform: none; }
.toggle .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform 200ms var(--ease);
}
.toggle [aria-checked="true"] .thumb { transform: translateX(20px); }
.toggle:has(button:disabled) { cursor: not-allowed; }
/* A disabled account dims, but its footer keeps full strength. */
.acct.off > :not(.acct-actions) { opacity: 0.68; }

.empty { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.empty p { margin: 0; }

/* OAuth Login: one card per subscription account. */
.oauth-list { display: flex; flex-direction: column; gap: 24px; }
.oauth-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-primary);
  box-shadow: var(--shadow);
}
.oauth-card header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 16px; }
.oauth-card h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 18px; font-weight: 700; }
.oauth-card header button { margin-left: auto; }
.oauth-card p { margin: 0; font-size: 14px; color: var(--text-secondary); }
.oauth-mark { display: flex; flex: none; }

/* Quota windows */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 32px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 2px 0 0; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-quaternary); }
.section-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qw { --provider-accent: var(--codex); }
.qw .seg { padding: 3px; }
.qw .seg button { padding: 4px 12px; font-size: 12.5px; }
.qw .seg button[aria-pressed="true"] { border-color: var(--border-hover); font-weight: 550; box-shadow: none; }
.qw .scroll { margin-top: 16px; border-radius: 12px; }
.qw-grid { min-width: 720px; }
.qw-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); border-bottom: 1px solid var(--border-color); }
.qw-row:last-child { border-bottom: 0; }
.qw-row:not(.qw-headrow):hover { background: color-mix(in srgb, var(--text-primary) 2%, transparent); }
.qw-cred { display: grid; align-content: center; gap: 3px; min-width: 0; padding: 9px 12px; }
.qw-headrow .qw-cred { align-content: end; padding: 8px 12px; font-family: var(--font); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-quaternary); }
.qw-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.qw-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.qw-limit { justify-self: start; padding: 1px 6px; border-radius: 4px; background: var(--bg-tertiary); font-size: 10.5px; color: var(--text-quaternary); }
.qw-limit b { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.qw-cred > .muted { font-size: 11px; color: var(--text-quaternary); }
.qw-days { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.qw-days > div { display: grid; justify-items: center; gap: 1px; padding: 6px 2px; border-left: 1px solid var(--border-color); }
.qw-days span { min-height: 12px; font-size: 10px; color: var(--text-quaternary); }
.qw-days b { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-secondary); }
.qw-days .today { background: color-mix(in srgb, var(--text-primary) 3%, transparent); }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--provider-accent, var(--text-quaternary)); }
.chip {
  flex: none;
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--count-badge-bg);
  font-size: 10px;
  font-weight: 600;
  color: var(--primary-active);
}
.qw-track {
  position: relative;
  min-height: 46px;
  overflow: hidden;
  background: linear-gradient(to right, var(--border-color) 1px, transparent 1px) 0 0 / calc(100% / var(--cols)) 100%;
}
.qw-bar {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  overflow: hidden;
  transform: translateY(-50%);
  border: 1px solid transparent;
  border-radius: 9999px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-quaternary);
}
.qw-bar.current {
  border-color: color-mix(in srgb, var(--provider-accent) 45%, transparent);
  background: color-mix(in srgb, var(--provider-accent) 26%, transparent);
  color: var(--text-primary);
}
.qw-bar.elapsed { background: color-mix(in srgb, var(--provider-accent) 8%, transparent); }
.qw-bar.upcoming { border: 1px dashed color-mix(in srgb, var(--provider-accent) 32%, transparent); }
.qw-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--provider-accent) 34%, transparent); pointer-events: none; }
.qw-text { position: relative; overflow: hidden; text-overflow: ellipsis; }
.qw-now { position: absolute; top: 0; bottom: 0; z-index: 1; width: 1px; background: var(--text-tertiary); opacity: 0.8; }
.qw-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 16px 0 0; font-size: 11px; color: var(--text-quaternary); }
.qw-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.qw-legend > span:last-child { flex: 1 1 320px; min-width: 0; }
.sw { display: inline-block; width: 22px; height: 10px; border-radius: 9999px; }
.sw.current {
  border: 1px solid color-mix(in srgb, var(--text-tertiary) 50%, transparent);
  background: color-mix(in srgb, var(--text-tertiary) 34%, transparent);
}
.sw.upcoming { border: 1px dashed color-mix(in srgb, var(--text-tertiary) 45%, transparent); }
.sw.elapsed { background: color-mix(in srgb, var(--text-tertiary) 12%, transparent); }
.sw.now { width: 1px; height: 14px; border-radius: 0; background: var(--text-tertiary); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  button:active:not(:disabled), nav a:hover, button.primary:hover:not(:disabled) { transform: none; }
  .acct-actions button[aria-busy="true"] svg { animation: none; }
}
