/* ============ Theme tokens ============
   Dark is the default; light is opt-in via the theme switch. Chart colours are the validated
   categorical palette (light and dark steps), status colours are reserved for state. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0b;
  --surface-1: #161616;
  --surface-2: #1d1d1d;
  --surface-3: #262626;
  --text-primary: #efefef;
  --text-secondary: #9c9c9c;
  --text-tertiary: #767676;
  --grid: #2a2a2a;
  --axis: #474747;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --hover: rgba(255, 255, 255, 0.05);
  --accent: #338ced;
  --accent-soft: rgba(51, 140, 237, 0.16);
  --series-1: #338ced;
  --series-2: #e76624;
  --series-3: #00a888;
  --series-4: #d28e05;
  --good: #0aac23;
  --good-text: #53c556;
  --warning: #fbb315;
  --serious: #f18a59;
  --critical: #dc3c3d;
  --critical-text: #f07373;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --btn-primary-bg: #efefef;
  --btn-primary-fg: #111111;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f6f6f6;
  --surface-1: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #efefef;
  --text-primary: #191919;
  --text-secondary: #666666;
  --text-tertiary: #8a8a8a;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.16);
  --hover: rgba(11, 11, 11, 0.04);
  --accent: #257de0;
  --accent-soft: rgba(37, 125, 224, 0.12);
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --series-4: #f2a600;
  --good-text: #006c10;
  --critical-text: #c42f30;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  --btn-primary-bg: #191919;
  --btn-primary-fg: #ffffff;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -0.015em; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
.sub { color: var(--text-secondary); margin: 2px 0 0; font-size: 13px; }
.muted { color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }
kbd {
  font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--border-strong); color: var(--text-secondary); margin-left: 6px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ============ Buttons & inputs ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; color: var(--text-primary); font-size: 13px; font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn.primary { background: var(--btn-primary-bg); color: var(--btn-primary-fg); border-color: transparent; }
.btn.primary:hover { opacity: 0.9; background: var(--btn-primary-bg); }
.btn.primary kbd { color: inherit; border-color: currentColor; opacity: 0.5; }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--hover); color: var(--text-primary); }
.btn.icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn.danger { color: var(--critical-text); }
.btn svg { width: 16px; height: 16px; flex: none; }

input[type="text"], input[type="email"], input[type="search"], input[type="number"], input[type="password"], input[type="date"], select, textarea {
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; width: 100%; color: var(--text-primary); transition: border-color 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.55; }
label.field { display: flex; flex-direction: column; gap: 5px; color: var(--text-secondary); font-size: 12px; font-weight: 500; }
label.field .opt { font-weight: 400; color: var(--text-tertiary); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: none; border: 0; border-radius: 6px; padding: 5px 11px; cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.seg button:hover { color: var(--text-primary); background: var(--hover); }
.seg button[aria-checked="true"] { background: var(--surface-3); color: var(--text-primary); font-weight: 500; }
.seg button .count { color: var(--text-tertiary); margin-left: 4px; font-variant-numeric: tabular-nums; }
select.compact { width: auto; padding: 6px 10px; font-size: 13px; }
input.compact { width: 220px; padding: 6px 10px; font-size: 13px; }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px; padding: 0 28px; height: 60px;
  background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand .logo svg { width: 15px; height: 15px; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs a {
  display: flex; align-items: center; gap: 7px; padding: 0 12px; color: var(--text-secondary);
  text-decoration: none; font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text-primary); }
.tabs a[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--text-primary); }
.tabs .badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.conn { position: relative; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); flex: none; display: inline-block; }
.dot.live { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.dot.syncing { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot.error { background: var(--critical); }
@keyframes pulse { 50% { opacity: 0.35; } }

.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 320px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px;
}
.popover .row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; }
.popover .row small { display: block; color: var(--text-secondary); font-size: 12px; }

/* ============ Layout ============ */
main { max-width: 1240px; margin: 0 auto; padding: 28px 28px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head .count { color: var(--text-tertiary); font-weight: 500; margin-left: 4px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-charts { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
main.loading .card { opacity: 0.7; transition: opacity 0.15s; }

/* ============ Summary chips (Today) ============ */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.chip { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.chip .label { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.chip .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.chip .value small { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.chip .note { color: var(--text-tertiary); font-size: 12px; }

/* ============ Lists (due, awaiting) ============ */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--grid); }
.list li:first-child { border-top: 0; }
.list .who { flex: 1; min-width: 0; }
.list .who .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; max-width: 100%; display: block; }
.list .who .name:hover { text-decoration: underline; }
.list .who small { display: block; color: var(--text-secondary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { text-align: right; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.list .meta b { display: block; color: var(--text-primary); font-weight: 500; font-size: 13px; }
.list .meta .overdue { color: var(--critical-text); }
.empty-state { text-align: center; padding: 28px 12px; color: var(--text-secondary); }
.empty-state .big { font-size: 22px; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 13px; }

/* ============ Mailbox cards ============ */
.mailboxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mailbox { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.mailbox .top { display: flex; align-items: center; gap: 8px; }
.mailbox .top .who { flex: 1; min-width: 0; }
.mailbox .top .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox .top .who small { color: var(--text-secondary); font-size: 12px; }
.mailbox .usage { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mailbox .usage .big { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mailbox .usage .big small { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.mailbox .usage .lvl { font-size: 12px; color: var(--text-secondary); text-align: right; }
.meter { display: block; height: 6px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s; }
.meter.full > i { background: var(--critical); }
.mailbox .facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; font-size: 12px; color: var(--text-secondary); }
.mailbox .facts b { display: block; color: var(--text-primary); font-weight: 500; font-size: 14px; font-variant-numeric: tabular-nums; }
.mailbox .actions { display: flex; gap: 6px; margin-top: auto; }

/* ============ Status ============ */
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
.ico {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; flex: none;
  font-size: 10px; font-weight: 700; color: #fff; background: var(--axis); font-style: normal; line-height: 1;
}
.status.replied .ico { background: var(--accent); }
.status.deal .ico, .ico.ok { background: var(--good); }
.status.unsuccessful .ico, .ico.back { background: var(--critical); }
.status.bounced .ico { background: var(--serious); color: #0b0b0b; }
.status.active .ico { background: transparent; border: 2px solid var(--axis); }
.ico.hold { background: var(--warning); color: #0b0b0b; }
.note-line { display: flex; gap: 7px; align-items: flex-start; font-size: 12px; color: var(--text-secondary); }
.note-line .ico { margin-top: 1px; }
.tag { display: inline-block; font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 5px; margin-left: 6px; }

/* ============ Analytics ============ */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .label { color: var(--text-secondary); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.tile .note { color: var(--text-tertiary); font-size: 12px; min-height: 1.4em; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 0 -4px; }

.chart { margin-top: 12px; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart text.val { fill: var(--text-primary); font-size: 12px; }
.chart text.cat { fill: var(--text-primary); font-size: 12px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--hover); }
.chart .nodata { fill: var(--text-secondary); font-size: 13px; }
.legend { list-style: none; display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 0; padding: 0; color: var(--text-secondary); font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.tableview { margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.tableview summary { cursor: pointer; }
.tableview table { border-collapse: collapse; margin-top: 8px; width: 100%; font-variant-numeric: tabular-nums; }
.tableview th, .tableview td { text-align: right; padding: 3px 8px; border-bottom: 1px solid var(--grid); }
.tableview th:first-child, .tableview td:first-child { text-align: left; }

/* ============ Tables (prospects) ============ */
.table-wrap { overflow-x: auto; margin: 0 -20px -18px; }
table.data { width: 100%; border-collapse: collapse; }
.data th {
  text-align: left; font-weight: 500; color: var(--text-tertiary); font-size: 12px; padding: 8px 12px;
  border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.data th:first-child, .data td:first-child { padding-left: 20px; }
.data th:last-child, .data td:last-child { padding-right: 20px; }
.data td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.data tbody tr { cursor: pointer; transition: background 0.1s; }
.data tbody tr:hover td { background: var(--hover); }
.data tbody tr:last-child td { border-bottom: 0; }
.data .who { display: flex; flex-direction: column; min-width: 0; }
.data .who b { font-weight: 500; }
.data .who small { color: var(--text-secondary); font-size: 12px; }
.data .right { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============ Menu ============ */
.menu {
  position: fixed; z-index: 60; min-width: 210px; background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow); padding: 5px;
}
.menu button {
  display: flex; width: 100%; align-items: center; gap: 8px; text-align: left; background: none; border: 0;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-primary);
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button.danger { color: var(--critical-text); }
.menu hr { border: 0; border-top: 1px solid var(--grid); margin: 4px 0; }

/* ============ Dialogs & drawer ============ */
dialog {
  color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: var(--shadow); padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
dialog.modal { width: min(640px, calc(100vw - 32px)); }
.modal form, .modal .body { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.modal-foot .spacer { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: -8px 0 0; font-size: 12px; color: var(--text-tertiary); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
code.ph { font: 12px ui-monospace, monospace; background: var(--surface-3); border: 0; border-radius: 4px; padding: 2px 5px; color: var(--text-secondary); cursor: pointer; }
code.ph:hover { color: var(--text-primary); }
.callout { font-size: 13px; color: var(--text-secondary); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: -4px 0 0; }
.callout b { color: var(--text-primary); font-weight: 500; }
.callout.warn { color: var(--critical-text); border-color: color-mix(in srgb, var(--critical) 35%, transparent); background: color-mix(in srgb, var(--critical) 8%, transparent); }
.form-error { margin: 0; color: var(--critical-text); font-size: 13px; }

dialog.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(460px, 100vw); border-radius: 0;
  border-width: 0 0 0 1px;
}
.drawer .body { padding: 22px; display: flex; flex-direction: column; gap: 20px; }
.drawer .facts { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; margin: 0; }
.drawer .facts dt { color: var(--text-secondary); }
.drawer .facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.drawer .drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 14px; width: 2px; background: var(--grid); }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 1px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--axis); }
.timeline li.out::before { border-color: var(--accent); }
.timeline li.reply::before { background: var(--good); border-color: var(--good); }
.timeline li.bounce::before { background: var(--serious); border-color: var(--serious); }
.timeline b { font-weight: 500; }
.timeline small { display: block; color: var(--text-secondary); font-size: 12px; }

/* ============ Templates page ============ */
.tpl-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.tpl-side { padding: 8px; }
.tpl-list { list-style: none; margin: 0; padding: 0; }
.tpl-list .group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); padding: 12px 10px 4px; }
.tpl-list button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px;
  padding: 8px 10px; cursor: pointer; color: var(--text-primary);
}
.tpl-list button:hover { background: var(--hover); }
.tpl-list button[aria-current="true"] { background: var(--surface-3); }
.tpl-list button small { display: block; color: var(--text-secondary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-missing { color: var(--text-tertiary); font-size: 12px; padding: 2px 10px 6px; font-style: italic; }
.tpl-editor form { display: flex; flex-direction: column; gap: 14px; }

/* ============ Tooltip & toast ============ */
.tooltip {
  position: fixed; pointer-events: none; z-index: 70; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow);
  font-size: 12px; min-width: 140px;
}
.tooltip .tt-title { color: var(--text-secondary); margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; }
.tooltip .row strong { font-weight: 600; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.tooltip .row span { color: var(--text-secondary); }
.tooltip .linekey { width: 12px; height: 2px; border-radius: 1px; }
.tooltip .total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--btn-primary-bg); color: var(--btn-primary-fg); border-radius: 10px; padding: 10px 16px;
  font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

@media (max-width: 1000px) {
  .summary, .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-charts, .tpl-layout { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 16px; }
  .brand span { display: none; }
  main { padding: 20px 16px 48px; }
}
@media (max-width: 620px) { .row2 { grid-template-columns: 1fr; } .tabs a { padding: 0 8px; } }
.stack > .seg { align-self: flex-start; }
.btn.more { color: var(--text-secondary); padding: 4px 8px; }

.tiles { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.attach { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: -4px; }
.attach-list { display: flex; gap: 6px; flex-wrap: wrap; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--surface-3); border-radius: 6px; padding: 3px 4px 3px 8px; }
.file-chip button { background: none; border: 0; color: var(--text-secondary); cursor: pointer; padding: 0 4px; }
.data.static tbody tr { cursor: default; }
.rate { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.rate .meter { width: 80px; flex: none; }
.best { font-size: 11px; color: var(--good-text); border: 1px solid color-mix(in srgb, var(--good) 40%, transparent); border-radius: 5px; padding: 0 5px; }
.tpl-list .seq-group { font-size: 12px; font-weight: 600; color: var(--text-primary); padding: 12px 10px 2px; }
.tpl-list .seq-group:first-child { padding-top: 4px; }

dialog.modal.wide { width: min(980px, calc(100vw - 32px)); }
.maps-form { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 10px; align-items: end; }
.maps-results { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.maps-results:empty { display: none; }
.maps-results table { width: 100%; border-collapse: collapse; font-size: 13px; }
.maps-results th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 500; color: var(--text-tertiary); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--grid); }
.maps-results td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.maps-results tr.known td { opacity: 0.55; }
.maps-results input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.maps-results small { display: block; color: var(--text-secondary); font-size: 12px; }
.badge-size { display: inline-block; font-size: 11px; border-radius: 5px; padding: 0 6px; margin-left: 6px; border: 1px solid var(--border-strong); color: var(--text-secondary); }
.badge-size.fit { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge-size.big { color: var(--critical-text); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.stage { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.stage i { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); }
.stage.qualified i { background: var(--accent); }
.stage.ready i { background: var(--good); }
.stage.contacted i { background: var(--text-primary); }
.stage.rejected i { background: var(--critical); }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.issues li { font-size: 12px; display: flex; gap: 7px; align-items: flex-start; color: var(--text-secondary); }
.issues li.block { color: var(--critical-text); }
.scan-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.scan-box .em { display: flex; align-items: center; gap: 8px; }
.scan-box .em span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-box a { color: var(--text-secondary); }
.footer-preview { white-space: pre-line; border-left: 2px solid var(--grid); padding-left: 10px; margin-top: -6px; }
#lead-form h3 { margin-top: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
a.btn { text-decoration: none; }
.email-preview { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); padding: 10px 12px; font-size: 13px; }
.email-preview-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-tertiary); margin-bottom: 6px; }
.email-preview-missing { color: var(--critical-text); }
.email-preview-subject { font-weight: 500; color: var(--text-primary); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.email-preview-body { white-space: pre-wrap; color: var(--text-secondary); max-height: 260px; overflow-y: auto; }
.email-preview mark { color: inherit; border-radius: 3px; padding: 0 2px; }
.email-preview mark.ph-filled { background: color-mix(in srgb, var(--series-1) 18%, transparent); }
.email-preview mark.ph-missing { background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical-text); }

/* ============ Settings ============ */
.set-form { display: flex; flex-direction: column; gap: 22px; }
.set-section { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--grid); }
.set-section:first-child { padding-top: 0; border-top: 0; }
.set-section > .sub { margin-top: -8px; }
.row4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.row4 .span2 { grid-column: span 2; }
label.field.narrow { max-width: 320px; }
label.field[hidden] { display: none; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; margin: 0; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list .who .tagline { color: var(--text-tertiary); }
.list .row-actions { flex: none; }
.callout.ok { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 8%, transparent); }
.callout ul { margin: 0; padding-left: 18px; }
@media (max-width: 1000px) { .row4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .row4 { grid-template-columns: 1fr; } .row4 .span2 { grid-column: auto; } }
