/* ============================================================================
   INTAKE COMMANDER — shared stylesheet (rough-draft prototype)
   ----------------------------------------------------------------------------
   One stylesheet for every page so the whole tool feels like one product.
   Palette is deliberately "trade pro": deep navy + safety orange, clean
   neutrals everywhere else. No frameworks — Jake reads this code, so every
   section is labeled and the why is written down, not just the what.
   ============================================================================ */

:root {
  /* Brand */
  --navy:        #16283f;   /* header bars, headings */
  --navy-soft:   #1f3a5f;   /* hover states, drawer header */
  --orange:      #f26a1b;   /* primary actions — safety-orange, hard to miss */
  --orange-dark: #d5570f;

  /* Surfaces & ink */
  --bg:          #f2f5f9;   /* page background */
  --card:        #ffffff;   /* cards, panels */
  --ink:         #1c2733;   /* body text */
  --muted:       #64748b;   /* secondary text */
  --line:        #e2e8f0;   /* hairline borders */

  /* SLA escalation ramp — green → amber → orange → red.
     Thresholds live in app.js (IntakeDB.sla); colors only live here. */
  --sla-ok:       #16a34a;
  --sla-caution:  #d97706;
  --sla-warn:     #ea580c;
  --sla-critical: #dc2626;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(22, 40, 63, .08), 0 4px 14px rgba(22, 40, 63, .06);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--navy-soft); }

/* ---------- top bar (internal pages: dashboard / response / tutorial) ---------- */

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .3px;
  white-space: nowrap;
}
.topbar .brand span { color: var(--orange); }

