:root {
  color-scheme: light;
  --bg: #f3f5f5;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dddcd6;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --grid: #e6e5e0;
  --accent-ui: #0b6f6d;
  --on-accent: #ffffff;
  --brand-orange: #f15e3c;
  --brand-teal: #00b3b1;
  --brand-navy: #04151e;
  --ok: #0b7a3e;
  --warn: #9a5b00;
  --danger: #b3261e;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --comp-seat: #5d5c57;
  --comp-base: #8f8e87;
  --comp-addon: #b9b8b0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #06141b;
    --surface-1: #0c1a21;
    --surface-2: #13262e;
    --border: #24383f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --grid: #1b2e35;
    --accent-ui: #2cc3c0;
    --on-accent: #04151e;
    --ok: #4fc47f;
    --warn: #e5a33a;
    --danger: #ef6b62;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --comp-seat: #8f8e87;
    --comp-base: #62615c;
    --comp-addon: #45443f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #06141b; --surface-1: #0c1a21; --surface-2: #13262e; --border: #24383f;
  --text-primary: #fff; --text-secondary: #c3c2b7; --text-muted: #9a998f; --grid: #1b2e35;
  --accent-ui: #2cc3c0; --on-accent: #04151e; --ok: #4fc47f; --warn: #e5a33a; --danger: #ef6b62;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --comp-seat: #8f8e87; --comp-base: #62615c; --comp-addon: #45443f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 13px; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
a { color: var(--accent-ui); }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }

main, footer { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
/* GigaOm brand hero: Sunrise gradation + white logo */
.top-wrap { max-width: 1320px; margin: 0 auto; padding: 16px 16px 0; }
.top {
  position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 16px;
  background: var(--brand-navy) url("../assets/sunrise-gradient.jpg") 30% 78% / cover no-repeat;
  color: #fff; padding: 22px 24px 24px;
  display: flex; gap: 16px 24px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap;
}
.top::before { /* keep text legible over the bright teal highlight */
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(4 21 30 / 0.6) 0%, rgb(4 21 30 / 0.25) 55%, rgb(4 21 30 / 0.1) 100%);
}
.top > * { position: relative; }
.brand-logo { display: block; height: 26px; width: auto; margin-bottom: 18px; }
.top h1 { font-size: 26px; color: #fff; }
.top p { margin: 0; max-width: 720px; color: rgb(255 255 255 / 0.86); }
.top .file-actions button { background: rgb(255 255 255 / 0.12); border-color: rgb(255 255 255 / 0.45); color: #fff; backdrop-filter: blur(4px); }
.top .file-actions button:hover { background: rgb(255 255 255 / 0.22); }
.top .file-actions button.primary { background: #fff; color: var(--brand-navy); border-color: #fff; }
.top .file-actions button.primary:hover { background: rgb(255 255 255 / 0.9); }
footer { padding-top: 8px; padding-bottom: 32px; }

.card { position: relative; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; overflow: hidden; }
.card::before { /* Sunrise accent strip */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand-orange), #b97a56 35%, var(--brand-teal) 75%, #0f4144);
}
.card.editor::before { display: none; }
.toolbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.controls, .file-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

button {
  font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px; padding: 6px 12px;
  border: 1px solid var(--accent-ui); background: var(--accent-ui); color: var(--on-accent); font-weight: 500;
}
button.ghost { background: transparent; color: var(--text-primary); border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent-ui); outline-offset: 1px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--text-secondary); padding: 5px 10px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-ui); color: var(--on-accent); font-weight: 600; }

input, select {
  font: inherit; font-size: 13px; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; min-width: 0;
}
input[type="number"] { width: 100%; max-width: 110px; text-align: right; }
input.inline { width: 64px; display: inline-block; }
input.units { width: 52px; margin-left: 4px; }

/* chart */
.chart { position: relative; width: 100%; margin: 4px 0 12px; }
.chart-svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart-svg .grid line { stroke: var(--grid); stroke-width: 1; }
.chart-svg .baseline { stroke: var(--text-muted); stroke-width: 1; }
.chart-svg .tick { fill: var(--text-muted); font-size: 11px; }
.chart-svg .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .hover-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart-svg .direct-label text { fill: var(--text-primary); font-size: 12px; }
.chart-svg .direct-label .direct-value { fill: var(--text-secondary); font-size: 11px; }
.chart-svg .chart-empty { fill: var(--text-muted); }
.chart-tip {
  position: absolute; pointer-events: none; min-width: 220px; max-width: 320px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.14); padding: 8px 10px; font-size: 12px; z-index: 5;
}
.tip-head { color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.tip-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.tip-val { font-weight: 600; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.swatch.lg { width: 14px; height: 14px; margin: 0; flex: none; }
.legend { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-secondary); font-size: 12px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }

/* tables */
.scroll { overflow-x: auto; position: relative; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { color: var(--text-secondary); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.data tbody th { font-weight: 500; }
table.compact th, table.compact td { padding: 4px 6px; }
table.editable td { white-space: nowrap; }
td.cov select { max-width: 140px; }
.sub { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.flag { font-size: 11px; color: var(--warn); font-weight: 400; margin-top: 2px; }

.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }

.swatch.lg { width: 14px; height: 14px; margin: 0; flex: none; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; }
.grid-fields label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-secondary); }
.grid-fields label input[type="number"] { max-width: none; text-align: left; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 12px; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--text-secondary); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; }
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent-ui); font-weight: 600; }
.vendor-note { color: var(--text-secondary); max-width: 900px; margin: 0; }
.sources { padding-left: 18px; margin: 0; font-size: 12px; }
.sources li { margin: 3px 0; }

