/* Ironbird UI. Colours come from the brand tokens inlined in index.html; the one exception is
   --primary-fg, text on filled buttons, which stays white in both themes.
   Components follow shadcn/ui (new-york): its sizes, radii, borders, focus rings and
   variants, ported to plain CSS for this no-build frontend. shadcn's colour roles map
   onto the brand tokens below, so both themes keep working. */

/* Type: Geist everywhere, Geist Mono for code. Overrides the brand block's font tokens
   (that block is generated; colours there still apply). */
:root {
  --font-display: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* shadcn colour roles → brand tokens */
  --background: var(--ground);
  --foreground: var(--ink);
  --surface: var(--card-3);            /* shadcn card / popover */
  --muted-bg: var(--card);             /* shadcn muted, accent (hover) */
  --muted-fg: var(--muted);
  --border: var(--line);
  --input: var(--line-2);
  --primary: var(--accent);
  --primary-fg: white;                 /* text on filled buttons: white in light and dark */
  --destructive: var(--alert);
  --ring: color-mix(in srgb, var(--accent-2) 50%, transparent);

  --radius: 10px;                      /* shadcn --radius 0.625rem */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font: 400 14px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "rlig" 1, "calt" 1;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code, pre, .mono { font-family: var(--font-mono); font-size: 12px; }
:not(pre) > code { background: var(--muted-bg); border-radius: 4px; padding: 1px 5px; }
a { color: var(--primary); text-underline-offset: 3px; }
.muted { color: var(--muted-fg); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.splash { padding: 48px 16px; text-align: center; color: var(--muted-fg); }

/* ---- shell */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; }
.brand-mark { width: 28px; height: 28px; flex: none; display: block; }
.brand small { color: var(--muted-fg); font-size: 12px; }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted-fg); font-size: 13px; }

/* Tabs — shadcn TabsList / TabsTrigger: a muted track with the active trigger raised. */
.tabs, .subtabs, .dg-tabs {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--muted-bg); border-radius: var(--radius-lg); color: var(--muted-fg);
}
.tabs { margin-left: 16px; flex-wrap: wrap; }
.subtabs { margin-left: 8px; }
.tab, .subtabs button, .dg-tabs button {
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius-md);
  background: none; color: var(--muted-fg); cursor: pointer;
  font: 500 14px var(--font-body); transition: color .15s, background-color .15s, box-shadow .15s;
}
.subtabs button, .dg-tabs button { height: 28px; font-size: 13px; padding: 0 10px; }
.tab:hover, .subtabs button:hover, .dg-tabs button:hover { color: var(--foreground); }
.tab[aria-selected="true"], .subtabs button[aria-selected="true"], .dg-tabs button[aria-selected="true"] {
  background: var(--surface); color: var(--foreground); box-shadow: var(--shadow-sm); border-color: var(--border);
}
.tab:focus-visible, .subtabs button:focus-visible, .dg-tabs button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; display: grid; gap: 24px; }
.layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
/* Install tab, top to bottom: cloud accounts in a row, workload (inputs | results), install matrix. */
.cloud-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; align-items: start; }
.cloud-row .cloud + .cloud { margin-top: 0; }
.notice + .cloud-row { margin-top: 12px; }
.wl-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 960px) { .wl-grid { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; padding: 10px 16px; } main { padding: 16px; } }

/* Card — shadcn Card: rounded-xl, border, shadow-sm. */
.card {
  background: var(--surface); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 28px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- forms — shadcn Label, Input, Select, Textarea */
label { display: grid; gap: 6px; font-size: 13px; line-height: 1.3; color: var(--foreground); font-weight: 500; }
input, select, textarea {
  width: 100%; min-width: 0; height: 36px;
  font: 400 14px var(--font-body); color: var(--foreground);
  background-color: var(--surface); border: 1px solid var(--input); border-radius: var(--radius-md);
  padding: 4px 12px; box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-fg); }
