:root {
  color-scheme: light dark;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-raised: #fbfcfd;
  --surface-soft: #eef3f3;
  --text: #111817;
  --muted: #5f6d6a;
  --line: #d9e2df;
  --line-strong: #c6d2cf;
  --primary: #0b7f6a;
  --primary-strong: #075d50;
  --blue: #1f6feb;
  --amber: #b76a00;
  --red: #bd3434;
  --shadow: 0 18px 46px rgba(20, 35, 32, 0.08);
  --shadow-soft: 0 8px 24px rgba(20, 35, 32, 0.06);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101312;
    --surface: #171c1a;
    --surface-raised: #1c2421;
    --surface-soft: #202b28;
    --text: #f0f5f2;
    --muted: #a0ada8;
    --line: #2e3a36;
    --line-strong: #43504c;
    --primary: #45d0a8;
    --primary-strong: #72e2c0;
    --blue: #78a8ff;
    --amber: #e8a84b;
    --red: #ff7878;
    --shadow: 0 20px 54px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.24);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary) 9%, transparent), transparent 300px),
    linear-gradient(135deg, color-mix(in srgb, var(--blue) 6%, transparent), transparent 44%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.intro,
.dashboard-head,
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.intro {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 26px;
  line-height: 1.18;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

.intro-copy {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.health-pill,
.status-badge,
.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
}

.dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

.dot-muted {
  background: var(--muted);
  box-shadow: none;
}

.lookup-card,
.panel,
.state-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.lookup-card {
  padding: 18px;
  margin-bottom: 18px;
}

.lookup-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

input {
  min-width: 0;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 26%, transparent);
  outline-offset: 2px;
}

input:focus {
  border-color: var(--primary);
}

button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 850;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.primary-button {
  min-width: 88px;
  background: var(--text);
  color: var(--surface);
  padding: 0 18px;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 14px;
}

.form-note,
.muted {
  color: var(--muted);
}

.form-note {
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.form-note.error {
  color: var(--red);
}

.hidden {
  display: none !important;
}

.state-panel {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.state-panel h2 {
  color: var(--text);
}

.dashboard {
  display: grid;
  gap: 18px;
}

.dashboard-head {
  padding: 12px 2px 0;
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: 1.2fr 0.8fr;
}

.one-col {
  grid-template-columns: 1fr;
}

.metric,
.pool-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--blue), var(--amber));
}

.metric .label,
.pool-item .label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric .value,
.pool-item .value {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 900;
  line-height: 1.08;
}

.metric .sub,
.pool-item .sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  padding: 18px;
}

.quota-panel {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 92%, transparent), var(--surface)),
    var(--surface);
}

.quota-hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quota-hero-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.quota-hero-card .caption {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.quota-hero-card .bigline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 950;
  line-height: 1.08;
}

.quota-hero-card .bigline .total {
  color: var(--muted);
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 850;
}

.quota-hero-card .remain {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 12px;
  margin: 18px 0 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue), var(--amber));
  transition: width 240ms ease;
}

.quota-details,
.pool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.model-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(160px, 1.7fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  padding: 12px;
}

.model-name {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

.model-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
  white-space: nowrap;
}

.chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(26px, 1fr);
  align-items: end;
  gap: 8px;
  min-height: 178px;
  margin-top: 18px;
}

.chart-col {
  display: grid;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.chart-bar {
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--primary), var(--blue));
}

.chart-label {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.table-wrap {
  width: 100%;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.ok {
  color: var(--primary);
}

.bad {
  color: var(--red);
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

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

@media (max-width: 980px) {
  .intro,
  .dashboard-head,
  .panel-title {
    display: grid;
  }

  .metrics-grid,
  .two-col,
  .quota-details,
  .pool-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-stack {
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  h1 {
    font-size: 40px;
  }

  .lookup-card,
  .panel {
    padding: 14px;
  }

  .input-row,
  .metrics-grid,
  .quota-hero,
  .quota-details,
  .pool-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .model-row {
    grid-template-columns: 1fr;
  }

  .model-meta {
    text-align: left;
    white-space: normal;
  }

  .chart {
    gap: 6px;
    grid-auto-columns: minmax(18px, 1fr);
    min-height: 150px;
  }

  .chart-label {
    font-size: 10px;
    writing-mode: vertical-rl;
    justify-self: center;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    padding: 10px;
  }

  td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 10px;
    border: 0;
    padding: 8px 0;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
  }

  td .muted {
    grid-column: 2;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  td.empty {
    display: block;
  }

  td.empty::before {
    content: "";
  }
}
