:root {
  --bg-white: #ffffff;
  --bg-subtle: #f5f5f7;
  --ink-black: #1d1d1f;
  --ink-body: #3a3a3c;
  --ink-muted: #6e6e73;
  --rule-light: #e5e5ea;
  --rule-strong: #d2d2d7;

  /* 4 Provider Identities */
  --agy-primary: #0066cc;
  --agy-ink: #004080;
  --agy-surface: #f0f7ff;
  --agy-border: #bdd9f8;

  --codex-primary: #0a7e56;
  --codex-ink: #065338;
  --codex-surface: #effaf5;
  --codex-border: #b6e6d3;

  --claude-primary: #d45500;
  --claude-ink: #963b00;
  --claude-surface: #fff5ee;
  --claude-border: #f6c9a8;

  --cursor-primary: #6434e9;
  --cursor-ink: #461fb5;
  --cursor-surface: #f5f1ff;
  --cursor-border: #d4c4fc;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-white);
  color: var(--ink-black);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* Sticky Minimal Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--rule-light);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--ink-black);
  color: var(--bg-white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.seg-group {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--rule-light);
  gap: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-muted);
  cursor: pointer;
}

.seg-btn.active {
  background: var(--ink-black);
  color: var(--bg-white);
  font-weight: 600;
}

.outline-btn {
  border: 1px solid var(--rule-strong);
  background: var(--bg-white);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}

.outline-btn.active {
  background: var(--ink-black);
  color: var(--bg-white);
  border-color: var(--ink-black);
}

/* Custom Price Bar */
.custom-price-bar {
  background: var(--bg-subtle);
  border-top: 1px solid var(--rule-light);
}

.custom-price-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.price-inputs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.price-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-white);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
}

.price-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.price-chip .currency {
  color: var(--ink-muted);
  margin-left: 2px;
}

.price-chip input {
  width: 52px;
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  outline: none;
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* Main Shell */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 72px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Compact 1-Line Winner Strip */
.winner-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--rule-light);
}

.winner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.winner-tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bg-white);
  background: var(--ink-black);
}

.winner-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.winner-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-muted);
}

.winner-metrics strong {
  color: var(--ink-black);
}

/* 4 Colored Provider Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.provider-card {
  border-radius: 16px;
  padding: 18px;
  border: 1.5px solid var(--rule-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease;
}

.provider-card:hover {
  transform: translateY(-2px);
}

.provider-card[data-provider="antigravity"] {
  background: var(--agy-surface);
  border-color: var(--agy-border);
  --p-color: var(--agy-primary);
  --p-ink: var(--agy-ink);
}

.provider-card[data-provider="codex"] {
  background: var(--codex-surface);
  border-color: var(--codex-border);
  --p-color: var(--codex-primary);
  --p-ink: var(--codex-ink);
}

.provider-card[data-provider="claude"] {
  background: var(--claude-surface);
  border-color: var(--claude-border);
  --p-color: var(--claude-primary);
  --p-ink: var(--claude-ink);
}

.provider-card[data-provider="cursor"] {
  background: var(--cursor-surface);
  border-color: var(--cursor-border);
  --p-color: var(--cursor-primary);
  --p-ink: var(--cursor-ink);
}

.provider-card.is-selected {
  box-shadow: 0 0 0 2px var(--ink-black);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-provider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--p-color);
}

.card-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}

.rank-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.85);
  color: var(--p-ink);
  border: 1px solid rgba(0, 0, 0, 0.07);
}

.rank-badge.is-winner {
  background: var(--ink-black);
  color: var(--bg-white);
  border-color: var(--ink-black);
}

.card-hero {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-big-num {
  font-size: 32px;
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1;
}

.card-big-num small {
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-muted);
  margin-left: 2px;
}

.card-mult {
  font-size: 15px;
  font-weight: 750;
  color: var(--p-ink);
}

.card-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.mini-kpi {
  display: flex;
  flex-direction: column;
}

.mini-kpi span {
  font-size: 11px;
  color: var(--ink-muted);
}

.mini-kpi strong {
  font-size: 13px;
  font-weight: 680;
  margin-top: 1px;
}

.drift-neg {
  color: #b91c1c;
}

.drift-pos {
  color: #065f46;
}

/* Structured Panels */
.panel {
  border: 1px solid var(--rule-light);
  border-radius: 16px;
  background: var(--bg-white);
  overflow: hidden;
}

.panel-head {
  padding: 14px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--rule-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.panel-hint {
  font-size: 12px;
  color: var(--ink-muted);
}

.chart-body {
  padding: 20px 20px 14px;
}

.chart-wrap {
  width: 100%;
  min-height: 310px;
}

/* Matrix Table */
.table-scroll {
  overflow-x: auto;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.matrix-table th {
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--rule-light);
  background: var(--bg-white);
  white-space: nowrap;
}

.matrix-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule-light);
  vertical-align: middle;
  white-space: nowrap;
}

.matrix-table tbody tr {
  cursor: pointer;
}

.matrix-table tbody tr:hover {
  background: var(--bg-subtle);
}

.matrix-table tbody tr:last-child td {
  border-bottom: none;
}

.provider-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 12px;
}

.provider-pill[data-provider="antigravity"] {
  background: var(--agy-surface);
  color: var(--agy-ink);
  border: 1px solid var(--agy-border);
}

.provider-pill[data-provider="codex"] {
  background: var(--codex-surface);
  color: var(--codex-ink);
  border: 1px solid var(--codex-border);
}

.provider-pill[data-provider="claude"] {
  background: var(--claude-surface);
  color: var(--claude-ink);
  border: 1px solid var(--claude-border);
}

.provider-pill[data-provider="cursor"] {
  background: var(--cursor-surface);
  color: var(--cursor-ink);
  border: 1px solid var(--cursor-border);
}

.tag-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid var(--rule-light);
}

.tag-chip.neg {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* Inspection Drawer */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(29, 29, 31, 0.32);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: min(480px, 100vw);
  height: 100vh;
  background: var(--bg-white);
  border-left: 1px solid var(--rule-light);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-light);
}

.drawer-title {
  margin: 6px 0 2px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.drawer-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.icon-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--rule-light);
  background: var(--bg-subtle);
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.d-box {
  background: var(--bg-subtle);
  border: 1px solid var(--rule-light);
  border-radius: 12px;
  padding: 14px;
}

.d-box h3 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-muted);
}

.d-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.d-stat {
  display: flex;
  flex-direction: column;
}

.d-stat span {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.d-stat strong {
  font-size: 15px;
  font-weight: 700;
  margin-top: 1px;
}

.score-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-bar-item {
  display: grid;
  grid-template-columns: 110px 1fr 38px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.score-track {
  height: 7px;
  background: var(--rule-light);
  border-radius: 999px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 999px;
}

.svg-interactive {
  cursor: pointer;
}

.svg-interactive:hover {
  opacity: 0.86;
}

@media (max-width: 920px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}
