:root {
  color-scheme: dark;
  --bg: #090b0f;
  --surface: #11151b;
  --surface-2: #171c23;
  --border: #2a313b;
  --text: #edf1f5;
  --muted: #929eaa;
  --accent: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --ready: #38bdf8;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --focus: #86efac;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 44px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.desk-nav { display: flex; gap: 4px; margin: -8px 0 16px; border-bottom: 1px solid var(--border); }
.desk-nav button { min-height: 44px; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 750; cursor: pointer; }
.desk-nav button:hover, .desk-nav button:focus-visible, .desk-nav button.active { color: var(--text); border-bottom-color: var(--accent); background: #10151a; }
.desk-view[hidden] { display: none; }
.eyebrow, .status-label, .metric span, .cell span, .muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, p { margin: 0; }
h1 { font-size: 34px; line-height: 1; }
h2 { font-size: 18px; line-height: 1.2; }
.subtitle { color: #adc0d5; margin-top: 10px; max-width: 760px; font-size: 15px; }
.status-card, .metric, .panel, .deal-row, .outreach, .stage {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
}
.status-card { display: grid; grid-template-columns: 10px 1fr; align-items: center; gap: 12px; min-width: 142px; padding: 12px 14px; }
.status-card strong { display: block; margin-top: 3px; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--warn); box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.12); }
.status-dot.live { background: var(--accent); box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12); }
.status-dot.error { background: var(--bad); box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.compact-metrics { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
.allocation-control { display: grid; grid-template-columns: 190px minmax(220px, 1fr); align-items: end; gap: 14px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.allocation-control label { display: grid; gap: 6px; }
.allocation-control label span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.allocation-control input { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); padding: 0 10px; font: inherit; }
.allocation-control input[type="range"] { padding: 0; accent-color: var(--accent); }
.decision-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, .7fr)) minmax(190px, 1.25fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(9, 11, 15, 0.96);
}
.decision-bar label { display: grid; gap: 6px; }
.decision-bar label span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.decision-bar input, .decision-bar select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}
.decision-bar input[type="range"] { padding: 0; accent-color: var(--accent); }
.metric { min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; padding: 14px; }
.metric strong { font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.panel { padding: 16px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
.stage { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; background: var(--surface-2); }
.stage strong { font-size: 24px; }
.portfolio-summary { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.portfolio-summary .cell { border-left: 2px solid var(--accent); padding: 6px 10px; }
.portfolio-list { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.portfolio-row { display: grid; grid-template-columns: 28px minmax(260px, 1.8fr) repeat(3, minmax(90px, .65fr)); gap: 12px; align-items: center; padding: 11px 12px; background: #0d1116; }
.portfolio-row + .portfolio-row { border-top: 1px solid var(--border); }
.portfolio-main { display: grid; gap: 4px; min-width: 0; }
.portfolio-main span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.portfolio-main .selection-reason { color: #c7d3df; }
.deal-select-link { border: 0; padding: 0; background: transparent; color: var(--text); font-weight: 750; text-align: left; cursor: pointer; }
.deal-select-link:hover { color: var(--accent); }
.mobile-kpis { display: none; color: #d7e3ef !important; font-weight: 700; }
.rank-number { color: var(--accent); font: 700 13px ui-monospace, monospace; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.9fr); gap: 16px; }
.deal-workspace { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(420px, .9fr); gap: 16px; align-items: start; }
.ranking-panel { min-width: 0; }
.inspector-panel { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow: auto; }
.deal-list, .outreach-list, .phone-list, .source-health-list { display: grid; gap: 10px; }
.compact-grid { grid-template-columns: 1fr 1fr; }
.deal-row {
  display: grid;
  width: 100%;
  grid-template-columns: 40px minmax(240px, 2.1fr) repeat(4, minmax(78px, 0.7fr));
  gap: 12px;
  align-items: center;
  border: 0;
  padding: 12px;
  background: #0d1116;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.deal-record { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #0d1116; }
.deal-record:hover { border-color: #45505d; }
.deal-record.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.deal-record.selected .deal-row { background: #111a16; }
.grade { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font: 800 15px ui-monospace, monospace; }
.grade-a { color: #bbf7d0; border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .12); }
.grade-b { color: #bae6fd; border-color: rgba(56, 189, 248, .45); background: rgba(56, 189, 248, .1); }
.grade-c { color: #fde68a; border-color: rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .1); }
.grade-d { color: #fecaca; border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .1); }
.inspector-head { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.inspector-head a, .inspector-head strong { display: block; margin-top: 4px; font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.inspector-meta, .muted-copy { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.scorecard { display: grid; gap: 9px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.score-row { display: grid; grid-template-columns: 72px minmax(80px, 1fr) 30px; gap: 8px; align-items: center; font-size: 12px; }
.score-row > span { color: var(--muted); font-weight: 700; }
.score-row > strong { text-align: right; font-variant-numeric: tabular-nums; }
.score-track { height: 6px; overflow: hidden; border-radius: 3px; background: #252c34; }
.score-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.inspector-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.inspector-section:last-child { border-bottom: 0; padding-bottom: 0; }
.inspector-section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: #d8e1e9; }
.inspector-metrics { display: grid; grid-template-columns: repeat(4, minmax(78px, 1fr)); gap: 12px 8px; }
.scenario-scroll { overflow-x: auto; }
.scenario-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 12px; }
.scenario-table th { padding: 7px; border-bottom: 1px solid var(--border); color: var(--muted); text-align: left; text-transform: uppercase; font-size: 10px; }
.scenario-table td { padding: 8px 7px; border-bottom: 1px solid #202731; vertical-align: top; }
.flag-list { margin: 12px 0 0; padding-left: 18px; color: #f5cf8d; font-size: 12px; line-height: 1.5; }
.deal-timeline { display: grid; gap: 8px; }
.timeline-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid #202731; }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row strong { display: block; font-size: 12px; }
.timeline-row p, .timeline-row time { color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.timeline-row time { text-align: right; max-width: 145px; }
.progress-track { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.progress-track span { min-width: 0; padding-top: 8px; border-top: 3px solid #2d3640; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.progress-track span.complete { border-top-color: var(--accent); color: #d5e7dc; }
.rationale ul { margin: 0; padding-left: 18px; color: #c6d1db; font-size: 12px; line-height: 1.55; }
.thesis { border-left: 2px solid var(--warn); padding-left: 14px; }
.thesis ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.deal-title { display: grid; gap: 7px; min-width: 0; }
.deal-title a, .deal-title strong { overflow-wrap: anywhere; font-size: 15px; }
.deal-title span, .outreach p { color: var(--muted); font-size: 12px; line-height: 1.4; }
.deal-title .deal-thesis-preview { color: #bfd0df; }
.cell { min-width: 0; display: grid; gap: 4px; }
.cell strong { font-size: 14px; overflow-wrap: anywhere; }
.pill, .touch {
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px;
  color: #cbd5e1;
  background: #162033;
  font-size: 12px;
  line-height: 1;
}
.pill.contacted, .pill.awaiting_reply, .pill.responded, .pill.financials_requested { color: #bbf7d0; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.12); }
.pill.dead { color: #fecaca; border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.1); }
.touch-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.touch.sent, .touch.replied { color: #bbf7d0; border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.12); }
.touch.ready { color: #bae6fd; border-color: rgba(56, 189, 248, 0.35); background: rgba(56, 189, 248, 0.12); }
.touch.queued { color: #fde68a; border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.12); }
.touch.blocked { color: #fecaca; border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.1); }
.outreach { display: grid; gap: 6px; padding: 12px; background: #0b1220; }
.outreach-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.outreach strong { overflow-wrap: anywhere; font-size: 14px; }
.phone-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  padding: 12px;
}
.phone-main { display: grid; gap: 6px; min-width: 0; }
.phone-main strong { font-size: 14px; overflow-wrap: anywhere; }
.phone-main span, .phone-main p { color: var(--muted); font-size: 12px; line-height: 1.4; }
.phone-main .queue-key {
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}
.phone-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  padding: 12px;
}
.source-row strong { display: block; font-size: 14px; }
.source-row p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.action-link {
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.1);
  color: #bae6fd;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
}
.empty-state { border: 1px dashed var(--border); border-radius: 8px; padding: 18px; color: var(--muted); }
.empty-state span { display: block; color: var(--text); font-weight: 700; margin-bottom: 6px; }
.auth-panel {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(14px);
}
.auth-panel.open { display: grid; }
.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  padding: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.auth-card h2 { margin: 4px 0 16px; font-size: 22px; }
.auth-card input, .auth-card button {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}
.auth-card input {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}
.auth-card button {
  margin-top: 10px;
  border: 0;
  background: var(--accent);
  color: #04110a;
  font-weight: 800;
  cursor: pointer;
}
.auth-error {
  min-height: 18px;
  margin-top: 10px;
  color: #fecaca;
  font-size: 13px;
}
@media (max-width: 1100px) {
  .grid-two { grid-template-columns: 1fr; }
  .deal-workspace { grid-template-columns: 1fr; }
  .inspector-panel { position: static; max-height: none; order: -1; }
  .decision-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-control { grid-column: 1 / -1; }
  .deal-row { grid-template-columns: 40px minmax(220px, 1fr) repeat(2, minmax(90px, .6fr)); }
  .deal-row .cell:nth-last-child(-n+2) { display: none; }
  .portfolio-summary { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1440px); padding: 18px 0 82px; }
  .topbar { display: grid; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 82px; }
  .decision-bar { position: static; grid-template-columns: 1fr 1fr; }
  .search-control { grid-column: 1 / -1; }
  .allocation-control { grid-template-columns: 1fr; }
  .compact-metrics { grid-template-columns: 1fr 1fr; }
  .portfolio-summary { grid-template-columns: 1fr 1fr; }
  .portfolio-row { grid-template-columns: 24px 1fr; }
  .portfolio-row .cell { display: none; }
  .mobile-kpis { display: block; }
  .deal-row { grid-template-columns: 36px 1fr; }
  .deal-row .cell { display: none; }
  .inspector-metrics { grid-template-columns: 1fr 1fr; }
  .progress-track { grid-template-columns: 1fr; gap: 0; }
  .progress-track span { border-top: 0; border-left: 3px solid #2d3640; padding: 5px 0 5px 10px; }
  .progress-track span.complete { border-left-color: var(--accent); }
  .phone-row { grid-template-columns: 1fr; }
  .phone-actions { justify-content: flex-start; }
  .outreach-head { align-items: flex-start; flex-direction: column; }
  .desk-nav { position: fixed; inset: auto 0 0; z-index: 30; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); background: rgba(9, 11, 15, 0.98); border-top: 1px solid var(--border); border-bottom: 0; }
  .desk-nav button { min-width: 0; min-height: 48px; padding: 8px 4px; text-align: center; font-size: 12px; border-bottom: 0; border-top: 2px solid transparent; }
  .desk-nav button:hover, .desk-nav button:focus-visible, .desk-nav button.active { border-top-color: var(--accent); border-bottom-color: transparent; }
  .timeline-row { grid-template-columns: 1fr; }
  .timeline-row time { text-align: left; max-width: none; }
}
