/* ── Variables (from the site style.css) ─────────────────── */
:root {
  --bg-page:        #12006b;
  --sidebar-dark:   #5A0000;
  --sidebar-darker: #3D0000;
  --accent:         #1b20bd;
  --accent-light:   #0f2f79;
  --accent-dim:     rgba(0, 153, 255, 0.18);
  --accent-mid:     rgba(0, 153, 255, 0.30);
  --nav-text:       #ffffff;
  --nav-text-dim:   rgba(255, 255, 255, 0.38);
  --bg-card:        #ffffff;
  --text:           #222222;
  --text-secondary: #555555;
  --field-line:     #b9b9c6;
  --content-width:  calc((68ch + 5.2rem) * 4 / 3);
  --topbar-h:       2.9rem;   /* sticky bar with the login button; the sticky header and step index sit below it */
  --box-gap:        2.4rem; /* the site uses 4.8rem; halved because a form stacks many cards */
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
[hidden]:not([hidden=until-found i]) { display: none !important; }

/* ── Page ────────────────────────────────────────────────── */
body {
  background-color: var(--bg-page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.shell {
  width: calc(var(--content-width) + 17rem);
  max-width: 100%;
  display: flex;
  align-items: flex-start;
  gap: var(--box-gap);
  padding: 0 clamp(1rem, 5vw, 4rem) 2rem;
}
.wrap {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--box-gap);
}

/* ── Step index (left) ───────────────────────────────────── */
.steps {
  flex: 0 0 15rem;
  position: sticky;
  top: calc(var(--topbar-h) + 0.5rem);
  margin-top: 0.5rem;
  z-index: 20;
  background: var(--sidebar-dark);
}
.steps ol { list-style: none; }
.steps li + li { border-top: 1px solid rgba(255, 255, 255, 0.1); }
.steps a, .steps .off {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.9rem 1.2rem;
  color: var(--nav-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.35;
  border-left: 3px solid transparent;
}
.steps a:hover { background: rgba(0, 0, 0, 0.22); }
.steps a[aria-current="step"] {
  background: rgba(0, 0, 0, 0.3);
  border-left-color: #fff;
  font-weight: 600;
}
.steps .off { color: var(--nav-text-dim); cursor: default; }
.steps .n {
  flex: none;
  min-width: 1.1rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}
.steps .result { background: rgba(0, 0, 0, 0.2); }
.steps .result .n { font-size: 1.1rem; }
.steps :focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* ── Top bar: floating dark-red box, sticky ──────────────── */
.masthead {
  position: sticky;
  top: calc(var(--topbar-h) + 0.5rem);
  z-index: 20;
  margin-top: 0.5rem;
  background: var(--sidebar-dark);
  color: var(--nav-text);
  padding: 1rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.6rem;
  flex-wrap: wrap;
}
.masthead h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}
.masthead p {
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--nav-text-dim);
}
.country {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.country label.cap { color: var(--nav-text); }
.country select {
  width: auto;
  min-width: 14rem;
  background-color: rgba(0, 0, 0, 0.25);
  color: var(--nav-text);
  border-color: rgba(255, 255, 255, 0.35);
}
.topbar { position: sticky; top: 0; z-index: 30; align-self: stretch; height: var(--topbar-h); display: flex; align-items: flex-end; justify-content: flex-end; padding: 0 clamp(1rem, 2vw, 1.6rem); background: var(--bg-page); }
.login-top { display: flex; align-items: center; gap: 0.7rem; }
.login-name { font-size: 0.95rem; color: var(--nav-text); max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-btn { background: transparent; color: var(--nav-text); border: 1px solid rgba(255, 255, 255, 0.6); padding: 0.45rem 1rem; font: inherit; font-size: 0.95rem; cursor: pointer; }
.login-btn:hover { background: #fff; color: var(--sidebar-dark); }
.country select option,
.country select optgroup { color: var(--text); background: #fff; }

/* ── Content cards ───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  color: var(--text);
  padding: 2.2rem 2.6rem 2.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-width: 0;
}
.eyebrow {
  font-size: 1.29rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem 1.6rem;
}
.trio {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--box-gap);
  align-items: stretch;
}
.f {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
label.cap {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

/* ── Form controls ───────────────────────────────────────── */
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--field-line);
  border-radius: 0;
  padding: 0.5rem 0.8rem;
  resize: none;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px);
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.country select:focus-visible { outline-color: #fff; }
#company-name {
  font-size: 1.86rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--accent);
  padding: 0.5rem 0.8rem;
}
.trio textarea { flex: 1 1 auto; }

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.slider-head strong {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.2rem 0.3rem;
  border-bottom: 1px solid #e3e3ea;
}
.row:last-of-type { border-bottom: none; }
.row:hover { background: var(--accent-dim); }
.row input[type="checkbox"] {
  width: 1.2rem; height: 1.2rem; flex: none;
  accent-color: var(--accent);
}
.row span { flex: 1; min-width: 0; font-size: 1rem; }
.row button {
  -webkit-appearance: none; appearance: none;
  font-family: inherit;
  font-size: 1.2rem;
  line-height: 1;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  flex: none;
}
.row button:hover { color: var(--accent); background: var(--accent-mid); }

.adder { display: flex; gap: 0.6rem; margin-top: 0.4rem; }
.adder input { flex: 1; min-width: 0; }
.ghost {
  -webkit-appearance: none; appearance: none;
  font-family: inherit;
  font-size: 1rem;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 0;
  padding: 0 1.2rem;
  cursor: pointer;
  flex: none;
}
.ghost:hover { background: var(--accent); color: #fff; }

/* ── Footer and primary action ───────────────────────────── */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.6rem;
  flex-wrap: wrap;
}
.footer p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--nav-text);
  max-width: 48ch;
}
.primary {
  -webkit-appearance: none; appearance: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 0;
  padding: 0 2rem;
  height: 3rem;
  cursor: pointer;
}
.primary:hover { background: var(--accent-light); }
.footer .primary:focus-visible, .masthead :focus-visible { outline-color: #fff; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .shell { flex-direction: column; align-items: stretch; gap: 0; }
  .wrap { margin-top: var(--box-gap); }
  .steps { flex: none; position: static; margin-top: 0.6rem; overflow-x: auto; }
  .steps ol { display: flex; }
  .steps li + li { border-top: none; border-left: 1px solid rgba(255, 255, 255, 0.1); }
  .steps a, .steps .off { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .steps a[aria-current="step"] { border-bottom-color: #fff; }
  .masthead { margin-top: 0; }
  .masthead { top: calc(var(--topbar-h) + 0.3rem); margin-top: 0.6rem; padding: 0.8rem 1.2rem; }
  .card { padding: 1.5rem; }
  #company-name { font-size: 1.5rem; }
}
@media (max-width: 600px) {
  .trio { grid-template-columns: 1fr; }
  .country { width: 100%; }
  .country select { flex: 1; min-width: 0; }
  .footer { flex-direction: column; align-items: stretch; }
  .primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Step 2 and shared additions ─────────────────────────── */
.view { display: flex; flex-direction: column; gap: var(--box-gap); }
.actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.ghost.tall { height: 3rem; padding: 0 1.4rem; }
.footer .ghost, .actions .ghost.tall { background: rgba(0,0,0,0.25); color: #fff; border-color: rgba(255,255,255,0.55); }
.footer .ghost:hover, .actions .ghost.tall:hover { background: rgba(0,0,0,0.45); }
.status { color: #fff; font-size: 0.95rem; }
.status.error { background: #5A0000; padding: 0.7rem 1rem; }
.on-step-2 .country { display: none; }
.hint { font-size: 0.95rem; color: var(--text-secondary); margin-top: 0.3rem; }
.step2-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.step2-head .ghost { color: var(--accent); background: transparent; border-color: var(--accent); }
.step2-head .ghost:hover { background: var(--accent); color: #fff; }
.firm-list { display: flex; flex-direction: column; gap: var(--box-gap); }
.firm-head { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(200px, 1.4fr) auto auto; gap: 1rem; align-items: end; }
.firm-head .chk { display: flex; align-items: center; gap: 0.5rem; height: 2.7rem; white-space: nowrap; }
.firm-head .chk input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.firm-head .name { font-size: 1.2rem; font-weight: 600; color: var(--accent); }
.mkt { width: 100%; border-collapse: collapse; }
.mkt th { text-align: left; font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); padding: 0 0.4rem 0.3rem 0; }
.mkt td { padding: 0 0.4rem 0.4rem 0; vertical-align: top; }
.mkt td.x { width: 2.4rem; padding-right: 0; }
.mkt .del { background: transparent; border: none; font-size: 1.3rem; line-height: 1; color: var(--text-secondary); cursor: pointer; padding: 0.4rem 0.6rem; }
.mkt .del:hover { color: var(--accent); background: var(--accent-mid); }
.mkt-wrap { overflow-x: auto; }
.mkt-wrap .mkt { min-width: 660px; }
.err-text { color: #a00000; font-size: 0.9rem; }
input.bad, select.bad { border-color: #a00000; }
@media (max-width: 860px) { .firm-head { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .firm-head { grid-template-columns: 1fr; } .actions { flex-direction: column; } }

/* ── Step 3 ──────────────────────────────────────────────── */
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; border-bottom: 1.5px solid var(--field-line); }
.tab { font: inherit; font-size: 1rem; font-weight: 600; background: transparent; color: var(--text-secondary); border: none; border-bottom: 3px solid transparent; padding: 0.6rem 1rem; cursor: pointer; margin-bottom: -1.5px; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:disabled { cursor: not-allowed; opacity: 0.6; }
.market-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: var(--box-gap); align-items: start; }
.controls { display: flex; flex-flow: row wrap; align-items: flex-end; gap: 1rem 2rem; margin-top: var(--box-gap); }
.controls .f { min-width: 12rem; }
.controls .hint { flex-basis: 100%; }
.controls fieldset { border: none; display: flex; flex-direction: column; gap: 0.3rem; }
.controls fieldset label { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }
.controls input[type="radio"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.controls label.off { color: #9a9aa8; }
.chart-block { margin-bottom: 0.6rem; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; font-size: 1rem; font-weight: 600; }
.chart-title .badge { font-size: 0.8rem; font-weight: 500; padding: 0 0.5rem; color: #fff; background: var(--accent); }
.chart-title .badge.calc { background: var(--sidebar-dark); }
.chart-svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.chart-svg text { font-family: inherit; font-size: 11px; fill: var(--text-secondary); }
.chart-svg .grid { stroke: #e3e3ea; stroke-width: 1; }
.chart-svg .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart-svg .line.calc { stroke: var(--sidebar-dark); stroke-dasharray: 6 4; }
.chart-svg .pt { fill: var(--accent); stroke: #fff; stroke-width: 2; cursor: ns-resize; touch-action: none; }
.chart-svg .pt:focus-visible { outline: none; stroke: #000; stroke-width: 3; }
.chart-svg .pt.calc { fill: var(--sidebar-dark); cursor: default; }
.chart-svg .pt.warn { stroke: #e08a00; stroke-width: 3; }
.data-wrap { overflow-x: auto; margin-top: 0.8rem; }
.data-table { border-collapse: collapse; min-width: 720px; width: 100%; }
.data-table th, .data-table td { padding: 0.15rem 0.25rem; font-size: 0.85rem; text-align: right; }
.data-table th:first-child { text-align: left; font-weight: 600; white-space: nowrap; padding-right: 0.6rem; }
.data-table thead th { color: var(--text-secondary); font-weight: 500; }
.data-table input { padding: 0.2rem 0.3rem; font-size: 0.85rem; text-align: right; min-width: 4.2rem; }
.data-table input:disabled { background: #f1e4e4; color: var(--sidebar-dark); border-color: #d9bcbc; }
@media (max-width: 860px) {
  .market-layout { grid-template-columns: 1fr; }
}

.chart-svg .pt.calc { cursor: ns-resize; touch-action: none; }
.chart-svg .pt.calc:focus-visible { outline: none; stroke: #000; stroke-width: 3; }
.data-table input:disabled { background: #fff; }
.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 50; width: min(28rem, calc(100vw - 2.4rem)); padding: 1.3rem 3rem 1.3rem 1.5rem; color: var(--text); font-size: 1rem; line-height: 1.5; background: #fff; border: 3px solid var(--sidebar-dark); border-radius: 16px; }
.toast[hidden] { display: none; }
.toast strong { color: var(--sidebar-dark); font-size: 1.15rem; }
.toast ul { padding-left: 1.1rem; margin-top: 0.4rem; }
.toast li { margin-bottom: 0.3rem; }
.toast-x { position: absolute; top: 0.4rem; right: 0.6rem; font: inherit; font-size: 1.6rem; line-height: 1; color: var(--sidebar-dark); background: transparent; border: none; border-radius: 8px; cursor: pointer; padding: 0.1rem 0.6rem; }
.toast-x:hover { background: #f1e4e4; }
.modal-back { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(8, 0, 40, 0.65); }
.modal { background: #fff; color: var(--text); width: min(30rem, 100%); padding: 1.8rem 2rem; display: flex; flex-direction: column; gap: 1rem; }
.modal h3 { font-size: 1.29rem; color: var(--accent); }
.modal .choices { display: flex; flex-direction: column; gap: 0.4rem; }
.modal .choices label { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }
.modal .choices input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.modal .actions { justify-content: flex-end; }
.modal .ghost.tall { color: var(--accent); background: transparent; border-color: var(--accent); }
.modal .ghost.tall:hover { background: var(--accent); color: #fff; }

.chart-svg text.val { font-size: 11px; font-weight: 600; fill: var(--text, #1a1a2e); pointer-events: none; }
.chart-svg .line.second { stroke-width: 1.5; }
.chart-svg text.val.second { font-style: italic; font-weight: 500; }
.chart-title .legend { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; font-weight: 500; align-items: flex-start; }
.chart-title .legend-item { display: flex; align-items: center; gap: 0.5rem; }
.chart-title .legend-item .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart-title .legend-item .line.second { stroke-width: 1.5; }
.chart-title .legend-item .line.calc { stroke: var(--sidebar-dark); stroke-dasharray: 6 4; }

/* One colour per series; shape shows the state (round = draggable, square = calculated). */
.s-tam_musd { --c: #1b20bd; }
.s-served_musd { --c: #0b86d9; }
.s-revenue_musd { --c: #a01818; }
.s-served_pct { --c: #1b20bd; }
.s-share_pct { --c: #a01818; }
.chart-svg .line, .chart-svg .line.second, .chart-title .legend-item .line, .chart-title .legend-item .line.second { stroke: var(--c); stroke-width: 2.5; stroke-dasharray: none; }
.chart-svg .pt, .chart-svg .pt.calc { fill: var(--c); }
.chart-svg text.val { fill: var(--c); font-style: normal; font-weight: 700; }
.chart-title .badge, .chart-title .badge.calc { background: none; color: inherit; border: 1px solid currentColor; font-size: 0.75rem; }
.legend-item .mk { fill: var(--c); stroke: #fff; stroke-width: 1; }

/* Step 3 header: one compact row, more room for the graphs */
.s3-head { padding-bottom: 0; gap: 0.4rem; }
.s3-head .tabrow { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 0.4rem 2rem; }
.s3-head .tabs { border-bottom: none; }
.s3-head .tabs.views { margin-left: auto; }
#charts { padding: 1rem 1rem 0.6rem; }

/* Step 3: tabs sit on top of the chart card; tighter spacing and a compact settings card */
#view-3 { gap: 0.8rem; }
.s3-main { display: flex; flex-direction: column; }
.s3-main .tabs.views { margin: 0; background: var(--bg-card); padding: 0.3rem 1.2rem 0; border-bottom: 1.5px solid var(--field-line); }
.s3-main .tab { padding: 0.4rem 0.9rem; font-size: 0.9rem; }
.s3-head .tabrow { margin: 0; }
.card.controls { margin-top: 0; padding: 0.6rem 1.2rem; gap: 0.5rem 1.5rem; }
.controls .f { min-width: 9rem; gap: 0.15rem; }
.controls label.cap { font-size: 0.75rem; }
.controls select, .controls input[type="number"] { font-size: 0.85rem; padding: 0.3rem 0.5rem; min-height: 0; height: auto; }
.controls .hint { font-size: 0.8rem; }
.controls select, .controls input[type="number"] { line-height: 1.3; }
.s3-main .tabs.views { background: #fff; border-bottom: none; }
.s3-main .tab { background: #fff; color: var(--text); }
.s3-main .tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* Sector activity (step 1) and workforce composition (step 4) */
.sector-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; border-bottom: 1px solid var(--field-line); }
.sector-row > span:first-child { flex: 1; min-width: 0; font-size: 0.95rem; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.sector-row input[type="number"], .occ-table input[type="number"] { width: 5.5rem; font-size: 0.9rem; padding: 0.25rem 0.5rem; text-align: right; }
.sector-row .unit { color: var(--text-secondary); }
.sector-row .x, .occ-table .x { font: inherit; font-size: 1.2rem; line-height: 1; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 0.1rem 0.5rem; }
.sector-row .x:hover, .occ-table .x:hover { color: var(--accent); }
.sector-total { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-weight: 600; }
.sector-total .bad, .occ-table .bad { color: #a00000; }
.occ-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.occ-table th, .occ-table td { padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--field-line); text-align: left; font-weight: 400; vertical-align: middle; }
.occ-table thead th { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; }
.occ-table .num { text-align: right; width: 9rem; white-space: nowrap; }
.occ-table .undo { width: 1.5rem; height: 1.5rem; margin-left: 0.4rem; padding: 0; border: 1px solid var(--accent); border-radius: 50%; background: none; color: var(--accent); font-size: 0.95rem; line-height: 1; cursor: pointer; vertical-align: middle; }
.occ-table .undo:hover { background: var(--accent); color: #fff; }
.occ-table .barcol { width: 28%; }
.occ-table tfoot th, .occ-table tfoot td { font-weight: 600; }
.bar { background: #e8e8f0; height: 0.6rem; }
.bar span { display: block; height: 100%; background: var(--accent); }
.sr { position: absolute; left: -9999px; }

.info-btn { font: italic 700 0.8rem/1 Georgia, serif; width: 1.3rem; height: 1.3rem; padding: 0; margin-left: 0.4rem; vertical-align: middle; border-radius: 50%; border: 1.5px solid var(--accent); background: #fff; color: var(--accent); cursor: pointer; }
.info-btn:hover { background: var(--accent); color: #fff; }

/* Competitors (1.1) and step index sub-items */
.adder select { width: auto; flex: none; min-width: 9rem; }
.comp-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0; border-bottom: 1px solid var(--field-line); }
.comp-row input[type="text"] { flex: 1; min-width: 0; font-size: 0.95rem; padding: 0.3rem 0.5rem; }
.comp-row select { width: auto; flex: none; min-width: 13rem; font-size: 0.9rem; padding: 0.3rem 0.5rem; line-height: 1.3; }
.comp-row .x { font: inherit; font-size: 1.2rem; line-height: 1; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 0.1rem 0.5rem; }
.comp-row .x:hover { color: var(--accent); }
.steps ol.sub li + li { border-top: none; }
.steps ol.sub a { padding: 0.4rem 1.2rem 0.4rem 2.2rem; font-size: 0.85rem; font-weight: 400; opacity: 0.85; }
.sector-buttons { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Intro page: the system explanation in a plain white box like the other cards */
.intro { background: var(--bg-card); color: var(--text); padding: 2.2rem 2.6rem 2.8rem; display: flex; flex-direction: column; gap: 0.9rem; line-height: 1.55; }
.intro h2 { color: var(--sidebar-dark); font-size: 1.5rem; line-height: 1.25; }
.intro h3 { color: var(--accent); font-size: 1.05rem; margin-top: 0.6rem; }
.intro ol, .intro ul { padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.35rem; }
.intro .intro-key { border-left: 5px solid var(--sidebar-dark); background: #f6eded; padding: 0.9rem 1.1rem; font-size: 1.05rem; }
.intro .actions { margin-top: 0.8rem; }
a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.info-btn.static { display: inline-block; text-align: center; line-height: 1.3rem; cursor: default; vertical-align: middle; }
.info-btn.static:hover { background: #fff; color: var(--accent); }
.modal.note { width: min(36rem, 100%); max-height: 88vh; overflow-y: auto; }
.modal.note ul { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.3rem; }
.modal.note p, .modal.note li { line-height: 1.5; }

/* Start page: account box; sign-in buttons; saved firms */
.start-actions { gap: 0.8rem; flex-wrap: wrap; justify-content: flex-start; }
.account { border-top: 1px solid var(--field-line); padding-top: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.account h4 { color: var(--accent); font-size: 1rem; margin-top: 0.4rem; }
.provider-buttons { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.provider-buttons .provider { min-width: 14rem; }
.provider-buttons .provider.apple { background: #000; }
.modal .provider-buttons { flex-direction: column; }
.saved-firm { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; border-bottom: 1px solid var(--field-line); }
.saved-firm > span:first-child { flex: 1; min-width: 0; font-weight: 600; }
.saved-firm .date { color: var(--text-secondary); font-size: 0.85rem; }
.account .ghost, .saved-firm .ghost { color: var(--accent); background: transparent; border: 1.5px solid var(--accent); padding: 0.3rem 0.9rem; cursor: pointer; font: inherit; }
.account .ghost:hover { background: var(--accent); color: #fff; }
.provider-buttons .ghost.tall { height: 3rem; }

/* Competitors: expandable description and notes */
.comp-item { border-bottom: 1px solid var(--field-line); }
.comp-item .comp-row { border-bottom: none; }
.comp-row .toggle { width: 1.6rem; padding: 0.1rem 0.2rem; text-align: center; color: var(--accent); }
.comp-row .toggle.has-text { font-weight: 700; }
.comp-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.8rem 1.2rem; padding: 0.2rem 0.4rem 0.8rem 2.2rem; }
.comp-details[hidden] { display: none; }
.comp-details textarea { font-size: 0.9rem; }
.footer-left { display: inline-flex; align-items: center; gap: 0.5rem; }

/* Links of the firms in 1.1 */
.comp-link { flex: 0 1 14rem; min-width: 0; display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
.comp-link a { color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.comp-link .link-none { font-size: 0.85rem; color: var(--text-secondary); cursor: help; }
.link-state { flex: none; font-size: 0.75rem; font-weight: 700; line-height: 1; padding: 0.2rem 0.35rem; border: 1px solid currentColor; cursor: help; }
.link-state.ok { color: #1a7a2e; }
.link-state.blocked { color: #8a6100; }
.link-state.not_found, .link-state.error { color: #a00000; }
.link-state.checking { color: var(--text-secondary); }
.comp-details input[type="url"] { font-size: 0.9rem; padding: 0.3rem 0.5rem; }

/* Admin: circled c opens the last LLM call of a button */
.call-btn { font: 700 0.8rem/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; width: 1.3rem; height: 1.3rem; padding: 0; margin-left: 0.4rem; vertical-align: middle; border-radius: 50%; border: 1.5px solid #a01818; background: #fff; color: #a01818; cursor: pointer; flex: none; }
.call-btn:hover { background: #a01818; color: #fff; }
.modal.llm-call { width: min(60rem, 100%); max-height: 90vh; overflow-y: auto; }
.llm-call dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; font-size: 0.85rem; }
.llm-call dt { color: var(--text-secondary); }
.llm-call h4 { font-size: 0.95rem; margin-top: 0.6rem; color: var(--accent); }
.llm-call h5 { font-size: 0.8rem; margin-top: 0.4rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.llm-call pre { white-space: pre-wrap; word-break: break-word; font-size: 0.78rem; line-height: 1.45; background: #f4f4f8; border: 1px solid var(--field-line); padding: 0.6rem 0.8rem; max-height: 22rem; overflow-y: auto; }
.llm-call pre.err { color: #a00000; }

/* Processing toast while the AI model works (app.js, renderLlmToast); does not block the page */
.llm-toast { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 60; width: min(24rem, calc(100vw - 2rem)); padding: 0.9rem 1.1rem; color: var(--text); font-size: 0.95rem; line-height: 1.45; background: #fff; border: 2px solid var(--sidebar-dark); border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.llm-toast[hidden] { display: none; }
.llm-toast-row { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; color: var(--sidebar-dark); }
.llm-toast-row + .llm-toast-row { margin-top: 0.35rem; }
.llm-toast-hint { margin-top: 0.4rem; color: var(--text-secondary); font-size: 0.85rem; }
.llm-spin { flex: none; width: 1rem; height: 1rem; border: 2px solid #e8caca; border-top-color: var(--sidebar-dark); border-radius: 50%; animation: llm-spin 0.9s linear infinite; }
@keyframes llm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .llm-spin { animation-duration: 3s; } }

/* "Keep firm saved" switch in the footers (auth.js); sits on the dark page background like the ghost buttons */
.keep-toggle { -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; gap: 0.6rem; height: 3rem; padding: 0 1.2rem; font: inherit; font-size: 1rem; color: #fff; background: rgba(0,0,0,0.25); border: 1.5px solid rgba(255,255,255,0.55); border-radius: 0; cursor: pointer; flex: none; }
.keep-toggle:hover { border-color: #fff; }
.keep-toggle .switch { position: relative; flex: none; width: 2.3rem; height: 1.3rem; border-radius: 999px; background: rgba(255,255,255,0.3); transition: background 0.15s; }
.keep-toggle .switch::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.keep-toggle[aria-checked="true"] .switch { background: #2fa84f; }
.keep-toggle[aria-checked="true"] .switch::after { transform: translateX(1rem); }
.keep-toggle .keep-when { font-size: 0.8rem; opacity: 0.8; }
.keep-toggle .keep-when:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .keep-toggle .switch, .keep-toggle .switch::after { transition: none; } }

/* Dialog button for deleting */
.danger { -webkit-appearance: none; appearance: none; font: inherit; font-size: 1rem; font-weight: 600; height: 3rem; padding: 0 1.4rem; color: #fff; background: #a00000; border: 1.5px solid #a00000; border-radius: 0; cursor: pointer; }
.danger:hover { background: #7a0000; }

/* Toasts about saving (auth.js); bottom left, the AI toast is bottom right */
.save-toast { position: fixed; left: 1.2rem; bottom: 1.2rem; z-index: 60; width: min(26rem, calc(100vw - 2rem)); padding: 0.9rem 2.6rem 0.9rem 1.1rem; color: var(--text); font-size: 0.92rem; line-height: 1.45; background: #fff; border: 2px solid #2fa84f; border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.save-toast.error { border-color: #a00000; }
.save-toast[hidden] { display: none; }
.save-toast strong { display: block; margin-bottom: 0.25rem; color: var(--sidebar-dark); font-size: 1rem; }
.save-toast p { margin: 0; }

/* "Load firm profile" menu next to Log out */
.firm-menu { position: relative; }
.firm-menu[hidden] { display: none; }
.firm-menu-list { position: absolute; right: 0; top: calc(100% + 0.3rem); z-index: 40; width: min(22rem, calc(100vw - 2rem)); max-height: 60vh; overflow-y: auto; background: #fff; color: var(--text); border: 1px solid #ccc; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }
.firm-menu-list[hidden] { display: none; }
.firm-menu-row { display: flex; align-items: stretch; border-bottom: 1px solid #eee; }
.firm-menu-row:last-child { border-bottom: none; }
.firm-menu-open { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.6rem 0.8rem; font: inherit; font-size: 0.95rem; text-align: left; color: var(--text); background: none; border: none; cursor: pointer; }
.firm-menu-open:hover, .firm-menu-open:focus-visible { background: var(--accent-mid, #eef); }
.firm-menu-open .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.firm-menu-open .date { flex: none; font-size: 0.8rem; color: var(--text-secondary); }
.firm-menu-row.current .name { font-weight: 700; }
.firm-menu-del { flex: none; width: 2.4rem; font: inherit; font-size: 1.3rem; line-height: 1; color: #a00000; background: none; border: none; border-left: 1px solid #eee; cursor: pointer; }
.firm-menu-del:hover, .firm-menu-del:focus-visible { background: #fbe9e9; }
.firm-menu-empty { margin: 0; padding: 0.8rem; font-size: 0.9rem; color: var(--text-secondary); }
.llm-call .call-sources { font-size: 0.8rem; max-height: 14rem; overflow-y: auto; padding-left: 1.2rem; }
.llm-call .call-sources a { color: var(--accent); word-break: break-word; }
/* Step 3: points selected with Shift + click */
.chart-svg .pt.sel { stroke: #000; stroke-width: 3.5; r: 10; }

/* "LLM costs" menu (administrators, auth.js) */
.cost-panel { width: min(40rem, calc(100vw - 2rem)); padding: 0.9rem 1rem; }
.cost-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; }
.cost-col h4 { margin: 0; font-size: 1rem; color: var(--sidebar-dark); }
.cost-sub { font-size: 0.8rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-total { margin: 0.3rem 0 0.4rem; font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.cost-col dl { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.6rem; margin: 0; font-size: 0.85rem; }
.cost-col dt { color: var(--text-secondary); }
.cost-col dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.cost-note { margin: 0.8rem 0 0; font-size: 0.78rem; color: var(--text-secondary); }
.cost-config { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.8rem; margin: 0 0 0.9rem; padding-bottom: 0.8rem; border-bottom: 1px solid #eee; font-size: 0.85rem; }
.cost-config dt { color: var(--text-secondary); }
.cost-config dd { margin: 0; }