.topbar nav { display: flex; gap: 4px; margin-left: 8px; }
.topbar nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a.active { background: var(--orange); color: #fff; font-weight: 600; }

.topbar .sla-chip {
  margin-left: auto;
  font-size: 13px;
  background: rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* ---------- layout ---------- */

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }

.page-head { margin: 4px 0 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; color: var(--navy); }
.page-head p  { margin: 0; color: var(--muted); }

/* ---------- cards & panels ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.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); }

.stat { text-align: left; }
.stat .num   { font-size: 30px; font-weight: 800; color: var(--navy); }
.stat .label { font-size: 13px; color: var(--muted); }

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary {
  background: #fff; color: var(--navy);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--navy); }
.btn-small { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-danger { background: #fee2e2; color: #991b1b; }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--navy); margin-bottom: 6px;
}
input[type=text], input[type=tel], input[type=email], input[type=date],
input[type=number], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--orange);
  outline-offset: -1px;
  border-color: var(--orange);
}
textarea { resize: vertical; min-height: 90px; }

/* ---------- intake form page (public capture) ---------- */

.capture-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: #fff;
  padding: 48px 20px;
  text-align: center;
}
.capture-hero h1 { margin: 0 0 8px; font-size: 34px; }
.capture-hero h1 span { color: var(--orange); }
.capture-hero p { margin: 0; color: #cbd5e1; font-size: 17px; }

.capture-card {
  max-width: 640px;
  margin: -28px auto 40px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(22,40,63,.18);
  padding: 30px;
}
.capture-card h2 { margin-top: 0; color: var(--navy); }
.urgency-row { display: flex; gap: 8px; flex-wrap: wrap; }
.urgency-row label {
  flex: 1 1 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  margin: 0;
}
.urgency-row input { display: none; }
.urgency-row input:checked + span { font-weight: 800; color: var(--orange-dark); }
.urgency-row label:has(input:checked) { border-color: var(--orange); background: #fff7ed; }

.success-panel { text-align: center; padding: 30px 10px; }
.success-panel .big-check {
  font-size: 54px; line-height: 1;
}
.demo-note {
  margin-top: 18px; padding: 12px 14px;
  background: #fffbeb; border: 1px dashed #d97706;
  border-radius: 8px; font-size: 13px; color: #92400e;
}

/* ---------- kanban ---------- */

.kanban {
  display: flex; gap: 14px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 12px;
}
.kanban-col {
  flex: 1 0 240px;
  background: #e8edf3;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}
.kanban-col h3 {
  margin: 0 0 10px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--navy);
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-col h3 .count {
  background: var(--navy); color: #fff;
  border-radius: 999px; font-size: 12px;
  padding: 1px 9px;
}
.lead-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.lead-card:hover { border-color: var(--orange); }
.lead-card .nm { font-weight: 700; font-size: 14px; }
.lead-card .sv { font-size: 13px; color: var(--muted); }
.lead-card .meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 12px; color: var(--muted);
}
/* left-edge color follows pipeline stage */
.lead-card.st-new       { border-left-color: var(--sla-warn); }
.lead-card.st-contacted { border-left-color: #2563eb; }
.lead-card.st-quoted    { border-left-color: #7c3aed; }
.lead-card.st-won       { border-left-color: var(--sla-ok); }
.lead-card.st-lost      { border-left-color: #94a3b8; opacity: .85; }

/* SLA pill — the color IS the message */
.sla {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 2px 10px;
  color: #fff; white-space: nowrap;
}
.sla.ok       { background: var(--sla-ok); }
.sla.caution  { background: var(--sla-caution); }
.sla.warn     { background: var(--sla-warn); }
.sla.critical { background: var(--sla-critical); }

/* ---------- detail drawer ---------- */

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none; z-index: 90;
}
.drawer-backdrop.open { display: block; }

.drawer {
  position: fixed; top: 0; right: -460px;
  width: 440px; max-width: 94vw; height: 100%;
  background: #fff; z-index: 100;
  box-shadow: -8px 0 30px rgba(0,0,0,.18);
  transition: right .25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { right: 0; }
.drawer header {
  background: var(--navy); color: #fff;
  padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.drawer header h2 { margin: 0; font-size: 18px; }
.drawer .body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer .close-x {
  background: none; border: 0; color: #fff;
  font-size: 22px; cursor: pointer;
}
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.stage-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* ---------- response center ---------- */

.sla-row {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.sla-row .timer {
  font-size: 24px; font-weight: 800; min-width: 110px;
  font-variant-numeric: tabular-nums;
}
.sla-row .who { flex: 1; }
.sla-row .who .nm { font-weight: 700; }
.sla-row .who .sv { font-size: 13px; color: var(--muted); }
.sla-bar { height: 8px; border-radius: 999px; background: #eef2f7; margin-top: 8px; overflow: hidden; }
.sla-bar i { display: block; height: 100%; border-radius: 999px; }
.sla-bar i.ok       { background: var(--sla-ok); width: 12%; }
.sla-bar i.caution  { background: var(--sla-caution); width: 38%; }
.sla-bar i.warn     { background: var(--sla-warn); width: 68%; }
.sla-bar i.critical { background: var(--sla-critical); width: 100%; }

.template {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; background: #fff;
}
.template h4 { margin: 0 0 6px; color: var(--navy); font-size: 15px; }
.template pre {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px;
  white-space: pre-wrap; font-family: inherit; font-size: 14px;
  margin: 0 0 10px;
}
.followup {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.followup:last-child { border-bottom: 0; }
.followup input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }
.followup.done .txt { text-decoration: line-through; color: var(--muted); }
.due { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.due.overdue { background: #fee2e2; color: #991b1b; }
.due.today   { background: #fef3c7; color: #92400e; }
.due.later   { background: #e0f2fe; color: #075985; }

/* ---------- tutorial ---------- */

.tutorial { max-width: 760px; margin: 0 auto; }
.tutorial h2 { color: var(--navy); margin-top: 34px; }
.tutorial .step-num {
  display: inline-block; background: var(--orange); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  text-align: center; line-height: 30px; font-weight: 800;
  margin-right: 8px;
}
.tutorial .tip {
  background: #eff6ff; border-left: 4px solid #2563eb;
  padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 16px 0;
}
.tutorial figure.demo-shot {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 14px; margin: 16px 0;
  font-size: 14px; color: var(--muted);
}

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .topbar nav a { padding: 8px 8px; font-size: 13px; }
  .topbar .sla-chip { display: none; }
  /* snap the kanban so one column lands cleanly per swipe */
  .kanban { scroll-snap-type: x mandatory; }
  .kanban-col { scroll-snap-align: start; }
}
@media (max-width: 600px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .capture-card { margin: -20px 12px 30px; padding: 22px; }
  .capture-hero { padding: 36px 16px; }
  .capture-hero h1 { font-size: 27px; }
  .capture-hero p { font-size: 15px; }
  /* 16px inputs stop iOS from auto-zooming on focus */
  input[type=text], input[type=tel], input[type=email], input[type=date],
  input[type=number], select, textarea { font-size: 16px; }
  /* urgency picks go 2×2 instead of four squeezed columns */
  .urgency-row label { flex: 1 1 44%; }
  /* four nav links fit by scrolling, not squishing */
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .brand { font-size: 15px; }
  .topbar nav { overflow-x: auto; margin-left: 0; }
  .topbar nav a { white-space: nowrap; }
  .page-head h1 { font-size: 22px; }
  .stat .num { font-size: 25px; }
  .sla-row { flex-wrap: wrap; }
  .sla-row .timer { min-width: 0; font-size: 20px; }
}

/* ============================================================================
   INTAKE COMMANDER v2 — additions: setup wizard, services, system
   ============================================================================ */

/* --- setup wizard --- */
.wizard-steps {
  display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap;
}
.wstep {
  flex: 1; min-width: 100px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--muted); padding: 8px 4px; border-radius: 8px;
  background: #f1f5f9; border: 1px solid var(--line);
}
.wstep.active { color: #fff; background: var(--navy); border-color: var(--navy); }
.wpage h2 { color: var(--navy); font-size: 20px; margin: 0 0 4px; }
.wizard-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line);
}
.big-check { font-size: 52px; margin-bottom: 8px; }

/* --- services rows (wizard + settings) --- */
.svc-row {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.svc-row .svc-name { flex: 2; min-width: 140px; }
.svc-row .svc-desc { flex: 3; min-width: 160px; }
.svc-row .svc-info { flex: 1; }
.svc-row.inactive .svc-info strong { color: var(--muted); text-decoration: line-through; }
.svc-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge-off {
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  background: #94a3b8; border-radius: 999px; padding: 2px 8px; margin-left: 6px;
}

/* --- system --- */
.danger-zone {
  margin-top: 16px; padding: 12px; border: 1px dashed #f87171;
  border-radius: 10px; background: #fef2f2;
}
.danger-zone strong { color: #b91c1c; }
.saved-flash { color: var(--sla-ok); font-weight: 700; display: none; margin-left: 8px; }

/* --- form helpers --- */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 640px) {
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .svc-row { flex-wrap: wrap; }
  .svc-row .svc-name, .svc-row .svc-desc { flex: 1 1 100%; }
}

/* small square icon button (✕ ↑ ↓) */
.btn-icon {
  padding: 6px 10px; font-size: 14px; border-radius: 6px;
  background: #f1f5f9; border: 1px solid var(--line); cursor: pointer;
  line-height: 1;
}
.btn-icon:hover:not(:disabled) { border-color: var(--navy); }
.btn-icon:disabled { opacity: .35; cursor: default; }

/* ---------- Flow Commander v4 additions ---------- */
/* password inputs match the other text inputs */
input[type=password] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input[type=password]:focus {
  outline: 2px solid var(--orange);
  outline-offset: -1px;
  border-color: var(--orange);
}
@media (max-width: 600px) {
  input[type=password] { font-size: 16px; }
}
/* setup wizard step dots reuse .wstep from v2 */
.flash-ok  { border-left: 4px solid var(--sla-ok); }
.flash-err { border-left: 4px solid var(--sla-critical); }
