/* Valor Node Sales Hub — shared styles.
   Color tokens follow the validated reference palette (light + dark selected,
   not auto-flipped). Chart code reads these same custom properties. */

:root {
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good-text: #006300;
  --critical: #d03b3b;
  --ghost: rgba(11, 11, 11, 0.045);

  /* ordinal funnel ramp — 4 steps, validated light */
  --ord-1: #86b6ef;
  --ord-2: #5598e7;
  --ord-3: #2a78d6;
  --ord-4: #184f95;

  --series-1: #2a78d6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good-text: #0ca30c;
    --ghost: rgba(255, 255, 255, 0.06);

    /* ordinal funnel ramp — 4 steps, validated dark */
    --ord-1: #9ec5f4;
    --ord-2: #6da7ec;
    --ord-3: #3987e5;
    --ord-4: #1c5cab;

    --series-1: #3987e5;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav .brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topnav .brand .mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.topnav nav { display: flex; gap: 4px; }
.topnav nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.topnav nav a:hover { background: var(--ghost); color: var(--text-primary); }
.topnav nav a.active { color: var(--text-primary); background: var(--ghost); font-weight: 600; }
.topnav .spacer { flex: 1; }
.topnav .who { color: var(--text-muted); font-size: 13px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.card .sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* stat tile: label / value / delta */
.stat-tile .label { color: var(--text-secondary); font-size: 13px; }
.stat-tile .value { font-size: 32px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.stat-tile .delta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.stat-tile .delta.up { color: var(--good-text); }

/* ---------- buttons & forms ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--ghost); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); }
.btn.small { padding: 4px 10px; font-size: 13px; }

input, select, textarea {
  font: inherit;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

.error-msg { color: var(--critical); font-size: 13px; min-height: 18px; }
.ok-msg { color: var(--good-text); font-size: 13px; min-height: 18px; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--baseline);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--ghost); }

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.stage-chip .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ---------- chart chrome ---------- */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.viz-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 8px 10px;
  font-size: 13px;
  z-index: 30;
  min-width: 120px;
  display: none;
}
.viz-tooltip .tt-title { color: var(--text-muted); font-size: 12px; margin-bottom: 3px; }
.viz-tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.viz-tooltip .tt-key { width: 12px; height: 0; border-top: 3px solid; border-radius: 2px; flex: none; }
.viz-tooltip .tt-val { font-weight: 600; }
.viz-tooltip .tt-label { color: var(--text-secondary); }

.empty-note { color: var(--text-muted); font-size: 14px; padding: 24px 0; text-align: center; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 460px;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand-lg {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700; margin-bottom: 4px;
}
.login-card .brand-lg .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
}

/* ---------- playbook ---------- */
.pb-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
@media (max-width: 860px) { .pb-layout { grid-template-columns: 1fr; } }
.pb-nav {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 14px;
}
.pb-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  border-left: 2px solid transparent;
}
.pb-nav a:hover { background: var(--ghost); color: var(--text-primary); }
.pb-content h1 { font-size: 24px; margin: 0 0 6px; }
.pb-content .lede { color: var(--text-secondary); font-size: 16px; margin: 0 0 28px; }
.pb-content section { margin-bottom: 36px; scroll-margin-top: 80px; }
.pb-content h2 {
  font-size: 18px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--grid);
}
.pb-content h3 { font-size: 15px; margin: 20px 0 8px; }
.pb-content p, .pb-content li { color: var(--text-secondary); }
.pb-content li { margin-bottom: 6px; }
.pb-content strong { color: var(--text-primary); }
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface-1);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 14px 0;
}
.callout.warn { border-left-color: var(--critical); }
.callout p { margin: 0; }
.script-block {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 14px 0;
  font-size: 14px;
  color: var(--text-secondary);
}
.script-block p { margin: 0 0 10px; }
.script-block p:last-child { margin-bottom: 0; }
.stage-defs { display: grid; gap: 10px; }
.stage-def {
  display: flex; gap: 12px; align-items: baseline;
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: 10px;
  padding: 10px 14px;
}
.stage-def .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; align-self: center; }
.stage-def b { min-width: 120px; }
.stage-def span { color: var(--text-secondary); font-size: 14px; }