/* Select trigger: our own chevron (shadcn's ChevronDown at 50% opacity), inset from the edge.
   Two token-coloured diagonal strokes; no image, so it follows the theme. */
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer;
  --chev: color-mix(in srgb, var(--foreground) 50%, transparent);
  background-image:
    linear-gradient(45deg, transparent calc(50% - 0.8px), var(--chev) calc(50% - 0.8px), var(--chev) calc(50% + 0.8px), transparent calc(50% + 0.8px)),
    linear-gradient(-45deg, transparent calc(50% - 0.8px), var(--chev) calc(50% - 0.8px), var(--chev) calc(50% + 0.8px), transparent calc(50% + 0.8px));
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 6px 6px; background-repeat: no-repeat;
}
select[multiple] { background-image: none; padding-right: 12px; height: auto; }
textarea { height: auto; font-family: var(--font-mono); font-size: 12px; min-height: 90px; padding: 8px 12px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--ring);
}
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.5; }
input[aria-invalid="true"] { border-color: var(--destructive); }
input[type="range"] { height: auto; padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--primary); }
/* Checkbox — shadcn: 16px, rounded-[4px], primary when checked. */
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; padding: 0; margin: 0; flex: none; box-shadow: none;
  accent-color: var(--primary); cursor: pointer;
}
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; color: var(--foreground); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px; }
@media (max-width: 700px) { .grid4 { grid-template-columns: 1fr 1fr; } }

/* Button — shadcn Button. .btn = default, .ghost = outline, .danger = destructive, .small = size sm. */
button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  height: 36px; padding: 0 16px; border-radius: var(--radius-md);
  font: 500 14px var(--font-body); cursor: pointer;
  border: 1px solid transparent; background: var(--primary); color: var(--primary-fg);
  box-shadow: var(--shadow-xs); transition: background-color .15s, color .15s, box-shadow .15s;
}
button.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 90%, transparent); }
button.btn.ghost { background: var(--surface); color: var(--foreground); border-color: var(--border); }
button.btn.ghost:hover:not(:disabled) { background: var(--muted-bg); }
button.btn.danger { background: var(--destructive); color: var(--primary-fg); }
button.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--destructive) 90%, transparent); }
button.btn.small { height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; }
button.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Group — a labelled set of options: border only, the label sits in the top edge. */
.groups { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 960px) { .groups { grid-template-columns: 1fr; } }
fieldset.group { margin: 0; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 16px 14px; }
fieldset.group legend { padding: 0 6px; margin-left: -6px; font-size: 13px; font-weight: 500; color: var(--muted-fg); }

/* ---- cloud accounts */
.cloud { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--surface); }
.cloud + .cloud { margin-top: 10px; }
.cloud summary { cursor: pointer; display: flex; align-items: center; gap: 10px; list-style: none; }
.cloud-name { display: grid; gap: 0; flex: 1; min-width: 0; line-height: 1.3; }
.cloud-name > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Logo tile; the initial underneath shows when there's no logo. */
.cloud-logo {
  position: relative; flex: none; width: 32px; height: 32px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface); overflow: hidden;
  display: grid; place-items: center;
}
.cloud-logo::before { content: attr(data-initial); font: 600 14px var(--font-display); color: var(--muted-fg); }
.cloud-logo img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: contain; background: var(--surface); }
.pill.off { background: var(--muted-bg); color: var(--muted-fg); }
.cloud summary::-webkit-details-marker { display: none; }
.cloud[open] summary { margin-bottom: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }
.dot.on { background: var(--good); }

/* ---- matrix */
.matrix { display: grid; grid-template-columns: 110px repeat(3, 1fr); gap: 8px; }
.matrix .h { font-size: 13px; color: var(--muted-fg); font-weight: 500; padding: 4px 2px; }
.cell { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; display: grid; gap: 6px; align-content: start; min-height: 112px; background: var(--surface); }
.cell.off { background: var(--muted-bg); }
.cell .name { font-weight: 500; font-size: 14px; }
.cell .size { font-size: 12px; color: var(--muted-fg); font-family: var(--font-mono); }
@media (max-width: 700px) { .matrix { grid-template-columns: 1fr; } .matrix .h.col { display: none; } }

