/* VRB CRM — cool paper, deep ink, one teal signal reserved for replies and Active clients. */
:root {
  --paper: #F3F5F7;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #5B6675;
  --line: #D8DEE5;
  --line-soft: #E8ECF0;
  --signal: #0F7B6C;
  --signal-soft: #E3F2EF;
  --warn: #9A6212;
  --warn-soft: #FBF1E0;
  --bad: #B03A2E;
  --bad-soft: #FBE9E7;
  --live: #2D5BA8;
  --live-soft: #E7EEF9;
  --radius: 8px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--signal); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2, .h2like { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
code, pre.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre.code { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }

/* Shell */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--ink) 216px, transparent 216px); }
.side { background: var(--ink); color: #C9D2DD; display: flex; flex-direction: column; padding: 20px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; padding: 0 10px 20px; }
.mark { width: 18px; height: 18px; border-radius: 4px; background: linear-gradient(135deg, var(--signal) 0 50%, #fff 50% 100%); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; justify-content: space-between; align-items: center; color: #C9D2DD; text-decoration: none; padding: 8px 10px; border-radius: 6px; font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }
.count { background: var(--signal); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 10px; font-size: 13px; }
.side-foot a { color: #9AA6B4; }
.main-wrap { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 22px 32px 16px; flex-wrap: wrap; }
.top h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.menu-btn { display: none; }
main { padding: 0 32px 48px; max-width: 1400px; }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; gap: 6px; font: 600 13.5px/1 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #AEB8C4; color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2B3747; }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--line); }
.btn.danger { color: var(--bad); border-color: #E7C2BD; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: default; }
.link { color: var(--muted); font-size: 13px; }
.danger-text { color: var(--bad) !important; }
form.inline { display: inline; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .filters label, .inline-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  font: 400 14px/1.4 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; color: var(--ink) !important; font-size: 13.5px !important; }
label.check.inline, label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--signal); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.inline-form.wrap { flex-wrap: wrap; margin: 0; }
.grow { flex: 1; min-width: 200px; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.drop { border: 1.5px dashed #AEB8C4; border-radius: var(--radius); padding: 22px; background: var(--paper); }
details > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
details[open] > summary { margin-bottom: 10px; }
summary.h2like { color: var(--ink); font-size: 15px; }

/* Flash */
.flash { border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--signal-soft); border-color: #B9DDD5; color: #0B5B50; }
.flash.err { background: var(--bad-soft); border-color: #EBC4BF; color: #8A2C22; }
.flash.warn { background: var(--warn-soft); border-color: #EBD3AA; color: #6E470E; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel.narrow { max-width: 640px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head a { font-size: 13px; color: var(--muted); }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.cols > .panel { margin-bottom: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.empty { color: var(--muted); text-align: center; padding: 22px 12px !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.good-text { color: var(--signal); font-weight: 600; }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); font-weight: 600; }
.err-text { color: var(--bad); font-size: 12.5px; margin-top: 3px; }

/* Funnel — the dashboard's signature element */
.funnel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px 18px; margin-bottom: 18px; }
.f-row { display: grid; grid-template-columns: 190px 1fr 90px 150px; align-items: center; gap: 16px; padding: 7px 0; }
.f-label { font-weight: 600; }
.f-track { height: 22px; background: var(--paper); border-radius: 4px; overflow: hidden; }
.f-bar { height: 100%; background: #9AA6B4; border-radius: 4px; }
.f-row:first-child .f-bar { background: var(--ink); }
.f-key .f-bar { background: var(--signal); }
.f-key .f-label, .f-key .f-num { color: var(--signal); }
.f-num { font-size: 18px; font-weight: 700; text-align: right; }
.f-rate { color: var(--muted); font-size: 12.5px; }

dl.kv { margin: 0; display: grid; gap: 0; }
dl.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; }
dl.kv small { color: var(--muted); font-weight: 400; }
.spark { width: 100%; height: auto; display: block; }
.spark .b-sent { fill: #C5CDD7; }
.spark .b-reply { fill: var(--signal); }
.spark .axis { stroke: var(--line); }
.spark text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.legend { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 6px 0 0; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.sw.sent { background: #C5CDD7; margin-left: 0; } .sw.reply { background: var(--signal); }
.meter { height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--ink); border-radius: 2px; }

/* Tables */
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAFBFC; white-space: nowrap; }
.tbl th a { color: var(--muted); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FAFBFC; }
.tbl .num { text-align: right; }
.tbl .chk { width: 36px; }
.tbl.compact td, .tbl.compact th { padding: 7px 8px; }
.panel .tbl th { background: transparent; }
.tbl td.actions { text-align: right; }
.tbl.map td { vertical-align: middle; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); white-space: nowrap; }
.stage-active-client, .stage-won { background: var(--signal-soft); border-color: #B9DDD5; color: #0B5B50; }
.stage-proposal-sent { background: var(--live-soft); border-color: #C3D3EE; color: #1F4380; }
.stage-lost, .stage-do-not-contact { color: var(--muted); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.pill.live { background: var(--live-soft); color: #1F4380; }
.pill.good { background: var(--signal-soft); color: #0B5B50; }
.pill.warn { background: var(--warn-soft); color: #6E470E; }
.pill.bad { background: var(--bad-soft); color: #8A2C22; }
.pill.muted { background: var(--line-soft); color: var(--muted); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.tag { font-size: 11.5px; background: var(--paper); border-radius: 3px; padding: 0 6px; color: var(--muted); }

/* Filters and bulk */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input { width: auto; }
.filters .grow input { width: 100%; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--ink); color: #fff; border-radius: var(--radius); margin-bottom: 10px; }
.bulkbar[hidden] { display: none; }
.bulkbar select, .bulkbar input { width: auto; }
.bulkbar label.check { color: #fff !important; }
.bulkbar .btn.primary { background: var(--signal); border-color: var(--signal); }
.list-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; gap: 12px; align-items: center; font-size: 13px; }

/* Detail layout */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.head-panel { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.head-panel .inline-form { margin: 0; }
.who { color: var(--muted); margin-bottom: 6px; overflow-wrap: anywhere; }
.enr { padding: 10px 0; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 4px; }
.side-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.danger-zone { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.custom .grid2 { margin-bottom: 6px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 2px 0 14px 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid #AEB8C4; }
.timeline li.in.kind-reply::before, .timeline li.in.kind-unsubscribe::before { background: var(--signal); border-color: var(--signal); }
.timeline li.in.kind-bounce::before { border-color: var(--bad); }
.timeline li.in.kind-reply .tl-body { background: var(--signal-soft); }
.tl-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.tl-meta time { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.tl-subj { font-weight: 500; margin: 2px 0 4px; }
.tl-body { background: var(--paper); border-radius: 6px; padding: 10px 12px; font-size: 13.5px; overflow-wrap: anywhere; }
.tl-act .tl-body { background: transparent; padding: 0; color: var(--muted); }
.tl-act.type-note .tl-body { color: var(--ink); background: var(--warn-soft); padding: 8px 12px; }

/* Sequence editor */
.statline { display: flex; gap: 28px; align-items: baseline; flex-wrap: wrap; margin: 0 0 18px; }
.statline div { color: var(--muted); font-size: 13px; }
.statline span { display: block; font-size: 22px; font-weight: 700; color: var(--ink); }
.statline .good span { color: var(--signal); }
.step-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.step-head h2 { margin: 0; }
.step-tools { margin-left: auto; display: flex; gap: 2px; }
input.days { width: 64px !important; padding: 5px 8px !important; }
.preview { margin-top: 4px; }
.mail-preview { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.mp-subj { font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); background: #FAFBFC; }
.mp-body { padding: 12px; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 500 12px/1 ui-monospace, Menlo, monospace; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; cursor: pointer; color: var(--ink); }
.chip.copied { background: var(--signal-soft); border-color: var(--signal); }

/* Pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { background: #E9EDF1; border-radius: var(--radius); padding: 10px; min-height: 320px; display: flex; flex-direction: column; }
.col header { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 10px; }
.col h2 { font-size: 13.5px; margin: 0; }
.col .n { font-weight: 700; color: var(--muted); }
.col.stage-active-client { background: var(--signal-soft); box-shadow: inset 0 3px 0 var(--signal); }
.col.stage-active-client h2 { color: #0B5B50; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 60px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; display: flex; flex-direction: column; gap: 2px; cursor: grab; }
.card a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.card.dragging { opacity: .5; }
.cards.over { outline: 2px dashed var(--signal); outline-offset: 2px; border-radius: 6px; }
.more { font-size: 12.5px; color: var(--muted); padding: 8px 4px 0; }

/* Replies */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--signal); }
.inbox, .reply-list { list-style: none; margin: 0; padding: 0; }
.inbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.inbox li { border-bottom: 1px solid var(--line-soft); }
.inbox li:last-child { border-bottom: 0; }
.inbox a { display: block; padding: 12px 16px; text-decoration: none; color: var(--ink); }
.inbox a:hover { background: #FAFBFC; }
.inbox li.unread { box-shadow: inset 3px 0 0 var(--signal); }
.inbox li.unread strong { color: var(--signal); }
.ib-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.ib-top time { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.ib-subj { font-weight: 500; margin-top: 2px; }
.ib-snip { color: var(--muted); font-size: 13.5px; margin: 2px 0; }
.reply-list li { display: flex; gap: 10px; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.reply-list li:last-child { border-bottom: 0; }
.reply-list a { text-decoration: none; min-width: 0; }
.reply-list .snip { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-list li.unread strong { color: var(--signal); }
.reply-list time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* Auth pages */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: 100%; max-width: 380px; }
.auth-card.wide { max-width: 640px; }
.auth-card .brand { color: var(--ink); padding: 0 0 18px; }
.auth-card h1 { margin-bottom: 16px; }

/* Responsive */
@media (max-width: 1100px) {
  .detail { grid-template-columns: 1fr; }
  .f-row { grid-template-columns: 130px 1fr 70px; }
  .f-rate { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .2s ease; z-index: 40; }
  body.nav-open .side { transform: none; }
  .menu-btn { display: inline-flex; font: 600 13px var(--font); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
  .top { padding: 14px 16px 12px; }
  main { padding: 0 16px 40px; }
  .cols, .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .top { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .top h1 { font-size: 19px; }
  .top-actions { grid-column: 1 / -1; }
  .tbl-wrap { -webkit-overflow-scrolling: touch; }
  .span2 { grid-column: auto; }
  .f-row { grid-template-columns: 1fr 64px; gap: 4px 12px; }
  .f-track { grid-column: 1 / -1; grid-row: 2; }
  .panel { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* v1.1: reply sorting, approvals, domain health */
nav.chips { margin: 0 0 14px; }
nav.chips .chip { font: 500 13px/1 var(--font); padding: 7px 10px; text-decoration: none; }
nav.chips .chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
nav.chips .chip.on .muted { color: #C9D1DA; }
.badge.intent-interested { background: var(--signal-soft); border-color: #B9DDD5; color: #0B5B50; }
.badge.intent-question, .badge.intent-referral { background: var(--live-soft); border-color: #C3D3EE; color: #1F4380; }
.badge.intent-not_now { background: var(--warn-soft); border-color: #EBD3A8; color: var(--warn); }
.badge.intent-not_interested, .badge.intent-other { color: var(--muted); }
.ib-top .badge + .badge { margin-left: 4px; }
.health { list-style: none; margin: 0; padding: 0; }
.health li { display: grid; grid-template-columns: 22px 170px 1fr; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line-soft); align-items: baseline; }
.health li:first-child { border-top: 0; }
.health .ok { color: var(--signal); font-weight: 700; }
.health .no { color: var(--bad); font-weight: 700; }
.health .unk { color: var(--warn); font-weight: 700; }
.health .det { word-break: break-word; color: var(--muted); font-size: 13px; }
.preview-mail { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 6px; padding: 10px 12px; font-size: 13px; margin: 6px 0 0; max-height: 240px; overflow: auto; }
@media (max-width: 640px) { .health li { grid-template-columns: 22px 1fr; } .health .det { grid-column: 2; } }
