/* Laufer & Co. CRM. Brand: navy #303B5A, olive #75724F / #999573 (marketing/email/brand/BRAND_KIT.md). */
:root {
  --canvas: #EEF0F2;
  --surface: #FFFFFF;
  --ink: #303B5A;          /* brand navy: headings, primary actions, the docket band */
  --ink-soft: #46527A;
  --text: #24282C;
  --muted: #5B6166;
  --line: #D5D9DE;
  --olive: #75724F;        /* brand olive, text-safe */
  --olive-light: #C9C5A0;
  --late: #A3242B;         /* overdue reply */
  --late-bg: #F8E7E8;
  --wait: #8A5A00;         /* waiting, within the reply window */
  --wait-bg: #FBF1DC;
  --won: #1D6B4F;
  --won-bg: #E1F1EA;
  --focus: #2F6FD6;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", "David", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #14171C; --surface: #1D2128; --ink: #AEBBE3; --ink-soft: #C6D0EE; --text: #E6E8EB;
    --muted: #A2A9B1; --line: #333A44; --olive: #C9C5A0; --late: #FF8C8F; --late-bg: #3A1D20;
    --wait: #F1C46B; --wait-bg: #352A12; --won: #7DD3AE; --won-bg: #16302A; --focus: #8AB4FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #14171C; --surface: #1D2128; --ink: #AEBBE3; --ink-soft: #C6D0EE; --text: #E6E8EB;
  --muted: #A2A9B1; --line: #333A44; --olive: #C9C5A0; --late: #FF8C8F; --late-bg: #3A1D20;
  --wait: #F1C46B; --wait-bg: #352A12; --won: #7DD3AE; --won-bg: #16302A; --focus: #8AB4FF;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 16px/1.55 var(--font); }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 1.25rem; color: var(--ink); text-decoration: none; direction: ltr; white-space: nowrap; }
.brand span { color: var(--olive); }
.brand small { font-family: var(--font); font-size: .75rem; color: var(--muted); margin-inline-start: 4px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { padding: 8px 12px; border-radius: var(--radius-s); text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--canvas); }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: .9rem; }
@media (max-width: 720px) {
  .topbar-inner { gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .who { margin-inline-start: auto; }
}

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }
main:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 .95rem var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: #303B5A; border-color: #303B5A; color: #FFFFFF; }
.btn-primary:hover { background: #26304B; }
.btn-danger { color: var(--late); border-color: var(--late); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.link-btn { background: none; border: 0; color: var(--ink); font: inherit; text-decoration: underline; cursor: pointer; padding: 6px; }
label { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; }
.field { margin-bottom: 12px; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; color: var(--text); margin: 0; }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } .filters .grow { grid-column: 1 / -1; } }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; margin-bottom: 16px; }
.panel > h2 { margin-bottom: 12px; }
.empty { color: var(--muted); padding: 8px 0; }

/* ---------- alerts ---------- */
.alerts { display: grid; gap: 8px; margin-bottom: 16px; }
.alert { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 14px;
  border-radius: var(--radius-s); border-inline-start: 4px solid var(--muted); background: var(--surface); }
.alert.critical { border-color: var(--late); background: var(--late-bg); }
.alert.warning { border-color: var(--wait); background: var(--wait-bg); }
.alert p { margin: 0; }

