:root {
  color-scheme: dark;
  font-family: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  --bg: #0b1013;
  --bg-soft: #0e161a;
  --surface: #111a1e;
  --surface-raised: #16232a;
  --surface-hover: #1b2f37;
  --surface-selected: #1e3f4a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e2ecef;
  --muted: #8ba0a8;
  --soft: #adc0c6;
  --accent: #7fd4e6;
  --accent-ink: #06222b;
  --good: #74d69d;
  --warn: #f2c078;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, "Liberation Mono", monospace;
  --shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 6px 18px rgba(0, 0, 0, 0.35);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  text-wrap: pretty;
}

h1, h2, h3 { text-wrap: balance; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 30;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
  transition: top 160ms var(--ease);
}
.skip-link:focus-visible { top: 12px; }

.app-shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "topbar topbar" "sidebar content";
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.app-shell > * { min-height: 0; min-width: 0; }

.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(11, 16, 19, 0.86);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 -1px 0 var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(160deg, #2b6b7c, #14343d);
  box-shadow: var(--shadow-1);
  font-weight: 700;
  font-size: 15px;
  color: #cdf0f8;
  padding-bottom: 1px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; letter-spacing: -0.01em; }
.eyebrow {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-search { flex: 1 1 320px; max-width: 460px; min-width: 0; }
.status {
  margin: 0;
  flex: 0 1 auto;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.status.is-warning { color: var(--warn); }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 140ms var(--ease);
}
.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 30px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: box-shadow 140ms var(--ease), background 140ms var(--ease);
}
.search-wrap input::placeholder { color: #6f858d; }
.search-wrap input:hover { background: var(--surface-raised); }
.search-wrap:focus-within svg { stroke: var(--accent); }
.search-wrap.compact input { padding-block: 6px; font-size: 12px; }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.6); }

.filters-toggle {
  display: none;
  padding: 7px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: 12px;
  font-weight: 600;
  transition: scale 120ms var(--ease), background 140ms var(--ease);
}
.filters-toggle:active { scale: 0.96; }

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--bg-soft);
  box-shadow: inset -1px 0 0 var(--line);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
}
.panel-head h2 {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--soft);
}
.panel-badge {
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.panel-note {
  margin: 0;
  color: var(--soft);
  font-size: 11px;
  line-height: 1.5;
}
.panel-note.subtle { color: var(--muted); font-size: 10.5px; }

.ghost-button {
  padding: 3px 8px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 140ms var(--ease), background 140ms var(--ease), scale 120ms var(--ease);
}
.ghost-button:hover { color: var(--text); background: var(--surface-hover); }
.ghost-button:active { scale: 0.96; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.28);
}
.segment {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px;
  border-radius: 7px;
  text-align: left;
  transition: background 160ms var(--ease), box-shadow 160ms var(--ease), scale 120ms var(--ease);
}
.segment:hover { background: var(--surface-hover); }
.segment:active { scale: 0.97; }
.segment[aria-checked="true"] {
  background: var(--surface-selected);
  box-shadow: 0 0 0 1px rgba(127, 212, 230, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}
.segment-label { font-size: 12px; font-weight: 650; }
.segment[aria-checked="true"] .segment-label { color: #d6f4fb; }
.segment-hint { color: var(--muted); font-size: 10px; line-height: 1.3; }

.provider-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.provider-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
  font-size: 11.5px;
  transition: background 140ms var(--ease), box-shadow 140ms var(--ease), color 140ms var(--ease), scale 120ms var(--ease);
}
.provider-button span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.provider-button:hover { background: var(--surface-hover); box-shadow: var(--shadow-2); }
.provider-button:active { scale: 0.96; }
.provider-button.is-selected {
  background: var(--surface-selected);
  color: #d6f4fb;
  box-shadow: 0 0 0 1px rgba(127, 212, 230, 0.45);
}
.provider-button.is-selected span { color: #a6dbe8; }

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 2px;
  cursor: pointer;
  min-height: 26px;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  position: relative;
  flex: none;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 160ms var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #cfdde1;
  transition: translate 180ms var(--ease), background 160ms var(--ease);
}
.switch input:checked + .switch-track { background: rgba(127, 212, 230, 0.55); }
.switch input:checked + .switch-track::after { translate: 13px 0; background: #eefaff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { font-size: 12px; color: var(--soft); }
.switch:hover .switch-text { color: var(--text); }

.group-panel { transition: opacity 180ms var(--ease); }
.group-panel.is-dimmed { opacity: 0.62; }

.group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.group-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--surface-raised);
  text-align: left;
  transition: background 140ms var(--ease), box-shadow 140ms var(--ease), scale 120ms var(--ease);
}
.group-option:hover { background: var(--surface-hover); }
.group-option:active { scale: 0.98; }
.group-option.is-selected {
  background: var(--surface-selected);
  box-shadow: 0 0 0 1px rgba(127, 212, 230, 0.45);
}
.group-option-name {
  font-family: var(--mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}
.group-option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.group-ratio {
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-family: var(--mono);
  color: var(--soft);
}
.group-ratio.is-cheapest { background: rgba(116, 214, 157, 0.16); color: var(--good); }
.group-count { font-family: var(--mono); }
.group-override-count { color: var(--warn); }

.secondary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
  font-size: 11.5px;
  font-weight: 600;
  text-align: left;
  transition: background 140ms var(--ease), box-shadow 140ms var(--ease), scale 120ms var(--ease);
}
.secondary-button:hover { background: var(--surface-hover); box-shadow: var(--shadow-2); }
.secondary-button:active { scale: 0.96; }
.secondary-button[disabled] { opacity: 0.55; cursor: progress; }

