/* ---------------------------------------------------------------------
 * style.css: dark finance-terminal theme shared with the Portfolio
 * Construction Lab. Neon cyan/indigo/magenta is interface chrome only;
 * data colours live in ui.js and come from a validated categorical and
 * status palette.
 * ------------------------------------------------------------------- */

:root {
  color-scheme: dark;
  --page-bg: #05070b;
  --surface-1: #0b0e15;
  --surface-2: #0f131c;
  --surface-3: #131826;
  --border: rgba(0, 240, 255, 0.14);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text-primary: #e6edf7;
  --text-secondary: #9fb0c3;
  --text-muted: #6b7a8f;
  --accent-cyan: #00f0ff;
  --accent-indigo: #8b7bff;
  --accent-magenta: #ff2ec4;
  --sig-gradient: linear-gradient(90deg, #00f0ff, #8b7bff, #ff2ec4, #8b7bff, #00f0ff);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --neg: #e66767;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --focus-ring: rgba(0, 240, 255, 0.55);
  --font: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "SFMono-Regular", "Consolas", "Cascadia Mono", "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--text-primary);
  font-family: var(--font);
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(0, 240, 255, 0.06), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(255, 46, 196, 0.05), transparent 40%);
  background-attachment: fixed;
}

a { color: var(--accent-cyan); }
::selection { background: rgba(0, 240, 255, 0.25); }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface-2); color: var(--accent-cyan); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

button, input, select { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Header ---------- */
.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  flex-wrap: wrap;
  background:
    radial-gradient(70% 160% at 0% 0%, rgba(139, 123, 255, 0.14), transparent 60%),
    radial-gradient(50% 140% at 100% 0%, rgba(0, 240, 255, 0.07), transparent 60%),
    linear-gradient(180deg, #0a0d16, #070910);
  box-shadow: 0 14px 40px -26px rgba(139, 123, 255, 0.55);
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--sig-gradient);
  background-size: 200% 200%;
  animation: sig-drift 8s ease-in-out infinite;
}
@keyframes sig-drift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 46px; height: 28px; flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(139, 123, 255, 0.45)); }
.brand h1 {
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
  font-weight: 700;
  background: linear-gradient(90deg, #e6edf7 30%, #b9b0ff 75%, #00f0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .sub { font-size: 11px; color: var(--text-muted); letter-spacing: 0.04em; margin-top: 2px; }
.brand .sub .as-of { color: var(--text-secondary); font-family: var(--mono); }

.header-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-badge { font-size: 10px; padding: 3px 7px; border: 1px solid var(--good); color: var(--good); border-radius: 3px; letter-spacing: 0.08em; font-family: var(--mono); }

.company-select {
  background: var(--surface-3);
  color: var(--text-primary);
  border: 1px solid var(--accent-cyan);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 12px;
  min-width: 230px;
  box-shadow: 0 10px 28px -14px rgba(0, 240, 255, 0.45);
}
select.plain {
  background: var(--surface-3);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 12px;
  width: 100%;
}

/* ---------- KPI strip ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.kpi-tile { background: var(--surface-1); padding: 12px 18px; }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text-primary); }
.kpi-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-family: var(--mono); }

/* ---------- Tabs ---------- */
.tab-nav { display: flex; gap: 2px; padding: 0 24px; border-bottom: 1px solid var(--border-soft); background: var(--surface-1); overflow-x: auto; }
.tab-btn {
  position: relative;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 16px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-cyan); text-shadow: 0 0 12px rgba(0, 240, 255, 0.5); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--sig-gradient);
  background-size: 200% 200%;
  animation: sig-drift 8s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(139, 123, 255, 0.55);
}
.tab-panel { display: none; padding: 20px 24px 40px; }
.tab-panel.active { display: block; }

.section-intro { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; max-width: 1020px; margin: 0 0 16px; }
.section-intro strong { color: var(--text-primary); }

/* ---------- Layout ---------- */
.panel-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .panel-grid { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }

