/* Runway Tool — mobile-first, dark, glanceable.
   One column on a phone, two on a tablet, roomy on a laptop. */

:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #172029;
  --line: #223041;
  --ink: #e8eef6;
  --muted: #8fa2b8;
  --faint: #5b6b7f;
  --green: #2fbf71;
  --yellow: #e0b341;
  --red: #e5544b;
  --accent: #4aa3ff;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main { padding: 0 14px 28px; max-width: 1100px; margin: 0 auto; }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(12px + env(safe-area-inset-top, 0));
  padding-top: calc(14px + env(safe-area-inset-top, 0));
  background: linear-gradient(180deg, #0b0f14 70%, rgba(11, 15, 20, 0.85));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.badge {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
}
.badge.plan { color: var(--yellow); border-color: #4a3d18; }
.badge.real { color: var(--green); border-color: #1d3f2c; }

/* ---------------------------------------------------------------- strip */
.strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 16px 0 4px;
  font-size: 13px;
  color: var(--muted);
}
.strip b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- metrics */
.metrics {
  display: grid;
  gap: 12px;
  margin: 14px 0 22px;
}
@media (min-width: 680px) { .metrics { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .metrics { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card.green { border-left-color: var(--green); }
.card.yellow { border-left-color: var(--yellow); }
.card.red { border-left-color: var(--red); }

.card .k {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.card .v {
  margin: 6px 0 4px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.card .v.tbd { font-size: 20px; color: var(--muted); }
.card .d { font-size: 13px; color: var(--muted); }
.card .d b { color: var(--ink); font-weight: 600; }
.card.wide { grid-column: 1 / -1; }

.leak { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13.5px; }
.leak li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.leak li:last-child { border-bottom: 0; }
.leak .over { color: var(--red); font-variant-numeric: tabular-nums; }
.leak .under { color: var(--green); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.panel-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 700;
}
.hint { margin: 6px 0 12px; font-size: 12.5px; color: var(--faint); }
.hint strong { color: var(--muted); }

/* ---------------------------------------------------------------- controls */
.controls { display: grid; gap: 18px; }
.group { display: grid; gap: 12px; }
.group > h3 {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}
.field { display: grid; gap: 6px; }
.field .lab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}
.field .lab .name { color: var(--ink); }
.field .lab .val {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.field .lab .val.unset { color: var(--faint); font-family: inherit; font-style: italic; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0f14;
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 2px solid #0b0f14; }
input[type="range"]:disabled { opacity: 0.4; }

.field .row2 { display: flex; align-items: center; gap: 10px; }
.field .row2 input[type="range"] { flex: 1; min-width: 0; }
.field input[type="number"],
.field input[type="text"] {
  width: 120px;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 14px;
}
.field input[type="number"]:focus,
.field input[type="text"]:focus,
.save-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.changed { color: var(--accent); }
.tag {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #04121f;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); font-weight: 600; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--red); border-color: #4a2622; }

.save-row { display: flex; gap: 10px; margin-bottom: 10px; }
.save-row input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
}

/* ---------------------------------------------------------------- scenarios */
.scenarios { display: grid; gap: 10px; }
.scenario {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
}
.scenario .nm { flex: 1; min-width: 0; }
.scenario .nm .t { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario .nm .s { font-size: 12px; color: var(--faint); }
.scenario label.cmp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  flex: none;
  user-select: none;
}
.scenario input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.empty { color: var(--faint); font-size: 13px; padding: 6px 0; }

/* ---------------------------------------------------------------- compare */
.compare-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.cmp { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 13.5px; }
table.cmp th, table.cmp td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
table.cmp th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.cmp td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.cmp .now td { color: var(--muted); }

/* ---------------------------------------------------------------- known */
.known { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.known li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.known .t { font-size: 14px; }
.known .w { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.known .m { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- footer */
footer {
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  max-width: 1100px;
  margin: 0 auto;
}
footer code { font-family: var(--mono); color: var(--muted); }
footer p { margin: 4px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; }
