:root {
  /* Nimbl forest-green dark theme */
  --bg: #0b100e;
  --bg-2: #101613;
  --panel: #141b18;
  --panel-2: #1b2420;
  --border: #26332c;
  --text: #e8f0ec;
  --muted: #8fa39a;
  --muted-2: #5f7268;

  --brand-deep: #034737;     /* logo green */
  --green-700: #0d4030;      /* deep surface */
  --green-600: #1a4f3e;      /* lighter surface */
  --brand: #3ddc84;          /* bright accent / CTA */
  --brand-2: #2fbf71;
  --teal: #2dd4bf;           /* secondary accent */

  --warn: #f5b84a;
  --danger: #ef6a6a;
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0,0,0,.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 560px at 82% -12%, #123127 0%, rgba(18,49,39,0) 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px; line-height: 1.5; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--panel-2);
  padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 234px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(3,71,55,.28), rgba(11,16,14,.6));
  backdrop-filter: blur(8px); border-right: 1px solid var(--border);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 22px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-deep), var(--green-600));
  display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(61,220,132,.18);
}
.brand .logo img { width: 20px; height: 20px; display: block; }
.brand .title { line-height: 1.1; }
.brand .title b { font-size: 1rem; letter-spacing: -.02em; display: block; }
.brand .title span { font-size: .68rem; color: var(--muted); letter-spacing: .08em;
  text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: linear-gradient(135deg, rgba(3,71,55,.55), rgba(26,79,62,.4));
  color: #eafff4; box-shadow: inset 0 0 0 1px rgba(61,220,132,.16); }
.nav a .ic { width: 18px; text-align: center; opacity: .95; }
.sidebar .spacer { flex: 1; }
.userbox { border-top: 1px solid var(--border); padding-top: 12px; font-size: .85rem; }
.userbox .email { color: var(--muted); display: block; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; padding: 26px 32px 70px; max-width: 1220px; }
.topbar { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px){ .grid.cols-4,.grid.cols-3,.grid.cols-2{grid-template-columns:1fr 1fr;} }

/* ---------- Mobile header + drawer ---------- */
.mobile-header { display: none; align-items: center; gap: 12px; padding: 12px 16px;
  background: rgba(11,16,14,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 60; }
.mobile-header .brand .logo { width: 30px; height: 30px; }
.mobile-header .title b { font-size: .95rem; }
.hamburger { background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; font-size: 1.2rem; cursor: pointer; line-height: 1; }
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; }

@media (max-width: 860px) {
  .mobile-header { display: flex; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
    transform: translateX(-100%); transition: transform .22s ease; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  body.nav-open .nav-backdrop { display: block; }
  .main { padding: 18px 16px 60px; }
}
@media (max-width: 620px){ .grid.cols-4,.grid.cols-3,.grid.cols-2{grid-template-columns:1fr;}
  .main { padding: 16px 13px 50px; } h1 { font-size: 1.3rem; }
  .topbar { gap: 10px; } .table-wrap { font-size: .82rem; }
  .bar-row { grid-template-columns: 110px 1fr 34px; }
  .stage-editor .stage-row { grid-template-columns: 1fr 48px 70px; }
}

.card { background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); }
.card h2 { display: flex; align-items: center; justify-content: space-between; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 2rem; font-weight: 720; letter-spacing: -.02em; margin-top: 4px; }
.stat .value.green { color: var(--brand); }

/* ---------- Bars / funnel ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 10px; }
.bar-row .name { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 10px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-600), var(--brand)); border-radius: 6px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel .seg { display: flex; align-items: center; gap: 10px; }
.funnel .seg .cap { width: 92px; color: var(--muted); font-size: .82rem; text-transform: capitalize; }
.funnel .seg .track { flex: 1; height: 26px; background: var(--panel-2); border-radius: 8px; position: relative; overflow: hidden; }
.funnel .seg .track > span { position: absolute; inset: 0 auto 0 0; border-radius: 8px;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand)); display: flex;
  align-items: center; padding-left: 10px; font-size: .8rem; font-weight: 600; color: #eafff4; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th { text-align: left; padding: 11px 14px; color: var(--muted); font-weight: 600;
  font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; background: var(--bg-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: rgba(61,220,132,.06); }
tbody tr[data-href] { cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; border: 1px solid transparent; }
.pill.green { background: rgba(61,220,132,.13); color: #8ff0bd; border-color: rgba(61,220,132,.25); }
.pill.teal { background: rgba(45,212,191,.13); color: #99ece0; border-color: rgba(45,212,191,.28); }
.pill.grey { background: var(--panel-2); color: var(--muted); border-color: var(--border); }
.pill.amber { background: rgba(245,184,74,.14); color: #f6cf8f; border-color: rgba(245,184,74,.3); }
.pill.red { background: rgba(239,106,106,.14); color: #f3a6a6; border-color: rgba(239,106,106,.3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Forms / buttons ---------- */
label { display: block; font-size: .8rem; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=color],
textarea, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: .9rem; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s; }
input[type=color] { padding: 4px; height: 40px; cursor: pointer; }
input:focus, textarea:focus, select:focus { border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(61,220,132,.16); }
textarea { resize: vertical; min-height: 90px; }
select[multiple] { min-height: 130px; }
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); padding: 9px 15px; border-radius: 10px; font-size: .88rem;
  font-weight: 600; font-family: inherit; transition: transform .05s, background .15s, border-color .15s; }
