/* style.css — Cap Table Commander */

:root {
  --bg: #F2EDE3;
  --surface: #FBF8F2;
  --surface-2: #F6F1E7;
  --ink: #1C1A17;
  --ink-2: #4A463E;
  --muted: #8A8275;
  --line: #DDD5C6;
  --line-2: #E8E1D2;
  --safe: #4A6B5C;
  --note: #8B6F47;
  --equity: #6B4A5C;
  --founder: #2D5A4A;
  --investor: #8B4A5C;
  --pool: #B89968;
  --good: #3E6B53;
  --warn: #B8843A;
  --bad: #9B4A3C;
  --shadow: 0 1px 0 rgba(28,26,23,.04), 0 8px 24px -12px rgba(28,26,23,.12);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, 'Times New Roman', Times, serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light){
  :root { color-scheme: light; }
}
html[data-theme="light"] {
  --bg: #F2EDE3; --surface:#FBF8F2; --surface-2:#F6F1E7;
  --ink:#1C1A17; --ink-2:#4A463E; --muted:#8A8275;
  --line:#DDD5C6; --line-2:#E8E1D2;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg:#1A1815; --surface:#232019; --surface-2:#2A2620;
  --ink:#F0EBE0; --ink-2:#C4BCAE; --muted:#8A8275;
  --line:#3A352C; --line-2:#332E26;
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 12px 32px -16px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.brand { display:flex; align-items:center; gap:10px; }
.brand-mark { color: var(--founder); font-size: 18px; }
.brand-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.stage-track {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.stage-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  transition: all .25s ease;
}
.stage-pill.done { color: var(--good); border-color: var(--line); }
.stage-pill.current {
  color: var(--ink);
  border-color: var(--founder);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(45,90,74,.08);
}
.stage-idx {
  display: inline-flex; align-items:center; justify-content:center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--line); color: var(--ink);
  font-size: 10px; font-weight: 600;
  font-family: var(--font-mono);
}
.stage-pill.current .stage-idx { background: var(--founder); color: #fff; }
.stage-pill.done .stage-idx { background: var(--good); color: #fff; }
.stage-name { font-weight: 500; }

.meters { display: flex; gap: 18px; }
.meter { display: flex; flex-direction: column; align-items: flex-end; }
.meter-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.meter-val {
  font-family: var(--font-mono);
  font-weight: 600; font-size: 14px; color: var(--ink);
}
.meter-sector { font-size: 12px; }

/* ---------- Grid ---------- */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 1fr;
  gap: 1px;
  background: var(--line);
  overflow: hidden;
  min-height: 0;
}
.panel {
  background: var(--bg);
  padding: 22px 24px;
  overflow-y: auto;
  min-height: 0;
}
.panel-head { margin-bottom: 18px; }
.panel-head h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.015em;
}
.panel-sub { font-size: 12px; color: var(--muted); }