@media (max-width: 640px) {
  .top { align-items: flex-start; }
  .toolbar { align-items: flex-start; }
}

/* v2: estimate builder */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions button { padding: 3px 8px; font-size: 12px; margin-left: 2px; }
tr.is-editing th, tr.is-editing td { background: var(--surface-2); }
table.data tfoot th, table.data tfoot td { font-weight: 600; border-bottom: 0; }
.warn-text { color: var(--warn); }

.platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; margin: 12px 0; }
button.platform {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 14px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px;
}
button.platform:hover { border-color: var(--accent-ui); background: var(--surface-2); }
.p-name { font-weight: 600; font-size: 15px; }
.p-desc { color: var(--text-secondary); font-size: 13px; }
.p-plans { color: var(--text-muted); font-size: 12px; }

.editor { border-left: 4px solid var(--accent); }
.editor-title { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; }
.editor-title .name { flex: 1; font-weight: 600; font-size: 15px; max-width: 360px; }
.plan-facts { color: var(--text-secondary); margin: 8px 0 0; }
.workloads select { max-width: 150px; }
.workloads td, .workloads th { padding-left: 4px; padding-right: 4px; }
.workloads input[type="number"] { width: 72px; }
.workloads input.tok { width: 84px; }
.workloads input.pct { width: 64px; }
.workloads td { vertical-align: middle; }
.row-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
button.icon { background: transparent; border: 0; color: var(--text-muted); padding: 2px 6px; }
button.icon.danger:hover { color: var(--danger); }
.calc { margin-top: 16px; }
.calc summary { cursor: pointer; font-weight: 500; }
.calc ul { margin: 8px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.7; }
.calc .calc-total { margin-top: 4px; font-size: 13px; }
.grid-fields label .muted.small { font-size: 11px; }

table.editable input[type="number"] { min-width: 72px; }
table.editable tbody th { min-width: 180px; }

/* composition views */
.legend-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }
.chart-svg .band-fill { fill-opacity: 0.13; stroke: none; }
.chart-svg .band-edge { fill: none; stroke-width: 1; stroke-opacity: 0.55; stroke-dasharray: 1 3; }
.tip-split { font-size: 11px; color: var(--text-muted); padding: 0 0 3px 18px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 12px 20px; margin: 10px 0 8px; }
.panel { margin: 0; border: 1px solid var(--border); border-radius: 8px; padding: 10px 10px 4px; }
.panel figcaption { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.p-title { font-weight: 600; }
.panel-chart { margin: 0; }
.chart-svg .stack-fill { stroke: none; }
.chart-svg .stack-gap { fill: none; stroke: var(--surface-1); stroke-width: 2; }
.tip-total { border-top: 1px solid var(--border); margin-top: 3px; padding-top: 4px; }
[hidden] { display: none !important; }
.sub.hint { white-space: normal; max-width: 110px; margin: 2px 0 0 auto; line-height: 1.3; cursor: help; text-decoration: underline dotted; }
.workloads td.req { white-space: nowrap; }
.workloads td.req input { width: 64px; margin-right: 4px; }
.workloads td.req select { width: auto; }

/* legend toggles + stacked shading */
.legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.legend-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; color: var(--text-secondary); padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 400; }
.legend-btn:hover { border-color: var(--border); background: var(--surface-2); }
.legend-btn[aria-pressed="false"] { color: var(--text-muted); text-decoration: line-through; }
.legend-btn[aria-pressed="false"] svg { opacity: 0.3; }
.shade-toggle { border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; }
.component-legend { margin-top: 4px; }
.component-legend:empty { display: none; }
.chart-svg .layer-fill { stroke: none; }
.chart-svg .layer-edge { fill: none; stroke-width: 1; stroke-opacity: 0.5; stroke-dasharray: 1 3; }