.btn:hover { background: #22302a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #05140c; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: #f3a6a6; border-color: rgba(239,106,106,.3); background: transparent; }
.btn.danger:hover { background: rgba(239,106,106,.1); }
.btn.sm { padding: 6px 10px; font-size: .8rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; border: none; color: var(--muted); padding: 10px 14px; cursor: pointer;
  font-size: .9rem; font-weight: 600; font-family: inherit; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--brand); }

/* ---------- Progress ---------- */
.progress { height: 10px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green-600), var(--brand)); transition: width .4s; }
.logbox { background: #070b09; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  font-family: ui-monospace, Menlo, monospace; font-size: .78rem; color: #9fc4b1; max-height: 240px;
  overflow: auto; white-space: pre-wrap; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 390px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.auth-logo img { height: 42px; }
.alert { padding: 10px 12px; border-radius: 10px; font-size: .85rem; margin: 10px 0; }
.alert.err { background: rgba(239,106,106,.12); color: #f3a6a6; border: 1px solid rgba(239,106,106,.25); }
.alert.ok { background: rgba(61,220,132,.12); color: #8ff0bd; border: 1px solid rgba(61,220,132,.25); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.spacer-16 { height: 16px; } .spacer-8 { height: 8px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: .88rem; }
.kv .k { color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline .item { border-left: 2px solid var(--border); padding: 0 0 2px 14px; position: relative; }
.timeline .item::before { content: ""; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--brand); }
.timeline .item .meta { color: var(--muted-2); font-size: .75rem; }

/* ---------- Guide ---------- */
.guide { max-width: 860px; }
.guide h2 { margin-top: 30px; font-size: 1.3rem; }
.guide h3 { margin-top: 22px; }
.guide p { color: #cfdcd5; }
.guide .lead { font-size: 1.05rem; color: var(--text); }
.steps { counter-reset: step; display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.step { display: grid; grid-template-columns: 38px 1fr; gap: 14px; align-items: start; }
.step .num { counter-increment: step; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-deep), var(--green-600)); color: #eafff4;
  display: grid; place-items: center; font-weight: 700; }
.step .num::before { content: counter(step); }
.step .body b { color: #fff; }
.callout { border: 1px solid var(--border); border-left: 3px solid var(--brand); background: var(--panel);
  border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
.callout.warn { border-left-color: var(--warn); }
.diagram { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 16px 0; overflow-x: auto; }
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.faq { border: 1px solid var(--border); border-radius: 10px; margin: 8px 0; overflow: hidden; }
.faq summary { padding: 13px 15px; cursor: pointer; font-weight: 600; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq[open] summary { border-bottom: 1px solid var(--border); color: var(--brand); }
.faq .ans { padding: 13px 15px; color: #cfdcd5; }

/* ---------- Settings ---------- */
.stage-editor .stage-row { display: grid; grid-template-columns: 1fr 56px 90px; gap: 10px;
  align-items: center; margin-bottom: 8px; }
.seg-head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 6px; }