/* ---------- Cap table ---------- */
.capbar {
  display: flex;
  height: 38px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.cap-seg {
  height: 100%;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.cap-seg:not(:last-child) { border-right: 1px solid rgba(0,0,0,.08); }
html[data-theme="dark"] .cap-seg:not(:last-child) { border-right-color: rgba(255,255,255,.06); }

.cap-legend { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink:0; }
.legend-label { color: var(--ink-2); flex: 1; }
.legend-pct {
  font-family: var(--font-mono);
  font-weight: 600; color: var(--ink);
}

.control-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.control-label {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.control-label span:first-child { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.control-val {
  font-family: var(--font-mono);
  font-weight: 600; font-size: 18px; color: var(--founder);
}
.control-track {
  position: relative;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: visible;
}
.control-fill {
  height: 100%;
  background: var(--founder);
  border-radius: 4px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.control-threshold {
  position: absolute; top: -3px; bottom: -3px;
  width: 1px; background: var(--ink-2); opacity: .4;
}
.control-threshold::after {
  content: attr(data-t) '%';
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 9px; color: var(--muted);
  font-family: var(--font-mono);
}
.control-threshold[data-t="51"] { left: 51%; }
.control-threshold[data-t="40"] { left: 40%; }
.control-status { margin-top: 10px; font-size: 12px; font-weight: 500; }
.control-status.good { color: var(--good); }
.control-status.warn { color: var(--warn); }
.control-status.bad { color: var(--bad); }

.cap-table { font-size: 13px; }
.ct-head, .ct-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
}
.ct-head { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ct-row:last-child { border-bottom: none; }
.ct-name { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.ct-dot { width: 8px; height: 8px; border-radius: 2px; }
.ct-dot.founder { background: var(--founder); }
.ct-dot.investor { background: var(--investor); }
.ct-dot.pool { background: var(--pool); }
.ct-pct, .ct-vote {
  font-family: var(--font-mono);
  font-weight: 600; text-align: right; color: var(--ink);
}

/* ---------- Action panel ---------- */
.instrument-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.inst-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all .2s ease;
  position: relative;
}
.inst-card::before {
  content: '';
  position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; background: var(--inst-color);
  border-radius: 0 2px 2px 0;
  opacity: .3;
  transition: opacity .2s;
}
.inst-card:hover { border-color: var(--inst-color); transform: translateY(-1px); }
.inst-card.selected {
  border-color: var(--inst-color);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--inst-color) 12%, transparent);
}
.inst-card.selected::before { opacity: 1; }
.inst-name { font-weight: 600; font-size: 13px; color: var(--ink); }
.inst-blurb { font-size: 11px; color: var(--muted); line-height: 1.4; }

.terms { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.term-slider { display: flex; flex-direction: column; gap: 6px; }
.term-head { display: flex; justify-content: space-between; align-items: baseline; }
.term-head span:first-child { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.term-val {
  font-family: var(--font-mono);
  font-weight: 600; font-size: 14px; color: var(--ink);
}
.term-slider input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
  margin: 0;
}
.term-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--founder);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  cursor: pointer;
}
.term-slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--founder); border: 2px solid var(--surface);
  cursor: pointer;
}
.term-range {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted);
  font-family: var(--font-mono);
}

.calc-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.calc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.calc-row span { color: var(--ink-2); }
.calc-row strong {
  font-family: var(--font-mono);
  font-weight: 600; color: var(--ink);
}
.calc-row.bad strong { color: var(--bad); }
.calc-row.warn strong { color: var(--warn); }
.calc-notes { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 4px; }
.calc-note { font-size: 11px; color: var(--muted); line-height: 1.4; }

