/* Exposure Tree. Colours, type and buttons follow RoSI's (Scopus CVI):
   teal for buttons, mineral for fills and borders, coral for the one
   accent that matters (exposure on charts, heavy path ends), amber only
   for "still missing". */
:root {
  --teal: #0D4D4D;
  --teal-dark: #093838;
  --teal-soft: #EAF2F2;
  --coral: #FF6B57;
  --mineral: #A7C8C8;
  --mineral-dark: #6B8888;
  --mineral-fill: rgba(167, 200, 200, 0.22);
  --mineral-fill-hover: rgba(167, 200, 200, 0.36);
  --fog: #F5F5F5;
  --graphite: #2E2E2E;

  --bg: var(--fog);
  --surface: #ffffff;
  --panel: #EEF4F4;
  --text: var(--graphite);
  --muted: #6B7574;
  --border: rgba(167, 200, 200, 0.55);
  --border-strong: rgba(107, 136, 136, 0.55);
  --branch: #9BB3B3;
  --amber: #E09A1B;
  --amber-bg: #FFF4E0;
  --danger: #B3261E;
  --danger-bg: #FDECEA;

  --font-header: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'DM Sans', -apple-system, 'Segoe UI', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .brand, .btn { font-family: var(--font-header); }
h1 { font-size: 1.7rem; margin: 0 0 6px; letter-spacing: -0.01em; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 0 0 8px; font-weight: 600; }
h3 { font-size: 0.95rem; margin: 0 0 6px; font-weight: 600; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

/* Buttons, as on scopusrisk.com: a 2px border in the fill colour, so filled
   and outlined are the same height, and a coral ring on hover. */
.btn {
  display: inline-block;
  background: var(--teal); color: #fff;
  border: 2px solid var(--teal); border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.88rem; font-weight: 700; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--teal-dark); border-color: var(--coral); }
.btn-secondary { background: transparent; color: var(--teal); }
.btn-secondary:hover { background: var(--teal-soft); color: var(--teal-dark); }
.btn-small { padding: 5px 12px; font-size: 0.8rem; }
.btn-link {
  background: none; border: none; padding: 4px 0; margin: 0;
  color: var(--teal); font-family: var(--font-header); font-weight: 600; font-size: 0.84rem;
  text-decoration: none; cursor: pointer; text-align: left;
}
.btn-link:hover { text-decoration: underline; color: var(--teal-dark); }
.btn-link.inline { padding: 0; font-weight: 500; font-family: var(--font-body); font-size: inherit; }
.btn-remove { color: var(--danger); }
.btn-remove:hover { color: var(--danger); }
.icon-btn {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--graphite); border: 1px solid var(--border); background: var(--surface); font-size: 1rem;
}
.icon-btn:hover:not(:disabled) { background: var(--mineral-fill); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: 0.4; }
.text-btn {
  flex: 0 0 auto; height: 30px; padding: 0 12px; border-radius: 8px;
  display: inline-flex; align-items: center;
  font-family: var(--font-header); font-size: 0.8rem; font-weight: 600; text-decoration: none;
  color: var(--graphite); border: 1px solid var(--border); background: var(--surface);
}
.text-btn:hover { background: var(--mineral-fill); border-color: var(--border-strong); }
.text-btn.is-disabled { opacity: 0.4; pointer-events: none; }
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: rgba(167, 200, 200, 0.45); font-size: 0.72rem; font-weight: 600;
}
.hint { font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; }

