/* NextIsWhat — phone-friendly (works at 380px). Brand colours: green and red (owner, 27 Sep 2026).
   Green = the brand, "go", won, on track. Red = the brand accent and overdue / lost / needs attention.
   (The variable is still called --blue so no other rule had to change; it now holds the brand green.) */
:root {
  --blue: #15803d;        /* brand green */
  --blue-dark: #116b33;
  --blue-soft: #e6f5eb;
  --brand-red: #dc2626;   /* brand accent red */
  --sidebar: #0f2a1b;     /* deep green menu */
  --text: #1c2430;
  --muted: #6b7686;
  --line: #e3e8ef;
  --bg: #f4f6f9;
  --card: #ffffff;
  --red: #c62828;
  --red-soft: #fdecec;
  --amber: #9a6700;
  --amber-soft: #fff4d6;
  --green: #1b7a3d;
  --green-soft: #e6f5ec;
  --wa: #1fa855;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
p { margin: 0 0 8px; }
ol, ul { margin: 0 0 8px; padding-left: 20px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-danger { color: var(--red); }
.brand { font-weight: 800; color: var(--blue); font-size: 18px; letter-spacing: -0.2px; }
.brand::before { content: ""; display: inline-block; width: 30px; height: 30px; margin-right: 9px; border-radius: 50%; background: #fff url(icons/logo-badge.png) center / 86% no-repeat; vertical-align: middle; flex: none; }
.brand-big::before { width: 44px; height: 44px; }
.brand:hover { text-decoration: none; }
.brand-big { font-size: 26px; margin: 0; }

/* ---------- layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 0;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: block; padding: 2px 10px 18px; color: #fff; }
.mainnav { display: flex; flex-direction: column; gap: 2px; }
.mainnav a { padding: 9px 10px; border-radius: 8px; color: #cfe5d7; font-weight: 500; border-left: 3px solid transparent; }
.mainnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.mainnav a.active { background: var(--blue); color: #fff; border-left-color: var(--brand-red); }
.content { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; }
.usermenu { margin-left: auto; position: relative; }
.usermenu summary { cursor: pointer; list-style: none; font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary::after { content: " ▾"; color: var(--muted); }
.usermenu .menu {
  position: absolute; right: 0; top: 38px; z-index: 10;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(20, 30, 50, .12);
  padding: 12px; min-width: 220px; display: flex; flex-direction: column; gap: 8px;
}
.usermenu form { margin: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 22px 24px 60px; }
.banner { background: var(--blue-soft); color: var(--blue-dark); padding: 8px 24px; font-size: 14px; }
.banner-warn { background: var(--amber-soft); color: var(--amber); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-bottom: 26px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

/* ---------- cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-warn { border-color: #f1d18a; background: #fffaf0; }
.card-ok { border-color: #b7e0c4; background: var(--green-soft); }
.na-missing { border-color: #f3b4b4; background: #fff8f8; }
.na-title { font-size: 16px; margin-bottom: 4px; }
.empty { color: var(--muted); padding: 8px 0; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; min-height: 40px;
  font: inherit; font-weight: 600; color: #fff;
  background: var(--blue); border: 1px solid var(--blue); border-radius: 8px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn-secondary { background: var(--card); color: var(--text); border-color: #cfd6e0; }
.btn-secondary:hover { background: var(--bg); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #178a45; }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #a61f1f; }
.btn-small { padding: 5px 11px; min-height: 34px; font-size: 14px; }
.btn-block { width: 100%; margin-top: 20px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfd6e0;
  border-radius: 8px;
  min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
/* Our own drop-down style: Safari's built-in one ignores height, which made drop-downs too small to tap. */
select {
  -webkit-appearance: none; appearance: none;
  padding-right: 34px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23116b33' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center;
  line-height: 1.3;
}
select::-ms-expand { display: none; }
input[type=checkbox], input[type=radio] { accent-color: var(--blue); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
.input-narrow { width: 90px; }
.form h2 { margin-top: 18px; }
.form h2:first-child, .form > input[type="hidden"] + h2 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { margin-bottom: 12px; }
.form-grid .field { margin-bottom: 0; }
.field.grow { flex: 1; min-width: 200px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 12px 0 0; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { max-width: 260px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="search"] { flex: 1; min-width: 200px; }
.filters select { width: auto; }

/* One-tap chips (outcome panel, due times) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { width: 100%; }
.chip { margin: 0; font-weight: 500; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 7px 12px; border: 1px solid #cfd6e0; border-radius: 999px;
  background: #fff; font-size: 14px; user-select: none;
}
.chip input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.due-custom { width: auto; margin-top: 4px; }

/* ---------- badges, flashes */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-info { background: var(--blue-soft); color: var(--blue-dark); }
.badge-soft { background: #eef1f5; color: var(--muted); }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.alert { padding: 10px 12px; color: var(--red); background: var(--red-soft); border-radius: 8px; }

/* ---------- tables and lists */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr.total td { font-weight: 700; background: #fafbfc; }
.card .table-wrap { border: 0; margin: 0; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 10px 0 0; font-size: 14px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 12px 0; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- KPIs and team strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--blue-dark); }
.kpi { border-top: 3px solid var(--blue); }
.kpi-label { color: var(--muted); font-size: 13px; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.strip-item { flex: 0 0 auto; min-width: 170px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; font-size: 13px; color: var(--text); }
.strip-item strong { font-size: 15px; }
.strip-item:hover { border-color: var(--blue); text-decoration: none; }

/* ---------- Next Action list */
.action-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.action-item { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.action-item.is-overdue { border-left-color: var(--red); }
.action-main { flex: 1; min-width: 220px; }
.action-top { margin-bottom: 4px; }
.action-title { font-weight: 700; font-size: 16px; color: var(--text); display: block; }
.action-sub { color: var(--text); }
.action-buttons { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.action-buttons .btn-row { margin: 0; justify-content: flex-end; }
.why { margin-top: 6px; font-size: 14px; }
.why summary { color: var(--blue); cursor: pointer; }
.why p { margin: 6px 0 0; }
.outcome-panel { flex-basis: 100%; border-top: 1px dashed var(--line); padding-top: 12px; }

/* ---------- Deals board and stage bar */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.board-col { flex: 0 0 250px; background: #eceff4; border-radius: var(--radius); padding: 10px; }
.board-col header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.deal-card { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; color: var(--text); }
.deal-card:hover { border-color: var(--blue); text-decoration: none; }
.deal-card.no-action { border-left: 3px solid var(--red); }
.deal-card .badge { align-self: flex-start; margin-top: 4px; }
.stage-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.stage-bar form { margin: 0; }
.stage { font: inherit; font-size: 14px; font-weight: 600; padding: 7px 14px; border: 1px solid #cfd6e0; border-radius: 999px; background: #fff; color: var(--text); cursor: pointer; list-style: none; }
.stage:hover { border-color: var(--blue); }
.stage.current { background: var(--blue); border-color: var(--blue); color: #fff; cursor: default; }
.stage-won:not(.current) { border-color: #b7e0c4; color: var(--green); }
.stage-lost { position: relative; }
.stage-lost summary::-webkit-details-marker { display: none; }
.stage-lost[open] form { position: absolute; z-index: 5; top: 40px; left: 0; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: 0 8px 24px rgba(20, 30, 50, .12); }

/* ---------- timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline p { margin: 6px 0 0; }
.badge-type-call { background: var(--blue-soft); color: var(--blue-dark); }
.badge-type-whatsapp { background: var(--green-soft); color: var(--green); }
.badge-type-meeting { background: var(--amber-soft); color: var(--amber); }

/* ---------- login page */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 12px; padding: 32px 28px; box-shadow: 0 4px 24px rgba(20, 30, 50, .08); border-top: 5px solid var(--blue); }
.auth-page { background: #0f2a1b; background-image: radial-gradient(circle at 20% 15%, rgba(34, 197, 94, .22), transparent 45%), radial-gradient(circle at 85% 90%, rgba(220, 38, 38, .18), transparent 40%); background-attachment: fixed; }
.auth-page .auth-card { border-top-color: var(--brand-red); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.auth-story { display: none; }
/* Computers (FEEDBACK #5, option C): green story panel on the left, the login card on the right. */
@media (min-width: 1000px) {
  .auth-page.auth-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); padding: 0; background: #f6f7f9; background-image: none; }
  .auth-split .auth-card { justify-self: center; align-self: center; margin: 40px 24px; border-top-color: var(--blue); box-shadow: 0 8px 30px rgba(20, 30, 50, .10); }
  .auth-story { display: flex; flex-direction: column; justify-content: center; gap: 36px; min-height: 100vh; padding: 56px 5vw; color: #fff;
    background: #0f2a1b; background-image: radial-gradient(circle at 15% 12%, rgba(34, 197, 94, .28), transparent 45%), radial-gradient(circle at 90% 95%, rgba(220, 38, 38, .22), transparent 40%); }
  .story-kicker { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #86efac; }
  .story-head h2 { margin: 0 0 12px; font-size: clamp(34px, 3.4vw, 50px); line-height: 1.05; letter-spacing: -.5px; }
  .story-head p { margin: 0; max-width: 34em; font-size: 17px; line-height: 1.55; opacity: .85; }
  .story-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 640px; }
  .story-card { background: rgba(255, 255, 255, .96); color: #1c2430; border-radius: 14px; padding: 14px 16px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); }
  .story-label { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
  .story-label .up { float: right; color: var(--blue); letter-spacing: 0; }
  .story-chart { display: block; width: 100%; height: auto; }
  .story-today { grid-column: 1 / -1; }
  .story-today ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .story-today li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
  .story-today em { font-style: normal; font-size: 12px; color: var(--muted); }
  .story-today em.due { color: var(--brand-red); font-weight: 600; }
  .story-today .chip { margin-left: auto; padding: 2px 9px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: 11px; font-weight: 600; }
  .story-today .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; }
  .story-today .dot.red { background: var(--brand-red); }
  .story-done { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
  .story-done div { display: flex; flex-direction: column; font-size: 14px; }
  .story-done span { font-size: 12px; color: var(--muted); }
}

.auth-card label { margin: 14px 0 6px; }
.tagline { margin: 4px 0 20px; color: var(--muted); }

/* ---------- phones and small tablets */
@media (max-width: 900px) {
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: sticky; top: 0; z-index: 20; padding: 8px 12px; border-right: 0; }
  .sidebar .brand { padding: 0 0 6px; font-size: 16px; }
  .mainnav { flex-direction: row; overflow-x: auto; gap: 2px; }
  .mainnav a { white-space: nowrap; padding: 7px 10px; font-size: 14px; }
  .topbar { padding: 8px 12px; }
  .page { padding: 16px 12px 60px; }
  .banner { padding: 8px 12px; }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .action-buttons { align-items: stretch; flex-basis: 100%; }
  .action-buttons .btn-row { justify-content: flex-start; }
  .board-col { flex-basis: 78vw; }
  .filters select, .filters .btn { flex: 1; }
  /* The outcome panel sits like a bottom sheet on phones. */
  .outcome-panel:not([hidden]) {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    max-height: 85vh; overflow-y: auto;
    background: #fff; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 30px rgba(20, 30, 50, .18);
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  }
}

/* ---------- sign-up / reset pages */
.auth-title { font-size: 20px; margin: 0 0 6px; }
.auth-links { margin: 18px 0 0; font-size: 14px; text-align: center; color: var(--muted); }
.auth-card .flash { margin-top: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- on-screen new-lead alert */
.nav-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }

/* ---------- getting started */
.getting-started { border-color: #c9d7ff; background: #f7f9ff; }
.checklist { padding-left: 22px; }
.checklist li { margin-bottom: 6px; }
.checklist li.done a { text-decoration: line-through; color: var(--muted); }

/* ---------- EKM admin panel */
.admin-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 24px; background: var(--sidebar); color: #fff; border-bottom: 3px solid var(--brand-red); }
.admin-bar .brand { color: #fff; }
.admin-bar .muted { color: #aab4c3; }
.admin-nav { display: flex; gap: 4px; }
.admin-nav a { color: #d7deea; padding: 6px 10px; border-radius: 8px; font-weight: 600; }
.admin-nav a.active, .admin-nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.admin-logout { margin: 0 0 0 auto; }
.admin-logout .link-button { color: #d7deea; }
@media (max-width: 760px) { .admin-bar { padding: 10px 12px; } }

/* ---------- read-only company (trial ended): hide everything that adds or changes data.
   The server refuses such changes anyway; this just keeps the screen honest. */
.read-only main form[method="post"]:not(.ro-ok),
.read-only .page-head .actions,
.read-only a[href*="-edit.php"],
.read-only a[href^="import.php"],
.read-only a[href*="lead-convert"],
.read-only .action-buttons button[data-open-panel],
.read-only .na-card details,
.read-only .stage-bar { display: none !important; }
.banner-warn a { color: inherit; text-decoration: underline; }

/* ---------- NIW Marketing */
.quick-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-link { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border: 1px solid #cfd6e0; border-radius: 999px; background: #fff; font-size: 14px; color: var(--text); }
.chip-link:hover { border-color: var(--blue); text-decoration: none; }
.chip-link.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip-link.active a, .chip-link.active .link-button { color: #fff; }
.chip-link.saved a { color: inherit; }
.chip-x { display: inline; margin: 0; }
.chip-x .link-button { font-size: 16px; line-height: 1; color: var(--muted); }
.save-filter { margin: -6px 0 16px; }
textarea[readonly] { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: #fafbfc; }
code { background: #f1f3f7; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* ---------- public web form (inside customers' websites) */
.public-form { background: transparent; }
.pf-card { max-width: 520px; margin: 0 auto; padding: 18px 16px; background: #fff; }
.pf-title { font-size: 20px; margin: 0 0 12px; }
.pf-card label { margin: 12px 0 5px; }
.pf-consent { align-items: flex-start; font-weight: 400; font-size: 14px; }
.pf-consent input { margin-top: 3px; }
.pf-foot { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.kpi-value.text-danger { color: var(--red); }

/* ---------- simple bars in reports (no chart library) */
.bar-cell { width: 38%; min-width: 120px; }
.bar { display: block; height: 10px; border-radius: 999px; background: var(--blue); min-width: 2px; }
.bar-red { background: var(--red); }
.bar-soft { background: #9fd4b1; }
.bar-track { display: block; background: #eef2ef; border-radius: 999px; }

/* ---------- Baton */
.baton-motto { margin: -8px 0 18px; font-weight: 800; letter-spacing: .3px; color: var(--blue-dark); font-size: 13px; }
.baton-motto span { font-weight: 500; color: var(--muted); letter-spacing: 0; }
.section h2 .count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: #eef2ef; color: var(--muted); font-size: 12px; text-align: center; vertical-align: 2px; }
.pinned { background: var(--red-soft); border: 1px solid #f3b4b4; border-radius: var(--radius); padding: 12px 16px; }
.pinned .plain-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pinned .plain-list li .btn { margin-left: auto; }
.badge-stage { background: #eef2ff; color: #3730a3; }
.action-item.is-waiting { border-left-color: var(--amber); }
.waiting-line { margin: 2px 0 4px; }
.handed-line { color: var(--blue-dark); margin-top: 2px; }
.na-waiting { border-color: #f1d18a; background: #fffaf0; }
.waiting-buttons { align-items: flex-start; }
.inline-details { display: inline-block; position: relative; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] form { position: absolute; z-index: 5; right: 0; top: 38px; width: 260px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: 0 8px 24px rgba(20, 30, 50, .12); }
.baton-received { background: var(--green-soft); color: var(--green); padding: 8px 12px; border-radius: 8px; }
.optional-steps { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 12px; }
.optional-steps .chip-link { font: inherit; font-size: 13px; cursor: pointer; border-style: dashed; }
.stage-static { cursor: default; }
.stage-static:hover { border-color: #cfd6e0; }
.stage-hint { margin: -10px 0 16px; }

/* =====================================================================
   Phones and tablets (REQUIREMENTS #119): 360px and up, no sideways scrolling,
   tap targets at least 44px, tables become cards. Desktop is unchanged.
   ===================================================================== */
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-btn { display: none; }


/* Calls (#125): phones get the Call button (dialer); computers with a mouse get the number, Copy and a call timer. */
.call-desk { display: none; }
.phone-num { font-variant-numeric: tabular-nums; align-self: center; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
  .js .call-phone { display: none; }
  .js .call-desk { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
}
.timer-running { background: var(--brand-red); border-color: var(--brand-red); color: #fff; }
.call-prompt { background: var(--amber-soft); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; }
.call-fields .form-row { margin-top: 4px; }
.wa-menu { position: relative; display: inline-block; }
.wa-menu > summary { list-style: none; cursor: pointer; }
.wa-menu > summary::-webkit-details-marker { display: none; }
.wa-menu .menu { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; min-width: 200px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 30, 50, .12); padding: 6px; display: flex; flex-direction: column; }
.wa-menu .menu a { padding: 8px 10px; border-radius: 6px; color: var(--text, #1f2937); white-space: nowrap; }
.wa-menu .menu a:hover { background: var(--green-soft); text-decoration: none; }
.wa-fields { margin: 0 0 8px; }
.last-contact { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.last-contact svg { flex: none; }
.last-call svg { color: var(--blue-dark); }
.last-whatsapp svg { color: #1a9e4b; }
.last-email svg { color: var(--brand-red); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-danger-outline { background: #fff; color: var(--red); border-color: var(--red); }
.btn-danger-outline:hover { background: var(--red-soft); }
.connect-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.connect-buttons form, .form-actions form { margin: 0; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.copy-row input { flex: 1 1 260px; font-family: ui-monospace, Menlo, monospace; }
details.card > summary { cursor: pointer; }
.compose-from { margin-bottom: 4px; }
.ai-lab { border-left: 4px solid #7c3aed; }
.ai-lab h2 .badge { vertical-align: 2px; }
.ai-points { margin: 6px 0 4px; padding-left: 20px; }
.ai-points li { margin: 4px 0; }
.ai-out { margin-top: 10px; }
.ai-out textarea { width: 100%; }
.ai-suggest { margin: 4px 0 8px; }
.ai-research p { margin: 6px 0; }
.ai-research .story-label { margin: 10px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
.ai-sources { margin: 4px 0; padding-left: 20px; }
.ai-sources a { word-break: break-word; }
.ai-suggest-frame { display: block; width: 100%; height: 64px; border: 0; margin: 8px 0 0; }
.action-brief { flex-basis: 100%; }
.steps-bar { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0 0 16px; padding: 0; }
.steps-bar li { padding: 6px 12px; border-radius: 999px; background: #eef1f5; color: var(--muted); font-size: 13px; font-weight: 600; }
.steps-bar li.on { background: var(--blue); color: #fff; }
.steps-bar li.done { background: var(--green-soft); color: var(--blue); }
.import-issues li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.sr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 1024px), (pointer: coarse) {
  .wa-menu .menu a { min-height: 44px; display: flex; align-items: center; }
  .ai-points a, .ai-sources a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ---- Touch sizes: phones, tablets (up to 1024px) and any touch screen: every tap target at least 44×44px ---- */
@media (max-width: 1024px), (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]), select, textarea { min-height: 44px; font-size: 16px; } /* 16px stops iPhone zooming in */
  .btn, .btn-small, .stage, .chip-link, .tabs a, .usermenu summary, .pager a, summary.btn, .mainnav a { min-height: 44px; min-width: 44px; }
  .btn-small { padding: 8px 14px; font-size: 15px; }
  .chip span { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; }
  .chip-link { display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; }
  .link-button { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .tabs a { display: inline-flex; align-items: center; }
  .pager a { display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; }
  .mainnav a { display: flex; align-items: center; }
  details > summary { min-height: 44px; display: flex; align-items: center; }
  .usermenu summary { display: flex; align-items: center; }
  .usermenu .menu a { min-height: 44px; display: flex; align-items: center; }
  label.check { min-height: 44px; }
  input[type=checkbox]:not(label input) { width: 44px; height: 44px; }
  input[type=checkbox], input[type=radio] { min-width: 22px; min-height: 22px; }
  /* Links inside lists, tables and cards get a comfortable tap area */
  .plain-list a, .table td a, .timeline a, .details dd a, .page-head a:not(.btn), .section-head a, .card-head a, .card p a, .section > p > a,
  .empty a, .auth-links a, .action-sub a, .banner a, .checklist a, .tl-head a {
    display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
  }
  .action-title { display: flex; align-items: center; min-height: 44px; }
  .brand { min-height: 44px; display: inline-flex; align-items: center; }
  .admin-nav a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ---- Phone layout (up to 760px): menu button, stacking, tables become cards ---- */
@media (max-width: 760px) {
  .sidebar .brand { padding: 0; }
  .mainnav { flex-wrap: wrap; overflow: visible; }
  .js .menu-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; font: inherit; font-weight: 700;
                  color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 8px; cursor: pointer; }
  .js .mainnav { display: none; }
  .js .mainnav.open { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px 0 4px; }
  .mainnav a { white-space: normal; }
  .input-narrow { width: 100%; }
  .badge { white-space: normal; }

  /* Things that used to scroll sideways now wrap or stack */
  .tabs { flex-wrap: wrap; overflow: visible; }
  .strip { flex-wrap: wrap; overflow: visible; }
  .strip-item { flex: 1 1 100%; }
  .board { flex-direction: column; overflow: visible; }
  .board-col { flex: 1 1 auto; width: 100%; }
  .inline-details[open] form, .stage-lost[open] form { position: static; width: 100%; box-shadow: none; margin-top: 8px; }
  .wa-menu[open] { display: block; width: 100%; }
  .wa-menu .menu { position: static; min-width: 0; box-shadow: none; margin-top: 6px; }
  .wa-menu .menu a { white-space: normal; }
  .inline-details { display: block; width: 100%; }
  .table-wrap { overflow: visible; border: 0; background: transparent; }

  /* Tables become cards: one card per row, each value with its column name */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 12px; }
  table.cards td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 8px 0;
                   border-bottom: 1px solid var(--line); text-align: right; overflow-wrap: anywhere; min-width: 0; }
  table.cards td:last-child { border-bottom: 0; }
  table.cards td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); }
  table.cards td:not([data-label])::before, table.cards td[data-label=""]::before { content: none; }
  table.cards td:not([data-label]), table.cards td[data-label=""] { justify-content: flex-start; text-align: left; }
  table.cards td > input:not([type=checkbox]):not([type=radio]), table.cards td > select { flex: 1 1 55%; min-width: 0; }
  table.cards td > input[type=checkbox] { flex: 0 0 auto; }
  table.cards td > .badge { max-width: 100%; }
  table.cards tr.total { background: #fafbfc; font-weight: 700; }
  .bar-cell { width: 100%; min-width: 0; }
  .bar-cell .bar-track { flex: 1 1 55%; }
}

@media (min-width: 761px) and (max-width: 1024px) {
  .table-wrap:has(table.wide) { overflow: visible; border: 0; background: transparent; }
  /* Wide editing tables (e.g. the Baton Map) are cards on tablets too */
  table.wide.cards, table.wide.cards tbody, table.wide.cards tr, table.wide.cards td { display: block; width: 100%; }
  table.wide.cards thead { display: none; }
  table.wide.cards tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 12px; }
  table.wide.cards td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 8px 0;
                   border-bottom: 1px solid var(--line); text-align: right; overflow-wrap: anywhere; min-width: 0; }
  table.wide.cards td:last-child { border-bottom: 0; }
  table.wide.cards td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); }
  table.wide.cards td:not([data-label])::before, table.wide.cards td[data-label=""]::before { content: none; }
  table.wide.cards td:not([data-label]), table.wide.cards td[data-label=""] { justify-content: flex-start; text-align: left; }
  table.wide.cards td > input:not([type=checkbox]):not([type=radio]), table.wide.cards td > select { flex: 1 1 55%; min-width: 0; }
  table.wide.cards td > input[type=checkbox] { flex: 0 0 auto; }
  table.wide.cards td > .badge { max-width: 100%; }
  table.wide.cards tr.total { background: #fafbfc; font-weight: 700; }
}

/* Installable app: "Put NIW on your home screen" bar (home screen + login page, filled in by app.js) */
.install-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line, #e5e7eb); border-left: 4px solid var(--brand-red); border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; }
.install-bar img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.install-text { flex: 1 1 150px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.install-btns { display: flex; align-items: center; gap: 10px; }
.ios-share { display: inline-block; width: 14px; height: 16px; vertical-align: -2px; background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18' fill='none' stroke='%23157fd8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 1v10M3.5 4.5 7 1l3.5 3.5M4 7H2v10h10V7h-2'/%3E%3C/svg%3E"); }
.auth-card .install-bar { margin-top: 4px; }

/* Lead import progress (import.php) */
.import-progress { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
.import-progress[hidden] { display: none; }
.import-progress progress { flex: 1 1 12rem; max-width: 24rem; height: 1rem; accent-color: var(--blue); }

/* Categories (REQUIREMENTS #153): badge + tab dot per colour. Red stays for overdue/lost, so no red here. */
.badge.cat { border: 1px solid transparent; }
.cat-sky { background: #e0f2fe; color: #075985; }
.cat-violet { background: #f3e8ff; color: #6b21a8; }
.cat-teal { background: #ccfbf1; color: #115e59; }
.cat-orange { background: #ffedd5; color: #9a3412; }
.cat-rose { background: #fce7f3; color: #9d174d; }
.cat-slate { background: #eef1f5; color: #475569; }
.cat-tabs a { display: inline-flex; align-items: center; gap: 6px; }
.cat-tabs .count { font-weight: 500; color: var(--muted); font-size: 12px; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; }
.cat-tabs .cat-dot { background: currentColor; }
.category-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.category-form select { width: auto; min-width: 9rem; }
.deal-card .badge.cat { align-self: flex-start; }

/* Policy warnings (REQUIREMENTS #155), e.g. "Racanaa policy: no free POC" */
.flash-warn { background: var(--amber-soft); color: var(--amber); border: 1px solid currentColor; }
.policy-live { margin: 6px 0 0; font-weight: 600; }

/* Files on leads and deals (REQUIREMENTS #156) */
.file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-list li:last-child { border-bottom: 0; }
.file-list a { word-break: break-word; }
.file-upload { margin-top: 12px; }

/* Long drop-down options (e.g. "Waiting for Pre-sales/Solutions – SJ, Rijin") must not widen a table cell on phones */
td select, td input:not([type="checkbox"]):not([type="radio"]) { max-width: 100%; min-width: 0; }
select { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Invoice requests (REQUIREMENTS #157) */
.pre-line { white-space: pre-line; }
.invoice-lines td:first-child input { min-width: 12rem; }
.invoice-lines .line-amount { white-space: nowrap; text-align: right; }
.invoice-total { margin-left: 12px; }

/* Timeline: edit a note (note-edit.php) */
.timeline .tl-edit { display: inline-block; margin-top: 2px; }
@media (max-width: 1024px), (pointer: coarse) { .timeline .tl-edit { min-height: 44px; line-height: 44px; min-width: 44px; } }

/* Tracker (REQUIREMENTS #159): Excel-like grid. It scrolls sideways inside its own box, never the page. */
.sheet-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }
.sheet-tools details > summary { list-style: none; cursor: pointer; }
.sheet-tools details > summary::-webkit-details-marker { display: none; }
.sheet-tools details[open] > .card { margin-top: 8px; max-width: 560px; }
.sheet-wrap { overflow-x: auto; max-width: 100%; }
.table.sheet { font-size: 13px; }
.table.sheet th { white-space: nowrap; position: relative; }
.table.sheet td[data-cell] { cursor: text; min-width: 7rem; max-width: 22rem; position: relative; }
.table.sheet td[data-cell]:hover, td[data-cell]:focus { background: var(--blue-soft); outline: none; }
.sheet-open a { text-decoration: none; font-size: 16px; }
.cell-ro { color: var(--muted); }
.cell-missing { color: var(--red); font-weight: 600; }
.cell-saving { opacity: .6; }
.cell-saved { background: var(--green-soft) !important; transition: background .6s; }
.cell-editor { width: 100%; min-width: 8rem; font: inherit; }
.cell-msg { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--red); }
.cell-msg-warn { color: var(--amber); }
.col-menu { display: inline-block; margin-left: 4px; }
.col-menu > summary { list-style: none; cursor: pointer; padding: 0 6px; border-radius: 6px; color: var(--muted); }
.col-menu > summary::-webkit-details-marker { display: none; }
.col-menu[open] > summary { background: var(--bg); }
.col-menu-body { position: fixed; z-index: 50; top: 0; left: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12); padding: 10px; width: 16rem; white-space: normal; display: grid; gap: 8px; font-weight: 400; }
.col-menu-body input, .col-menu-body textarea { width: 100%; }
.details-table th { width: 40%; font-weight: 600; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 1024px), (pointer: coarse) {
  .col-menu > summary { display: inline-block; min-width: 44px; min-height: 44px; line-height: 44px; text-align: center; }
  .sheet-open a { display: inline-block; min-width: 44px; min-height: 44px; line-height: 44px; text-align: center; }
  .table.sheet td[data-cell] { min-height: 44px; }
  .table.sheet thead th > a { display: inline-block; min-height: 44px; min-width: 44px; line-height: 44px; }
}