.action-buttons { display: flex; gap: 10px; }
.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary {
  background: var(--founder);
  color: #fff;
  border-color: var(--founder);
}
.btn-primary:hover { background: #245040; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary.disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; }

/* ---------- Feed ---------- */
.sentiment-block { margin-bottom: 20px; }
.sent-label { display: flex; justify-content: space-between; margin-bottom: 8px; }
.sent-label span:first-child { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sent-label span:last-child {
  font-family: var(--font-mono);
  font-weight: 600; font-size: 14px;
}
.sent-track {
  height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden;
  border: 1px solid var(--line);
}
.sent-fill {
  height: 100%; background: var(--muted);
  transition: width .6s cubic-bezier(.4,0,.2,1), background .3s;
}
.sent-fill.hot { background: var(--good); }
.sent-fill.cold { background: var(--bad); }
.sent-zones { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 6px; }

.milestones { margin-bottom: 20px; }
.ms-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid transparent;
}
.ms-item.done { color: var(--ink); background: var(--surface); border-color: var(--line); }
.ms-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.ms-item.done .ms-mark { background: var(--good); color: #fff; }

.feed-list { display: flex; flex-direction: column; gap: 2px; }
.feed-item {
  display: flex; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 12px;
  line-height: 1.45;
}
.feed-stage {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
  width: 64px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 1px;
}
.feed-text { color: var(--ink-2); }
.feed-item.good .feed-text { color: var(--good); }
.feed-item.warn .feed-text { color: var(--warn); }
.feed-item.bad .feed-text { color: var(--bad); }
.feed-item.macro .feed-text { color: var(--ink); font-style: italic; }

/* ---------- Overlay ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(28,26,23,.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
  overflow-y: auto;
}
.overlay.show { display: flex; }
.overlay-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 40px;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 24px 80px -20px rgba(0,0,0,.5);
  max-height: 90vh;
  overflow-y: auto;
}
.ov-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin-bottom: 12px;
}
.ov-eyebrow-good { color: var(--good); }
.ov-eyebrow-warn { color: var(--warn); }
.ov-eyebrow-bad { color: var(--bad); }
.ov-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.ov-lede { color: var(--ink-2); font-size: 15px; line-height: 1.55; margin: 0 0 24px; }
.ov-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 10px; font-weight: 600;
}
.ov-objectives { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.ov-obj {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 13px; color: var(--ink-2);
}
.ov-obj strong { color: var(--ink); }
.ov-obj-num {
  font-family: var(--font-mono);
  font-weight: 600; font-size: 12px;
  color: var(--founder);
  flex-shrink: 0;
  width: 24px;
}
.ov-obj.miss { background: rgba(155,74,60,.08); }
.ov-obj.miss .ov-obj-num { color: var(--bad); }
.ov-rules { font-size: 13px; color: var(--ink-2); line-height: 1.55; margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.ov-rules strong { color: var(--ink); }
.ov-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 22px;
}
.ov-stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
}
.ov-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.ov-stat strong {
  font-family: var(--font-mono);
  font-size: 18px; color: var(--ink); font-weight: 600;
}
.ov-start { width: 100%; padding: 14px; font-size: 15px; }

/* ---------- Sector selection ---------- */
.sector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}
.sector-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}
.sector-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--sector-color);
  opacity: .25;
  transition: opacity .2s;
}
.sector-card:hover { border-color: var(--sector-color); transform: translateY(-1px); }
.sector-card.selected {
  border-color: var(--sector-color);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sector-color) 12%, transparent);
}
.sector-card.selected::before { opacity: 1; }
.sector-name { font-weight: 600; font-size: 13px; color: var(--ink); }
.sector-desc { font-size: 11px; color: var(--muted); line-height: 1.4; }
.sector-stat {
  font-size: 10px; color: var(--muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ---------- Chance card ---------- */
.chance-card {
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  animation: chanceReveal .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes chanceReveal {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chance-card.good {
  background: linear-gradient(135deg, color-mix(in srgb, var(--good) 14%, var(--surface-2)), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--good) 30%, var(--line));
}
.chance-card.bad {
  background: linear-gradient(135deg, color-mix(in srgb, var(--bad) 14%, var(--surface-2)), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line));
}
.chance-card.neutral {
  background: linear-gradient(135deg, color-mix(in srgb, var(--warn) 12%, var(--surface-2)), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--warn) 25%, var(--line));
}
.chance-icon-wrap {
  display: flex; justify-content: center; margin-bottom: 14px;
}
.chance-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 22px; font-weight: 700;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
}
.chance-card.good .chance-icon { color: var(--good); border: 2px solid color-mix(in srgb, var(--good) 40%, var(--line)); }
.chance-card.bad .chance-icon { color: var(--bad); border: 2px solid color-mix(in srgb, var(--bad) 40%, var(--line)); }
.chance-card.neutral .chance-icon { color: var(--warn); border: 2px solid color-mix(in srgb, var(--warn) 40%, var(--line)); }
.chance-eyebrow {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted); margin-bottom: 8px; font-weight: 600;
}
.chance-title {
  font-family: var(--font-serif);
  font-weight: 600; font-size: 24px;
  margin: 0 0 10px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.chance-desc {
  font-size: 14px; color: var(--ink-2); line-height: 1.5;
  margin: 0 0 18px;
}
.chance-effects {
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.chance-effect {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 80px;
}
.chance-effect span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.chance-effect strong { font-family: var(--font-mono); font-size: 16px; font-weight: 600; }
.chance-effect.pos strong { color: var(--good); }
.chance-effect.neg strong { color: var(--bad); }

/* ---------- Responsive ---------- */
@media (max-width: 980px){
  .grid { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; }
  .panel { overflow-y: visible; }
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .stage-track { order: 3; width: 100%; overflow-x: auto; justify-content: flex-start; }
  .meters { margin-left: auto; }
}
@media (max-width: 560px){
  .panel { padding: 18px 16px; }
  .overlay-card { padding: 26px 22px; }
  .ov-title { font-size: 30px; }
  .ov-stats { grid-template-columns: 1fr; }
  .instrument-row { grid-template-columns: 1fr; }
  .sector-grid { grid-template-columns: 1fr; }
  .stage-name { display: none; }
  .stage-pill { padding: 6px 8px; }
  .meters { gap: 10px; }
  .meter-val { font-size: 12px; }
  .meter-sector { font-size: 11px; }
  .chance-title { font-size: 20px; }
  .chance-effect { min-width: 70px; padding: 6px 12px; }
}