/* --- Header -------------------------------------------------------------- */
.site-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header .brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand-logo-link { display: block; }
.brand-logo { height: 20px; width: auto; display: block; }
.brand-app {
  font-weight: 700; font-size: 1rem; letter-spacing: -0.01em;
  border-left: 1px solid var(--border-strong); padding-left: 12px;
  color: var(--graphite); text-decoration: none;
}
.brand-app:hover { text-decoration: underline; }
.analysis-title {
  background: none; border: none; border-left: 1px solid var(--border-strong);
  padding: 2px 0 2px 16px; margin: 0;
  color: var(--muted); font-size: 0.88rem; text-decoration: none; text-align: left;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.analysis-title:hover { color: var(--text); text-decoration: underline; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.save-status { font-size: 0.8rem; color: var(--muted); margin-right: 6px; white-space: nowrap; }
.save-status[data-status="saved"]::before { content: '✓ '; color: var(--teal); }
.save-status[data-status="error"], .save-status[data-status="conflict"] { color: var(--danger); }
.header-cta { flex: none; }

/* --- Banners: "Saved", and the example's ---------------------------------- */
.banner {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 24px 0; padding: 10px 14px; border-radius: 10px;
  background: var(--mineral-fill); border: 1px solid var(--border); font-size: 0.88rem;
}
.banner p { margin: 0; flex: 1; }
.banner-float {
  position: absolute; top: 12px; left: 12px; right: 12px; margin: 0; z-index: 5;
  background: #F4F9F9; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.banner form { margin: 0; }

/* --- The app page: header, canvas | panel, footer, filling the screen ----- */
body.app-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 430px; }

.canvas {
  position: relative; overflow: hidden; outline: none;
  cursor: grab; touch-action: none;
  background-color: #FAFAF9;
  background-image: radial-gradient(rgba(107, 136, 136, 0.22) 1px, transparent 1px);
  background-size: 22px 22px;
}
.canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--mineral); }
.canvas.is-panning { cursor: grabbing; }
.canvas-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.canvas-edges { position: absolute; left: 0; top: 0; overflow: visible; }
.canvas-nodes { position: absolute; inset: 0; }

.branch { fill: none; stroke: var(--branch); stroke-width: 1.5; stroke-linecap: round; transition: stroke 0.15s; }
.branch.on-path { stroke: var(--teal); }

.q-node {
  position: absolute; cursor: default;
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 8px 12px;
}
.q-node.on-path { border-color: var(--teal); }
.q-node.is-selected { border: 2px solid var(--teal); padding: 7px 11px; box-shadow: 0 4px 16px rgba(13, 77, 77, 0.14); }
.q-text {
  width: 100%; height: 100%; border: none; outline: none; resize: none; overflow: hidden;
  background: transparent; padding: 0; margin: 0;
  font-family: var(--font-header); font-size: 0.82rem; font-weight: 600; line-height: 1.35; color: var(--text);
}
.q-text::placeholder { color: var(--mineral-dark); font-weight: 500; }
.dot-missing {
  display: none; position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 0 2px #fff;
}
.q-node .dot-missing { top: -4px; right: -4px; }
.is-missing > .dot-missing { display: block; }
.q-handles {
  display: none; position: absolute; left: 0; right: 0; bottom: -32px;
  gap: 6px; justify-content: space-between;
}
.q-node.is-selected .q-handles { display: flex; }
.handle {
  height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-family: var(--font-header); font-size: 0.72rem; font-weight: 600; color: var(--teal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.handle:hover { background: var(--teal-soft); border-color: var(--teal); }
.handle-remove { color: var(--danger); width: 24px; padding: 0; }

.a-label {
  position: absolute; height: 26px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px; border-radius: 6px;
}
.a-label.is-selected { background: var(--teal-soft); box-shadow: inset 0 0 0 1.5px var(--teal); }
.a-text {
  flex: 1 1 auto; min-width: 0; border: none; outline: none; background: transparent; padding: 0;
  font-family: var(--font-header); font-size: 0.8rem; font-weight: 600; color: var(--text);
}
.a-text:focus { text-decoration: underline; text-decoration-color: var(--mineral); }
.a-p { flex: none; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; cursor: pointer; }
.a-p.is-rest { color: var(--mineral-dark); }
.a-p.has-range { text-decoration: underline dotted; }
.a-label .dot-missing { position: static; flex: none; }
.a-cost {
  position: absolute; padding: 0 7px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
}
.a-cost.is-missing { color: #8A5A00; background: var(--amber-bg); border-color: rgba(224, 154, 27, 0.5); }

.leaf { position: absolute; height: 28px; display: flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; }
.leaf-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--branch); flex: none; }
.leaf.is-heavy .leaf-dot { background: var(--coral); border-color: var(--coral); }
.leaf-text { font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.leaf .handle { display: none; }
.leaf:hover .handle, .leaf.is-selected .handle { display: inline-block; }

.canvas-tools {
  position: absolute; left: 14px; bottom: 14px;
  display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.canvas-tools button {
  height: 28px; min-width: 28px; padding: 0 8px; border: none; background: none; border-radius: 7px;
  font-family: var(--font-header); font-weight: 600; font-size: 0.85rem;
}
.canvas-tools button:hover { background: var(--mineral-fill); }
.zoom-level { font-size: 0.75rem; color: var(--muted); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.canvas-help { position: absolute; right: 14px; bottom: 10px; margin: 0; font-size: 0.75rem; color: var(--muted); pointer-events: none; }
.toast {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); margin: 0;
  padding: 8px 14px; border-radius: 8px; background: var(--graphite); color: #fff; font-size: 0.85rem;
}

/* --- The panel --------------------------------------------------------------- */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--border);
}
.panel-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 22px 22px; }
.panel-eyebrow, .kicker, .eyebrow {
  margin: 0 0 4px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--mineral-dark);
}
.panel-title { font-size: 1.15rem; margin: 0; line-height: 1.3; }
.panel-sub { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; }
.panel-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.section-title { font-size: 0.9rem; margin-bottom: 8px; }
.field-label { display: block; margin: 12px 0 6px; font-size: 0.82rem; font-weight: 600; }
.field-sub { margin: 10px 0 6px; font-size: 0.76rem; color: var(--muted); }

