:root {
  --bg: #0d1415;
  --bg-2: #121b1d;
  --surface: #f7faf8;
  --surface-2: #edf3ef;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #112022;
  --muted: #627174;
  --line: rgba(17, 32, 34, 0.12);
  --line-dark: rgba(255, 255, 255, 0.12);
  --teal: #0f766e;
  --teal-2: #14b8a6;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 24px 70px rgba(2, 11, 13, 0.22);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(20, 184, 166, 0.18), transparent 34rem),
    linear-gradient(135deg, #0b1112 0%, #142022 44%, #e8efeb 44.2%, #f7faf8 100%);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(140deg, rgba(7, 17, 18, 0.92), rgba(17, 32, 34, 0.82)),
    url("img/plan-overlay.png") center / cover;
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: rgba(13, 20, 21, 0.84);
  color: #f7faf8;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-mark,
.rail-brand {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), #072f2d);
  color: white;
  font-weight: 850;
  text-decoration: none;
}

.login-card h1 {
  margin: 8px 0 10px;
  font-size: clamp(34px, 8vw, 58px);
  line-height: 0.94;
  letter-spacing: 0;
}

.login-card p {
  color: rgba(247, 250, 248, 0.74);
  line-height: 1.55;
}

.overline,
.eyeline,
.section-head p,
.cost-panel p,
.variant-card span {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.login-form label {
  font-size: 13px;
  color: rgba(247, 250, 248, 0.72);
}

.login-form input,
.table-filter,
.note-form input,
.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  outline: none;
}

.login-form input {
  padding: 14px 15px;
}

.login-form button,
.note-form button {
  border: 0;
  border-radius: var(--radius);
  background: var(--teal);
  color: white;
  padding: 13px 16px;
  font-weight: 800;
}

.login-error,
.setup-warning {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  font-size: 13px;
}

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

.rail {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  height: 100vh;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px 14px;
  background: rgba(9, 16, 17, 0.96);
  border-right: 1px solid var(--line-dark);
  color: white;
}

.rail nav {
  display: grid;
  gap: 10px;
  width: 100%;
}

.rail nav a,
.rail-exit {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.rail nav a:hover,
.rail-exit:hover {
  border-color: var(--line-dark);
  background: rgba(255, 255, 255, 0.07);
  color: white;
}

.rail-exit {
  margin-top: auto;
  width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  width: min(1500px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1 {
  margin: 0;
  color: white;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.92;
  letter-spacing: 0;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-cluster span {
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.82);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  min-width: 0;
  gap: 18px;
  align-items: stretch;
}

.plan-stage,
.decision-stack > article,
.metrics-row article,
.copy-panel,
.media-panel,
.data-section,
.cost-panel,
.doc-card,
.doc-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.plan-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 0;
}

.section-head h2,
.copy-panel h2,
.cost-panel h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.02;
  letter-spacing: 0;
}

.plan-tabs {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.plan-tabs button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.plan-tabs button.is-active {
  background: var(--ink);
  color: white;
}

.plan-frame {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #dce8e3;
}

.plan-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 220ms ease, transform 220ms ease;
}

.plan-img.is-visible {
  opacity: 1;
  transform: scale(1);
}

.pin {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 850;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.pin-rg { left: 67%; top: 47%; background: var(--red); }
.pin-p01 { left: 82%; top: 15%; }
.pin-p15 { left: 4%; top: 72%; background: var(--amber); color: #201500; }
.pin-p28 { right: 4%; bottom: 8%; background: var(--teal); }

.plan-frame:not([data-layer="plan"]) .pin {
  display: none;
}

.decision-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.variant-card,
.phase-card {
  padding: 18px;
}

.variant-card.primary {
  background: #102426;
  color: white;
  border-color: rgba(20, 184, 166, 0.35);
}

.variant-card h3 {
  margin: 0;
  font-size: 42px;
  line-height: 0.95;
}

.variant-card p {
  margin: 8px 0 24px;
  color: var(--muted);
}

.variant-card.primary p {
  color: rgba(255, 255, 255, 0.68);
}

.variant-card strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 850;
}

.phase-row {
  display: grid;
  grid-template-columns: 28px 1fr 58px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
}

.bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #d9e4df;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.metrics-row,
.cost-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-width: 0;
  gap: 14px;
}

.metrics-row article,
.cost-panel {
  padding: 18px;
}

.metrics-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics-row strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.metrics-row p,
.cost-panel span,
.copy-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.split-section {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  min-width: 0;
  gap: 14px;
}

.copy-panel {
  padding: 26px;
}

.rule-list {
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.rule-list span {
  border-left: 3px solid var(--teal);
  background: var(--surface-2);
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 750;
}

.media-panel {
  overflow: hidden;
  min-height: 320px;
}

.media-panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.data-section {
  padding: 18px;
}

.table-filter {
  max-width: 310px;
  padding: 10px 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid #e2e8e5;
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5f2;
  color: #395052;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td:last-child {
  max-width: 540px;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  background: #e8f4f1;
  color: #0f766e;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.compact-pill {
  max-width: 220px;
  white-space: normal;
}

.cost-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cost-panel h2 {
  margin-top: 6px;
}

.docs-section {
  padding-bottom: 32px;
}

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

.doc-card {
  display: grid;
  gap: 9px;
  min-height: 148px;
  padding: 16px;
  text-align: left;
}

.doc-card:hover {
  border-color: rgba(15, 118, 110, 0.45);
  transform: translateY(-1px);
}

.doc-card strong {
  font-size: 16px;
  line-height: 1.22;
}

.doc-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 850;
}

.doc-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  border: 1px solid var(--line);
  padding: 0;
  overflow: auto;
}

.doc-dialog::backdrop {
  background: rgba(2, 8, 9, 0.74);
  backdrop-filter: blur(6px);
}

.dialog-close {
  position: sticky;
  top: 12px;
  float: right;
  z-index: 2;
  width: 38px;
  height: 38px;
  margin: 12px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 22px;
  line-height: 1;
}

.markdown-body {
  padding: 34px;
  color: var(--ink);
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 22px 0 10px;
  line-height: 1.1;
}

.markdown-body p,
.markdown-body li {
  color: #425154;
  line-height: 1.62;
}

.markdown-body code,
.setup-warning code {
  border-radius: 5px;
  background: #e7efec;
  padding: 2px 5px;
}

.markdown-body pre {
  overflow: auto;
  border-radius: var(--radius);
  background: #0f1819;
  color: #d8f7ef;
  padding: 16px;
}

.note-form {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.note-form input,
.note-form textarea {
  padding: 10px 12px;
}

.note-item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.note-item time,
.muted {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .hero-grid,
  .split-section {
    grid-template-columns: minmax(0, 1fr);
  }

  .decision-stack,
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    background: var(--surface);
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: sticky;
    bottom: auto;
    top: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    width: 100%;
    max-width: 100vw;
    height: auto;
    align-items: center;
    padding: 10px;
    overflow: hidden;
  }

  .rail nav {
    display: flex;
    min-width: 0;
    overflow-x: auto;
  }

  .rail nav a,
  .rail-exit {
    flex: 0 0 auto;
    padding: 0 12px;
  }

  .rail-exit {
    width: auto;
    margin-top: 0;
    white-space: nowrap;
  }

  .workspace {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    padding: 16px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    color: var(--ink);
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .status-cluster span {
    border-color: var(--line);
    background: rgba(17, 32, 34, 0.06);
    color: var(--muted);
  }

  .hero-grid,
  .metrics-row,
  .cost-grid,
  .doc-grid,
  .decision-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .plan-frame {
    min-height: 360px;
  }

  .table-filter {
    max-width: none;
  }
}
