:root {
  --bg: #0f1115; --panel: #181b22; --panel2: #1f232c; --line: #2a2f3a;
  --text: #e6e9ef; --muted: #8b93a3; --accent: #6ea8fe; --accent2: #3b82f6;
  --good: #4ade80; --warn: #fbbf24; --bad: #f87171; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.muted { color: var(--muted); }
.grow { flex: 1; }

header {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { display: block; flex: none; border-radius: 8px; filter: drop-shadow(0 1px 3px rgba(60,90,200,.35)); }
.tagline { color: var(--muted); font-size: 12px; }
.health { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.health .ok { color: var(--good); } .health .no { color: var(--bad); }

nav#tabs { display: flex; gap: 8px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
nav#tabs .navgroup { display: flex; align-items: flex-end; gap: 0; position: relative; }
nav#tabs .navgroup + .navgroup { padding-left: 8px; border-left: 1px solid var(--line); }
nav#tabs .navlabel {
  position: absolute; top: -2px; left: 11px; font-size: 9px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted); opacity: .75;
  pointer-events: none; white-space: nowrap;
}
nav#tabs button {
  background: none; border: none; color: var(--muted); padding: 13px 10px 9px;
  border-radius: 8px 8px 0 0; cursor: pointer; font-size: 13px; font-weight: 600;
}
nav#tabs button:hover { color: var(--text); }
nav#tabs button.active { color: var(--text); background: var(--bg); box-shadow: inset 0 -2px 0 var(--accent); }

main { flex: 1; padding: 18px 20px; overflow: auto; }
.tab { display: none; } .tab.active { display: block; }

button { font-family: inherit; }
.primary { background: var(--accent2); color: white; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.primary:hover { background: var(--accent); }
.primary:disabled { opacity: .5; cursor: default; }
.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.ghost:hover { border-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); padding: 5px 11px; border-radius: 20px; cursor: pointer; font-size: 12px; }
.filters button.active { background: var(--accent2); border-color: var(--accent2); color: white; }
.filters .count { opacity: .7; margin-left: 5px; }

.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }

