/* Funnel OS app shell - internal tool.
   Design read: operational control panel for a non-technical funnel team.
   Continuity with the funnel system's own palette (navy + teal, Poppins),
   quiet and disciplined - the stage rail is the one signature element. */

:root {
  --navy: #10243c;
  --navy-soft: #1b3a5c;
  --teal: #0d8a80;
  --teal-soft: #e3f4f2;
  --ink: #1d2a38;
  --muted: #63707e;
  --line: #e2e7ec;
  --bg: #f6f8f9;
  --card: #ffffff;
  --ok: #147a4d;
  --warn: #b2620a;
  --bad: #b3261e;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Poppins", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--navy);
  color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.02em; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, var(--teal) 0 55%, #35b3a8 55% 100%);
  display: inline-block;
}
.topnav { display: flex; gap: 6px; }
.navlink {
  font: inherit; font-size: 0.86rem; font-weight: 500;
  color: #cfd9e4; background: transparent;
  border: 1px solid transparent; border-radius: 8px;
  padding: 7px 14px; cursor: pointer;
}
.navlink.is-active { color: #fff; background: var(--navy-soft); border-color: rgba(255,255,255,0.14); }
.navlink:disabled { opacity: 0.55; cursor: not-allowed; }
.soon {
  font-family: var(--mono); font-size: 0.62rem; font-weight: 500;
  background: rgba(255,255,255,0.12); border-radius: 4px;
  padding: 1px 5px; margin-left: 4px; vertical-align: 1px;
}

/* Layout */
.page { max-width: 1080px; margin: 0 auto; padding: 44px 20px 72px; }

.intro { margin-bottom: 32px; max-width: 720px; }
.eyebrow {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 10px;
}
h1 { font-size: 2rem; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; margin-bottom: 12px; }
.lede { color: var(--muted); font-size: 0.98rem; }

/* Panel */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px 28px;
  margin-bottom: 44px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
h2 { font-size: 1.15rem; font-weight: 700; color: var(--navy); }
h3 { font-size: 0.92rem; font-weight: 600; color: var(--navy); margin-bottom: 10px; }
h4 { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

.btn {
  font: inherit; font-size: 0.84rem; font-weight: 600;
  background: var(--teal); color: #fff;
  border: none; border-radius: 8px;
  padding: 9px 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { filter: brightness(1.06); }
.btn:focus-visible { outline: 3px solid var(--teal-soft); outline-offset: 2px; }

.status {
  font-family: var(--mono); font-size: 0.8rem;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 20px;
}
.status-loading { background: #eef1f4; color: var(--muted); }
.status-ok { background: var(--teal-soft); color: var(--ok); }
.status-bad { background: #fbeae9; color: var(--bad); }

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

/* File table */
.filetable { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.filetable th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line); padding: 6px 8px;
}
.filetable td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.filetable td.file { font-family: var(--mono); font-size: 0.78rem; }
.filetable .num, .filetable td.bytes { text-align: right; font-family: var(--mono); font-size: 0.78rem; }
.pill {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 500;
  border-radius: 999px; padding: 2px 9px;
}
.pill-ok { background: var(--teal-soft); color: var(--ok); }
.pill-bad { background: #fbeae9; color: var(--bad); }

.hint { font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }

.orders { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.order-col ol { padding-left: 20px; font-family: var(--mono); font-size: 0.72rem; color: var(--ink); }
.order-col li { margin-bottom: 3px; }
.order-col li.constants { color: var(--teal); font-weight: 500; }

.bindings { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 12px; }
.bindings span { display: block; margin-bottom: 3px; }

/* Stage rail - the signature element */
.stages h2 { margin-bottom: 6px; }
.stage-rail { list-style: none; counter-reset: stage; margin-top: 18px; }
.stage-rail li {
  counter-increment: stage;
  display: flex; align-items: baseline; gap: 14px;
  padding: 11px 4px 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 0.92rem;
}
.stage-rail li::before {
  content: counter(stage, decimal-leading-zero);
  font-family: var(--mono); font-size: 0.74rem; font-weight: 500;
  color: var(--teal);
  min-width: 26px;
}
.stage-rail .sname { font-weight: 600; color: var(--navy); min-width: 260px; }
.stage-rail .sphase {
  margin-left: auto;
  font-family: var(--mono); font-size: 0.66rem;
  border-radius: 4px; padding: 2px 7px;
  background: #eef1f4; color: var(--muted);
}
.stage-rail .sphase.p1 { background: var(--teal-soft); color: var(--teal); }

.foot {
  text-align: center; font-size: 0.76rem; color: var(--muted);
  padding: 22px 16px 30px;
}

@media (max-width: 820px) {
  .page { padding: 30px 16px 56px; }
  .grid, .orders { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .stage-rail .sname { min-width: 0; }
}

/* ---------- M2 additions ---------- */
.view.hidden, .hidden { display: none !important; }

.form { max-width: 760px; }
.field { margin-bottom: 22px; border: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
.field legend, .field > label {
  display: block; font-size: 0.88rem; font-weight: 600;
  color: var(--navy); margin-bottom: 8px;
}
.field small { display: block; font-size: 0.76rem; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.opt { font-weight: 400; color: var(--muted); font-size: 0.78rem; }

.choice {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  font-size: 0.85rem; background: #fff;
}
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.choice input { margin-top: 3px; accent-color: var(--teal); }
.choice small { color: var(--muted); font-weight: 400; }

input[type="text"], input[type="url"], textarea {
  width: 100%; font: inherit; font-size: 0.88rem;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: #fff; color: var(--ink);
}
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
textarea { resize: vertical; }

.errors {
  background: #fbeae9; color: var(--bad);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 18px;
  font-size: 0.84rem;
}
.errors ul { padding-left: 18px; margin-top: 6px; }

.btn-lg { padding: 13px 30px; font-size: 0.95rem; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-ghost { background: #fff; color: var(--teal); border: 1px solid var(--teal); }

/* workspace */
.stagebox .panel-head { margin-bottom: 6px; }
.stage-state {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
  border-radius: 999px; padding: 4px 12px;
}
.stage-state.running { background: #eef1f4; color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }
.stage-state.waiting { background: #fdf3e3; color: var(--warn); }
.stage-state.confirmed { background: var(--teal-soft); color: var(--ok); }
.stage-state.error { background: #fbeae9; color: var(--bad); }
@keyframes pulse { 50% { opacity: 0.55; } }

.output {
  white-space: pre-wrap;
  font-size: 0.88rem; line-height: 1.65;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; margin: 14px 0 18px;
  max-height: 480px; overflow-y: auto;
  min-height: 90px;
}
.stage-actions { display: flex; gap: 12px; justify-content: flex-end; }
.confirmed-note {
  background: var(--teal-soft); color: var(--ok);
  border-radius: 8px; padding: 12px 16px; font-size: 0.86rem;
}

@media (max-width: 820px) {
  .field-row { grid-template-columns: 1fr; }
  .stage-actions { flex-direction: column; }
}
