:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #000000;
  --muted: var(--fg);
  --border: #000000;
  --card: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --fg: #ffffff;
  --border: #ffffff;
  --card: #000000;
}

* { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
a { color: inherit; }
button, select { font: inherit; padding: 6px 10px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); }
button { cursor: pointer; font-weight: 600; }
button:hover, button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
button:disabled { cursor: wait; border-style: dashed; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
svg { display: block; }
p, h1, h2 { margin: 0; }
h1 { font-size: 28px; font-weight: 700; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.appnav { display: flex; justify-content: space-between; align-items: stretch; border-bottom: 2px solid var(--border); }
.nav-links { display: flex; align-items: stretch; min-width: 0; }
.nav-section-links { display: flex; }
.nav-links a { display: flex; align-items: center; padding: 10px 16px; border-right: 1px solid var(--border); text-decoration: none; font-weight: 600; }
.nav-links a:hover, .nav-links .active { background: var(--fg); color: var(--bg); }
.nav-controls { display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.icon-toggle { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.icon-toggle svg { width: 18px; height: 18px; }
.mobile-brand, .mobile-overview { display: none; }
[data-theme="dark"] .theme-sun, :root:not([data-theme="dark"]) .theme-moon { display: none; }
.app-shell { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }
[data-align="left"] .app-shell { margin-left: 0; margin-right: auto; }
[data-align="right"] .app-shell { margin-left: auto; margin-right: 0; }
[data-align="fit"] .app-shell { max-width: none; }
.page-heading { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin: 16px 0 20px; }
.page-description { color: var(--muted); margin-top: 8px; }
.refresh-button { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.refresh-button svg { width: 18px; height: 18px; }
.refresh-button:disabled svg { animation: rotate 1.2s linear infinite; }
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.range-control { display: flex; }
.range-control button { font-weight: 600; white-space: nowrap; }
.range-control button + button { border-left: 0; }
.toolbar-end { display: flex; align-items: center; gap: 12px; }
.date-range { color: var(--muted); font-size: 12px; }
.day-navigation { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; margin-bottom: 16px; }
.day-navigation button { width: 44px; height: 44px; padding: 0; font-size: 20px; }
.day-navigation button:disabled { cursor: default; }
.day-navigation button:disabled:hover { background: var(--bg); color: var(--fg); }
#selected-day { text-align: center; font-weight: 600; }
.provider-control { display: flex; position: relative; align-items: center; }
.provider-control select { appearance: none; padding-right: 30px; cursor: pointer; }
.provider-control svg { width: 14px; height: 14px; position: absolute; right: 10px; pointer-events: none; }
.notice { white-space: pre-line; font-size: 12px; line-height: 1.6; border: 1px solid var(--border); border-left-width: 3px; margin-bottom: 16px; padding: 10px 12px; color: var(--muted); }
.notice.error { color: var(--fg); font-weight: 600; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); margin-bottom: 16px; }
.summary-item { padding: 16px; min-width: 0; }
.summary-item + .summary-item { border-left: 1px solid var(--border); }
.metric-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; text-transform: uppercase; font-weight: 600; }
.metric-value { font-size: 28px; font-weight: 700; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.metric-note { font-size: 12px; color: var(--muted); }
.unit-tag { border: 1px solid var(--border); padding: 0 4px; font-size: 10px; font-weight: 400; }
.cache-icon { width: 16px; height: 16px; }
.panel { min-width: 0; border: 1px solid var(--border); background: var(--card); scroll-margin-top: 16px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; }
.activity-panel { margin-bottom: 16px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend svg { width: 16px; height: 16px; outline: 1px solid var(--border); flex: none; }
.chart-container { padding: 10px 16px 16px; height: 300px; display: flex; flex-direction: column; justify-content: center; }
.chart-container.chart-hourly { height: 384px; }
.activity-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.chart-resolution { font-size: 11px; }
.usage-chart { width: 100%; height: 100%; overflow: visible; }
.chart-grid, .chart-cumulative-grid { stroke: var(--fg); stroke-width: 1; stroke-dasharray: 1 5; shape-rendering: crispEdges; vector-effect: non-scaling-stroke; }
.chart-label { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart-placeholder { display: flex; flex: 1; align-items: center; justify-content: center; text-align: center; flex-direction: column; gap: 8px; min-height: 190px; color: var(--muted); font-size: 14px; }
.chart-placeholder strong { font-weight: 600; color: var(--fg); }
.chart-placeholder p { max-width: 330px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.composition-bar { margin: 0 16px 12px; height: 16px; border: 1px solid var(--border); overflow: hidden; }
.composition-bar svg { width: 100%; height: 100%; }
.composition-divider { stroke: var(--fg); stroke-width: 1; vector-effect: non-scaling-stroke; shape-rendering: crispEdges; }
.composition-list { margin: 0; padding: 0 16px; }
.composition-list div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; }
.composition-list dt { display: flex; gap: 8px; align-items: center; }
.composition-list dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.type-dot { width: 16px; height: 16px; display: inline-block; border: 1px solid var(--border); flex: none; }
.texture-pattern { shape-rendering: crispEdges; }
.composition-note { padding: 12px 16px 16px; color: var(--muted); font-size: 12px; }
.source-list { display: grid; }
.source-item { display: flex; align-items: center; gap: 10px; margin: 0 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.source-item:first-child { border-top: 0; padding-top: 0; }
.source-item:last-child { padding-bottom: 16px; }
.source-content { flex: 1; min-width: 0; }
.source-name { font-size: 14px; font-weight: 600; }
.source-detail { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.source-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.source-status.ok { font-weight: 700; color: var(--fg); }
.source-status.error { font-weight: 700; color: var(--fg); text-decoration: underline; }
.source-placeholder { padding: 0 16px 16px; font-size: 14px; color: var(--muted); }
.provider-mark { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border: 1px solid var(--border); font-size: 14px; background: var(--bg); color: var(--fg); }
.source-item .provider-mark { display: none; }

.model-count { padding: 1px 8px; border: 1px solid var(--border); font-size: 12px; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { padding: 10px 12px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; }
td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
tbody tr:last-child td { border-bottom: 0; }
.numeric { text-align: right; }
.model-name { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.model-info { display: flex; flex-direction: column; }
.model-provider { color: var(--muted); font-size: 12px; font-weight: 400; }
.table-subtle { color: var(--muted); }
.table-total { font-weight: 700; }
.table-empty { padding: 24px; text-align: center; white-space: normal; color: var(--muted); font-size: 14px; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding-top: 16px; margin-top: 24px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.footer-status { display: flex; align-items: center; gap: 8px; }
.live-dot { height: 6px; width: 6px; border: 1px solid var(--border); }
.live-dot.connected { background: var(--fg); }
.live-dot.failed { background: var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 16px; padding: 10px; background: var(--fg); color: var(--bg); z-index: 30; }
.skip-link:focus { top: 12px; }
.noscript { padding: 16px; }

/* Phone layout follows usgraphics.com's framed page and always-visible navigation. */
@media (max-width: 720px) {
  :root { --paper-border: var(--fg); --paper-shadow: var(--fg); background: var(--bg); }
  body { margin: 24px 0; padding: 6px 12px 3px; border: 1px solid var(--paper-border); box-shadow: 2px 2px var(--paper-shadow); font-size: 13px; line-height: 1.5; }
  a, button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .appnav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; border: 0; margin-bottom: 22px; }
  .nav-links, .nav-section-links { display: contents; }
  .mobile-brand { display: flex; align-items: center; grid-column: 1 / 3; grid-row: 1; min-height: 44px; font-size: 17px; font-weight: 800; text-decoration: none; }
  .desktop-brand { display: none; }
  .mobile-overview { display: inline; }
  .nav-controls { grid-column: 3; grid-row: 1; justify-content: flex-end; padding: 0; gap: 4px; }
  .icon-toggle { width: 44px; height: 44px; border-color: var(--paper-border); }
  .nav-links a { grid-row: 2; min-height: 44px; justify-content: center; padding: 8px 4px; border: 1px solid var(--border); box-shadow: 2px 2px var(--paper-shadow); font-size: 13px; font-weight: 400; }
  .nav-links > a { grid-column: 1; }
  .nav-section-links a:first-child { grid-column: 2; }
  .nav-section-links a:last-child { grid-column: 3; }
  .nav-links .active { background: var(--bg); color: var(--fg); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
  .nav-links a:hover { background: var(--fg); color: var(--bg); }
  #main, #model-heading, #sources-heading { scroll-margin-top: 12px; }
  .app-shell { padding: 0 0 24px; }
  .page-heading { align-items: flex-start; gap: 12px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px dotted var(--paper-border); }
  .page-heading > div { min-width: 0; }
  h1 { font-size: 20px; }
  h2 { font-size: 14px; text-transform: none; letter-spacing: 0; }
  .page-description { font-size: 12px; margin-top: 6px; }
  .refresh-button { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .refresh-button span { display: none; }
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .range-control { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .range-control button { min-height: 44px; padding: 8px 4px; font-size: 13px; }
  .toolbar-end { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .provider-control { order: -1; min-width: 0; }
  .provider-control select { width: 100%; min-height: 44px; font-size: 16px; }
  .date-range { text-align: left; font-size: 11px; }
  .notice { overflow-wrap: anywhere; font-size: 11px; padding: 8px; border-color: var(--paper-border); }
  .summary, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .summary { border-color: var(--paper-border); box-shadow: 2px 2px var(--paper-shadow); margin-bottom: 24px; }
  .summary-item { padding: 8px; }
  .summary-item + .summary-item { border-left: 0; border-top: 1px solid var(--paper-border); }
  .metric-label { gap: 6px; font-size: 11px; text-transform: none; }
  .metric-value { font-size: clamp(22px, 6vw, 26px); line-height: 1.2; margin: 5px 0 4px; overflow-wrap: anywhere; }
  .metric-note { font-size: 11px; }
  .summary-primary .metric-value { font-size: 30px; }
  .panel { border: 0; }
  .panel-heading { flex-wrap: wrap; padding: 0; margin-bottom: 12px; gap: 6px; }
  .panel-heading::after { content: ""; flex: 0 0 100%; height: 6px; background-image: radial-gradient(var(--paper-border) .65px, transparent .65px); background-size: 3px 3px; }
  .activity-panel { margin-bottom: 24px; }
  .activity-panel .panel-heading { align-items: flex-start; }
  .activity-panel h2 { flex-basis: 100%; }
  .legend { justify-content: flex-start; font-size: 11px; }
  .chart-container { height: 284px; padding: 4px 0 10px; }
  .chart-container.chart-hourly { height: 368px; }
  .detail-grid { gap: 24px; margin-bottom: 24px; }
  .composition-bar { margin: 0 0 8px; height: 12px; border-color: var(--paper-border); }
  .composition-list { padding: 0; border: 1px solid var(--paper-border); box-shadow: 2px 2px var(--paper-shadow); }
  .composition-list div { padding: 5px 8px; }
  .composition-list div + div { border-top: 1px solid var(--paper-border); }
  .composition-note { padding: 8px 0 0; font-size: 11px; }
  .source-list { border: 1px solid var(--paper-border); box-shadow: 2px 2px var(--paper-shadow); }
  .source-item { margin: 0; padding: 8px; border-color: var(--paper-border); }
  .source-item:first-child, .source-item:last-child { padding: 8px; }
  .source-name { font-size: 13px; }
  .source-detail, .source-status { font-size: 11px; }
  .source-placeholder { padding: 8px; }
  .model-count { font-size: 11px; border-color: var(--paper-border); }
  .table-scroll { overflow: visible; border: 1px solid var(--paper-border); box-shadow: 2px 2px var(--paper-shadow); }
  table, tbody { display: block; white-space: normal; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 6px; }
  tbody tr + tr { border-top: 1px solid var(--paper-border); }
  td, th:first-child, td:first-child, th:last-child, td:last-child { padding: 6px 8px; }
  td { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; border: 0; text-align: left; overflow-wrap: anywhere; font-size: 12px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 400; }
  td:first-child { grid-column: 1 / -1; padding-top: 10px; padding-bottom: 6px; }
  td:first-child::before, .table-empty::before { display: none; }
  td:nth-child(5), td:nth-child(6) { grid-row: 2; font-size: 18px; font-weight: 700; }
  td:nth-child(4) { grid-column: 1 / -1; }
  .model-name { align-items: flex-start; min-width: 0; font-size: 13px; }
  .model-info { min-width: 0; }
  .model-provider { font-size: 11px; }
  .provider-mark { width: 24px; height: 24px; font-size: 12px; }
  .table-empty { grid-column: 1 / -1; padding: 16px 8px; align-items: center; text-align: center; }
  .footer { flex-direction: column; margin-top: 24px; padding-top: 12px; gap: 4px; border-color: var(--paper-border); font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
@keyframes rotate { to { transform: rotate(360deg); } }
