/* AG Admin — mobile-first, readable on a roof.
   Look: plain white, Trello-like. Every colour here is a DESIGN.md token —
   read DESIGN.md before changing anything visual. No dark mode, no decorative
   effects, no uppercase labels, radius 3px, 14px system font. */
:root {
  --bg: #ffffff;
  --bg-alt: #f4f5f7;
  --panel: #ebecf0;
  --card: #ffffff;
  --border: #dfe1e6;
  --text: #172b4d;
  --muted: #5e6c84;
  --accent: #0052cc;
  --accent-hover: #0747a6;
  --ok: #216e4e;
  --ok-bg: #dcfff1;
  --warn: #974f0c;
  --warn-bg: #fff7d6;
  --danger: #ae2a19;
  --danger-bg: #ffedeb;
  --label-blue: #deebff;
  /* legacy alias: older tab sheets used --surface for a card/panel fill */
  --surface: #ffffff;
  font-size: 14px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---------- nav ----------
   ONE row: hamburger, current page name, whoami/logout. Replaced the
   horizontally-scrolling strip on 2026-09-09 — at thirteen tabs the strip had
   become a row of unlabelled words you had to swipe through to discover, and
   swiping a sticky header on a roof is exactly the wrong gesture.

   The menu is a <details>/<summary>, NOT a script: this app ships zero
   JavaScript. Breakpoint-free by design (this file has no media queries) — the
   panel is capped by dvh and scrolls if it has to. */
nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}
/* The email is the first thing to give up room on a narrow phone; the Logout
   button must never be the thing that wraps. */
.nav-user .whoami {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-user .logout { margin-left: 0; flex: 0 0 auto; }

/* ---------- the menu ---------- */
.menu { position: relative; flex: 0 0 auto; }
.menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;          /* kill the default disclosure triangle */
  user-select: none;
}
.menu-btn::-webkit-details-marker { display: none; }
.menu-btn:hover { background: var(--panel); }
.menu[open] > .menu-btn { background: var(--panel); }
.menu-btn svg { flex: 0 0 auto; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 264px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 72px);
  overflow-y: auto;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(9, 30, 66, .12);
}
.menu-group { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.menu-group:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.menu-group-head {
  display: flex;
  flex-direction: column;
  padding: 6px 8px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.menu-group-blurb { font-size: 12px; font-weight: 400; color: var(--muted); }
.menu-link {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text);
}
.menu-link:hover { background: var(--panel); color: var(--text); }
.menu-link.active {
  background: var(--label-blue);
  border-color: var(--border);
  font-weight: 600;
}
.menu-link-label { font-size: 14px; }
.menu-link-blurb { font-size: 12px; color: var(--muted); font-weight: 400; }

nav button {
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
}
nav button:hover { color: var(--text); background: var(--panel); }
nav .logout { color: var(--muted); font-size: 13px; }

/* ---------- main ---------- */
main {
  padding: 16px 12px;
  max-width: 680px;
  margin: 0 auto;
}

h1 { font-size: 20px; font-weight: 600; margin-bottom: 12px; }
h2 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }

.count {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--panel);
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 6px;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px;
  margin-bottom: 8px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.lead-name { font-weight: 600; font-size: 15px; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.phone-link { color: var(--accent); text-decoration: none; }
.estimate { color: var(--text); font-weight: 500; }
.ts { font-size: 12px; color: var(--muted); }
.notes { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- status stripes ----------
   A 3px left edge is the only status colour a card carries; the rest of the
   surface stays white. Soft ok / danger for outcomes, gray for in-flight. */
.status-won   { border-left: 3px solid var(--ok); }
.status-lost  { border-left: 3px solid var(--danger); }
.status-quoted { border-left: 3px solid var(--muted); }
.status-at_risk, .status-lapsed { border-left: 3px solid var(--danger); }

/* ---------- badges ----------
   Small gray tags. .ok / .warn / .danger are the three soft status pairs;
   .channel is one pastel label. No uppercase, no tracking, no pills. */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  background: var(--panel);
  color: var(--text);
}
.badge.channel { background: var(--label-blue); }

/* ---------- inline form ---------- */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.inline-form select, .inline-form button {
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.inline-form button {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}
.inline-form button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---------- whoami (nav) ---------- */
.whoami {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
  margin-right: 12px;
}
.error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 600; }

/* ---------- misc ---------- */
.empty { color: var(--muted); font-style: italic; margin-top: 8px; }
.stub-notice {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.stub-notice.small { font-size: 12px; padding: 6px 8px; }
.warn { color: var(--text); }

.range-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.range-tabs a {
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
}
.range-tabs a:hover { color: var(--text); background: var(--bg-alt); }
.range-tabs a.active {
  color: var(--text);
  background: var(--panel);
  font-weight: 600;
}

.summary-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}
.summary-card .label { font-size: 12px; color: var(--muted); }
.summary-card .value { font-size: 20px; font-weight: 600; color: var(--text); }

.at-risk-section { margin-bottom: 20px; }

.meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* ==========================================================================
   SHARED TAB VOCABULARY (integrator-owned, step 0)
   Everything below is the class kit every tab builds from. A tab adds NEW CSS
   only for a genuinely new component, in its own app/static/tabs/<slug>.css,
   token-driven and breakpoint-free (this file has zero media queries — keep
   it that way).
   ========================================================================== */

/* ---------- dry-run banner ----------
   Shown automatically by render() when an upstream's status dict says
   dry_run: true. Anything that spends money or contacts a real human must be
   visibly dry-run in the UI. Soft amber on a light tint — a mark, not a slab. */
.dry-run-banner {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--border);
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 3px;
  margin-bottom: 12px;
  font-size: 13px;
}

/* ---------- flash messages (Post-Redirect-Get) ----------
   render() reads ?ok= / ?err= into flash_ok / flash_err; base.html paints them. */
.flash {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.flash.error {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ---------- buttons ----------
   .inline-form button is already the primary (accent) button. Use .btn for a
   standalone button/link outside an .inline-form. Primary = accent with white
   text; secondary = white with a border; danger = soft red pair. */
.btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #ffffff; }
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-alt); color: var(--text); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ---------- cards (generic) ----------
   .card / .card-header / .card-meta already exist. .card-title is the generic
   name for the bold headline in a card-header (.lead-name is the leads-only
   original and stays for that tab). .card-actions is the button row at the
   bottom of a card. */
.card-title { font-weight: 600; font-size: 15px; }
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* ---------- badge modifiers — the three soft status pairs ---------- */
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- stacked form ----------
   For a multi-field form (a send, a schedule, a new record). .inline-form stays
   the one-row control strip inside a card. Both are plain HTML forms doing
   Post-Redirect-Get — this app ships zero JavaScript. */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px;
  margin-bottom: 12px;
}
.stack-form .field { display: flex; flex-direction: column; gap: 3px; }
.stack-form label { font-size: 12px; color: var(--muted); }
/* Text-like inputs only: a radio or checkbox stretched to width:100% detaches
   from its label (YP28b item 1, mailshot-step2-look-1280.png). :where() keeps
   the selector's specificity at (0,1,1), so every tab override still wins
   exactly as before. */
.inline-form input:where(:not([type="radio"], [type="checkbox"])), .inline-form textarea,
.stack-form input:where(:not([type="radio"], [type="checkbox"])), .stack-form select, .stack-form textarea {
  padding: 6px 8px;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}
.stack-form button {
  padding: 6px 12px;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  cursor: pointer;
  align-self: flex-start;
}
.stack-form button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.field-hint { font-size: 12px; color: var(--muted); }

/* ---------- section header row (title + a control on the right) ---------- */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 8px;
}
