:root {
  --bg: #f0efe9;
  --panel: #fbfaf6;
  --line: #d8d3c4;
  --text: #1f1d18;
  --muted: #615b4f;
  --accent: #8f3b2e;
  --accent-2: #1e6a74;
  --good: #2f7a38;
  --warn: #c17b2f;
  --target: #9f2f2f;
  --shadow: 0 10px 24px rgba(21, 17, 12, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(143, 59, 46, 0.12), transparent 42%),
    radial-gradient(circle at 100% 100%, rgba(30, 106, 116, 0.12), transparent 44%),
    linear-gradient(180deg, var(--bg), #e5dfd2);
  line-height: 1.45;
}

.escape-app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
}

.hero {
  background:
    linear-gradient(180deg, rgba(143, 59, 46, 0.07), transparent 48%),
    var(--panel);
}

.back-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration-color: rgba(143, 59, 46, 0.35);
  text-underline-offset: 2px;
  font-size: 0.84rem;
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 1.1;
}

h1 {
  margin-top: 6px;
  font-size: clamp(1.45rem, 6.3vw, 2.4rem);
  max-width: 24ch;
}

h2 {
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
}

.eyebrow {
  margin: 10px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--muted);
}

.lead {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 76ch;
}

.note {
  margin: 10px 0 0;
  border: 1px dashed #d4cab6;
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
  font-size: 0.8rem;
  color: #5b5246;
}

.section-head {
  margin-bottom: 10px;
}