/* ---- deployments */
.dep { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; display: grid; gap: 8px; }
.dep + .dep { margin-top: 10px; }
.dep-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* Badge — shadcn Badge: rounded-md, text-xs, medium; secondary by default. */
.pill {
  display: inline-block; vertical-align: middle; white-space: nowrap;
  font-size: 12px; font-weight: 500; line-height: 1.4; padding: 2px 8px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--muted-bg); color: var(--foreground);
}
.pill::first-letter { text-transform: uppercase; }
.pill.ready { background: var(--good-wash); color: var(--good); }
.pill.failed { background: var(--alert-wash); color: var(--destructive); }
.pill.provisioning, .pill.installing { background: var(--wash); color: var(--accent-3); }
.pill.deleting { background: var(--muted-bg); color: var(--muted-fg); }
pre.cmd { margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* ---- notices — shadcn Alert; the toast follows Sonner. */
.notice { border-radius: var(--radius-lg); padding: 12px 16px; font-size: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--foreground); }
.notice.small { font-size: 13px; }
.notice.error { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 40%, transparent); background: var(--surface); }
.notice.warn { background: color-mix(in srgb, var(--wash) 55%, var(--surface)); border-color: color-mix(in srgb, var(--accent-2) 45%, transparent); }
.toast { position: fixed; bottom: 16px; right: 16px; max-width: min(420px, calc(100vw - 32px)); z-index: 10; box-shadow: var(--shadow-lg); background: var(--surface); }
.toast.warn { background: var(--surface); border-color: var(--border); }

/* ---- tables — shadcn Table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 500; color: var(--foreground); font-size: 13px; height: 40px; vertical-align: middle; white-space: nowrap; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: color-mix(in srgb, var(--muted-bg) 50%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 8px; background: var(--muted-bg); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar { height: 100%; border-radius: 99px; background: var(--accent-2); }
.bar.paradime { background: var(--primary); }
.bar.ops { background: var(--neb-d); }
tr.paradime td:first-child { font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted-fg); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.table-wrap { overflow-x: auto; }
details.lines summary { cursor: pointer; color: var(--foreground); font-size: 13px; font-weight: 500; }
details.lines summary:hover { text-decoration: underline; text-underline-offset: 3px; }
details.lines table { margin-top: 6px; font-size: 13px; }

/* ---- costs */
.grid5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 960px) { .grid5 { grid-template-columns: 1fr 1fr; } }
.grid5 > label { grid-template-rows: 1fr auto; align-items: end; }
details.quotes > summary { font-size: 14px; }
.quote-table th { font-size: 12px; color: var(--muted-fg); height: 32px; }
.quote-table td { vertical-align: middle; }
.quote-table td:first-child { min-width: 170px; }
.quote-table input { height: 32px; font-size: 13px; padding: 4px 8px; min-width: 90px; }
.quote-table tbody tr:hover { background: none; }
.vs-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.vs-tile { gap: 4px; align-content: start; }
.vs-tile .vs-title { font-size: 13px; font-weight: 500; color: var(--muted-fg); }
.vs-tile strong { font-size: 26px; }
.vs-tile span { font-size: 13px; }
.vs-tile.paradime { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.vs { font-weight: 500; color: var(--foreground); }
.breakdown .opt-name { font-weight: 500; }
.breakdown details.lines summary { font-size: 12px; color: var(--muted-fg); margin-top: 2px; }

/* ---- TCO */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; vertical-align: 0; }
.tco-platforms { display: grid; gap: 10px; }
details.tco-platform { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
details.tco-platform > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; list-style: none; }
details.tco-platform > summary::-webkit-details-marker { display: none; }
details.tco-platform > summary::after {
  content: ""; width: 7px; height: 7px; margin-left: 4px; flex: none;
  border-right: 1.5px solid var(--muted-fg); border-bottom: 1.5px solid var(--muted-fg); transform: rotate(45deg) translateY(-2px); transition: transform .15s;
}
details.tco-platform[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
details.tco-platform[open] > summary { border-bottom: 1px solid var(--border); }
.tco-p-name { display: grid; flex: 1; min-width: 0; line-height: 1.35; }
.tco-p-body { padding: 16px; }
.tco-add { display: grid; gap: 10px; margin-top: 4px; }
.tco-add-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .tco-add-options { grid-template-columns: 1fr; } }
.tco-add-option { display: grid; gap: 6px; align-content: start; border: 1px dashed var(--input); border-radius: var(--radius-lg); padding: 12px 14px; }
.tco-add-option select { height: 32px; font-size: 13px; }
.chart-empty { position: relative; }
.chart-empty svg { opacity: 0.7; }
.chart-empty-msg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; padding: 0 64px 28px; }
table.runs td { vertical-align: middle; }

