:root {
  --navy: #0B2B54;
  --navy-deep: #071F3D;
  --navy-muted: #3A4F6A;
  --gold: #D49B2A;
  --gold-hover: #C08A1F;
  --gold-soft: #F3E6C8;
  --off-white: #F7F4EE;
  --white: #ffffff;
  --border: #E4DED3;
  --text: #3A4F6A;
  --heading: #0B2B54;
  --ok: #1F7A4D;
  --ok-soft: #E7F5EE;
  --danger: #8C2F2F;
  --danger-soft: #F8E8E8;
  --shadow: 0 8px 28px rgba(11, 43, 84, 0.08);
  --sidebar: 252px;
  --font: "Lato", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--off-white);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--navy); }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  width: auto;
  height: auto;
  margin: 0;
  clip: auto;
  background: var(--navy);
  color: white;
  padding: 0.6rem 0.8rem;
}

.shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--navy);
  color: rgba(255,255,255,0.86);
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow: hidden;
}
.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 1rem 0.75rem;
  text-decoration: none;
  color: white;
}
.brand-mark {
  background: white;
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
  width: 92px;
  flex: none;
}
.brand-mark img { height: 36px; width: auto; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; letter-spacing: 0.01em; }
.brand-text em { font-style: normal; color: var(--gold-soft); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.sidenav { overflow: auto; padding: 0.25rem 0.65rem 1.5rem; }
.nav-label {
  margin: 0.9rem 0.55rem 0.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}
.sidenav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: rgba(255,255,255,0.86);
  text-decoration: none;
  padding: 0.42rem 0.6rem;
  border-radius: 8px;
  font-size: 0.94rem;
  border-left: 3px solid transparent;
}
.sidenav a:hover { background: rgba(255,255,255,0.06); color: white; }
.sidenav a.is-active {
  background: rgba(255,255,255,0.08);
  color: white;
  border-left-color: var(--gold);
}
.ico { width: 18px; height: 18px; flex: none; }
.soon {
  margin-left: auto;
  font-style: normal;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy-deep);
  background: var(--gold-soft);
  border-radius: 99px;
  padding: 0.1rem 0.4rem;
}
.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  background: rgba(247,244,238,0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 15;
}
.topbar-title { min-width: 0; }
.topbar h1 { margin: 0; color: var(--heading); font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.topbar-title p { margin: 0.1rem 0 0; font-size: 0.88rem; color: var(--navy-muted); }
.userchip { margin-left: auto; display: flex; align-items: center; gap: 0.55rem; }
.userchip a { font-weight: 700; text-decoration: none; }
.userchip .role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--gold-soft);
  color: var(--navy-deep);
  border-radius: 99px;
  padding: 0.15rem 0.45rem;
}
.userchip form { margin: 0; }
.userchip button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  color: var(--navy);
}
.userchip button:hover { border-color: var(--gold); }
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--navy);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  position: relative;
}
.nav-toggle-bars::before, .nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.nav-backdrop { display: none; }
.content { padding: 1.1rem 1.25rem 2.5rem; }

