:root {
  color-scheme: dark;
  --bg: #080c12;
  --panel: #111823;
  --panel-soft: #151e2a;
  --line: #263244;
  --line-strong: #35445a;
  --text: #f2f5f8;
  --muted: #91a0b4;
  --blue: #78a8ff;
  --cyan: #46d7c5;
  --green: #3edc98;
  --amber: #f2bb55;
  --red: #ff707b;
  --claude: #ef9465;
  --codex: #78a8ff;
  --radius: 17px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 16% -8%, #16243a 0, transparent 34rem), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .5; }
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.shell { width: min(1500px, calc(100% - 44px)); margin: 0 auto; padding: 34px 0 26px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 11px; font-weight: 850; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(30px, 4vw, 48px); line-height: 1.04; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.025em; }
h3 { margin: 0; font-size: 17px; }
.muted { color: var(--muted); }

.login-card { width: min(460px, 100%); margin: 9vh auto 0; padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgba(17, 24, 35, .96); box-shadow: 0 28px 80px rgba(0, 0, 0, .38); }
.brand-mark { display: grid; width: 48px; height: 48px; margin-bottom: 28px; place-items: center; border-radius: 14px; background: linear-gradient(145deg, var(--blue), var(--cyan)); color: #071019; font-weight: 900; }
.login-card h1 { font-size: 33px; }
.login-card form { display: grid; gap: 10px; margin-top: 27px; }
.login-card button { margin-top: 13px; }
.form-error { min-height: 20px; margin: 3px 0 0; color: var(--red); }

label { color: #c8d1dd; font-size: 12px; font-weight: 750; }
input, select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #0b1119; color: var(--text); }
button { min-height: 42px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--blue); color: #08111d; font-weight: 820; }
button.secondary { border: 1px solid var(--line); background: var(--panel-soft); color: var(--text); }
button.ghost { border: 1px solid var(--line); background: transparent; color: var(--muted); }
button.text-button { min-height: 36px; padding: 0; background: transparent; color: var(--blue); }

.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.topbar .muted { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.view-tabs { display: inline-flex; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #0b1119; }
.view-tab { min-height: 38px; background: transparent; color: var(--muted); }
.view-tab.active { background: var(--panel-soft); color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, .23); }

.filters { position: sticky; z-index: 8; top: 0; display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: rgba(12, 18, 27, .94); box-shadow: 0 10px 30px rgba(0, 0, 0, .16); backdrop-filter: blur(14px); }
.preset-group { display: inline-flex; flex-shrink: 0; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #080e15; }
.preset { min-height: 34px; padding: 0 12px; background: transparent; color: var(--muted); font-size: 12px; }
.preset.active { background: #213149; color: #dce9ff; }
.date-range { display: flex; align-items: center; gap: 7px; }
.date-range input { width: 138px; min-height: 38px; font-size: 12px; }
.date-range span { color: var(--muted); font-size: 12px; }
.toolbar-main { display: flex; min-width: 0; align-items: center; gap: 10px; margin-left: auto; }
.toolbar-main > select { width: 138px; min-height: 38px; font-size: 12px; }
.filter-drawer { position: relative; }
.filter-drawer summary { display: flex; min-height: 38px; padding: 0 13px; align-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 12px; font-weight: 750; cursor: pointer; list-style: none; }
.filter-drawer summary::-webkit-details-marker { display: none; }
.filter-drawer[open] summary { border-color: var(--blue); }
.filter-grid { position: absolute; top: calc(100% + 9px); right: 0; display: grid; width: 330px; grid-template-columns: 92px 1fr; gap: 9px 10px; align-items: center; padding: 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: #101721; box-shadow: 0 22px 55px rgba(0, 0, 0, .45); }
.filter-grid select { width: 100%; min-width: 0; }
.filter-grid button { min-height: 38px; }
.range-line { min-height: 24px; margin: 8px 0 14px; color: var(--green); font-size: 12px; font-weight: 700; }
.notice { margin: 0 0 14px; padding: 13px 15px; border: 1px solid rgba(242, 187, 85, .45); border-radius: 11px; background: rgba(242, 187, 85, .09); color: #ffd789; }
.notice.error { border-color: rgba(255, 112, 123, .5); background: rgba(255, 112, 123, .09); color: #ffa7af; }

.metrics { display: grid; grid-template-columns: 1.16fr repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.metric { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(155deg, rgba(20, 29, 41, .98), rgba(13, 18, 26, .98)); }
.metric.primary { border-color: rgba(120, 168, 255, .42); background: linear-gradient(150deg, rgba(31, 51, 80, .96), rgba(15, 23, 34, .98)); }
.metric.warning-card { border-color: rgba(242, 187, 85, .42); }
.metric span { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 760; }
.metric strong { display: block; overflow: hidden; margin-bottom: 6px; font-size: clamp(24px, 2.7vw, 34px); font-variant-numeric: tabular-nums; letter-spacing: -.04em; text-overflow: ellipsis; }
.metric small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.dashboard-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.hero-grid { grid-template-columns: minmax(0, 2fr) minmax(290px, .75fr); }
.rank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17, 24, 35, .92); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-head .eyebrow { margin-bottom: 6px; }
.panel-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: 11px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.legend-dot.claude { background: var(--claude); }
.legend-dot.codex { background: var(--codex); }

.trend-chart { display: grid; min-height: 210px; grid-auto-columns: minmax(24px, 1fr); grid-auto-flow: column; gap: 7px; align-items: end; overflow-x: auto; padding: 4px 2px 2px; }
.trend-column { display: grid; min-width: 24px; grid-template-rows: 176px 24px; align-items: end; gap: 5px; }
.trend-stack { display: flex; width: min(100%, 32px); height: 170px; margin: 0 auto; flex-direction: column-reverse; justify-content: flex-start; overflow: hidden; border-bottom: 1px solid var(--line-strong); border-radius: 5px 5px 2px 2px; }
.trend-segment { width: 100%; min-height: 0; background: #627087; transition: opacity .15s ease; }
.trend-segment:hover, .trend-stack:focus-visible .trend-segment { opacity: .82; }
.trend-segment.claude { background: var(--claude); }
.trend-segment.codex { background: var(--codex); }
.trend-segment.scale-0 { height: 0; }
.trend-segment.scale-1 { height: 5%; }
.trend-segment.scale-2 { height: 10%; }
.trend-segment.scale-3 { height: 15%; }
.trend-segment.scale-4 { height: 20%; }
.trend-segment.scale-5 { height: 25%; }
.trend-segment.scale-6 { height: 30%; }
.trend-segment.scale-7 { height: 35%; }
.trend-segment.scale-8 { height: 40%; }
.trend-segment.scale-9 { height: 45%; }
.trend-segment.scale-10 { height: 50%; }
.trend-segment.scale-11 { height: 55%; }
.trend-segment.scale-12 { height: 60%; }
.trend-segment.scale-13 { height: 65%; }
.trend-segment.scale-14 { height: 70%; }
.trend-segment.scale-15 { height: 75%; }
.trend-segment.scale-16 { height: 80%; }
.trend-segment.scale-17 { height: 85%; }
.trend-segment.scale-18 { height: 90%; }
.trend-segment.scale-19 { height: 95%; }
.trend-segment.scale-20 { height: 100%; }
.trend-label { overflow: hidden; color: #708096; font-size: 9px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.quality-list { display: grid; gap: 9px; }
.quality-item { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #0d141d; }
.quality-icon { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(62, 220, 152, .1); }
.quality-item.warning .quality-icon { background: var(--amber); box-shadow: 0 0 0 4px rgba(242, 187, 85, .1); }
.quality-item.error .quality-icon { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 112, 123, .1); }
.quality-item strong, .quality-item small { display: block; }
.quality-item strong { margin-bottom: 3px; font-size: 12px; }
.quality-item small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.status-badge { padding: 6px 9px; border-radius: 999px; background: rgba(145, 160, 180, .12); color: var(--muted); font-size: 10px; font-weight: 800; }
.status-badge.good { background: rgba(62, 220, 152, .12); color: var(--green); }
.status-badge.warning { background: rgba(242, 187, 85, .12); color: var(--amber); }
.status-badge.error { background: rgba(255, 112, 123, .12); color: var(--red); }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #0a1018; }
.segmented button { min-height: 30px; padding: 0 9px; background: transparent; color: var(--muted); font-size: 10px; }
.segmented button.active { background: var(--panel-soft); color: var(--text); }
.rank-list { display: grid; gap: 9px; }
.rank-row { display: block; width: 100%; min-height: 0; padding: 10px 11px; border: 1px solid transparent; background: #0d141d; color: var(--text); text-align: left; }
button.rank-row:hover { border-color: var(--line-strong); background: #111a26; }
.rank-row.static { cursor: default; }
.rank-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 8px; }
.rank-identity { min-width: 0; }
.rank-identity strong, .rank-identity small, .rank-value strong, .rank-value small { display: block; }
.rank-identity strong { overflow: hidden; margin-bottom: 3px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.rank-identity small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { flex: 0 0 auto; text-align: right; }
.rank-value strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.rank-value small { color: var(--muted); font-size: 9px; }
.bar-track { height: 5px; overflow: hidden; border-radius: 999px; background: #202b39; }
.bar-fill { height: 100%; border-radius: inherit; background: #687992; }
.bar-fill.claude { background: var(--claude); }
.bar-fill.codex { background: var(--codex); }
.bar-fill.scale-0 { width: 0; }
.bar-fill.scale-1 { width: 5%; }
.bar-fill.scale-2 { width: 10%; }
.bar-fill.scale-3 { width: 15%; }
.bar-fill.scale-4 { width: 20%; }
.bar-fill.scale-5 { width: 25%; }
.bar-fill.scale-6 { width: 30%; }
.bar-fill.scale-7 { width: 35%; }
.bar-fill.scale-8 { width: 40%; }
.bar-fill.scale-9 { width: 45%; }
.bar-fill.scale-10 { width: 50%; }
.bar-fill.scale-11 { width: 55%; }
.bar-fill.scale-12 { width: 60%; }
.bar-fill.scale-13 { width: 65%; }
.bar-fill.scale-14 { width: 70%; }
.bar-fill.scale-15 { width: 75%; }
.bar-fill.scale-16 { width: 80%; }
.bar-fill.scale-17 { width: 85%; }
.bar-fill.scale-18 { width: 90%; }
.bar-fill.scale-19 { width: 95%; }
.bar-fill.scale-20 { width: 100%; }
.rank-list.detailed .rank-row { padding: 13px; }
.compact-list { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.downstream-summary-panel { margin-bottom: 20px; }
.account-trend-panel { margin-bottom: 14px; }
.account-trend-panel .panel-head > span { font-size: 10px; }
.compact-trend { min-height: 160px; }
.compact-trend .trend-column { grid-template-rows: 128px 22px; }
.compact-trend .trend-stack { height: 124px; }
.empty { padding: 25px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }

.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 28px 1px 15px; }
.section-title p:last-child { max-width: 600px; margin: 0; color: var(--muted); font-size: 12px; text-align: right; }

.details-panel { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17, 24, 35, .9); }
.details-panel > summary { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 20px; padding: 0 20px; cursor: pointer; list-style: none; }
.details-panel > summary::-webkit-details-marker { display: none; }
.details-panel > summary span { display: flex; align-items: baseline; gap: 10px; }
.details-panel > summary small, .details-panel > summary > span:last-child { color: var(--muted); font-size: 11px; }
.details-panel[open] > summary { border-bottom: 1px solid var(--line); }
.details-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 13px 18px 0; color: var(--muted); font-size: 11px; }
.details-toolbar select { min-height: 36px; }
.details-toolbar button { min-height: 36px; }
.table-wrap { max-height: 620px; overflow: auto; margin: 13px 18px 18px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; z-index: 2; top: 0; background: #111823; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
th button { min-height: 28px; padding: 0; background: transparent; color: inherit; font-size: inherit; text-transform: inherit; }
th button:hover { color: var(--text); }
td { font-size: 11px; }
th.number, td.number { text-align: right; font-variant-numeric: tabular-nums; }
.provider-badge { display: inline-flex; padding: 3px 7px; border-radius: 999px; background: rgba(120, 168, 255, .12); color: var(--blue); font-size: 9px; font-weight: 800; }
.provider-badge.claude { background: rgba(239, 148, 101, .12); color: var(--claude); }
.warning-text { color: var(--amber); }
.error-text { color: var(--red); }
.empty-cell { padding: 35px; color: var(--muted); text-align: center; }

footer { display: flex; justify-content: space-between; gap: 18px; padding: 20px 2px 0; color: #68778b; font-size: 10px; }
.loading .metrics, .loading .view-panel, .loading .details-panel { opacity: .68; }

@media (max-width: 1180px) {
  .filters { align-items: flex-start; flex-wrap: wrap; }
  .toolbar-main { width: 100%; justify-content: flex-end; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .hero-grid { grid-template-columns: minmax(0, 1.5fr) minmax(270px, .8fr); }
}

@media (max-width: 860px) {
  .shell { width: min(100% - 28px, 1500px); padding-top: 26px; }
  .topbar, .section-title { align-items: flex-start; flex-direction: column; }
  .section-title p:last-child { text-align: left; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  .view-tabs { display: flex; }
  .view-tab { flex: 1; padding: 0 10px; }
  .preset-group { width: 100%; overflow-x: auto; }
  .preset { flex: 1 0 auto; }
  .date-range { width: 100%; }
  .date-range input { flex: 1; width: auto; }
  .toolbar-main { justify-content: space-between; }
  .filter-grid { right: 0; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric.primary { grid-column: 1 / -1; }
  .hero-grid, .rank-grid { grid-template-columns: 1fr; }
  .quality-panel { order: -1; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1500px); padding-top: 18px; }
  h1 { font-size: 31px; }
  .topbar { margin-bottom: 18px; }
  .view-tabs { width: 100%; overflow-x: auto; }
  .view-tab { flex: 1 0 auto; font-size: 11px; }
  .filters { position: static; gap: 9px; padding: 10px; }
  .toolbar-main { align-items: stretch; flex-direction: column; }
  .toolbar-main > select, .filter-drawer, .filter-drawer summary { width: 100%; }
  .filter-grid { position: static; width: 100%; grid-template-columns: 1fr; margin-top: 9px; box-shadow: none; }
  .metrics { grid-template-columns: 1fr; }
  .metric.primary { grid-column: auto; }
  .panel { padding: 15px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .trend-chart { min-height: 190px; }
  .trend-column { grid-template-rows: 155px 24px; }
  .trend-stack { height: 150px; }
  .rank-heading { gap: 8px; }
  .rank-identity small { max-width: 220px; }
  .details-panel > summary { align-items: flex-start; flex-direction: column; justify-content: center; }
  .details-panel > summary span { display: block; }
  .details-panel > summary small { margin-left: 7px; }
  .details-toolbar { align-items: stretch; flex-wrap: wrap; justify-content: flex-start; }
  .table-wrap { margin: 10px; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