.card { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 16px 18px; min-width: 0; }
.card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--accent-cyan); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 6px; height: 6px; background: var(--accent-cyan); box-shadow: 0 0 6px 1px var(--accent-cyan); border-radius: 1px; flex-shrink: 0; }
.card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.55; margin: -6px 0 14px; }
.card-desc strong { color: var(--text-secondary); }

/* ---------- Controls ---------- */
.control-group { margin-bottom: 16px; }
.control-group:last-child { margin-bottom: 0; }
.control-label { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; }
.control-label .value { font-family: var(--mono); color: var(--accent-cyan); font-weight: 600; white-space: nowrap; }
.control-hint { font-size: 10px; color: var(--text-muted); margin-top: 5px; line-height: 1.45; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; background: var(--border-soft); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--accent-cyan); box-shadow: 0 0 8px 1px rgba(0, 240, 255, 0.6); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--accent-cyan); box-shadow: 0 0 8px 1px rgba(0, 240, 255, 0.6); cursor: pointer; }
input[type="range"]:disabled { opacity: 0.35; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); margin: 10px 0 0; cursor: pointer; }
.check-row input { accent-color: #00f0ff; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { background: var(--surface-3); border: 1px solid var(--border-soft); color: var(--text-secondary); padding: 8px 12px; border-radius: 5px; font-size: 11px; letter-spacing: 0.04em; cursor: pointer; transition: all 0.15s ease; }
.btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.btn.active { border-color: var(--accent-cyan); color: var(--accent-cyan); background: rgba(0, 240, 255, 0.08); }
.btn.signature { background: linear-gradient(135deg, rgba(0, 240, 255, 0.16), rgba(110, 123, 255, 0.12)); border: 1px solid var(--accent-cyan); color: var(--accent-cyan); font-weight: 600; box-shadow: 0 10px 28px -12px rgba(0, 240, 255, 0.45); }
.btn.signature:hover { background: linear-gradient(135deg, rgba(0, 240, 255, 0.24), rgba(110, 123, 255, 0.18)); transform: translateY(-1px); }

/* ---------- Stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-box { background: var(--surface-3); border: 1px solid var(--border-soft); border-radius: 6px; padding: 12px 14px; min-width: 0; }
.stat-box.lead { border-left: 3px solid var(--accent-cyan); }
.stat-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--text-primary); }
.stat-sub { font-size: 11px; color: var(--text-secondary); margin-top: 3px; font-family: var(--mono); }
.delta-up { color: var(--good); }
.delta-down { color: var(--neg); }

.chart-wrap { position: relative; height: 320px; }
.chart-wrap.tall { height: 400px; }
.chart-wrap.short { height: 250px; }
.legend-note { font-size: 10.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.55; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11px; color: var(--text-secondary); margin: 0 0 10px; }
.legend-row .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 11.5px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data-table th, table.data-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border-soft); color: var(--text-secondary); white-space: nowrap; }
table.data-table th:first-child, table.data-table td:first-child { text-align: left; color: var(--text-primary); }
table.data-table th { color: var(--text-muted); text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.06em; font-weight: 600; }
table.data-table tr.total td { color: var(--text-primary); font-weight: 700; border-top: 1px solid var(--border); }
table.data-table tr.sub td:first-child { color: var(--text-muted); padding-left: 18px; }
table.data-table tr.sub td { color: var(--text-muted); }
table.data-table tr.focus td { background: rgba(57, 135, 229, 0.12); color: var(--text-primary); }
table.data-table tr.group td { color: var(--text-muted); text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.08em; padding-top: 12px; border-bottom-color: var(--border); }
table.data-table td.wrap, table.data-table th.wrap { white-space: normal; text-align: left; font-family: var(--font); line-height: 1.45; }
table.data-table.loose td, table.data-table.loose th { white-space: normal; }
table.data-table th.sortable { cursor: pointer; }
table.data-table th.sortable:hover { color: var(--accent-cyan); }

table.heat { border-collapse: separate; border-spacing: 2px; width: 100%; font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
table.heat th { color: var(--text-muted); font-size: 10px; font-weight: 600; padding: 5px 6px; text-align: center; }
table.heat td { text-align: center; padding: 9px 6px; border-radius: 3px; color: var(--text-primary); }
table.heat td.base { outline: 2px solid var(--text-primary); outline-offset: -2px; font-weight: 700; }
table.heat td.na { color: var(--text-muted); background: var(--surface-3); }
.axis-caption { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.status .ico { width: 14px; height: 14px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #05070b; }
.status.pass .ico { background: var(--good); }
.status.warn .ico { background: var(--warning); }
.status.fail .ico { background: var(--critical); color: #fff; }
.status.pass { color: var(--text-secondary); }
.status.warn { color: var(--text-primary); }
.status.fail { color: var(--text-primary); }

.note-list { margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.note-list li { padding: 7px 0 7px 16px; border-bottom: 1px solid var(--border-soft); position: relative; }
.note-list li:last-child { border-bottom: none; }
.note-list li::before { content: ''; position: absolute; left: 0; top: 14px; width: 6px; height: 6px; border-radius: 1px; background: var(--text-muted); }
.note-list li.warn::before { background: var(--warning); }
.note-list strong { color: var(--text-primary); }

/* comparison meter: what the price implies vs history */
.implied-row { margin-bottom: 16px; }
.implied-row:last-child { margin-bottom: 0; }
.implied-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-secondary); margin-bottom: 7px; }
.implied-head .value { font-family: var(--mono); color: var(--text-primary); font-weight: 700; }
.meter { position: relative; height: 26px; }
.meter .track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; border-radius: 2px; background: var(--surface-3); border: 1px solid var(--border-soft); }
.meter .mark { position: absolute; top: 3px; width: 3px; height: 20px; border-radius: 2px; transform: translateX(-1px); }
.meter .mark.hist { background: var(--text-secondary); }
.meter .mark.implied { background: var(--s2); width: 4px; }
.meter .span { position: absolute; top: 11px; height: 4px; background: rgba(217, 89, 38, 0.45); }
.meter-scale { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--text-muted); font-family: var(--mono); margin-top: 2px; }

