:root {
  --bg: #f3f1e9;
  --surface: #fffdf7;
  --ink: #1d2925;
  --muted: #65716c;
  --line: #c8cec9;
  --accent: #23624c;
  --good: #277247;
  --bad: #9c3838;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font:
    15px/1.45 system-ui,
    sans-serif;
}
button,
select,
input {
  font: inherit;
}
button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 7px 11px;
  cursor: pointer;
}
.quiet {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.header-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.header-link:hover { text-decoration: underline; }
.telemetry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.telemetry-card, .telemetry-table-wrap { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 12px; }
.telemetry-card strong { display: block; font-size: 22px; }
.telemetry-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.telemetry-table th, .telemetry-table td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: right; }
.telemetry-table th:first-child, .telemetry-table td:first-child, .telemetry-table th:nth-child(2), .telemetry-table td:nth-child(2) { text-align: left; }
@media (max-width: 650px) { .telemetry-grid { grid-template-columns: 1fr; } .telemetry-table-wrap { overflow-x: auto; } }
button:disabled {
  opacity: 0.55;
  cursor: default;
}
main {
  width: min(1080px, calc(100% - 28px));
  margin: auto;
  padding: 14px 0 48px;
}
.app-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 4%, transparent);
}
.page-head {
  width: min(1080px, calc(100% - 28px));
  min-height: 48px;
  margin: auto;
  padding: 6px 0;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.brand span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.page-head,
.head-actions,
.toolbar,
.chart-head,
.legend,
.provider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}
h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}
h2 {
  font-size: 16px;
  margin: 0;
}
.head-actions,
#updated,
.chart-head p,
.status {
  color: var(--muted);
  font-size: 13px;
}
.gate {
  margin: 18vh auto;
  max-width: 440px;
  text-align: center;
}
.onboarding {
  max-width: 720px;
  margin: clamp(70px, 16vh, 180px) auto;
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
}
.onboarding[hidden] { display: none; }
.onboarding h2 {
  margin: 10px 0;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.05;
}
.onboarding > p:not(.eyebrow) {
  margin: 0 auto 26px;
  color: var(--muted);
  font-size: 17px;
}
.primary-cta {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}
.primary-cta:hover { filter: brightness(0.92); }
.primary-cta:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 3px;
}
.auth-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.auth-actions[hidden] {
  display: none;
}
.toolbar {
  justify-content: flex-end;
  margin: 14px 0 7px;
}
.metrics-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.metric-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.series-status { display: grid; gap: 3px; margin-top: 8px; }
.series-status p { margin: 0; font-size: 12px; }
.series-available { color: var(--muted); }
.series-unavailable { color: var(--bad); }
.guide-note { color: var(--muted); font-size: 13px; }
.guide-note a { color: var(--accent); }
.toolbar label {
  display: flex;
  align-items: center;
  gap: 7px;
}
.load-progress {
  display: grid;
  grid-template-columns: auto minmax(120px, 260px);
  align-items: center;
  justify-content: end;
  gap: 9px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
}
.load-progress i {
  display: block;
  width: 260px;
  max-width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}
