:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #eef4f3;
  --ink: #172026;
  --muted: #65727b;
  --border: #dce2e6;
  --accent: #187a6d;
  --accent-2: #225c9a;
  --warm: #ba5b2c;
  --danger: #b23a48;
  --good: #1f7a4f;
  --shadow: 0 18px 44px rgba(28, 38, 47, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(24, 122, 109, 0.1), transparent 340px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid rgba(220, 226, 230, 0.75);
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 36px) 40px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.refresh-status {
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
}

.icon-button {
  padding: 0 14px;
  box-shadow: 0 6px 18px rgba(28, 38, 47, 0.08);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.score-panel,
.leaderboard,
.source-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.score-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.9fr);
  gap: 24px;
  padding: 24px;
}

.score-copy h2 {
  margin: 8px 0 12px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
}

.muted {
  color: var(--muted);
}

.score-meter {
  align-self: center;
}

.meter-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), #d9b84f 50%, var(--danger));
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.15);
}

.meter-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 8px;
  background: var(--ink);
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.meta-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.warning-strip {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border: 1px solid rgba(186, 91, 44, 0.3);
  border-radius: 8px;
  color: #7a3c1d;
  background: rgba(186, 91, 44, 0.1);
  font-size: 13px;
  line-height: 1.45;
}

.score-explain {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(34, 92, 154, 0.18);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(34, 92, 154, 0.07);
  font-size: 13px;
  line-height: 1.5;
}

.meta-grid div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.meta-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.dimension-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dimension-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
}

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

.dimension-card strong {
  font-size: 18px;
}

.dimension-card span,
.dimension-card p {
  display: block;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.dimension-card.pressure-up {
  border-left-color: var(--danger);
}

.dimension-card.pressure-up strong {
  color: var(--danger);
}

.dimension-card.pressure-down {
  border-left-color: var(--good);
}

.dimension-card.pressure-down strong {
  color: var(--good);
}

.leaderboard {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.small-copy {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.driver-list {
  display: grid;
  gap: 10px;
}

.driver {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 0 10px 10px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
}

.driver:last-child {
  border-bottom: 0;
}

.driver span {
  color: var(--muted);
  font-size: 12px;
}

.driver strong {
  font-size: 14px;
}

.driver.pressure-up {
  border-left-color: var(--danger);
}

.driver.pressure-up > strong {
  color: var(--danger);
}

.driver.pressure-down {
  border-left-color: var(--good);
}

.driver.pressure-down > strong {
  color: var(--good);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 24px 0 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  padding: 0 16px;
  white-space: nowrap;
}

.tab.active {
  border-color: rgba(24, 122, 109, 0.55);
  color: #fff;
  background: var(--accent);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.chart-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

select {
  min-height: 36px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.card-section {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
  padding: 16px 0 4px;
  border-bottom: 1px solid var(--border);
}

.card-section:first-child {
  margin-top: 0;
}

.card-section h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.card-section p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}

.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 26px rgba(28, 38, 47, 0.07);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(24, 122, 109, 0.11);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.warn {
  color: var(--warm);
  background: rgba(186, 91, 44, 0.12);
}

.badge.danger {
  color: var(--danger);
  background: rgba(178, 58, 72, 0.12);
}

.badge.cache {
  color: var(--accent-2);
  background: rgba(34, 92, 154, 0.12);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 12px;
}

.stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.chart {
  width: 100%;
  height: 190px;
  padding: 0 12px 8px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.grid-line {
  stroke: #d7dee3;
  stroke-width: 1;
}

.line {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 2.4;
}

.alt-line {
  stroke: var(--warm);
}

.area {
  fill: rgba(34, 92, 154, 0.09);
}

.point-dot {
  fill: var(--accent-2);
}

.zero-line {
  stroke: rgba(178, 58, 72, 0.55);
  stroke-dasharray: 4 4;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.axis-left {
  fill: var(--accent-2);
}

.axis-right {
  fill: var(--warm);
}

.chart-legend {
  display: flex;
  gap: 12px;
  margin: -4px 0 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chart-legend i {
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-2);
}

.chart-legend i.alt {
  background: var(--warm);
}

.card-note {
  margin: 0;
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.manual-card {
  padding: 18px;
}

.manual-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.source-section {
  margin-top: 28px;
  padding: 20px;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--panel);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #f3f6f7;
}

td a {
  color: var(--accent-2);
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

footer {
  padding: 0 clamp(16px, 3vw, 36px) 32px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  text-align: center;
}

@media (max-width: 1120px) {
  .overview,
  .score-panel,
  .dimension-grid,
  .cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .chart-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .meta-grid,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .card-section {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .card-section p {
    max-width: none;
    text-align: left;
  }

  .chart {
    height: 170px;
  }
}
