:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --soft: #f4f6f8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(20, 32, 45, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f5;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  background: #16212d;
  color: #f8fafc;
  padding: 28px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #10b981;
  color: #06201a;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.brand p,
.eyebrow {
  margin: 4px 0 0;
  color: #a9b4c2;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.progress-block {
  margin: 28px 0 22px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #dbe4ee;
  font-size: 13px;
}

.progress-track {
  height: 9px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: #10b981;
  transition: width 180ms ease;
}

.section-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #dbe4ee;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-item small {
  color: #9fb0c1;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 3px 0 0;
  font-size: 30px;
}

.topbar .eyebrow {
  color: var(--muted);
}

.top-actions,
.dialog-actions,
.stepper {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary,
.ghost {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
}

.primary {
  color: white;
  background: var(--accent);
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: #f8fafc;
}

.survey-form {
  display: grid;
  gap: 14px;
}

.submit-status {
  margin: -10px 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.submit-status[data-type="success"] {
  color: var(--accent-dark);
}

.submit-status[data-type="error"] {
  color: var(--red);
}

.intro-panel {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.intro-kicker {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.intro-panel h3 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.3;
}

.intro-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.strategy-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.strategy-panel > div {
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.strategy-panel h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.strategy-panel ol {
  margin: 0;
  padding-left: 21px;
  color: var(--muted);
  line-height: 1.7;
}

.visual-docs {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.visual-head,
.source-map,
.driver-map {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.visual-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.visual-head h3 {
  margin: 0;
  font-size: 21px;
}

.visual-head > p {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.source-map,
.driver-map {
  padding: 18px;
}

.source-map h4,
.driver-map h4 {
  margin: 0 0 12px;
  font-size: 17px;
}

.map-note {
  margin: -4px 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.lane-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(160px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.lane-grid article {
  min-width: 160px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.lane-grid h5 {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #d7ece8;
  color: var(--accent-dark);
  font-size: 15px;
}

.lane-grid ul,
.driver-branches ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.logic-card {
  background: #fff8ed !important;
}

.logic-card h5 {
  border-bottom-color: #f2c48c;
  color: #8a4b12;
}

.driver-map {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.driver-title {
  grid-column: 1 / -1;
}

.driver-title h4 {
  margin-bottom: 8px;
}

.map-center {
  display: grid;
  place-items: center;
  min-height: 100%;
  border-radius: 8px;
  background: #ef5350;
  color: white;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
}

.driver-branches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.driver-branches article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.driver-branches p {
  margin: -4px 0 8px;
  color: var(--muted);
  font-weight: 700;
}

.compact-map {
  padding-top: 16px;
}

.leader-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.leader-grid article {
  display: grid;
  gap: 6px;
  border: 1px solid #e7c0c0;
  border-radius: 8px;
  background: #fff6f6;
  padding: 13px;
}

.leader-grid strong {
  color: #9f4f56;
  font-size: 15px;
}

.leader-grid span {
  color: var(--muted);
  line-height: 1.45;
}

.respondent-panel {
  display: grid;
  grid-template-columns: minmax(220px, 420px);
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.respondent-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.respondent-panel .text-input {
  color: var(--ink);
  font-weight: 500;
}

.question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.section-context {
  background: #f9fbfc;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.section-context h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.section-context p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.question-meta {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.question-meta p {
  margin: 0;
  color: #475467;
  font-size: 13px;
  line-height: 1.45;
}

.remark-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.remark-block summary {
  width: max-content;
  color: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.question-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.question-note {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #edf7f5;
  color: var(--accent-dark);
}

.badge.risk {
  background: #fff4e5;
  color: var(--amber);
}

.badge.critical {
  background: #ffebe9;
  color: var(--red);
}

.options {
  display: grid;
  gap: 9px;
}

.option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.option input {
  margin-top: 3px;
}

.text-input,
.number-input,
.textarea-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 11px 12px;
  color: var(--ink);
}

.textarea-input {
  min-height: 96px;
  resize: vertical;
}

.textarea-input.compact {
  min-height: 70px;
  margin-top: 8px;
}

.rank-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.rank-item {
  display: grid;
  gap: 6px;
}

.stepper {
  justify-content: space-between;
  margin-top: 22px;
  padding: 18px 0 6px;
}

#stepInfo {
  color: var(--muted);
  font-weight: 700;
}

.summary-dialog {
  width: min(880px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 32px 90px rgba(15, 23, 42, 0.28);
}

.summary-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 22px 22px 12px;
}

.dialog-head h2 {
  margin: 2px 0 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #eef2f5;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

#summaryOutput {
  width: calc(100% - 44px);
  min-height: 440px;
  margin: 0 22px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
  color: var(--ink);
}

.dialog-actions {
  justify-content: flex-end;
  padding: 0 22px 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  background: #111827;
  color: white;
  border-radius: 8px;
  padding: 11px 14px;
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .section-nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .topbar {
    display: grid;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .top-actions,
  .stepper {
    align-items: stretch;
  }

  .respondent-panel {
    grid-template-columns: 1fr;
  }

  .strategy-panel {
    grid-template-columns: 1fr;
  }

  .visual-head {
    display: grid;
  }

  .lane-grid,
  .driver-branches,
  .leader-grid {
    grid-template-columns: 1fr;
  }

  .driver-map {
    grid-template-columns: 1fr;
  }

  .map-center {
    min-height: 82px;
  }

  .top-actions button,
  .stepper button {
    width: 100%;
  }
}