.text-box, .text-area, .select-box, .number-box {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 0.88rem;
}
.text-area { resize: vertical; min-height: 54px; }
.text-box:focus, .text-area:focus, .select-box:focus, .number-box:focus { outline: 2px solid var(--mineral); outline-offset: 1px; }
.title-box { font-family: var(--font-header); font-size: 1.05rem; font-weight: 600; padding: 8px 10px; }
.number-wrap { display: inline-flex; align-items: center; gap: 5px; }
.number-box { width: 110px; font-variant-numeric: tabular-nums; }
.number-box.is-invalid { outline: 2px solid var(--danger); }
.affix { font-size: 0.85rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 0.82rem; font-weight: 500; line-height: 1.3; text-align: left;
}
.chip:hover:not(:disabled) { background: var(--mineral-fill); }
.chip.is-on { background: #E3EEEE; border: 2px solid var(--mineral-dark); padding: 5px 10px; font-weight: 600; }
.chips .text-box { width: auto; flex: 1 1 140px; }
.suggestions .chip { font-size: 0.78rem; }

.likelihood { display: flex; flex-direction: column; gap: 4px; }
.refine-link { align-self: flex-start; font-size: 0.8rem; }
.refine { margin-top: 2px; }
.range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-row .number-box { width: 80px; }
.range-dash { font-size: 0.8rem; color: var(--muted); }
.answer-chance + .answer-chance { margin-top: 6px; }
.rest-line { margin: 12px 0 0; font-size: 0.86rem; color: var(--muted); }
.answer-list { list-style: none; margin: 0 0 10px; padding: 0; }
.answer-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dotted var(--border); }
.answer-name { flex: 1; background: none; border: none; padding: 0; text-align: left; font-weight: 600; }
.answer-name:hover { text-decoration: underline; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 8px; }
.figure { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.figure-value { display: block; font-family: var(--font-header); font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.figure-label { display: block; font-size: 0.74rem; color: var(--muted); line-height: 1.3; }

.cost-editor {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px 12px; margin-bottom: 10px;
}
.cost-head { display: flex; gap: 8px; margin-bottom: 8px; }
.cost-head .text-box { font-weight: 600; }

.scope-details { margin-top: 10px; }
.scope-details summary { cursor: pointer; font-size: 0.84rem; font-weight: 600; color: var(--teal); }

.next-step {
  margin-top: 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--teal);
}
.next-text { margin: 0 0 8px; font-weight: 500; }

.results { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.headline { margin: 0; font-family: var(--font-header); font-size: 1.35rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.headline-sub { margin: 4px 0 10px; color: var(--muted); font-size: 0.88rem; }
.chart-mini { background: var(--surface); border-radius: 10px; padding: 6px; margin-bottom: 10px; }
.insights { margin: 0 0 12px; padding-left: 18px; font-size: 0.88rem; }
.insights li + li { margin-top: 6px; }
.outcomes { list-style: none; margin: 0 0 12px; padding: 0; }
.outcome {
  display: block; width: 100%; text-align: left; margin-bottom: 6px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.outcome:hover { border-color: var(--mineral-dark); }
.outcome-path { display: block; font-size: 0.72rem; color: var(--muted); }
.outcome-end { display: block; font-size: 0.84rem; font-weight: 600; }
.outcome-figures { display: block; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li + li { margin-top: 4px; }
.check-item {
  display: block; width: 100%; text-align: left; padding: 6px 10px 6px 26px; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-size: 0.82rem;
}
.check-item::before {
  content: ''; position: absolute; left: 9px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber);
}
button.check-item:hover { border-color: var(--mineral-dark); }

/* The guidance box at the bottom of the panel (as in RoSI). */
.panel-guide {
  flex: 0 0 auto; max-height: 34%; overflow-y: auto;
  background: var(--graphite); color: #fff; padding: 12px 22px 14px;
}
.guide-eyebrow {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--mineral);
}
.guide-title { color: #fff; margin: 6px 0 4px; font-size: 0.92rem; }
.guide-text { color: rgba(255, 255, 255, 0.85); font-size: 0.84rem; line-height: 1.5; margin: 0; }
.guide-prompts-head { margin: 12px 0 6px; }
.prompt { background: #3A3A3A; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.prompt-text { margin: 0 0 8px; font-size: 0.78rem; line-height: 1.5; color: #EDEDED; white-space: pre-line; }
.copy-btn {
  padding: 4px 10px; font-size: 0.74rem; font-weight: 600;
  background: transparent; border: 1px solid #5A5A5A; color: #fff; border-radius: 6px;
}
.copy-btn:hover { background: #2E2E2E; }
.tip-icon {
  width: 20px; height: 20px; border-radius: 50%; background: var(--mineral); color: var(--graphite);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.72rem;
}

/* --- Footer ---------------------------------------------------------------- */
.app-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 6px 24px; flex-wrap: wrap;
  padding: 8px 24px; border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--muted);
}
.footer-keep { margin: 0; }
.footer-keep strong { color: var(--text); font-weight: 600; }
.footer-keep > span { display: none; }
.footer-keep[data-state="fresh"] .keep-fresh,
.footer-keep[data-state="saved"] .keep-saved,
.footer-keep[data-state="example"] .keep-example { display: inline; }
.footer-keep .text-btn { height: 24px; margin-left: 6px; }
.footer-credit { color: var(--muted); text-decoration: none; white-space: nowrap; }
.footer-credit:hover { color: var(--text); text-decoration: underline; }

/* --- "Are you sure?" -------------------------------------------------------- */
.confirm { border: none; border-radius: 14px; padding: 20px 22px; max-width: 420px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2); }
.confirm::backdrop { background: rgba(46, 46, 46, 0.35); }
.confirm p { margin: 0 0 16px; }
.confirm .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* --- The report page -------------------------------------------------------- */
.report { max-width: 980px; margin: 0 auto; padding: 28px 24px 60px; }
.report .lede { color: var(--muted); margin: 0 0 20px; font-size: 1rem; }
.key-figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.key-figure { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.key-value { display: block; font-family: var(--font-header); font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.key-label { display: block; color: var(--muted); font-size: 0.84rem; }
.report-section { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.report-section .insights { font-size: 0.95rem; margin: 0; }
.report .chart { margin: 12px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-top: 8px; }
.data-table th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--mineral-dark); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 8px; border-bottom: 1px dotted var(--border); vertical-align: top; font-variant-numeric: tabular-nums; }
.data-table td:not(:first-child), .data-table th:not(:first-child) { white-space: nowrap; }
.path-steps { margin: 0; padding-left: 18px; font-size: 0.82rem; }
.bar { display: inline-block; width: 120px; height: 8px; border-radius: 4px; background: var(--mineral-fill); vertical-align: middle; margin-right: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--coral); }
.outline, .outline ul { list-style: none; padding-left: 18px; margin: 0; }
.outline { padding-left: 0; }
.outline-question { margin: 6px 0; }
.outline-q { font-weight: 600; }
.outline-answer { margin: 4px 0; padding-left: 10px; border-left: 2px solid var(--border); }
.outline-a { font-weight: 600; margin-right: 6px; }
.outline-p { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.outline-cost { display: inline-block; margin-right: 8px; padding: 0 7px; border-radius: 999px; background: var(--mineral-fill); font-size: 0.8rem; }
.outline-note { display: block; color: var(--muted); font-size: 0.8rem; font-style: italic; }
.checklist-plain { padding-left: 18px; }
.method { margin-top: 16px; }

@media print {
  .site-header .header-cta, .site-header .analysis-title { display: none; }
  .report-section { break-inside: avoid; }
  body { background: #fff; }
}

/* --- Narrow screens: the panel goes below the canvas (low priority, as in RoSI). */
@media (max-width: 900px) {
  body.app-page { height: auto; overflow: visible; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  .panel { border-left: none; border-top: 1px solid var(--border); }
  .panel-guide { max-height: none; }
  .canvas-help { display: none; }
  .site-header { flex-wrap: wrap; padding: 10px 16px; }
  .header-tools { margin-left: 0; }
  .key-figures { grid-template-columns: 1fr; }
}