/* ---- cost simulation */
table.ranges td { vertical-align: middle; }
.unit-input { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.unit-input input { width: 80px; height: 32px; font-size: 13px; padding: 4px 8px; text-align: right; }
.unit-input span { font-size: 12px; color: var(--muted-fg); min-width: 38px; text-align: left; }
.tornado { display: grid; gap: 8px; }
.t-row { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) 150px; gap: 12px; align-items: center; }
.t-label { font-size: 13px; }
.t-track { position: relative; height: 18px; background: var(--muted-bg); border-radius: var(--radius-sm); }
.t-bar { position: absolute; top: 3px; bottom: 3px; background: var(--series-1); border-radius: 3px; }
.t-mid { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1.5px dashed var(--ink-2); }
.t-scale { display: flex; justify-content: space-between; }
@media (max-width: 700px) { .t-row { grid-template-columns: 1fr; } }

/* ---- sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { max-width: 400px; width: 100%; text-align: left; }
.auth h1 { margin: 14px 0 6px; }

/* ---- TCO */
.tco-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.tco-name { font: 600 16px var(--font-display); border-color: transparent; background: none; box-shadow: none; padding: 4px 6px; margin-left: -6px; }
.tco-name:hover { border-color: var(--border); }
h3.sub { font-size: 12px; font-family: var(--font-body); font-weight: 500; color: var(--muted-fg); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .axis { font: 400 11px var(--font-body); fill: var(--muted-fg); }
svg.chart .endlabel { font: 500 12px var(--font-body); fill: var(--ink-2); }
svg.chart .endlabel.base { fill: var(--foreground); font-weight: 600; }
.chart-tip { position: absolute; top: 8px; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-lg); pointer-events: none; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip-row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.grid4 > label, .grid2 > label { grid-template-rows: 1fr auto; align-items: end; }

/* ---- workload profile */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-row div { display: grid; gap: 2px; }
.stat-row strong { font: 600 20px var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-row span { font-size: 12px; color: var(--muted-fg); line-height: 1.3; }
svg.profile { width: 100%; height: auto; display: block; overflow: visible; }
svg.profile .axis { font: 400 9px var(--font-body); fill: var(--muted-fg); }
details.lines label { margin-top: 4px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; margin: 6px 0 4px; }
/* Segmented choice — shadcn RadioGroup as cards. */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button {
  display: grid; gap: 2px; text-align: left; padding: 10px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--input); background: var(--surface); color: var(--foreground); cursor: pointer;
  font: 400 13px var(--font-body); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.seg button:hover { background: var(--muted-bg); }
.seg button strong { font: 600 14px var(--font-display); }
.seg button span { color: var(--muted-fg); }
.seg button[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: color-mix(in srgb, var(--wash) 45%, var(--surface)); }
.seg button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.cloud, .notice, .dep { min-width: 0; overflow-wrap: anywhere; }
button.brand { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
button.brand:hover .brand-mark { opacity: 0.85; }

/* ---- settings */
form[data-settings] .grid2 > label { grid-template-rows: auto; align-content: start; align-items: start; }
