:root {
  --ink: #262626;
  --ink-2: #4a4a4a;
  --ink-3: #7a7a7a;
  --ink-4: #a9abaa;
  --paper: #e3e5e4;
  --paper-2: #eef0ef;
  --surface: #ffffff;
  --line: #d3d6d5;
  --line-soft: #e6e8e7;
  --red: #a62727;
  --red-dark: #8a1f1f;
  --red-soft: #f5e6e6;
  --green: #2f6b45;
  --green-soft: #e4efe8;
  --amber: #8a5a0b;
  --amber-soft: #f6eedb;
  --blue: #2c5282;
  --blue-soft: #e3ebf4;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(38, 38, 38, 0.06), 0 8px 24px -16px rgba(38, 38, 38, 0.25);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--red-soft); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--ink);
  color: var(--paper);
  display: flex; flex-direction: column;
  padding: 22px 16px 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 20px; }
.brand-logo { height: 46px; width: auto; display: block; }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); align-self: flex-end; padding-bottom: 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--paper); color: var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text span { font-size: 12px; color: var(--ink-4); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #c9cccb; font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); margin: 14px 10px 4px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-group:empty { margin: 10px 10px 2px; padding-top: 0; }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: var(--ink-4); }
.conn { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.conn-row { display: flex; align-items: center; gap: 8px; }
.who { margin-top: 8px; }
.who .link { color: inherit; text-decoration: underline; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #5a5a5a; flex: none; }
.dot.on { background: #58b37a; }
.dot.off { background: var(--red); }
.tagline { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #6f6f6f; }

.main { padding: 28px 36px 60px; max-width: 1240px; width: 100%; }

/* ---------- typography & layout ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--ink-3); margin-top: 2px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 14px 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.input, textarea.input, select.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(38,38,38,0.08); }
textarea.input { resize: vertical; min-height: 180px; line-height: 1.55; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; }
.search .input { padding-left: 34px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); transition: all .15s;
}
.chip:hover { border-color: var(--ink-4); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.pos { background: var(--green-soft); color: var(--green); }
.badge.neg { background: var(--red-soft); color: var(--red); }
.badge.neu { background: var(--amber-soft); color: var(--amber); }
.badge.info { background: var(--blue-soft); color: var(--blue); }
.badge.plain { background: var(--paper-2); color: var(--ink-2); }
.badge.plain::before { display: none; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--paper-2); color: var(--ink-2); font-size: 12px; }

.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--paper-2); color: var(--ink); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

/* ---------- inbox ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.list { overflow: hidden; }
.lead-row {
  display: grid; grid-template-columns: 38px minmax(200px, 1.4fr) 108px minmax(160px, 1fr) 150px 110px 28px;
  gap: 14px; align-items: center; padding: 13px 18px; border-top: 1px solid var(--line-soft); cursor: pointer;
  transition: background .12s;
}
.lead-row:first-child { border-top: 0; }
.lead-row:hover { background: var(--paper-2); }
.lead-row .name { font-weight: 600; }
.lead-row .meta { color: var(--ink-3); font-size: 12px; }
.lead-row .chev { width: 18px; height: 18px; stroke: var(--ink-4); fill: none; stroke-width: 1.8; justify-self: end; }
.lead-row .snippet { color: var(--ink-2); font-size: 13px; grid-column: 2 / -1; margin-top: -6px; }
.lead-row.unread .name::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: 8px; vertical-align: middle; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- lead view ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-weight: 500; margin-bottom: 14px; }
.back:hover { color: var(--ink); }
.back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.lead-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.lead-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.lead-head .meta { color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line-soft); background: var(--surface); }
.msg.in { border-left: 3px solid var(--red); }
.msg.out { background: var(--paper-2); }
.msg .who { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.msg .who b { color: var(--ink); font-weight: 600; }
.msg .body { white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: hidden; position: relative; }
.msg .body.open { max-height: none; }
.msg .body:not(.open)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48px; background: linear-gradient(transparent, var(--surface)); }
.msg.out .body:not(.open)::after { background: linear-gradient(transparent, var(--paper-2)); }
.msg .more { margin-top: 6px; }

.compose .tpl-chips { margin-bottom: 10px; }
.compose .cc { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin: 10px 0; }
.compose .cc label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.cc-lock { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; font-family: var(--mono, ui-monospace, monospace); font-size: 12px; }
.cc-lock svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.compose .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note { border-radius: 10px; background: var(--paper-2); padding: 10px 12px; font-size: 13px; }
.note .t { color: var(--ink-3); font-size: 11px; margin-bottom: 3px; }
.link { color: var(--red); font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- templates ---------- */
.tpl-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .tpl-grid { grid-template-columns: 1fr; } }
.tpl-item { padding: 12px 14px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.tpl-item:first-child { border-top: 0; }
.tpl-item:hover { background: var(--paper-2); }
.tpl-item .n { font-weight: 600; }
.tpl-item .u { color: var(--ink-3); font-size: 12px; }
textarea.editor { min-height: 520px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------- settings ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-grid .s-main { grid-column: span 8; }
.settings-grid .s-side { grid-column: span 4; display: flex; flex-direction: column; gap: 16px; }
.settings-grid .s-full { grid-column: 1 / -1; }
.settings-grid .s-half { grid-column: span 6; }
.settings-grid .card { margin: 0; }
.s-fu .form { grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.s-fu .form .f { grid-template-columns: 150px 1fr; }
.s-fu .form .f.wide, .s-fu .form .f:has(.switch) { grid-column: 1 / -1; }
.s-side .form .f { grid-template-columns: 130px 1fr; }
.s-side .form .f:has(.switch) { grid-template-columns: 1fr; gap: 4px; }
.s-side .form .f:has(.switch) > label:first-child { font-size: 12px; color: var(--ink-3); }
.s-side .form .f .switch { align-items: flex-start; line-height: 1.4; }
.s-side .form .f .switch input { margin-top: 2px; }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px -4px 0; padding: 12px 16px; background: rgba(255,255,255,0.92); backdrop-filter: blur(8px); border: 1px solid var(--line-soft); border-radius: 12px; box-shadow: 0 -8px 24px -16px rgba(38,38,38,.35), var(--shadow); }
@media (max-width: 1100px) { .settings-grid .s-main, .settings-grid .s-side, .settings-grid .s-half { grid-column: 1 / -1; } .s-fu .form { grid-template-columns: 1fr; } }

/* ---------- modal & toasts ---------- */
.modal-root:empty { display: none; }
.modal-root { position: fixed; inset: 0; background: rgba(38,38,38,0.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: min(680px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
.modal .mh { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal .mh h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.modal .mb { padding: 16px 22px; }
.modal .mf { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line-soft); }
.preview { border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden; }
.preview .hdr { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; padding: 12px 14px; background: var(--paper-2); font-size: 13px; }
.preview .hdr span:nth-child(odd) { color: var(--ink-3); }
.preview .bd { padding: 14px; line-height: 1.6; }
.checks { display: grid; gap: 8px; margin-top: 14px; }
.checks label { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.checks input { width: 16px; height: 16px; accent-color: var(--red); }
.result-list { display: grid; gap: 8px; }
.result-list .r { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.result-list .r .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 11px; font-weight: 700; }
.ic.ok { background: var(--green-soft); color: var(--green); }
.ic.warn { background: var(--amber-soft); color: var(--amber); }
.ic.err { background: var(--red-soft); color: var(--red); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: up .2s ease-out; max-width: 380px; }
.toast.err { background: var(--red); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.skeleton { background: linear-gradient(90deg, var(--paper-2) 25%, #f6f7f6 50%, var(--paper-2) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- pipeline ---------- */
.main.wide { max-width: none; }
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; cursor: grab; user-select: none; scrollbar-width: thin; }
.board.panning { cursor: grabbing; }
.board.panning .kcard { pointer-events: none; }
.col { flex: 0 0 262px; background: rgba(255,255,255,0.45); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); min-height: 200px; display: flex; flex-direction: column; transition: flex-basis .18s ease; }
.col-h { cursor: pointer; user-select: none; }
.col-h .chev { width: 16px; height: 16px; margin-left: 6px; stroke: var(--ink-4); fill: none; stroke-width: 1.8; transform: rotate(90deg); transition: transform .18s; }
.col.collapsed { flex: 0 0 46px; min-height: 200px; }
.col.collapsed .col-h { flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px; padding: 12px 6px; }
.col.collapsed .col-h .t { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.col.collapsed .col-h .chev { transform: rotate(-90deg); margin: 0; }
.col.collapsed .col-body { display: none; }
.col.over { background: var(--red-soft); border-color: var(--red); }
.col-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.col-h .t { font-weight: 600; font-size: 13px; }
.col-h .n { font-size: 12px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px; padding: 1px 8px; }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px; min-height: 60px; }
.kcard { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); transition: transform .08s, border-color .12s; }
.kcard:hover { border-color: var(--ink-4); }
.kcard.dragging { opacity: .5; transform: rotate(1deg); }
.kcard .top { display: flex; align-items: center; gap: 8px; }
.kcard .avatar { width: 28px; height: 28px; font-size: 11px; }
.kcard .nm { font-weight: 600; font-size: 13px; }
.kcard .co { color: var(--ink-3); font-size: 12px; }
.kcard .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.kcard .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.kcard select { font-size: 12px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); max-width: 140px; }
.kcard .warn { color: var(--amber); }
.kcard svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.kcard .foot .fu { white-space: nowrap; }
.sync-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sync-bar .sel { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.callout { border-radius: 12px; padding: 12px 14px; background: var(--amber-soft); color: var(--amber); font-size: 13px; margin-bottom: 14px; }
.callout.info { background: var(--blue-soft); color: var(--blue); }

/* ---------- settings form ---------- */
.form { display: grid; gap: 12px; align-content: start; }
.form .f { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 10px; }
.form .f label { font-size: 13px; color: var(--ink-2); }
.form .f .input { padding: 7px 10px; }
.form .f .help { grid-column: 2; font-size: 12px; color: var(--ink-3); margin-top: -6px; }
.form .f.inline .input { width: auto; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.switch input { width: 16px; height: 16px; accent-color: var(--red); }
.form .f.stacked { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.form .f.stacked > .row { width: 100%; }
.form .f.stacked label { font-size: 12px; color: var(--ink-3); }
.form .f.stacked .row .input, .form .f.stacked .row select { flex: 1; min-width: 0; }

/* ---------- meetings ---------- */
.mt-row { display: grid; grid-template-columns: 150px minmax(0, 1.3fr) minmax(0, 1.7fr) auto; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line-soft); align-items: start; }
.mt-row:first-child { border-top: 0; }
.mt-row .when { font-weight: 600; font-size: 13px; }
.mt-row .when .sub { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.mt-row .lead-n { font-weight: 600; }
.mt-row .actions-col { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 150px; }
.assess { background: var(--paper-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.assess .o { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; margin-bottom: 4px; }
.assess ul { margin: 6px 0 0 16px; padding: 0; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.off { background: var(--paper-2); color: var(--ink-3); }

/* inline spinner (template tailoring) */
.spin { display:inline-block; width:10px; height:10px; border:2px solid var(--line, #d9dbda); border-top-color: var(--accent, #a62727); border-radius:50%; animation: spin .8s linear infinite; vertical-align:-1px; margin-right:4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* rich-text reply editor */
.editor { border: 1px solid var(--line, #d9dbda); border-radius: 10px; background: #fff; }
.editor:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(38,38,38,0.08); }
.toolbar { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line, #e6e7e6); }
.toolbar button { border: 0; background: transparent; border-radius: 6px; padding: 5px 7px; cursor: pointer; color: var(--ink-2, #444); font-size: 13px; line-height: 1; min-width: 28px; }
.toolbar button:hover { background: var(--paper-2, #f1f2f1); color: var(--ink); }
.toolbar button.on { background: var(--ink); color: #fff; }
.toolbar button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.toolbar .sep { width: 1px; height: 18px; background: var(--line, #e6e7e6); margin: 0 6px; }
.toolbar .state { margin-left: auto; font-size: 12px; color: var(--ink-3, #777); }
.rich { min-height: 180px; padding: 12px 14px; line-height: 1.55; outline: none; font-size: 14px; word-break: break-word; }
.rich:empty::before { content: attr(data-placeholder); color: var(--ink-4, #9a9c9b); pointer-events: none; }
.rich p, .preview .bd p { margin: 0 0 10px; }
.rich p:last-child, .preview .bd p:last-child { margin-bottom: 0; }
.rich ul, .rich ol, .preview .bd ul, .preview .bd ol { margin: 0 0 10px; padding-left: 22px; }
.rich a, .preview .bd a { color: var(--red, #a62727); text-decoration: underline; }
.rich b, .rich strong { font-weight: 700; }
.pill.draft { background: var(--blue-soft, #e8eef7); color: var(--blue, #2a4d8f); }
.link-form .f { margin-bottom: 10px; }
.link-form label { display: block; font-size: 12px; color: var(--ink-3, #777); margin-bottom: 4px; font-weight: 600; }
/* Icons used inline in text (notes, hints): small, stroked, on the baseline. Without this an SVG fills the line at 300x150 as a black shape. */
p svg, .muted svg, .checks svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; margin-right: 4px; }

/* Send dialog: the recipient first, big, with what they wrote; red when the checks found something. */
.recipient { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--paper-2); margin-bottom: 12px; border: 1px solid var(--line-soft); }
.recipient.bad { border-color: var(--red, #a62727); background: #fbf1f1; }
.recipient .rn { font-weight: 700; font-size: 15px; }
.recipient .rq { margin-top: 6px; font-size: 13px; color: var(--ink-2); font-style: italic; }
.checks label.ack { font-weight: 600; color: var(--red, #a62727); }
.lead-row.processed { opacity: .55; }
.pill.done { background: #e9f3ea; color: #2f6b3a; }
.switch.small { font-size: 12px; }
.sel.sm { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; margin-left: 4px; }
.nav a .count { margin-left: auto; font-size: 12px; color: #fff; font-weight: 600; }

.actions .btn.active { background: var(--ink, #262626); color: #fff; border-color: var(--ink, #262626); }
.stage-chips .chip.active { background: var(--ink, #262626); color: #fff; border-color: var(--ink, #262626); }
.stage-chips .chip.active .muted { color: #cfcfcf; }
.stage-chips .chip:disabled { opacity: .6; }
.stage-pick { padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 12px; margin-bottom: 12px; }
.stage-pick .eyebrow { margin-bottom: 8px; }

iframe.mail { width: 100%; border: 0; display: block; height: 120px; background: transparent; }
.msg .more { margin-top: 6px; }

.btn.done-btn { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); transition: background .15s, border-color .15s, color .15s; }
.btn.done-btn:hover { background: #e9f3ea; border-color: #2f6b3a; color: #2f6b3a; }
.btn.done-btn:active { background: #d9ead9; }
.toast.undo { display: flex; align-items: center; gap: 12px; }
.toast .undo-btn { background: #fff; color: var(--ink); border: 0; border-radius: 6px; padding: 4px 10px; font-weight: 600; cursor: pointer; font-size: 12px; }

/* Relationship colours: soft tint at rest, solid when it is the current / chosen one. */
.tone-grey   { --tone: #6b6b6b; --tone-soft: #efefef; }
.tone-green  { --tone: #2f6b3a; --tone-soft: #e9f3ea; }
.tone-sky    { --tone: #1f6f8b; --tone-soft: #e6f2f7; }
.tone-blue   { --tone: #2a4d8f; --tone-soft: #e8eef7; }
.tone-indigo { --tone: #4b3fa3; --tone-soft: #ecebf8; }
.tone-purple { --tone: #6d2e8a; --tone-soft: #f2e9f6; }
.tone-amber  { --tone: #8a5a00; --tone-soft: #fbf1dd; }
.tone-red    { --tone: #a62727; --tone-soft: #fbeaea; }
.tone-gold   { --tone: #7a5a12; --tone-soft: #f8f0d8; }
.actions .btn[class*="tone-"], .stage-chips .chip[class*="tone-"] { background: var(--tone-soft); color: var(--tone); border-color: transparent; }
.actions .btn[class*="tone-"]:hover, .stage-chips .chip[class*="tone-"]:hover { border-color: var(--tone); }
.actions .btn[class*="tone-"].active, .stage-chips .chip[class*="tone-"].active { background: var(--tone); color: #fff; border-color: var(--tone); }
.stage-chips .chip[class*="tone-"].active .muted { color: rgba(255,255,255,.75); }

.queue-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.queue-nav .btn svg { width: 14px; height: 14px; }

/* Recipients: chips for CC / BCC */
.recips { margin-top: 12px; }
.rrow { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.rrow label { width: 36px; padding-top: 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.rrow.over .toks { outline: 2px dashed var(--blue, #2a4d8f); outline-offset: 2px; border-radius: 10px; }
.toks { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; align-items: center; min-height: 34px; }
.tok { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; font-family: var(--mono, ui-monospace, monospace); cursor: grab; }
.tok.dragging { opacity: .5; }
.tok.locked { background: var(--blue-soft, #e8eef7); color: var(--blue, #2a4d8f); border-color: transparent; padding-right: 10px; cursor: default; }
.tok.locked svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.tok button { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 50%; }
.tok button:hover { background: var(--paper-2); color: var(--ink); }
.tok button.x:hover { color: var(--red, #a62727); }
.tok-in { border: 0; outline: 0; background: transparent; font-size: 13px; min-width: 120px; flex: 1; padding: 6px 4px; }
.tok-edit { font-size: 12px; font-family: var(--mono, ui-monospace, monospace); border: 1px solid var(--blue, #2a4d8f); border-radius: 999px; padding: 3px 8px; outline: 0; min-width: 220px; }
.tok.to { background: var(--paper-2); cursor: default; padding-right: 10px; }
.tok.to .muted { font-family: Inter, sans-serif; }

.fu-card { margin-bottom: 12px; }
.fu-when { margin-top: 4px; }
.fu-left { margin-top: 10px; display: grid; gap: 8px; }
.fu-msg { border-radius: 10px; padding: 8px 12px; font-size: 13px; background: var(--paper-2); }
.fu-msg.in { border-left: 3px solid var(--red); }
.fu-msg .who { font-size: 11px; color: var(--ink-3); margin-bottom: 3px; font-weight: 600; }

.chip .n { color: var(--ink-3); font-weight: 500; margin-left: 2px; }
.chip.active .n { color: #cfcfcf; }
.reload-bar { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 10px; align-items: center; z-index: 70; box-shadow: var(--shadow); }
.reload-bar .btn { background: #fff; color: var(--ink); border: 0; }

/* ---------- dashboard ---------- */
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi[class*="tone-"] .v { color: var(--tone); }
.dash-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid.two { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 1100px) { .dash-grid, .dash-grid.two { grid-template-columns: 1fr; } }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 52px minmax(90px, auto); align-items: center; gap: 10px; padding: 4px 0; }
.bar-row .bl { font-size: 13px; }
.bar-row .bt { background: var(--paper-2); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-row .bar { height: 100%; background: var(--ink-3); border-radius: 6px; transition: width .4s ease; }
.bar-row .bar.good { background: var(--green); }
.bar-row .bar.bad { background: var(--red); }
.bar-row .bar.warn { background: var(--amber); }
.bar-row .bar.faint { background: var(--ink-4); }
.bar-row .bn { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row .bp { font-size: 12px; white-space: nowrap; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl th[data-sort] { cursor: pointer; }
.tbl th[data-sort].on { color: var(--ink); }
.tbl th[data-sort].on::after { content: " ↓"; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.total td { background: var(--paper-2); font-weight: 600; }
.tbl tr.fam-row { cursor: pointer; }
.tbl tr.fam-row:hover td { background: var(--paper-2); }
.tbl tr.fam-copies td { background: var(--paper-2); padding: 12px; }
.copies { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.copy-card { padding: 14px 16px; }
.copy-subj { font-weight: 600; margin: 8px 0 4px; }
.copy-body { font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.copy-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.badge.good { background: var(--green-soft); color: var(--green); }
.badge.up { background: var(--blue-soft); color: var(--blue); }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.v2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.wk-row { display: flex; gap: 8px; align-items: flex-end; }
.wk { flex: 1; text-align: center; }
.wk-bar { background: var(--ink-3); border-radius: 4px 4px 0 0; min-height: 2px; margin: 0 6px 4px; }
.dm-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); align-items: center; }
.dm-row:last-child { border-bottom: 0; }
.dm-date { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.dm-date.up { color: var(--blue); font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- meetings grid ---------- */
.mt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 1200px) { .mt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .mt-grid { grid-template-columns: 1fr; } }
.mt-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.mt-card .mt-title { font-weight: 600; font-size: 13.5px; }
.mt-card .mt-body { font-size: 13px; }
.mt-card .mt-body ul { margin: 6px 0 0 18px; padding: 0; }
.mt-card .mt-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.badge[class*="tone-"] { background: var(--tone-soft); color: var(--tone); }
/* ---------- templates editor ---------- */
.tpl-item.active { background: var(--paper-2); box-shadow: inset 3px 0 0 var(--red); }
.tpl-item.add { color: var(--red); font-weight: 600; }
.tpl-move { display: flex; flex-direction: column; gap: 2px; }
.tpl-move button { border: 0; background: transparent; color: var(--ink-4); cursor: pointer; font-size: 10px; padding: 0 4px; line-height: 1.2; }
.tpl-move button:hover { color: var(--ink); }
.editor .body { min-height: 260px; padding: 12px 14px; outline: none; line-height: 1.55; }
.editor .body p { margin: 0 0 10px; }
.btn.attention { box-shadow: 0 0 0 3px var(--red-soft); }
.btn.danger { color: var(--red); border-color: var(--red-soft); }
.btn.danger:hover { background: var(--red-soft); }
/* ---------- settings mapping, send timing ---------- */
.tbl.map td { vertical-align: middle; }
.tbl.map .sel { max-width: 220px; }
.when-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.input.sm { padding: 5px 8px; font-size: 12px; border-radius: 8px; }

/* ---- prospecting (app/static/prospecting.js) ---- */
.pro-sub { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.pro-sub .chips { margin-right: auto; }
.pro-meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 14px; flex-wrap: wrap; }
.pro-meta b { color: var(--ink); }
.tbl tr.faint td { color: var(--ink-4); }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--paper-2); }
.progress { height: 8px; background: var(--paper-2); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress > div { background: var(--red); height: 100%; transition: width .3s ease; }
.pro-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pro-steps .chip { pointer-events: none; }
.pro-steps .chip.done { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.known { background: var(--amber-soft); color: var(--amber); }
.badge.good { background: var(--green-soft); color: var(--green); }
.badge.grey { background: var(--paper-2); color: var(--ink-3); }
.pro-note { border-radius: 10px; padding: 10px 12px; font-size: 13px; background: var(--paper-2); margin: 10px 0; }
.pro-note.warn { background: var(--red-soft); color: var(--red); }
.pro-note.ok { background: var(--green-soft); color: var(--green); }
.pro-query { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; }
.pro-query .f { display: flex; flex-direction: column; gap: 4px; }
.pro-query label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.pro-query .input { padding: 7px 10px; width: 100%; }
.pro-kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 13px; }
.pro-kv dt { color: var(--ink-3); }
.pro-kv dd { margin: 0; word-break: break-word; }
.modal.wide { width: min(980px, 100%); }
.lift { font-weight: 600; }
.lift.up { color: var(--green); }
.lift.down { color: var(--red); }
.drive-file { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.drive-file:last-child { border-bottom: 0; }
.drive-file .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pro .card { overflow-x: auto; }

/* ---------- inbox split view (replies open on the right) ---------- */
.inbox-split { display: grid; grid-template-columns: minmax(380px, 0.85fr) minmax(520px, 1.3fr); gap: 18px; align-items: start; margin-top: 2px; }
.inbox-split .inbox-col, .inbox-split .lead-pane { margin-top: 0; }
.lead-head-card { position: relative; margin-bottom: 16px; }
.lead-head-card .lead-head { margin-bottom: 0; padding-right: 22px; }
.lead-head-card > .back { position: absolute; top: 8px; right: 12px; margin: 0; font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.lead-head-card > .back:hover { background: var(--bg); }
.lead-head-card .skel, .lead-head-card .empty { margin-top: 14px; }
@media (max-width: 1100px) { .inbox-split { grid-template-columns: 1fr; } .lead-pane { position: static; max-height: none; } }
.lead-pane { position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: auto; padding: 0 2px 20px; }
.lead-pane .pane-empty { padding: 60px 20px; text-align: center; }
.lead-pane .lead-head h1 { font-size: 19px; }
.lead-pane .cols { grid-template-columns: minmax(0, 1fr) 280px; }
.inbox-split .stats { grid-template-columns: repeat(2, 1fr); }
.inbox-split .lead-row { grid-template-columns: 34px minmax(140px, 1fr) 96px 120px 64px 16px; gap: 10px; padding: 11px 14px; }
.inbox-split .lead-row > div:nth-child(4) { display: none; }
.inbox-split .lead-row .snippet { grid-column: 2 / -1; }
.lead-row.open { background: var(--red-soft); }
.lead-row .snippet:empty { display: none; }

/* ---------- brand accents ---------- */
.page-mark { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 2px 6px -2px rgba(38,38,38,.35); flex: none; }
.page-head h1 { position: relative; }
.stats .stat { position: relative; overflow: hidden; }
.stats .stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red); opacity: .85; border-radius: 3px 0 0 3px; }
.kpi[class*="tone-"]::before { background: var(--tone); }
.nav a.active { box-shadow: inset 3px 0 0 var(--red); }
/* ---------- motion ---------- */
.btn { transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px -6px rgba(38,38,38,.5); }
.btn:active { transform: translateY(0) scale(.97); box-shadow: none; }
.btn:disabled { transform: none; box-shadow: none; }
.chip { transition: background .15s, color .15s, border-color .15s, transform .08s; }
.chip:active { transform: scale(.96); }
.nav a { transition: background .15s, color .15s, transform .15s; }
.nav a:hover { transform: translateX(2px); }
.lead-row { transition: background .15s, transform .15s; }
.lead-row:hover { transform: translateX(2px); }
.card { transition: box-shadow .2s, transform .2s; }
.mt-card:hover, .fu-card:hover, .copy-card:hover, .tpl-item:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -20px rgba(38,38,38,.5); }
.tpl-item:hover { transform: none; }
#main > * { animation: fadein .18s ease-out both; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.modal { animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.stage-chips .chip.active, .chip.active { animation: settle .22s ease-out; }
@keyframes settle { from { transform: scale(.94); } to { transform: none; } }
.lead-pane > * { animation: fadein .18s ease-out both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
/* ---------- inbox tools and layout ---------- */
.toolbar.chips-row { margin-bottom: 10px; }
.inbox-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 12px; }
.inbox-tools .search.grow { flex: 1 1 320px; min-width: 240px; }
.inbox-tools .search .input { width: 100%; }
.inbox-split .inbox-tools { gap: 10px; }
.fu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; align-items: start; }
.fu-grid .fu-card { margin-bottom: 0; height: 100%; }