.flash { padding: 0.7rem 0.9rem; border-radius: 10px; margin-bottom: 0.8rem; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

.toolbar, .filters, .range-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filters, .range-bar {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
}
.filters input, .filters select, .range-custom input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--navy);
  min-height: 44px;
}
.field textarea { min-height: 6rem; width: 100%; resize: vertical; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select { width: 100%; }
.filters input[type="search"], .filters input[type="text"] { min-width: min(100%, 220px); }
.range-custom { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-left: auto; }
.range-custom input { min-height: 40px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  color: var(--navy-deep);
  background: transparent;
}
.btn-primary { background: var(--gold); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn-ghost { background: white; border-color: var(--border); color: var(--navy); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger { background: white; border-color: #e4c2c2; color: var(--danger); }
.btn-small { min-height: 36px; padding: 0.3rem 0.65rem; font-size: 0.88rem; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  text-decoration: none;
  color: var(--navy);
  background: var(--off-white);
  font-weight: 700;
  font-size: 0.9rem;
}
.pill.is-on { background: var(--navy); color: white; }

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.kpi {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem 0.75rem;
  box-shadow: var(--shadow);
}
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.4rem; }
.kpi .ico-wrap {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--navy);
}
.kpi:nth-child(2) .ico-wrap, .kpi:nth-child(6) .ico-wrap { background: #E7EEF6; }
.kpi:nth-child(4) .ico-wrap { background: var(--ok-soft); color: var(--ok); }
.kpi strong { display: block; color: var(--heading); font-size: 1.35rem; letter-spacing: -0.02em; margin-top: 0.35rem; }
.kpi span.label { color: var(--navy-muted); font-size: 0.82rem; }
.kpi .delta { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--navy-muted); }

.inquiry-strip {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
}
.inquiry-strip strong { color: var(--heading); }

.grid-2 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.grid-2.even { grid-template-columns: 1.4fr 1fr; }
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
}
.card h2, .card h3 { margin: 0 0 0.7rem; color: var(--heading); font-size: 1.05rem; }
.chart-wrap { position: relative; height: 280px; }
.chart-empty {
  position: absolute;
  inset: 38% 10% auto;
  text-align: center;
  color: var(--navy-muted);
  font-size: 0.92rem;
  pointer-events: none;
}
.spend-list { display: flex; flex-direction: column; gap: 0.7rem; }
.spend-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 0.2rem 0.6rem; align-items: center; }
.spend-row b { color: var(--heading); font-weight: 700; }
.spend-row .amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--heading); }
.bar { height: 8px; background: var(--off-white); border-radius: 99px; grid-column: 1 / -1; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy-muted); padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:hover td { background: #fbfaf7; }
.table a { font-weight: 700; text-decoration: none; }
.table a:hover { color: var(--gold-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--navy-muted); }
.empty-state, .empty-inline { color: var(--navy-muted); }
.empty-state { text-align: center; padding: 1.5rem 1rem; }
.empty-state h2 { margin-bottom: 0.35rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 0.12rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: #E7EEF6;
  color: var(--navy);
  white-space: nowrap;
}
.tone-won, .tone-paid, .tone-complete, .tone-active { background: var(--ok-soft); color: var(--ok); }
.tone-lost, .tone-void, .tone-inactive { background: #EEEAE4; color: #6d655c; }
.tone-proposal, .tone-proposal_sent, .tone-negotiation, .tone-overdue { background: var(--gold-soft); color: #7a5a10; }
.tone-call_booked, .tone-sent { background: #E5F3F6; color: #1F6F8B; }
.tone-task { background: var(--gold-soft); color: #7a5a10; }
.tone-note { background: #E7EEF6; color: var(--navy); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.field { display: flex; flex-direction: column; gap: 0.28rem; }
.field.span-2, .span-2 { grid-column: 1 / -1; }
.field span { font-weight: 700; color: var(--heading); font-size: 0.9rem; }
.hint { color: var(--navy-muted); font-size: 0.8rem; }
.checks { display: flex; flex-direction: column; gap: 0.45rem; }
.checks label {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  line-height: 1.3;
}
.field input[type="checkbox"],
.field input[type="radio"],
.checks input[type="checkbox"],
.checks input[type="radio"] {
  width: auto;
  min-width: 1.15rem;
  min-height: 0;
  height: 1.15rem;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--navy);
  padding: 0;
}
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.stack-form { display: flex; flex-direction: column; gap: 0.6rem; }
.split-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.inline-form { display: inline; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.timeline li { border-left: 3px solid var(--border); padding: 0.15rem 0 0.15rem 0.8rem; }
.timeline li.is-overdue { border-left-color: var(--danger); }
.timeline-top { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; }
.timeline p { margin: 0.3rem 0; }
.task-meta { font-size: 0.88rem; }

.board { display: flex; gap: 0.7rem; overflow-x: auto; padding-bottom: 0.6rem; align-items: flex-start; }
.board-col {
  flex: 0 0 250px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
}
.board-col h2 { margin: 0 0 0.6rem; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy-muted); display: flex; justify-content: space-between; }
.board-card {
  background: var(--off-white);
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.55rem;
}
.board-card a { text-decoration: none; color: var(--heading); }
.board-card p { margin: 0.25rem 0; font-size: 0.88rem; }
.board-card select { width: 100%; min-height: 36px; margin-top: 0.35rem; border-radius: 8px; border: 1px solid var(--border); background: white; }

.pager { display: flex; gap: 0.8rem; align-items: center; margin-top: 0.8rem; }
.pager a { font-weight: 700; }

.coming-banner {
  background: var(--gold-soft);
  color: var(--navy-deep);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.8rem;
  font-weight: 700;
}
.stat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.6rem; }
.stat-list div { background: var(--off-white); border-radius: 10px; padding: 0.7rem 0.8rem; }
.stat-list strong { display: block; color: var(--heading); font-size: 1.25rem; }

.guest { background: linear-gradient(180deg, var(--navy) 0 180px, var(--off-white) 180px); }
.guest-main { max-width: 460px; margin: 0 auto; padding: 2.2rem 1rem 3rem; }
.guest-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.3rem 1.2rem 1.4rem;
  border: 1px solid var(--border);
}
.guest-logo { width: 180px; margin: 0 auto 0.6rem; }
.guest-card h1 { margin: 0.2rem 0 0.2rem; text-align: center; color: var(--heading); font-size: 1.45rem; }
.guest-card .lede { text-align: center; margin: 0 0 1rem; }
.guest-card .field { margin-bottom: 0.75rem; }
.guest-card .btn { width: 100%; }
.hp { position: absolute; left: -9999px; height: 0; width: 0; opacity: 0; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .grid-2.even, .split-forms, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { transform: translateX(-105%); transition: transform 0.2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(7, 31, 61, 0.45); z-index: 25; }
  .main { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .userchip .role { display: none; }
  .content { padding: 0.9rem 0.8rem 2rem; }
  .topbar { padding: 0.7rem 0.8rem; }
  .range-custom { margin-left: 0; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
}
.callout { border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 0.8rem; }
.callout-draft { background: #EEEAE4; color: var(--navy); }
.callout-ok { background: var(--ok-soft); color: var(--ok); }
.callout p { margin: 0.25rem 0 0; }
.stack-top { margin-top: 0.8rem; }
.step-card { margin-bottom: 0.75rem; }
.merge-preview { margin-top: 0.8rem; }
.preview-box {
  white-space: pre-wrap;
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  margin: 0.35rem 0 0;
  font: inherit;
  color: var(--navy);
}
.preview-subject { font-weight: 700; color: var(--heading); margin: 0.2rem 0; }
.char-count { margin: 0.35rem 0 0; color: var(--navy-muted); font-size: 0.85rem; }
.char-count.is-over { color: #8C2F2F; font-weight: 700; }
.fallback-block { margin-top: 0.8rem; }
.check-line { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.7rem; font-weight: 700; }
.today-stats { margin-bottom: 0.9rem; }
.tone-replied, .tone-queued { background: #E5F3F6; color: #1F6F8B; }
.tone-draft, .tone-skipped, .tone-stopped, .tone-inactive { background: #EEEAE4; color: #6d655c; }
.tone-approved, .tone-completed { background: var(--ok-soft); color: var(--ok); }
.tone-paused { background: var(--gold-soft); color: #7a5a10; }
.tone-failed { background: #FDECEC; color: #8C2F2F; }
.tone-digest { background: #E7EEF6; color: var(--navy); }

.copy-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.copy-row input { flex: 1 1 16rem; min-width: 0; }
.window-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 0.4rem 0.6rem; align-items: center; }
.window-grid input { min-height: 40px; }
.feed-list { list-style: none; padding: 0; margin: 0.4rem 0; }
.feed-list li { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.call-list { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.call-list li { margin: 0.25rem 0; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; }
.week-day { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 0.45rem; min-height: 7rem; }
.week-day h3 { margin: 0 0 0.35rem; font-size: 0.82rem; }
.week-day a { display: block; font-size: 0.82rem; margin-top: 0.25rem; }
.tone-scheduled { background: #E7EEF6; color: var(--navy); }
.tone-no_show, .tone-cancelled { background: #FDECEC; color: #8C2F2F; }
@media (max-width: 800px) {
  .week-grid { grid-template-columns: 1fr; }
  .window-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Sortable lead columns */
.table th a.sort-link { color: inherit; font-weight: 700; text-decoration: none; }
.table th a.sort-link:hover, .table th a.sort-link.is-sorted { color: var(--navy); }
.table th .sort-arrow { font-size: 0.7rem; }

/* Clickable lead rows + nameless-lead fallback */
.table tr.row-link { cursor: pointer; }
.table tr.row-link:hover td { background: var(--gold-soft); }
.table a.lead-fallback { font-style: italic; font-weight: 400; color: var(--navy-muted); }
.table a.lead-fallback:hover { color: var(--gold-hover); }

/* Lead page Prev / Next (big tap targets for phone use) */
.lead-nav { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.lead-nav-steps { display: flex; gap: 0.5rem; align-items: center; }
.lead-nav .btn { min-height: 48px; min-width: 48px; }
.lead-nav-btn { min-width: 6.5rem; font-size: 1rem; }
.lead-nav-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.lead-nav-btn[disabled]:hover { border-color: var(--border); }
.lead-nav-pos { min-width: 5.5rem; text-align: center; font-weight: 700; color: var(--navy); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 800px) {
  .lead-nav { flex-direction: column-reverse; align-items: stretch; }
  .lead-nav-steps { width: 100%; }
  .lead-nav .lead-nav-btn { flex: 1 1 0; min-height: 52px; font-size: 1.05rem; }
  .lead-nav-back { width: 100%; }
}