.sub {
  margin: 5px 0 0;
  font-size: 0.83rem;
  color: var(--muted);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.first-run {
  background:
    linear-gradient(180deg, rgba(30, 106, 116, 0.07), rgba(143, 59, 46, 0.04)),
    var(--panel);
}

.first-run-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.first-run-card {
  border: 1px solid #d3c9b7;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 11px;
}

.first-run-card .k {
  margin: 0;
  color: #6f6456;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  font-weight: 700;
}

.first-run-card .v {
  margin: 5px 0 0;
  color: #2f2821;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}

.first-run-card .d {
  margin: 6px 0 0;
  color: #4e463c;
  font-size: 0.8rem;
  line-height: 1.3;
}

.first-run-tip {
  margin: 10px 0 0;
  border: 1px dashed #cdbfa8;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  color: #4f463a;
  font-weight: 600;
}

.control-hangar {
  background:
    linear-gradient(160deg, rgba(20, 18, 15, 0.96), rgba(36, 30, 24, 0.96)),
    var(--panel);
  color: #f3ede2;
  border-color: #4d3f2f;
}

.control-hangar .sub {
  color: #d0c2af;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quick-steps {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #dcc8ae;
  font-weight: 600;
}

.mini-clarity {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #5a5146;
}

.control-hangar .mini-clarity {
  color: #ddcebb;
}

.control-hangar label {
  border: 1px solid rgba(231, 214, 190, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  color: #f2eadf;
  font-weight: 600;
  font-size: 0.79rem;
}

.control-hangar select,
.control-hangar input[type="number"] {
  border-color: rgba(241, 226, 205, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: #fff7eb;
}

.control-hangar select:focus-visible,
.control-hangar input:focus-visible {
  outline: 2px solid rgba(210, 160, 94, 0.6);
}

.advanced-lab {
  margin-top: 10px;
  border: 1px dashed rgba(235, 217, 192, 0.28);
  border-radius: 12px;
  padding: 8px 10px 10px;
  background: rgba(255, 255, 255, 0.03);
}

.advanced-lab summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f4ddbc;
}

.advanced-hint {
  margin: 8px 0 0;
  color: #d2c0a6;
  font-size: 0.76rem;
}

.advanced-grid {
  margin-top: 10px;
}

.field-help {
  font-size: 0.72rem;
  color: #cfbda4;
  line-height: 1.25;
  font-weight: 500;
}

.advanced-note {
  margin: 0;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(235, 217, 192, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: #d9c9b1;
  font-size: 0.74rem;
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: #fff;
}

select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(30, 106, 116, 0.35);
  outline-offset: 1px;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.decision-card {
  border: 1px solid #d2c7b5;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.decision-card.ok {
  border-color: #7db08d;
  background: #f4fbf5;
}

.decision-card.warn {
  border-color: #d4b181;
  background: #fff9f0;
}

.decision-card.hard {
  border-color: #d39c93;
  background: #fff4f3;
}

.decision-k {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64594b;
}

.decision-card h3 {
  margin: 6px 0 0;
  font-size: clamp(1.1rem, 3.3vw, 1.55rem);
  line-height: 1.08;
}

.decision-detail {
  margin: 7px 0 0;
  color: #40372d;
  font-size: 0.88rem;
}

.decision-action {
  margin: 7px 0 0;
  color: #2f2a23;
  font-size: 0.83rem;
  font-weight: 700;
}

.decision-strip {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.decision-strip-head {
  margin: 0;
  border: 1px solid #d2c7b5;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #413a31;
}

.decision-strip-head.ok {
  border-color: #7db08d;
  background: #f4fbf5;
  color: #22532f;
}

.decision-strip-head.warn {
  border-color: #d4b181;
  background: #fff9f0;
  color: #6f481b;
}

.decision-strip-head.hard {
  border-color: #d39c93;
  background: #fff4f3;
  color: #7f2b22;
}

.decision-strip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.decision-strip-card {
  border: 1px solid #d8d0c0;
  border-radius: 10px;
  background: #fff;
  padding: 9px;
}

.decision-strip-k {
  margin: 0;
  color: #675d50;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.64rem;
  font-weight: 700;
}

.decision-strip-v {
  margin: 4px 0 0;
  color: #2f2821;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.1;
}

.decision-strip-sub {
  margin: 4px 0 0;
  color: #4e463c;
  font-size: 0.72rem;
}

.decision-meter {
  margin-top: 10px;
  border: 1px solid #d2c7b5;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.decision-meter-head {
  margin: 0;
  color: #2f2821;
  font-size: 0.82rem;
  font-weight: 700;
}

.decision-meter-copy {
  margin: 6px 0 0;
  color: #4f463b;
  font-size: 0.78rem;
}

.decision-meter-track {
  margin-top: 8px;
  position: relative;
  height: 12px;
  border-radius: 999px;
  border: 1px solid #d8d0c0;
  background: #efe9dc;
  overflow: hidden;
}

.decision-meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #2f7a38, #4ca65a);
}

.decision-meter-fill.warn {
  background: linear-gradient(90deg, #c17b2f, #d49a4f);
}

.decision-meter-plan {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 16px;
  background: #1f1d18;
}

.decision-meter-target {
  position: absolute;
  right: 0;
  top: -3px;
  width: 2px;
  height: 16px;
  background: #9f2f2f;
}

.decision-meter-legend {
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  font-size: 0.72rem;
  color: #4f463b;
}

.decision-meter-legend p {
  margin: 0;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 10px;
}

.metric-k {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  color: var(--muted);
}

.metric-v {
  margin: 6px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}

.metric-sub {
  margin: 5px 0 0;
  font-size: 0.75rem;
  color: #4c453d;
}

.summary-line {
  margin: 10px 0 0;
  border: 1px solid #d2c7b5;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  font-size: 0.84rem;
  color: #413a31;
  font-weight: 600;
}

.chart-panel {
  background:
    linear-gradient(180deg, rgba(30, 106, 116, 0.07), transparent 40%),
    var(--panel);
}

.chart {
  width: 100%;
  max-width: 100%;
  height: 100% !important;
  max-height: 100%;
  display: block;
  border: 1px solid #d8d0c0;
  border-radius: 10px;
  background: #fff;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: clamp(210px, 38vh, 320px);
  max-height: 320px;
  overflow: hidden;
}

.reverse-wrap {
  height: clamp(220px, 40vh, 330px);
  max-height: 330px;
}

.budget-wrap {
  height: clamp(250px, 44vh, 380px);
  max-height: 380px;
}

.compare-wrap {
  height: clamp(220px, 38vh, 300px);
  max-height: 300px;
}

.chart-group {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.chart-block {
  border: 1px solid #d8d0c0;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.chart-block h3 {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(0.98rem, 3.4vw, 1.2rem);
}

.inline-advanced {
  margin-top: 8px;
  border: 1px dashed #d2c7b5;
  border-radius: 10px;
  background: #fcfaf5;
  padding: 8px;
}

.inline-advanced summary {
  cursor: pointer;
  color: #3f372e;
  font-size: 0.8rem;
  font-weight: 700;
}

.inline-advanced[open] summary {
  margin-bottom: 8px;
}

.inline-budget-advanced summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: #3f372e;
}

.inline-budget-advanced > section {
  margin-top: 10px;
}

.chart-group .chart-wrap {
  height: clamp(260px, 48vh, 420px);
  max-height: 420px;
}

.chart-group .reverse-wrap {
  height: clamp(270px, 50vh, 440px);
  max-height: 440px;
}

.secondary-head {
  margin-top: 12px;
}

.advanced-view summary {
  cursor: pointer;
  font-weight: 700;
  color: #3d362d;
  letter-spacing: 0.01em;
}

.advanced-view[open] summary {
  margin-bottom: 12px;
}

.advanced-view-body {
  display: grid;
  gap: 12px;
}

.inner-panel {
  border: 1px solid #d8d0c0;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.advanced-view .chart-wrap {
  height: clamp(220px, 36vh, 320px);
  max-height: 320px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid #e2dac9;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.8rem;
}

th {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #51483f;
  background: #f5f1e9;
  position: sticky;
  top: 0;
}

tbody tr:nth-child(odd) {
  background: #fcfbf8;
}

tbody tr .good {
  color: var(--good);
  font-weight: 700;
}

tbody tr .warn {
  color: #965f22;
  font-weight: 700;
}

@media (min-width: 760px) {
  .escape-app {
    gap: 14px;
    padding: 18px;
  }

  .panel {
    padding: 18px;
  }

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

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

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

  .decision-strip-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

  .chart-wrap {
    height: clamp(240px, 38vh, 350px);
    max-height: 350px;
  }

  .reverse-wrap {
    height: clamp(250px, 40vh, 370px);
    max-height: 370px;
  }

  .budget-wrap {
    height: clamp(280px, 46vh, 420px);
    max-height: 420px;
  }

  .compare-wrap {
    height: clamp(230px, 36vh, 320px);
    max-height: 320px;
  }

  .chart-group .chart-wrap {
    height: clamp(300px, 52vh, 500px);
    max-height: 500px;
  }

  .chart-group .reverse-wrap {
    height: clamp(320px, 55vh, 540px);
    max-height: 540px;
  }

  .advanced-view .chart-wrap {
    height: clamp(220px, 30vh, 320px);
    max-height: 320px;
  }
}

@media (min-width: 980px) {
  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

@media (min-width: 1240px) {
  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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