.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li { padding: 11px 13px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: none; }
.list li:hover { background: var(--panel2); }
.list li.sel { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.list .co { font-weight: 600; }
.list .sub { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; margin-top: 2px; flex-wrap: wrap; }

.pill { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line); }
.src-badge { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
  padding: 1px 6px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.drafted { color: var(--accent); border-color: var(--accent); }
.pill.approved { color: var(--good); border-color: var(--good); }
.pill.sent { color: #c4b5fd; border-color: #c4b5fd; }
.pill.skipped { color: var(--muted); }
.pill.replied { color: var(--warn); border-color: var(--warn); }
.pill.high { color: var(--good); } .pill.medium { color: var(--warn); } .pill.low { color: var(--bad); }
.pill.loom { color: #f0abfc; border-color: #f0abfc; }

.detail { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 340px; background: var(--panel); }
.detail .empty { color: var(--muted); text-align: center; padding: 80px 0; }
.detail h2 { display: flex; align-items: center; gap: 8px; }
.detail .meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.detail .findings { margin: 10px 0; padding-left: 18px; } .detail .findings li { margin: 3px 0; }
.detail label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; }
.detail input[type=text], .detail textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit; resize: vertical;
}
.detail textarea { min-height: 190px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.detail .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.notes { background: #2a2410; border: 1px solid #4a3f18; color: #f2e6b8; padding: 9px 12px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; margin-top: 10px; }
.notes.lead { background: #0f2a1a; border-color: #1e5b39; color: #b8f2d0; }
.notes.fit { background: #101c2e; border-color: #2a4a7a; color: #b8d4f2; }
.sitelink { color: inherit; text-decoration: underline dotted; text-underline-offset: 2px; }
.sitelink:hover { color: #4f8cff; text-decoration-style: solid; }
.shots { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.shots a { display: inline-block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.shots img { max-height: 150px; display: block; }
.sitetext { max-height: 160px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; color: var(--muted); white-space: pre-wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; max-width: 900px; }
.card input[type=file] { display: block; margin: 10px 0; }
.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.log { background: #0a0c10; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 340px; overflow: auto; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #cbd5e1; }

.mailboxes { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.mbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 150px; }
.mbox .addr { font-weight: 600; } .mbox .cap { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--panel2); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent2); }

.pipeline { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; min-width: 92px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 12px; text-transform: capitalize; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* model selector + search */
.modelsel { font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
select { background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12px; }
.search { background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font: inherit; min-width: 240px; }

/* leads table */
.tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
#leadsTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#leadsTable th { position: sticky; top: 0; background: var(--panel2); cursor: pointer; white-space: nowrap; }
#leadsTable td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
#leadsTable tbody tr { cursor: pointer; }
#leadsTable tbody tr:hover { background: var(--panel2); }
.score-chip { display: inline-block; min-width: 22px; text-align: center; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.score-chip.high { background: #0f2a1a; color: var(--good); }
.score-chip.medium { background: #2a2410; color: var(--warn); }
.score-chip.low { background: #2a1416; color: var(--bad); }
.dupe-flag { color: var(--warn); font-size: 11px; margin-left: 4px; cursor: help; }
.ps { font-weight: 700; } .ps.bad { color: var(--bad); } .ps.mid { color: var(--warn); } .ps.ok { color: var(--good); }

/* setup banner */
.setup-banner { background: #2a2410; border-bottom: 1px solid #4a3f18; color: #f2e6b8;
  padding: 10px 20px; font-size: 13px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.setup-banner[hidden] { display: none; }   /* display:flex would defeat the hidden attribute */
.setup-banner b { color: #fff; }
.setup-banner .item { display: inline-flex; gap: 6px; align-items: center; }
.setup-banner .ok { color: var(--good); } .setup-banner .no { color: var(--warn); }

/* kanban board */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 230px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.col.won { border-color: #1e5b39; } .col.lost { border-color: #5b1e2a; }
.col-head { padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; text-transform: capitalize; }
.col-head .n { color: var(--muted); font-weight: 400; font-size: 12px; }
.col-body { padding: 8px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.col.drag-over .col-body { background: var(--panel2); outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 8px; }
.dcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: grab; }
.dcard:hover { border-color: var(--accent); }
.dcard:active { cursor: grabbing; }
.dcard .co { font-weight: 600; font-size: 13px; }
.dcard .em { color: var(--muted); font-size: 11px; margin: 2px 0 6px; }
.dcard .act { color: #b8f2d0; font-size: 11px; }
.col-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 4px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  width: 100%; max-width: 620px; max-height: 88vh; overflow: auto; padding: 20px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.stage-picker { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 4px; }
.stage-picker button { background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  padding: 5px 10px; border-radius: 20px; cursor: pointer; font-size: 12px; text-transform: capitalize; }
.stage-picker button.on { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 4px 0 8px 12px; position: relative; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); }
.timeline .k { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .04em; }
.timeline .t { color: var(--muted); font-size: 10px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(60px);
  background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px;
  opacity: 0; transition: all .25s; pointer-events: none; z-index: 60; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { border-color: var(--bad); color: var(--bad); }

/* generic state colors (header/banner keep their scoped rules too) */
.ok { color: var(--good); } .no { color: var(--bad); }
td.bad, .bad { color: var(--bad); }

/* ---- v2 additions ---- */

/* company switcher + send-window indicator (header) */
.campname { color: var(--accent); font-weight: 700; }
.campbox { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }
.campbox select { font-weight: 600; font-size: 13px; min-width: 160px; }
.sendwin { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }

/* review queue: confidence group headers, bulk select, keyboard hints */
.list li.group { background: var(--panel2); color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding: 5px 13px; cursor: default; }
.list li.group:hover { background: var(--panel2); }
.list li.empty-li { cursor: default; }
.list .rsel { margin-right: 6px; vertical-align: -2px; }
.kbdhint { font-size: 12px; margin: -6px 0 12px; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: inherit; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none; }
.chk input { accent-color: var(--accent2); }
.bump { display: flex; margin-top: 12px; color: var(--text); }
.notes.verify { border-width: 2px; font-size: 13px; }

/* status badges (mailboxes) */
.badge { font-size: 11px; padding: 1px 9px; border-radius: 20px; background: var(--panel2);
  border: 1px solid var(--line); }
.badge.active { color: var(--good); border-color: var(--good); }
.badge.paused { color: var(--warn); border-color: var(--warn); cursor: help; }

/* forms in cards (find leads, settings) */
.card.wide { max-width: none; }
.form label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 12px 0 4px; }
.form label.chk, .toolbar label.chk { display: inline-flex; text-transform: none; font-size: 12px;
  letter-spacing: 0; margin: 0; }
.form input[type=text], .form input[type=number], .form input[type=date], .form textarea, .form select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 11px; font: inherit; width: 100%; max-width: 560px; }
.form textarea { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; resize: vertical; }
.ranges { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 0; }
.formrow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.formrow label { flex: 1 1 150px; margin: 0; }
.formrow input, .formrow select { margin-top: 4px; }
.addmb { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }

/* mailbox admin table */
.mbadmin td { vertical-align: middle; font-size: 13px; }
.mbadmin input[type=number] { width: 70px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; font: inherit; font-size: 12px; }
.mbadmin input[type=date] { width: 135px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; font: inherit; font-size: 12px; }
button.small { padding: 4px 10px; font-size: 12px; }

/* lead-run history */
#leadRuns td.wrap { white-space: normal; max-width: 420px; }

/* dashboard extras */
.bumpstat { margin-top: 10px; color: var(--muted); font-size: 13px; }
details > summary { cursor: pointer; font-weight: 600; }
details > summary .muted { font-weight: 400; font-size: 12px; }

/* ---- v3 additions ---- */

/* Today tab */
.tabbadge { display: inline-block; min-width: 17px; text-align: center; background: var(--bad);
  color: #fff; border-radius: 20px; font-size: 10px; font-weight: 700; padding: 1px 5px;
  vertical-align: 2px; margin-left: 2px; }
.today-warn { background: #2a2410; border: 1px solid #4a3f18; color: #f2e6b8; padding: 8px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 6px; }
.today-warn a { color: var(--accent); text-decoration: none; margin-left: 6px; }
.today-warn a:hover { text-decoration: underline; }
.today-org { font-size: 15px; font-weight: 700; margin-bottom: 8px; letter-spacing: .2px; }
.today-org .muted { font-weight: 400; font-size: 13px; }
.atth { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  margin: 16px 0 6px; font-weight: 600; }
.atth:first-of-type { margin-top: 4px; }
table.attr { width: 100%; border-collapse: collapse; font-size: 13px; }
table.attr th { text-align: right; color: var(--muted); font-weight: 600; padding: 4px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
table.attr th:first-child, table.attr td:first-child { text-align: left; }
table.attr td { text-align: right; padding: 5px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.attr tr:last-child td { border-bottom: none; }
table.attr td.wonc { color: #3fbf6f; font-weight: 700; }
.today-card h2 { color: var(--accent); }
.trow { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.trow:last-child { border-bottom: none; }
.trow.info { color: var(--muted); }
.trow.hotrow, .trow.resrow { cursor: pointer; border-radius: 6px; }
.trow.hotrow:hover, .trow.resrow:hover { background: var(--panel2); }
.trow .age { font-weight: 700; font-size: 12px; color: var(--muted); margin-left: 4px; }
.trow .age.overdue { color: var(--bad); }
.allclear { text-align: center; padding: 80px 0; font-size: 20px; font-weight: 600; }
.allclear .muted { font-size: 13px; font-weight: 400; }

/* hot / due badges (Replies list, Leads table, Today rows) */
.pill.hot { color: #fb923c; border-color: #fb923c; }
.pill.due { color: var(--warn); border-color: var(--warn); }

/* draft lint strip (under the body textareas) */
.lint { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
.lint-item { padding: 1px 9px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line); }
.lint-item.ok { color: var(--good); border-color: var(--good); }
.lint-item.info { color: var(--muted); }
.lint-item.warn { color: var(--warn); border-color: var(--warn); }
.lint-item.bad { color: var(--bad); border-color: var(--bad); }

/* thread view (conversation list in the modal) */
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.tmsg { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.tmsg.ours { border-color: #2a4a7a; background: #131b2a; margin-left: 24px; }
.tmsg.theirs { margin-right: 24px; }
.tmsg .thead { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.tmsg.ours .thead { color: var(--accent); }
.tmsg .tbody { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text); overflow-wrap: anywhere; }

/* ---- v4 additions ---- */

/* Inbox (unified cross-campaign reply stream) */
.inbox { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.empty-inbox { padding: 50px 20px; text-align: center; }
.irow { border-bottom: 1px solid var(--line); }
.irow:last-child { border-bottom: none; }
.irow .ihead { display: flex; align-items: center; gap: 8px; padding: 10px 13px; cursor: pointer; flex-wrap: wrap; }
.irow .ihead:hover { background: var(--panel2); }
.irow.open .ihead { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.irow .co { font-weight: 600; }
.irow .iemail { font-size: 12px; }
.irow .age { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.pill.camp { color: var(--accent); border-color: var(--accent); }
.ipeek { color: var(--muted); font-size: 12px; padding: 0 13px 10px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ibody { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.ibody .meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.ibody label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 12px 0 4px; }
.ibody input[type=text], .ibody textarea { width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; resize: vertical; }
.ibody textarea { min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.ibody .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* DNS doctor (Settings mailbox table) */
.mbactions { white-space: nowrap; }
.mbactions button { margin-right: 4px; }
tr.dnsrow td { background: var(--bg); padding: 8px 14px; }
.dnsfix { font-size: 12px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; white-space: pre-wrap; }
.dnsfix.err { background: #2a1416; border: 1px solid #5b1e2a; color: #fecaca; }
.dnsfix.adv { background: #2a2410; border: 1px solid #4a3f18; color: #f2e6b8; }

/* bump sequence editor (Settings) */
.bumpcamp { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.bumpcamp:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.bumpcamp h3 { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 14px; }
.bumprow { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.bumprow .bumpdays { flex: 0 0 130px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; }
.bumprow .bumptext { flex: 1; min-width: 240px; }
.bumprow input[type=number], .bumprow textarea { background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font: inherit; width: 100%; }
.bumprow input[type=number] { margin-top: 4px; }
.bumprow textarea { min-height: 70px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.bumprow .bp-del { flex: 0 0 auto; margin-top: 18px; }

/* ---- Archive tab (read-only 2016–2018 dumps explorer) ---- */
.archive-caveat { background: #2a2410; border: 1px solid #4a3f18; color: #f2e6b8;
  padding: 12px 16px; border-radius: var(--radius); font-size: 13px; line-height: 1.5;
  margin-bottom: 16px; }
.archive-caveat b { color: #fff; }
.archive-total { color: var(--warn); font-weight: 700; }
.archive-filters { align-items: center; }
.archive-filters .search { min-width: 150px; }
#archiveTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#archiveTable th { position: sticky; top: 0; background: var(--panel2); white-space: nowrap; }
#archiveTable td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
#archiveTable tbody tr:hover { background: var(--panel2); }
#archiveTable td.ar-pattern { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700; color: var(--accent); }
#archiveTable td.ar-email { color: var(--muted); opacity: .65;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.ar-li { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700;
  color: var(--accent); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
  text-decoration: none; text-transform: uppercase; vertical-align: 1px; }
.ar-li:hover { border-color: var(--accent); }
.ar-status { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; padding: 1px 6px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.ar-status.ar-st-ok { color: #137333; border-color: #b7dfc0; background: #eaf6ed; }
.ar-status.ar-st-guess { color: #8a5a00; border-color: #f0dcae; background: #fbf3e0; }
.archive-pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
#tab-archive .empty { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 14px; }

/* Archive: enrich bar + selection */
.archive-enrich { gap: 8px; }
.archive-enrich .grow { flex: 1; }
.archive-filters .ar-dm { display: inline-flex; align-items: center; gap: 5px; text-transform: none; font-size: 12px; color: var(--muted); }
#archiveTable th:first-child, #archiveTable td:first-child { width: 26px; text-align: center; }
#archiveTable .ar-row, #arSelAll { cursor: pointer; }
#chTable th:first-child, #chTable td:first-child { width: 26px; text-align: center; }
#chTable .ch-row, #chSelAll { cursor: pointer; }
#chTable td.ch-sic { font-size: 11px; color: var(--muted); max-width: 320px; }
.ch-sicline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dompill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.ch-loading { padding: 30px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 13px; height: 13px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= v6 — light theme + workspace switcher ================= */

/* Light theme: overrides the dark :root vars when <html data-theme="light"> */
:root[data-theme="light"] {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #eef1f6; --line: #d9dee7;
  --text: #1b2230; --muted: #5b6478; --accent: #2563eb; --accent2: #2563eb;
  --good: #15a34a; --warn: #b45309; --bad: #dc2626;
}
/* hardcoded dark surfaces that don't use vars — light equivalents */
:root[data-theme="light"] .log { background: #eef1f6; color: #334155; }
:root[data-theme="light"] .notes,
:root[data-theme="light"] .setup-banner,
:root[data-theme="light"] .today-warn,
:root[data-theme="light"] .archive-caveat,
:root[data-theme="light"] .dnsfix.adv,
:root[data-theme="light"] .notes.verify {
  background: #fdf6e3; border-color: #ecd9a0; color: #785a12; }
:root[data-theme="light"] .setup-banner b,
:root[data-theme="light"] .archive-caveat b,
:root[data-theme="light"] .today-card h2 { color: #1b2230; }
:root[data-theme="light"] .notes.lead {
  background: #e8f6ee; border-color: #a5d6b7; color: #1c6b3a; }
:root[data-theme="light"] .dnsfix.err {
  background: #fdecec; border-color: #f2b8b8; color: #a12222; }
:root[data-theme="light"] .tmsg.ours { background: #eaf1ff; border-color: #bcd3fb; }
:root[data-theme="light"] .score-chip.high { background: #e8f6ee; }
:root[data-theme="light"] .score-chip.medium { background: #fdf6e3; }
:root[data-theme="light"] .score-chip.low { background: #fdecec; }
:root[data-theme="light"] .toast { box-shadow: 0 4px 20px rgba(0,0,0,.12); }
:root[data-theme="light"] nav#tabs button.active,
:root[data-theme="light"] .list li.sel { background: #e8eefc; }

/* theme toggle button in the top bar */
#themeToggle { padding: 6px 10px; font-size: 15px; line-height: 1; }

/* workspace / org switcher at the top of the left rail (Instantly-style) */
.wsswitch { display: flex; flex-direction: column; gap: 4px; padding: 4px 6px 12px;
  margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.wslabel { font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); opacity: .7; padding-left: 4px; }
.wsswitch select { width: 100%; font-weight: 600; font-size: 13px; padding: 8px 10px; }

/* ================= v5 — Instantly-style app shell ================= */

/* App shell: left nav rail + content column (grid places existing DOM, no HTML change) */
body { display: grid; height: 100vh; min-height: 100vh; overflow: hidden;
  grid-template-columns: 214px minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "nav topbar" "nav banner" "nav main"; }
nav#tabs { grid-area: nav; }
header { grid-area: topbar; }
#setupBanner { grid-area: banner; }
main { grid-area: main; overflow: auto; }

/* Left nav rail (overrides the old horizontal tab bar) */
nav#tabs { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 2px;
  padding: 12px 10px 18px; background: var(--panel); border-right: 1px solid var(--line);
  border-bottom: none; overflow-y: auto; }
nav#tabs .navgroup { flex-direction: column; align-items: stretch; gap: 2px; padding: 0; }
nav#tabs .navgroup + .navgroup { border-left: none; padding-left: 0;
  border-top: 1px solid var(--line); margin-top: 8px; padding-top: 9px; }
nav#tabs .navlabel { position: static; left: auto; top: auto; opacity: .55;
  padding: 2px 10px 4px; font-size: 9.5px; }
nav#tabs button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 11px; border-radius: 8px; box-shadow: none; font-size: 13px; }
nav#tabs button:hover { background: var(--panel2); color: var(--text); }
nav#tabs button.active { background: var(--panel2); color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent); border-radius: 8px; }
nav#tabs .tabbadge { margin-left: auto; }

/* Top bar tidy */
header { padding: 10px 20px; }

/* Colored status labels (inbox reply categories) — dot + text, Instantly-style */
.cat { display: inline-flex; align-items: center; gap: 5px; }
.cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.cat.cat-interested { color: #4ade80; border-color: #2f6f47; } .cat.cat-interested::before { background: #4ade80; }
.cat.cat-question { color: #6ea8fe; border-color: #2f4f83; } .cat.cat-question::before { background: #6ea8fe; }
.cat.cat-not_now { color: #fbbf24; border-color: #6b5518; } .cat.cat-not_now::before { background: #fbbf24; }
.cat.cat-referral { color: #c4b5fd; border-color: #4a3f83; } .cat.cat-referral::before { background: #c4b5fd; }
.cat.cat-auto_reply { color: var(--muted); } .cat.cat-auto_reply::before { background: var(--muted); }
.cat.cat-not_interested, .cat.cat-unsubscribe { color: #f87171; border-color: #6b2530; }
.cat.cat-not_interested::before, .cat.cat-unsubscribe::before { background: #f87171; }

/* Kanban: per-stage colored column top-accent + header dot + count chip */
.col { border-top: 2px solid var(--line); }
.col-head { gap: 8px; }
.col-head::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.col-head .n { margin-left: auto; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 20px; padding: 0 8px; min-width: 20px; text-align: center; }
.col.replied { border-top-color: #6ea8fe; } .col.replied .col-head::before { background: #6ea8fe; }
.col.meeting_booked { border-top-color: #a78bfa; } .col.meeting_booked .col-head::before { background: #a78bfa; }
.col.proposal_sent { border-top-color: #fbbf24; } .col.proposal_sent .col-head::before { background: #fbbf24; }
.col.negotiating { border-top-color: #fb923c; } .col.negotiating .col-head::before { background: #fb923c; }
.col.won { border-top-color: #4ade80; } .col.won .col-head::before { background: #4ade80; }
.col.lost { border-top-color: #f87171; } .col.lost .col-head::before { background: #f87171; }

/* Modal forms (client add/edit, etc.) — match the dark theme */
.modal-card label { display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; }
.modal-card label.chk { display: inline-flex; align-items: center; gap: 6px;
  text-transform: none; letter-spacing: 0; font-size: 12px; }
.modal-card .formrow { gap: 12px; }
.modal-card .formrow label { margin: 12px 0 0; }
.modal-card input[type=text], .modal-card input[type=date],
.modal-card select, .modal-card textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; font: inherit; }
.modal-card textarea { min-height: 84px; resize: vertical; }
.modal-card .actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }

/* Clients CRM status pills */
.pill.client-active { color: var(--good); border-color: #2f6f47; }
.pill.client-past { color: var(--muted); }
.pill.client-prospect { color: var(--accent); border-color: var(--accent); }
#clientsTable td { vertical-align: top; }
#clientsTable td b { font-size: 13px; }

/* Narrow screens: rail collapses to a top strip */
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; height: auto; overflow: visible;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    grid-template-areas: "nav" "topbar" "banner" "main"; }
  nav#tabs { flex-direction: row; flex-wrap: wrap; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--line); }
  nav#tabs button { width: auto; }
  nav#tabs .navgroup { flex-direction: row; }
}

/* ── Header search · command palette · export (added) ───────────────────── */
.hsearch { flex: 0 1 360px; margin-left: 20px; margin-right: auto; position: relative; }
#globalSearch {
  width: 100%; background: var(--panel2); color: var(--text); font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
}
#globalSearch:focus { outline: none; border-color: var(--accent); }
header > .health { margin-left: 14px; }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35); max-height: 62vh; overflow: auto; padding: 4px;
}
.search-results[hidden] { display: none; }
.sr-item { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.sr-item:hover { background: var(--panel2); }
.sr-co { font-weight: 600; font-size: 13px; }
.sr-sub { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.sr-empty { padding: 10px; font-size: 12px; }

.cmdk { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; }
.cmdk[hidden] { display: none; }
.cmdk-box { margin-top: 12vh; width: min(560px, 92vw); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.5); overflow: hidden; }
#cmdkInput { width: 100%; border: none; border-bottom: 1px solid var(--line); background: none;
  color: var(--text); font: inherit; font-size: 15px; padding: 14px 16px; }
#cmdkInput:focus { outline: none; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow: auto; }
.cmdk-list li { padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.cmdk-list li.sel { background: var(--accent2); color: #fff; }
.cmdk-list li.empty { cursor: default; }

/* keyboard-shortcut help overlay */
.help-box { padding-bottom: 6px; }
.help-head { padding: 14px 18px; font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--line); }
.help-list { list-style: none; margin: 0; padding: 12px 18px 16px; display: grid; gap: 9px; }
.help-list li { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.help-list li > span:last-child { color: var(--muted); }
.help-list .keys { flex: 0 0 92px; display: flex; gap: 4px; }
.help-list kbd {
  background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 7px; font: 600 12px ui-monospace, Menlo, monospace; color: var(--text);
}

/* deliverability / inbox-score panel (Review detail) */
.deliver { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel2); }
.deliver-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.deliver-issues { margin: 8px 0 0; padding-left: 18px; }
.deliver-issues li { margin: 2px 0; font-size: 12px; }
.deliver-issues li.bad { color: var(--bad); }
.deliver-issues li.warn { color: var(--warn); }
.deliver-clean { margin-top: 6px; font-size: 12px; color: var(--good); }

/* ===================== Login screen ===================== */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 460px at 50% -8%, rgba(110,168,254,.10), transparent 70%),
    var(--bg);
  padding: 24px; z-index: 10000; }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 40px 34px 26px; box-shadow: 0 24px 60px -24px rgba(0,0,0,.45); }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; margin-bottom: 26px; }
.login-brand .logo { width: 54px; height: 54px; margin-bottom: 6px; }
.login-brand h1 { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.login-brand .sub { color: var(--muted); font-size: 13.5px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.login-field input { width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 13px; color: var(--text); font-size: 15px;
  transition: border-color .12s, box-shadow .12s; }
.login-field input:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(37,99,235,.20); }
.login-btn { width: 100%; margin-top: 6px; background: var(--accent2); color: #fff; border: 0; border-radius: 9px;
  padding: 12px; font-size: 15px; font-weight: 650; cursor: pointer; transition: filter .12s; }
.login-btn:hover { filter: brightness(1.07); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 12px 0 2px; text-align: center; }
.login-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 18px; letter-spacing: .02em; }

/* ===================== Header user menu ===================== */
.usermenu { display: flex; align-items: center; gap: 10px; margin-left: 14px; }
.usermenu .uname { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.usermenu .udot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; }
.usermenu .wspill { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: capitalize;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); border-radius: 999px; padding: 2px 9px; }

/* ===================== Admin page ===================== */
.adminusers td { vertical-align: middle; }
.admin-actions { white-space: nowrap; text-align: right; }
.admin-actions .small { margin-left: 6px; }
.ghost.small.danger { color: var(--bad); }
.ghost.small.danger:hover { border-color: var(--bad); }
.rolechip { font-size: 11px; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--line); }
.rolechip.role-admin { color: var(--accent); border-color: var(--accent); }
.rolechip.role-member { color: var(--good); border-color: var(--good); }
.rolechip.role-viewer { color: var(--muted); }
.orgpick { margin: 8px 0 16px; }
.orgchks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0; }
.orgchk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.orgchk.allorgs { margin-top: 6px; font-weight: 600; }

/* ===================== Lead owner ===================== */
.ownercell { cursor: pointer; }
.ownerchip { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line); }
.ownercell:hover .ownerchip { border-color: var(--accent); }
.ownercell:hover .muted { color: var(--accent); }