.content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 16px 20px 28px;
}

.table-surface {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.table-summary {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  box-shadow: inset 0 -1px 0 var(--line);
}
.table-summary h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.table-summary h3 span { color: var(--accent); }
.price-unit {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 12px;
  background: #131e23;
  box-shadow: inset 0 -1px 0 var(--line);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
thead th.number { text-align: right; }
tbody td {
  padding: 7px 12px;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.045);
  vertical-align: middle;
}
tbody tr { transition: background 120ms var(--ease); }
tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
tbody td.number { text-align: right; }

.model-name {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.provider-tag {
  display: inline-block;
  padding: 1.5px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 10.5px;
  white-space: nowrap;
}
.provider-tag.openai { background: rgba(116, 214, 157, 0.14); color: #93e0b5; }
.provider-tag.anthropic { background: rgba(242, 192, 120, 0.14); color: #f0cd96; }
.provider-tag.grok { background: rgba(255, 255, 255, 0.1); color: #d8e4e8; }
.provider-tag.gemini { background: rgba(127, 212, 230, 0.14); color: #a8e2f0; }
.release-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--soft);
  white-space: nowrap;
}
.muted-value { color: #63787f; }
.number {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.group-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  cursor: help;
}
.winning-group {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--soft);
  overflow-wrap: anywhere;
}
.multiplier-badge {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--soft);
  white-space: nowrap;
}
.multiplier-badge.is-override { background: rgba(242, 192, 120, 0.16); color: var(--warn); }

.empty-state {
  margin: 0;
  padding: 28px 14px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "topbar" "sidebar" "content";
    height: auto;
    overflow: visible;
  }
  .topbar { flex-wrap: wrap; gap: 10px 12px; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .status { order: 4; flex-basis: 100%; text-align: left; }
  .filters-toggle { display: block; margin-left: auto; }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    box-shadow: inset 0 -1px 0 var(--line);
  }
  .sidebar:not(.is-open) { display: none; }
  .content { overflow: visible; }
  .table-surface { flex: 0 0 auto; }
  .table-wrap { max-height: none; overflow-x: auto; }
}

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