.load-progress b {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}
.table-scroll { overflow-x:auto; }
.load-progress.complete b {
  width: 100%;
}
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 9px;
}
.metric,
.chart-card,
.provider {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.provider[data-provider="aws"] {
  grid-column: 1 / -1;
}
.metric {
  padding: 12px;
}
.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.metric strong {
  display: block;
  font-size: 23px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.metric strong.loading-number { width:18px; height:18px; margin-top:8px; border:2px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:summary-spin .75s linear infinite; }
@keyframes summary-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .metric strong.loading-number { animation:none; border-top-color:var(--line); background:var(--accent); opacity:.45; } }
.chart-card {
  position: relative;
  padding: 14px;
  margin-bottom: 18px;
}
.cost-tooltip { position:absolute; z-index:4; top:64px; width:min(290px,calc(100% - 24px)); transform:translateX(-50%); padding:10px 12px; border:1px solid var(--line); border-radius:7px; background:var(--surface); color:var(--ink); box-shadow:0 8px 24px rgba(0,0,0,.18); pointer-events:none; }
.cost-tooltip strong { display:block; margin-bottom:5px; }
.cost-tooltip p { display:flex; justify-content:space-between; gap:12px; margin:2px 0; }
.cost-tooltip span { color:var(--muted); }
.cost-tooltip-key { display:block; margin-top:5px; color:var(--muted); font-size:10px; }
.chart-hit { fill:transparent; cursor:crosshair; }
.chart-hit:focus { fill:color-mix(in srgb,var(--accent) 8%,transparent); outline:none; }
.projection-guide { stroke:var(--ink); stroke-width:1.5; stroke-dasharray:5 4; opacity:.72; }
.chart-head p {
  margin: 2px 0 0;
}
.legend {
  justify-content: flex-start;
  flex-wrap: wrap;
}
.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legend i {
  width: 14px;
  height: 7px;
  border-radius: 2px;
}
#chart {
  display: block;
  width: 100%;
  height: 320px;
}
.grid {
  stroke: var(--line);
  stroke-width: 1;
}
.axis {
  fill: var(--muted);
  font-size: 12px;
}
.stack-line {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.provider {
  position: relative;
  padding: 12px;
  padding-bottom: 46px;
  min-width: 0;
}
.provider-head {
  min-height: 34px;
}
.provider-name {
  display: flex;
  align-items: center;
  gap: 9px;
}
.provider-logo {
  display: grid;
  width: 36px;
  height: 34px;
  flex: none;
  place-items: center;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--provider-color) 45%, var(--line));
  border-radius: 7px;
  background: #fff;
}
.provider-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.provider p {
  margin: 3px 0 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.provider-total {
  font-size: 22px;
  font-weight: 750;
  margin: 7px 0 2px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.detail-row span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.detail-row span:last-child {
  flex: none;
  font-variant-numeric: tabular-nums;
}
.aws-inventory {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.aws-inventory-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.aws-inventory-head h3 {
  margin: 0;
  font-size: 13px;
}
.aws-inventory-head span {
  color: var(--muted);
  font-size: 12px;
}
.aws-instance-scroll {
  overflow-x: auto;
}
.aws-instance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.aws-instance-table th,
.aws-instance-table td {
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.aws-instance-table th {
  color: var(--muted);
  font-weight: 650;
}
.aws-instance-table .instance-name {
  max-width: 260px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 650;
  text-overflow: ellipsis;
}
.instance-state {
  color: var(--muted);
}
.instance-state-running {
  color: var(--good);
  font-weight: 700;
}
.instance-state-terminated,
.aws-inventory-error {
  color: var(--bad);
}
.state {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
}
.state.pending {
  color: var(--muted);
}
.state.failed {
  color: var(--bad);
  border-color: var(--bad);
}
.status.error {
  color: var(--bad);
}
@media (max-width: 650px) {
  main {
    width: calc(100% - 16px);
    padding-top: 14px;
  }
  .summary {
    grid-template-columns: 1fr;
  }
  .chart-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .head-actions {
    gap: 7px;
  }
  .brand span {
    display: none;
  }
  #viewer {
    display: none;
  }
  .load-progress {
    grid-template-columns: 1fr;
  }
  .load-progress i {
    width: 100%;
  }
  #chart {
    height: 240px;
  }
  .auth-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
@media (prefers-reduced-motion: reduce) {
  .load-progress b {
    transition: none;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111915;
    --surface: #19231e;
    --ink: #eef5f1;
    --muted: #b5c1bb;
    --line: #52635a;
    --accent: #72c7a4;
    --good: #78d59e;
  }
  .primary-cta {
    border-color: #b6efd8;
    background: #b6efd8;
    color: #10261d;
  }
}