.formula { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.pill { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 10px; border: 1px solid var(--border-soft); color: var(--text-secondary); font-family: var(--mono); letter-spacing: 0.04em; }

.footer-note { padding: 18px 24px 32px; color: var(--text-muted); font-size: 11px; line-height: 1.65; border-top: 1px solid var(--border-soft); margin-top: 12px; }
.footer-note strong { color: var(--text-secondary); }

/* chart tooltip (shared, HTML) */
.viz-tip { position: fixed; z-index: 50; pointer-events: none; background: #0b0e15; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 11px; color: var(--text-secondary); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: 280px; line-height: 1.5; opacity: 0; transition: opacity 0.08s ease; }
.viz-tip.show { opacity: 1; }
.viz-tip .tip-title { color: var(--text-primary); font-weight: 600; margin-bottom: 3px; }
.viz-tip .tip-row { display: flex; justify-content: space-between; gap: 14px; font-family: var(--mono); }
.viz-tip .tip-row b { color: var(--text-primary); font-weight: 600; }

/* ---------- Boot ---------- */
.boot { position: fixed; inset: 0; z-index: 200; background: var(--page-bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; transition: opacity 0.35s ease, visibility 0.35s ease; }
.boot.done { opacity: 0; visibility: hidden; }
.boot-mark { width: 120px; height: 72px; filter: drop-shadow(0 0 14px rgba(139, 123, 255, 0.5)); }
.boot-mark rect { animation: bm-grow 1.2s ease-in-out infinite alternate; transform-origin: left center; transform-box: fill-box; }
.boot-mark rect:nth-of-type(2) { animation-delay: 0.15s; }
.boot-mark rect:nth-of-type(3) { animation-delay: 0.3s; }
.boot-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); text-align: center; max-width: 360px; }
@keyframes bm-grow { from { transform: scaleX(0.35); opacity: 0.4; } to { transform: scaleX(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .app-header::after, .tab-btn.active::after, .boot-mark rect { animation: none; }
}

/* ---------- Memo (print-ready one-pager) ---------- */
.memo-overlay { display: none; position: fixed; inset: 0; z-index: 150; background: rgba(5, 7, 11, 0.86); overflow: auto; padding: 24px; }
.memo-overlay.open { display: block; }
.memo-bar { max-width: 820px; margin: 0 auto 12px; display: flex; justify-content: flex-end; gap: 8px; }
.memo-page { max-width: 820px; margin: 0 auto; background: #ffffff; color: #14181f; border-radius: 4px; padding: 34px 38px; font-size: 11.5px; line-height: 1.5; }
.memo-page h2 { font-size: 20px; margin: 0; letter-spacing: 0.01em; }
.memo-page h3 { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: #4a5568; border-bottom: 1px solid #cbd2dc; padding-bottom: 4px; margin: 18px 0 8px; }
.memo-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 3px solid #14181f; padding-bottom: 10px; }
.memo-head .meta { text-align: right; font-size: 10.5px; color: #4a5568; }
.memo-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.memo-kpi { border: 1px solid #cbd2dc; border-radius: 4px; padding: 8px 10px; }
.memo-kpi .l { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: #4a5568; }
.memo-kpi .v { font-size: 16px; font-weight: 700; font-family: var(--mono); }
.memo-kpi .s { font-size: 10px; color: #4a5568; font-family: var(--mono); }
.memo-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.memo-page table { width: 100%; border-collapse: collapse; font-size: 10.5px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.memo-page th, .memo-page td { text-align: right; padding: 3.5px 5px; border-bottom: 1px solid #e2e6ec; }
.memo-page th:first-child, .memo-page td:first-child { text-align: left; }
.memo-page th { font-size: 9px; text-transform: uppercase; color: #4a5568; letter-spacing: 0.05em; }
.memo-page p { margin: 0 0 7px; }
.memo-page .fine { font-size: 9.5px; color: #4a5568; margin-top: 14px; border-top: 1px solid #cbd2dc; padding-top: 8px; }
.memo-range { position: relative; height: 16px; margin: 3px 0; }
.memo-range .bar { position: absolute; top: 4px; height: 8px; background: #2a78d6; border-radius: 2px; }
.memo-range .px { position: absolute; top: 0; width: 2px; height: 16px; background: #14181f; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  body > *:not(.memo-overlay) { display: none !important; }
  .memo-overlay { position: static; display: block !important; background: #fff; padding: 0; overflow: visible; }
  .memo-bar { display: none; }
  .memo-page { max-width: none; padding: 0; border-radius: 0; }
}

/* ---------- Research desk additions ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
@media (max-width: 1100px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero-figure { font-family: var(--mono); font-size: 54px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.hero-figure small { font-size: 22px; color: var(--text-muted); font-weight: 400; }
.hero-caption { font-size: 13px; color: var(--text-secondary); margin-top: 10px; line-height: 1.55; max-width: 560px; }
.project-card { display: block; text-decoration: none; background: var(--surface-3); border: 1px solid var(--border-soft); border-radius: 6px; padding: 14px 16px; transition: border-color 0.15s ease, transform 0.15s ease; }
.project-card:hover { border-color: var(--accent-cyan); transform: translateY(-1px); }
.project-card .name { color: var(--text-primary); font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.project-card .what { color: var(--text-muted); font-size: 11.5px; line-height: 1.5; }
.project-card .state { margin-top: 10px; }
.hash { font-family: var(--mono); font-size: 11px; color: var(--text-secondary); word-break: break-all; }
.empty-state { border: 1px dashed var(--border-soft); border-radius: 6px; padding: 18px; color: var(--text-secondary); font-size: 12.5px; line-height: 1.6; }
.empty-state strong { color: var(--text-primary); }
.tag { display: inline-block; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; border: 1px solid var(--border-soft); color: var(--text-muted); font-family: var(--mono); margin-left: 8px; vertical-align: 1px; }
.tag.live { border-color: var(--good); color: var(--good); }
.tag.recon { border-color: var(--warning); color: var(--warning); }
