/* C/AI Value Calculator v3 — scoped for Economics embed */

/* Layout: inputs rail on the left, results stacked on the right; one column on phones. */
.cai-calculator-v3-mount {
  --bg: #F4F8F8; --surface: #FFFFFF; --ink: #0E2A2D; --muted: #557072; --line: #D5E1E2;
  --accent: #004A51; --accent-ink: #FFFFFF; --soft: #E8F4F5;
  --s-cai: #0093A3; --s-cap: #E0720B; --s-unc: #8E2F5C;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: Inter, "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  .cai-calculator-v3-mount:not([data-theme="light"]) {
    --bg: #0A1517; --surface: #0F1D1F; --ink: #E6F0F1; --muted: #9DB4B6; --line: #26393C;
    --accent: #5CC4CC; --accent-ink: #06181A; --soft: #15292C;
    --s-cai: #1F9AA5; --s-cap: #E08410; --s-unc: #D65C9C; color-scheme: dark;
  }
}
.cai-calculator-v3-mount[data-theme="dark"] {
  --bg: #0A1517; --surface: #0F1D1F; --ink: #E6F0F1; --muted: #9DB4B6; --line: #26393C;
  --accent: #5CC4CC; --accent-ink: #06181A; --soft: #15292C;
  --s-cai: #1F9AA5; --s-cap: #E08410; --s-unc: #D65C9C; color-scheme: dark;
}
.cai-calculator-v3-mount { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
.cai-calculator-v3-mount .cai-calculator-v3 {
* { box-sizing: border-box; }
.wrap { max-width: 1180px; margin: 0 auto; padding-block: 28px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 0; text-wrap: balance; }
header p { margin: 0; color: var(--muted); max-width: 65ch; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 0; }
.grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; overflow: hidden; }
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.grid > section.panel { min-width: 0; overflow: hidden; }
.grid > .results { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.results { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; font-size: 14px; }
.field small { color: var(--muted); font-size: 12px; }
input[type="number"], select { font: inherit; font-variant-numeric: tabular-nums; width: 100%; padding: 8px 10px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 36px;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='%23557072' d='M1.2 1.2L6 6l4.8-4.8L12 2.4 6 8.4 0 2.4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:disabled { opacity: .45; }
.toggle { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; max-width: 100%; }
.toggle input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.toggle label { line-height: 1.45; min-width: 0; overflow-wrap: anywhere; }
.headline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
@media (max-width: 620px) { .headline { grid-template-columns: minmax(0, 1fr); } }
.stat { padding: 4px 20px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.stat:first-child { border-left: 0; padding-left: 0; }
@media (max-width: 620px) { .stat { border-left: 0; padding: 12px 0; border-top: 1px solid var(--line); } .stat:first-child { border-top: 0; padding-top: 0; } }
.stat .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .v { font-family: var(--font-display); font-weight: 600; font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .s { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.message { margin: 0; padding: 12px 14px; background: var(--soft); border-radius: 4px; font-weight: 500; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
td.rule { text-align: left; color: var(--muted); white-space: normal; font-size: 13px; }
tr.sub td { font-weight: 600; background: var(--soft); }
tr.total td, tfoot td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
#chart { position: relative; }
#chart svg { display: block; width: 100%; }
#tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; font-size: 13px; font-variant-numeric: tabular-nums; box-shadow: 0 4px 14px rgba(0,0,0,.12); min-width: 190px; }
#tip b { display: block; margin-bottom: 4px; }
#tip div { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
#tip div span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.notice { border: 1px solid var(--line); background: var(--soft); border-radius: 6px; padding: 24px; }
.notice p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }
details summary { cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 17px; }
details .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 16px; }
details h3 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 6px; }
details dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
details dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.group { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.note { margin: 0; color: var(--muted); font-size: 13px; max-width: 75ch; }
.foot { color: var(--muted); font-size: 12px; margin: 0; max-width: 80ch; }
.calc-lead { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.calc-lead-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .calc-lead-actions { grid-template-columns: 1fr; } }
.calc-lead .pdf-btn {
  font: inherit; font-weight: 600; width: 100%; padding: 10px 14px; border: 0; border-radius: 4px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.calc-lead .pdf-btn--secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.calc-lead .pdf-btn:disabled { opacity: .45; cursor: not-allowed; }
.calc-lead #pdfNeed { display: none; }
.calc-lead.is-invalid #pdfNeed { display: block; }
.results-gated { position: relative; }
.results-gated.is-locked { pointer-events: none; user-select: none; }
.results-gated.is-locked::after {
  content: ""; position: absolute; inset: 0; z-index: 2;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  border-radius: 6px;
}
.results-gated.is-locked > * { filter: blur(6px); }
.is-pdf-export.results-gated.is-locked::after,
.is-pdf-export.results-gated.is-locked > * { filter: none; backdrop-filter: none; pointer-events: auto; }

.pdf-capture { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
#sizingPanel table th:nth-child(2), #sizingPanel table td.rule,
table:has(#parts) th:nth-child(2), table:has(#parts) td.rule {
  white-space: normal; overflow-wrap: break-word; word-break: normal;
}
@media (max-width: 720px) {
  #sizingPanel .scroll,
  .panel:has(#parts) .scroll { overflow: visible; }
  #sizingPanel table,
  #sizingPanel thead, #sizingPanel tbody, #sizingPanel tr, #sizingPanel th, #sizingPanel td,
  table:has(#parts), table:has(#parts) thead, table:has(#parts) tbody,
  table:has(#parts) tr, table:has(#parts) th, table:has(#parts) td {
    display: block; width: 100%;
  }
  #sizingPanel thead,
  table:has(#parts) thead {
    position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  #sizingPanel tr,
  table:has(#parts) tr {
    padding: 14px 0; border-bottom: 1px solid var(--line);
  }
  #sizingPanel tr:last-child,
  table:has(#parts) tr:last-child { border-bottom: 0; }
  #sizingPanel th, #sizingPanel td,
  table:has(#parts) th, table:has(#parts) td {
    text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;
    border-bottom: 0; padding: 2px 0;
  }
  #sizingPanel td:first-child,
  table:has(#parts) td:first-child { font-weight: 600; color: var(--ink); }
  #sizingPanel td.rule,
  table:has(#parts) td.rule { color: var(--muted); }
  #sizingPanel td:last-child,
  table:has(#parts) td:last-child {
    font-weight: 600; font-variant-numeric: tabular-nums; padding-top: 6px;
  }
  #sizingPanel tr.sub td, #sizingPanel tr.total td,
  table:has(#parts) tr.sub td, table:has(#parts) tr.total td { background: transparent; }
  #sizingPanel tr.total, table:has(#parts) tr.total { border-top: 2px solid var(--ink); }
}
.pdf-capture.is-pdf-export {
  width: 794px;
  max-width: none;
  box-sizing: border-box;
}
.is-pdf-export .scroll { overflow: visible; }
.is-pdf-export #sizingPanel table,
.is-pdf-export table:has(#parts) { display: table; width: 100%; }
.is-pdf-export #sizingPanel thead,
.is-pdf-export table:has(#parts) thead { display: table-header-group; position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: nowrap; }
.is-pdf-export #sizingPanel tbody,
.is-pdf-export table:has(#parts) tbody { display: table-row-group; }
.is-pdf-export #sizingPanel tr,
.is-pdf-export table:has(#parts) tr { display: table-row; padding: 0; }
.is-pdf-export #sizingPanel th, .is-pdf-export #sizingPanel td,
.is-pdf-export table:has(#parts) th, .is-pdf-export table:has(#parts) td {
  display: table-cell; width: auto; padding: 8px 10px;
}
.is-pdf-export table th, .is-pdf-export table td { white-space: normal; }
.is-pdf-export #sizingPanel table td:first-child { white-space: nowrap; }
.is-pdf-export .panel { overflow: visible; }
.is-pdf-export .note { max-width: none; }
.is-pdf-export td.rule { line-height: 1.5; padding-block: 10px; }
.is-pdf-export #chart { overflow: visible; padding-right: 8px; }
.is-pdf-export table { table-layout: fixed; }
.is-pdf-export #parts td.rule,
.is-pdf-export #sizingPanel td.rule { overflow-wrap: anywhere; }
}