/* ---------- the docket: who is waiting for Netanel ---------- */
.docket { background: #303B5A; color: #FFFFFF; border-radius: var(--radius-m); padding: 20px 20px 8px; margin-bottom: 20px; }
.docket-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.docket-count { font-family: var(--serif); font-size: 3.25rem; line-height: 1; font-variant-numeric: tabular-nums; }
.docket-head h1 { color: #FFFFFF; font-size: 1.35rem; }
.docket-head .sub { color: #C9C5A0; font-size: .95rem; }
.docket ol { list-style: none; margin: 0; padding: 0; }
.docket li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid rgba(255,255,255,.16);
  color: #FFFFFF; text-decoration: none; }
.docket li a:hover .d-name { text-decoration: underline; }
.d-name { font-weight: 600; }
.d-wait { font-variant-numeric: tabular-nums; color: #C9C5A0; text-align: end; white-space: nowrap; }
.d-wait.late { color: #FFB3B6; font-weight: 600; }
.d-meta { color: rgba(255,255,255,.72); font-size: .875rem; grid-column: 1 / -1; }
.docket .all { display: inline-block; color: #FFFFFF; padding: 12px 0; }
.docket .calm { color: #C9C5A0; padding-bottom: 12px; }

/* ---------- funnel ---------- */
.funnel { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.funnel li { position: relative; padding: 4px 12px 4px 0; border-inline-start: 1px solid var(--line); }
.funnel li:first-child { border-inline-start: 0; padding-inline-start: 0; }
.funnel li { padding-inline-start: 14px; }
.f-value { display: block; font-size: 1.9rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; }
.f-label { display: block; color: var(--text); font-weight: 600; font-size: .9rem; }
.f-rate { display: block; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .funnel { grid-template-columns: repeat(3, 1fr); row-gap: 16px; }
  .funnel li:nth-child(4) { border-inline-start: 0; padding-inline-start: 0; }
}
@media (max-width: 480px) {
  .funnel { grid-template-columns: repeat(2, 1fr); }
  .funnel li:nth-child(4) { border-inline-start: 1px solid var(--line); padding-inline-start: 14px; }
  .funnel li:nth-child(odd) { border-inline-start: 0; padding-inline-start: 0; }
}
.footnote { color: var(--muted); font-size: .8rem; margin: 14px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--ink-soft); }
.kpi b { display: block; font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .875rem; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.spark { width: 100%; height: 80px; display: block; }
.spark rect.c { fill: var(--olive-light); }
.spark rect.m { fill: var(--ink); }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i.sw-c { background: var(--olive-light); }
.legend i.sw-m { background: var(--ink); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 6px; vertical-align: -1px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
td:first-child { min-width: 150px; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

/* ---------- lead list ---------- */
.lead-list { list-style: none; margin: 0; padding: 0; }
.lead-list li a { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 4px; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none; }
.lead-list li:last-child a { border-bottom: 0; }
.lead-list li a:hover .l-name { text-decoration: underline; }
.l-name { font-weight: 600; color: var(--ink); }
.l-meta { color: var(--muted); font-size: .875rem; grid-column: 1 / -1; }
.l-side { text-align: end; font-size: .875rem; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--canvas); color: var(--text); white-space: nowrap; }
.pill.wait { background: var(--wait-bg); color: var(--wait); }
.pill.late { background: var(--late-bg); color: var(--late); }
.pill.won { background: var(--won-bg); color: var(--won); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

/* ---------- lead page ---------- */
.lead-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .lead-grid { grid-template-columns: 1fr; } }
.lead-head { margin-bottom: 16px; }
.lead-head .contact { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--canvas); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; text-align: start; border-start-start-radius: 3px; }
.msg.out { align-self: flex-end; background: #DCE3F4; color: #1F2840; border-start-end-radius: 3px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg.out { background: #2C3756; color: #E6E8EB; } }
.msg time, .ev time { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.msg.out time { color: inherit; opacity: .75; }
/* Email messages: same bubble; a side rule marks the channel (the time line also says it). */
.msg.email { border-inline-start: 3px solid var(--muted); }
.msg .rest { margin-top: .5rem; color: var(--muted); font-size: .85rem; white-space: pre-wrap; }
.msg .rest summary { cursor: pointer; }
.ev { align-self: center; text-align: center; font-size: .8rem; color: var(--muted); padding: 2px 8px; }
.ev.bot { text-decoration: line-through; }
.note { border-bottom: 1px solid var(--line); padding: 10px 0; white-space: pre-wrap; }
.note:last-child { border-bottom: 0; }
.fu { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.fu.done { color: var(--muted); text-decoration: line-through; }
.warn-box { background: var(--wait-bg); color: var(--text); border-radius: var(--radius-s); padding: 10px 12px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 12vh auto 0; }
.btn-block { width: 100%; }
.login .brand { display: block; font-size: 1.8rem; margin-bottom: 24px; text-align: center; }
.error { color: var(--late); margin-top: 8px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 16px; inset-inline: 16px; margin: 0 auto; max-width: 420px; background: #303B5A; color: #fff;
  padding: 12px 16px; border-radius: var(--radius-s); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- tracked-link interstitial (/w/<token>) ---------- */
.go-page { display: grid; place-items: center; min-height: 100vh; direction: ltr; text-align: center; }
.go-card { padding: 24px; }
.go-title { font-family: var(--serif); font-size: 1.4rem; color: var(--ink); }
