:root {
  --navy-950: #071c29;
  --navy-900: #0b2434;
  --navy-800: #12384c;
  --blue: #0f6f8f;
  --blue-soft: #e8f5f8;
  --teal: #158675;
  --orange: #ef7d50;
  --orange-soft: #fff0e9;
  --red: #c94444;
  --amber: #b87517;
  --green: #25825d;
  --ink: #17242e;
  --muted: #66747e;
  --line: #dce4e8;
  --surface: #ffffff;
  --canvas: #f3f6f7;
  --shadow: 0 12px 32px rgba(7, 28, 41, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 268px 1fr; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px 22px;
  color: #eef7f9;
  background:
    radial-gradient(circle at 30% 12%, rgba(25, 132, 149, .26), transparent 24%),
    linear-gradient(160deg, var(--navy-800), var(--navy-950) 70%);
}

.brand { display: flex; align-items: center; gap: 13px; padding: 0 8px 28px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand h1 { margin: 2px 0 0; font-size: 21px; line-height: 1.15; letter-spacing: -.02em; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 750; letter-spacing: .13em; color: #70828d; }
.brand .eyebrow { color: #8db1bd; }
.brand-mark { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 7px solid #f7fbfc; box-shadow: 0 0 0 3px var(--orange); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; inset: -8px 12px; background: var(--navy-800); }
.brand-mark::after { inset: 12px -8px; }
.brand-mark span { position: absolute; z-index: 1; inset: 9px; border-radius: 50%; background: var(--orange); }

.main-nav { display: grid; gap: 7px; margin-top: 28px; }
.nav-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 13px;
  border: 0;
  border-radius: 11px;
  color: #bdd0d7;
  background: transparent;
  text-align: left;
  transition: .18s ease;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 3px 0 var(--orange); }
.nav-icon { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid rgba(255,255,255,.22); border-radius: 7px; font-size: 12px; font-weight: 800; }
.nav-count { min-width: 24px; padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.12); text-align: center; font-size: 12px; }

.sidebar-foot { margin-top: auto; }
.privacy-note { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 13px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(255,255,255,.05); }
.privacy-note div { display: grid; }
.privacy-note strong { font-size: 12px; }
.privacy-note span { color: #90aeb8; font-size: 11px; }
.privacy-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: #56d09d; box-shadow: 0 0 0 4px rgba(86,208,157,.12); }
.text-btn { width: 100%; border: 0; background: transparent; color: #a7bdc5; padding: 8px; font-size: 12px; }
.text-btn:hover { color: white; }

.main { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.93); backdrop-filter: blur(12px); }
.topbar h2 { margin: 3px 0 0; font-size: clamp(21px, 2vw, 28px); letter-spacing: -.035em; }
.top-actions, .summary-actions { display: flex; align-items: center; gap: 9px; }
.save-state { display: flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-state span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.save-state.saving span { background: var(--amber); }
.btn { min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; font-size: 13px; transition: .16s ease; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { color: white; background: var(--navy-900); box-shadow: 0 5px 14px rgba(11,36,52,.13); }
.btn.primary:hover { background: var(--navy-800); }
.btn.secondary { color: var(--navy-800); background: white; border-color: var(--line); }
.btn.secondary:hover { border-color: #b9c9d0; }
.btn.danger-solid { color: white; background: var(--red); }

.view { display: none; padding: 26px 34px 42px; }
.view.active { display: block; }

.context-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.context-stat { display: flex; align-items: baseline; gap: 10px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.context-stat strong { color: var(--navy-800); font-size: 23px; letter-spacing: -.04em; white-space: nowrap; }
.context-stat span { color: var(--muted); font-size: 12px; line-height: 1.25; }

.workspace-grid { display: grid; grid-template-columns: minmax(235px, 286px) minmax(0, 1fr); gap: 18px; align-items: start; }
.process-list-panel, .process-detail-card, .summary-card, .questions-board { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.process-list-panel { position: sticky; top: 20px; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; padding: 17px 18px 12px; color: var(--muted); font-weight: 800; font-size: 10px; letter-spacing: .1em; }
.panel-heading small { letter-spacing: 0; font-weight: 600; }
.process-list { padding: 0 8px 10px; }
.process-row { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; padding: 10px; border: 0; border-radius: 10px; color: #52616b; background: transparent; text-align: left; }
.process-row:hover { background: #f5f8f9; }
.process-row.active { color: var(--navy-900); background: var(--blue-soft); }
.process-row .process-number { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #fff; background: #86a0aa; font-weight: 800; font-size: 11px; }
.process-row.active .process-number { background: var(--blue); }
.process-row .process-name { font-weight: 680; font-size: 13px; }
.process-row .mini-progress { width: 28px; height: 4px; overflow: hidden; border-radius: 99px; background: #d9e1e4; }
.process-row .mini-progress span { display: block; height: 100%; background: var(--teal); }

.process-detail-card { overflow: hidden; }
.process-hero { display: flex; justify-content: space-between; gap: 22px; padding: 25px 27px 21px; color: white; background: linear-gradient(120deg, var(--navy-800), #0d5f73); }
.process-hero h3 { margin: 4px 0 7px; font-size: 25px; letter-spacing: -.03em; }
.process-hero p { max-width: 730px; margin: 0; color: #c2d8df; }
.process-index { flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--navy-900); background: var(--orange); font-size: 18px; font-weight: 850; }
.known-facts { display: flex; gap: 9px; flex-wrap: wrap; padding: 14px 27px; border-bottom: 1px solid var(--line); background: #f7fafb; }
.fact-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid #cedde2; border-radius: 99px; color: #3f5965; background: white; font-size: 12px; }
.fact-chip::before { content: "✓"; color: var(--teal); font-weight: 900; }
.detail-body { padding: 23px 27px 30px; }
.section-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-label h4 { margin: 0; font-size: 14px; color: var(--navy-900); }
.section-label span { color: var(--muted); font-size: 11px; }
.question-stack { display: grid; gap: 13px; }
.question-card { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: white; }
.question-head { display: grid; grid-template-columns: 24px 1fr auto; align-items: start; gap: 11px; padding: 14px 15px; }
.question-head .q-number { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; color: var(--blue); background: var(--blue-soft); font-size: 11px; font-weight: 850; }
.question-text { margin: 1px 0 0; font-weight: 680; font-size: 13px; }
.question-status { padding: 3px 8px; border-radius: 99px; color: var(--amber); background: #fff5df; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.question-status.done { color: var(--green); background: #e9f7f1; }
.answer-area { padding: 0 15px 15px 50px; }
textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  border: 1px solid #ced9de;
  border-radius: 9px;
  color: var(--ink);
  background: white;
  outline: none;
  transition: .16s ease;
}
textarea { min-height: 84px; resize: vertical; padding: 10px 11px; font-size: 13px; line-height: 1.45; }
input[type="text"], input[type="number"], select { min-height: 38px; padding: 8px 10px; font-size: 12px; }
textarea:focus, input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15,111,143,.1); }
.answer-tools { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-top: 9px; }
.field label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 750; }
.toggle-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.toggle-line input { accent-color: var(--teal); }

.qualifier-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; margin-top: 22px; }
.qualifier-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #f9fbfb; }
.qualifier-card h4 { margin: 0 0 12px; font-size: 13px; }
.range-row { display: grid; grid-template-columns: 1fr 45px; align-items: center; gap: 12px; margin-bottom: 12px; }
.range-row:last-child { margin-bottom: 0; }
.range-row label { display: grid; gap: 1px; color: #40505a; font-size: 12px; }
.range-row label small { color: var(--muted); font-size: 10px; }
input[type="range"] { width: 100%; accent-color: var(--orange); }
.range-value { display: grid; place-items: center; height: 34px; border-radius: 9px; color: var(--navy-900); background: white; border: 1px solid var(--line); font-weight: 850; }
.priority-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.priority-badge.critical { color: #9d2f2f; background: #fdeaea; }
.priority-badge.high { color: #925a0f; background: #fff1d5; }
.priority-badge.medium { color: #1a657a; background: var(--blue-soft); }
.priority-badge.low { color: #53717b; background: #edf2f4; }
.notes-box { margin-top: 12px; }

.section-intro { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 20px; }
.section-intro h3 { margin: 4px 0; font-size: 28px; letter-spacing: -.04em; }
.section-intro p:not(.eyebrow) { margin: 0; color: var(--muted); }
.segmented { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.segmented button { border: 0; border-radius: 8px; padding: 8px 11px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.segmented button.active { color: white; background: var(--navy-900); }
.questions-board { overflow: hidden; }
.question-board-row { display: grid; grid-template-columns: 190px 1fr 110px; gap: 16px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.question-board-row:last-child { border-bottom: 0; }
.question-board-row .process-ref { color: var(--blue); font-size: 11px; font-weight: 800; }
.question-board-row h4 { margin: 0 0 7px; font-size: 13px; }
.question-board-row p { margin: 0; color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.board-actions { display: flex; justify-content: flex-end; align-items: center; }
.link-btn { border: 0; color: var(--blue); background: transparent; font-weight: 750; font-size: 11px; }
.empty-state { padding: 55px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); }

.summary-intro { align-items: center; }
.summary-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 15px; }
.summary-card { padding: 20px; box-shadow: 0 7px 24px rgba(7,28,41,.055); }
.summary-card h4 { margin: 0 0 14px; color: var(--navy-900); font-size: 14px; }
.summary-card h4 small { display: block; margin-top: 2px; color: var(--muted); font-weight: 500; font-size: 10px; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { position: relative; display: grid; place-items: center; width: 112px; height: 112px; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--teal) var(--p), #e8edef 0); }
.donut::before { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: white; }
.donut strong { position: relative; font-size: 22px; }
.legend { display: grid; gap: 8px; width: 100%; }
.legend-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.legend-row strong { color: var(--ink); }
.priority-list { display: grid; gap: 9px; }
.priority-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; }
.priority-rank { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: white; background: var(--navy-800); font-size: 11px; font-weight: 850; }
.priority-item strong { display: block; font-size: 12px; }
.priority-item small { color: var(--muted); font-size: 10px; }
.fit-bar { display: flex; height: 12px; overflow: hidden; border-radius: 99px; background: #e8edef; }
.fit-bar span:nth-child(1) { background: var(--green); }
.fit-bar span:nth-child(2) { background: var(--blue); }
.fit-bar span:nth-child(3) { background: var(--orange); }
.fit-bar span:nth-child(4) { background: #9aa7ad; }
.fit-legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px 16px; margin-top: 15px; }
.fit-legend div { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.fit-legend strong { color: var(--ink); }
.framework-grid { display: grid; gap: 10px; }
.framework-item { display: grid; grid-template-columns: 118px 1fr; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.framework-item:last-child { border-bottom: 0; padding-bottom: 0; }
.framework-item label { color: var(--blue); font-size: 11px; font-weight: 850; }
.framework-item textarea { min-height: 60px; }
.meddci-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.meddci-field { display: grid; gap: 5px; }
.meddci-field label { color: var(--muted); font-size: 10px; font-weight: 800; }
.global-note { color: var(--muted); font-size: 11px; margin: -5px 0 12px; }

.toast { position: fixed; right: 25px; bottom: 24px; z-index: 20; transform: translateY(20px); opacity: 0; pointer-events: none; padding: 11px 15px; border-radius: 10px; color: white; background: var(--navy-900); box-shadow: var(--shadow); font-size: 12px; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

dialog { width: min(430px, calc(100vw - 32px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 24px 80px rgba(3,18,28,.28); }
dialog::backdrop { background: rgba(7,28,41,.55); backdrop-filter: blur(3px); }
.dialog-card { padding: 28px; text-align: center; }
.dialog-card h3 { margin: 13px 0 6px; }
.dialog-card p { margin: 0; color: var(--muted); font-size: 13px; }
.dialog-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: auto; border-radius: 50%; color: var(--red); background: #fdeaea; font-weight: 900; }
.dialog-actions { display: flex; justify-content: center; gap: 9px; margin-top: 22px; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .sidebar { padding-inline: 14px; }
  .topbar, .view { padding-left: 24px; padding-right: 24px; }
  .context-strip { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 220px minmax(0, 1fr); }
  .answer-tools { grid-template-columns: 1fr; }
  .qualifier-grid { grid-template-columns: 1fr; }
  .span-4 { grid-column: span 6; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 15px; }
  .brand { padding: 0 4px 14px; }
  .brand-mark { width: 36px; height: 36px; border-width: 6px; }
  .main-nav { grid-template-columns: repeat(3, 1fr); margin-top: 13px; gap: 5px; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; gap: 3px; text-align: center; padding: 9px 5px; font-size: 11px; }
  .nav-icon, .nav-count, .sidebar-foot { display: none; }
  .topbar { min-height: 0; align-items: flex-start; padding: 17px 16px; }
  .topbar .eyebrow, .save-state, .top-actions .secondary { display: none; }
  .topbar h2 { font-size: 19px; }
  .view { padding: 16px; }
  .context-strip { grid-template-columns: 1fr 1fr; }
  .context-stat { display: grid; gap: 0; padding: 12px; }
  .workspace-grid { display: block; }
  .process-list-panel { position: static; margin-bottom: 13px; }
  .process-list { display: flex; gap: 6px; padding: 0 10px 10px; overflow-x: auto; }
  .process-row { flex: 0 0 auto; width: auto; grid-template-columns: 28px 1fr; }
  .process-row .mini-progress { display: none; }
  .process-hero, .detail-body { padding: 19px; }
  .known-facts { padding: 12px 19px; }
  .process-hero h3 { font-size: 21px; }
  .answer-area { padding-left: 15px; }
  .section-intro { display: block; }
  .segmented, .summary-actions { margin-top: 15px; }
  .question-board-row { grid-template-columns: 1fr; gap: 7px; }
  .board-actions { justify-content: flex-start; }
  .summary-grid { display: block; }
  .summary-card { margin-bottom: 13px; }
  .meddci-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .sidebar, .topbar, #processes-view, #questions-view, .summary-actions, .toast { display: none !important; }
  .app-shell { display: block; }
  .main { width: 100%; }
  #summary-view { display: block !important; padding: 0; }
  .section-intro { margin-bottom: 14px; }
  .summary-grid { display: grid; gap: 10px; }
  .summary-card { break-inside: avoid; box-shadow: none; }
  textarea, input { border-color: transparent; padding-left: 0; }
}
