/* Layout: fixed navy rail on the left, working area on the right (rail becomes a top bar on phones).
   Type: Onest for UI (supports Cyrillic names), JetBrains Mono for slugs and IDs. */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceff3;
  --ink: #131a27;
  --ink-2: #485164;
  --muted: #7a8396;
  --line: #e2e6ec;
  --line-2: #eef1f4;
  --rail: #0f1b33;
  --rail-2: #1b2b4b;
  --rail-ink: #c9d2e3;
  --accent: #c8963e;
  --accent-soft: #fbf1df;
  --accent-ink: #8a6420;
  --link: #2f6fed;
  --info-bg: #e9f0ff; --info: #2b55b8;
  --violet-bg: #f0eaff; --violet: #6a3fc4;
  --ok: #1f8a5b;   --ok-bg: #e5f4ec;
  --warn: #a96500; --warn-bg: #fff1d9;
  --bad: #c0392b;  --bad-bg: #fdeceb;
  --overlay: rgba(15, 27, 51, .45);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font-ui: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1220; --surface: #151c2c; --surface-2: #1a2235; --surface-3: #1f283c;
    --ink: #e7ebf3; --ink-2: #b6bfd0; --muted: #8590a6; --line: #273249; --line-2: #212a3e;
    --rail: #0a1120; --rail-2: #18243d; --rail-ink: #b9c4d8;
    --accent-soft: #3a2e17; --accent-ink: #e8c27c; --link: #7aa5ff;
    --info-bg: #1c2b4d; --info: #9dbaff; --violet-bg: #2b2148; --violet: #c3a8ff;
    --ok: #5fd39c; --ok-bg: #14352a; --warn: #f2b65a; --warn-bg: #3a2a10; --bad: #ff8a7d; --bad-bg: #3d1b1b;
    --overlay: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1220; --surface: #151c2c; --surface-2: #1a2235; --surface-3: #1f283c;
  --ink: #e7ebf3; --ink-2: #b6bfd0; --muted: #8590a6; --line: #273249; --line-2: #212a3e;
  --rail: #0a1120; --rail-2: #18243d; --rail-ink: #b9c4d8;
  --accent-soft: #3a2e17; --accent-ink: #e8c27c; --link: #7aa5ff;
  --info-bg: #1c2b4d; --info: #9dbaff; --violet-bg: #2b2148; --violet: #c3a8ff;
  --ok: #5fd39c; --ok-bg: #14352a; --warn: #f2b65a; --warn-bg: #3a2a10; --bad: #ff8a7d; --bad-bg: #3d1b1b;
  --overlay: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font-ui); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); color: var(--ink-2); padding: 2px 6px; border-radius: 5px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h3 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.pad { padding: 18px; }
.danger { color: var(--bad); font-weight: 600; }
.cap { text-transform: capitalize; }
.boot { padding: 40px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* layout */
#app { height: 100%; }
.layout { display: flex; height: 100%; }
.sidebar { width: 224px; flex-shrink: 0; background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; padding-block: 18px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #0f1b33; display: grid; place-items: center; font-weight: 700; font-size: 17px; flex-shrink: 0; }
.brand-mark.big { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; margin: 0 auto 14px; }
.brand-name { color: #fff; font-weight: 600; font-size: 14px; }
.brand-sub { font-size: 10.5px; letter-spacing: .16em; color: var(--accent); font-weight: 700; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--rail-ink); padding: 9px 12px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.sidebar nav a:hover { background: var(--rail-2); color: #fff; }
.sidebar nav a.active { background: var(--rail-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.me { font-size: 12px; color: var(--rail-ink); opacity: .75; margin: 8px 0 4px; word-break: break-all; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; font-size: 12px; }
.demo-pill { display: inline-block; font-size: 10px; letter-spacing: .12em; font-weight: 700; color: #0f1b33; background: var(--accent); border-radius: 999px; padding: 3px 8px; }
main#view { flex: 1; min-width: 0; overflow: auto; padding-block: 26px 60px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-sub { margin: -8px 0 16px; max-width: 65ch; }
.count { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; font-variant-numeric: tabular-nums; }

/* controls */
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; box-shadow: var(--shadow); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--rail); border-color: var(--rail); color: #fff; }
.btn-primary:hover { background: var(--rail-2); border-color: var(--rail-2); }
.btn-block { width: 100%; padding: 11px; margin-top: 6px; }
.icon-btn { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--link) 30%, transparent); border-color: var(--link); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.filters { display: grid; grid-template-columns: 1fr 180px 200px; gap: 10px; margin-bottom: 14px; }

/* cards & tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 8px 6px; background: transparent; }
.table .num { text-align: right; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who.big { gap: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; background: var(--rail); color: var(--accent); }
.tags-cell { max-width: 260px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

/* badges & chips */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.type { background: var(--info-bg); color: var(--info); font-weight: 500; }
.st-lead { background: var(--surface-3); color: var(--ink-2); }
.st-booked { background: var(--info-bg); color: var(--info); }
.st-consulted { background: var(--violet-bg); color: var(--violet); }
.st-offer_sent { background: var(--warn-bg); color: var(--warn); }
.st-student { background: var(--ok-bg); color: var(--ok); }
.st-lost { background: var(--bad-bg); color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 2px 8px; margin: 2px 4px 2px 0; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-weight: 500; font-family: var(--font-mono); }
.chip-clf { background: var(--accent-soft); color: var(--accent-ink); }
.chip-student { background: var(--ok-bg); color: var(--ok); }
.chip-soft { background: var(--info-bg); color: var(--info); font-family: var(--font-ui); }
.chip-x { border: 0; background: none; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; padding: 0 0 0 2px; opacity: .6; }
.chip-x:hover { opacity: 1; }

/* contact card */
.back { display: inline-block; margin-bottom: 12px; font-weight: 500; }
.contact-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.stage-select { width: auto; font-weight: 600; border-radius: 999px; padding: 7px 12px; border: 0; }
.contact-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dl { display: grid; grid-template-columns: 96px 1fr; gap: 9px 10px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12.5px; }
.dl dd { margin: 0; min-width: 0; }
.note-box { margin-top: 12px; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; white-space: pre-wrap; }
.tags-wrap { margin-bottom: 10px; }
.inline-form { display: flex; gap: 8px; }
.consent-row, .list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.consent-row:last-child, .list-row:last-child { border-bottom: 0; }
.list-row > div { min-width: 0; }
.mini-select { width: auto; font-size: 12.5px; padding: 5px 8px; flex-shrink: 0; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.tl-item:last-child { border-bottom: 0; }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.tl-payment .tl-dot { background: var(--ok-bg); color: var(--ok); }
.tl-refund .tl-dot { background: var(--bad-bg); color: var(--bad); }
.tl-note .tl-dot { background: var(--accent-soft); color: var(--accent-ink); }
.tl-form_submit .tl-dot { background: var(--info-bg); color: var(--info); }
.tl-subscription .tl-dot { background: var(--accent-soft); color: var(--accent-ink); }
.tl-body { flex: 1; min-width: 0; }
.tl-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tl-text { margin-top: 4px; white-space: pre-wrap; color: var(--ink-2); }
.answers { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; margin: 6px 0 0; font-size: 12.5px; }
.answers dt { color: var(--muted); text-transform: capitalize; }
.answers dd { margin: 0; }

/* pipeline */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.seg a { padding: 6px 12px; border-radius: 7px; color: var(--ink-2); font-weight: 500; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column { flex: 0 0 244px; background: var(--surface-3); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.column.drop { outline: 2px dashed var(--link); outline-offset: -2px; }
.col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 11px 12px 8px; font-weight: 600; }
.col-meta { font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.col-won .col-head { color: var(--ok); }
.col-lost .col-head { color: var(--bad); }
.col-body { padding: 0 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-empty { color: var(--muted); opacity: .6; text-align: center; padding: 14px 0; }
.deal-card { background: var(--surface); border-radius: 8px; padding: 10px 11px; box-shadow: var(--shadow); cursor: grab; border: 1px solid transparent; }
.deal-card:hover { border-color: var(--line); }
.deal-card.dragging { opacity: .45; }
.deadline { margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.deadline.soon { color: var(--warn); }
.deadline.over { color: var(--bad); }

/* campaigns */
.slug { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); border: 0; border-radius: 6px; padding: 3px 8px; cursor: pointer; color: var(--ink-2); }
.slug:hover { color: var(--ink); }
.howto { margin-top: 18px; }
.howto p { max-width: 70ch; }
.copy-line { display: flex; gap: 8px; align-items: center; margin: 8px 0; min-width: 0; }
.copy-line code { flex: 1; min-width: 0; padding: 9px 10px; overflow-x: auto; white-space: nowrap; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 50; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 6px; }
.modal-head h3 { text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--ink); margin: 0; }
.modal-body { padding: 10px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.form-error { margin: 0 20px; padding: 9px 12px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); font-weight: 500; }
.login-card .form-error { margin: 10px 0 0; }
#toast-root { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: calc(20px + env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--rail); color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; font-weight: 500; }
.toast.show { opacity: 1; transform: none; }
.toast-err { background: var(--bad); }

/* login / misc */
.login-wrap { min-height: 100%; display: grid; place-items: center; background: var(--rail); padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-card { background: var(--surface); padding: 32px 30px; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h1 { font-size: 21px; }
.login-card p { margin: -6px 0 6px; }
.login-card label { text-align: left; }
.center-card { max-width: 420px; margin: 12vh auto; background: var(--surface); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; height: auto; min-height: 100%; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding-block: 10px; padding-right: max(12px, env(safe-area-inset-right, 0px)); gap: 10px; }
  .brand { padding: 0; }
  .brand-name, .brand-sub { display: none; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { padding: 7px 10px; font-size: 13px; }
  .sidebar-foot { display: none; }
  main#view { padding-block: 16px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); overflow: visible; }
  .filters { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: minmax(0, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .column { flex-basis: 78vw; max-height: none; }
}

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi:first-child { background: var(--rail); border-color: var(--rail); }
.kpi:first-child .kpi-label, .kpi:first-child .kpi-sub { color: var(--rail-ink); }
.kpi:first-child .kpi-value { color: #fff; }
.kpi-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-sub.up { color: var(--ok); }
.kpi-sub.down { color: var(--bad); }
.kpi:first-child .kpi-sub.up { color: #7fe0ae; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.link-row { color: inherit; }
.link-row:hover .strong { color: var(--link); }
.deadline-pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.deadline-pill.soon { background: var(--warn-bg); color: var(--warn); }
.deadline-pill.over { background: var(--bad-bg); color: var(--bad); }
.stage-bars { display: flex; flex-direction: column; gap: 8px; }
.stage-bar { display: grid; grid-template-columns: 96px 1fr 36px; align-items: center; gap: 10px; color: inherit; }
.sb-label { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.sb-fill { display: block; height: 100%; border-radius: 999px; }
.sb-fill.src { background: var(--accent); }
.sb-fill.st-lead { background: var(--muted); }
.sb-fill.st-booked { background: var(--info); }
.sb-fill.st-consulted { background: var(--violet); }
.sb-fill.st-offer_sent { background: var(--warn); }
.sb-fill.st-student { background: var(--ok); }
.sb-fill.st-lost { background: var(--bad); }
.sb-n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.compact-tl .tl-item { padding: 8px 0; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }

/* import */
.head-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-wide { max-width: 760px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 34px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer; color: var(--ink); background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--link); }
.form-error.inline { margin: 10px 0 0; }
.file-line { margin-bottom: 8px; font-family: var(--font-mono); }
.map-table-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.map-table th { position: sticky; top: 0; background: var(--surface-2); }
.map-table td.ex { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.map-table select { padding: 5px 8px; font-size: 12.5px; }
.import-opts { margin-top: 14px; }
.map-summary { margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: var(--info-bg); color: var(--info); font-size: 13px; }
.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; }
.progress span { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; text-align: center; padding: 10px 0; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .result-grid { grid-template-columns: 1fr; }
}

/* settings & messaging */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 920px; }
.sec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.sec-title { font-size: 16px; font-weight: 600; margin: 0 0 2px; }
.sec-head p { margin: 0; max-width: 60ch; }
.integ-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.integ-main { min-width: 0; flex: 1 1 280px; }
.integ-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.integ-err { margin-top: 6px; font-size: 12.5px; color: var(--bad); }
.integ-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; box-shadow: none; }
.btn-danger { color: var(--bad); }
.help { margin: 0; }
.warn-box { margin-bottom: 12px; padding: 9px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.msg-bubble { margin-top: 6px; padding: 8px 11px; border-radius: 10px; max-width: 60ch; }
.msg-bubble.out { background: var(--info-bg); color: var(--ink); }
.msg-bubble.in { background: var(--surface-3); color: var(--ink); }
.tl-email_sent .tl-dot, .tl-sms_sent .tl-dot { background: var(--info-bg); color: var(--info); }
.tl-email_received .tl-dot, .tl-sms_received .tl-dot { background: var(--violet-bg); color: var(--violet); }

/* inbox */
.nav-badge { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: #0f1b33; font-size: 11px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.nav-badge[hidden] { display: none; }
.inbox { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 14px; height: calc(100vh - 86px); min-height: 480px; }
.inbox-list, .inbox-thread { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.inbox-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
#threads { overflow-y: auto; flex: 1; }
.thread-row { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line-2); color: inherit; }
.thread-row:hover { background: var(--surface-2); }
.thread-row.on { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--accent); }
.tr-main { flex: 1; min-width: 0; }
.tr-top { display: flex; justify-content: space-between; gap: 8px; }
.tr-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-row.unread .tr-name { font-weight: 700; }
.tr-sub { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.thread-row.unread .tr-sub { color: var(--ink); }
.ch { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 5px; margin-right: 6px; background: var(--info-bg); color: var(--info); }
.ch-sms { background: var(--violet-bg); color: var(--violet); }
.unread-n { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #0f1b33; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.thread-empty { margin: auto; text-align: center; padding: 30px; max-width: 40ch; display: flex; flex-direction: column; gap: 6px; }
.thread-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.thread-head .who { flex: 1; }
.thread-back { display: none; font-size: 20px; padding: 0 6px 0 0; color: var(--ink-2); }
.thread-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.tm { display: flex; flex-direction: column; max-width: 78%; }
.tm.in { align-self: flex-start; }
.tm.out { align-self: flex-end; align-items: flex-end; }
.tm-meta { font-size: 11.5px; color: var(--muted); margin: 0 4px 3px; }
.tm-bubble { padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--line); }
.tm.out .tm-bubble { background: var(--info-bg); border-color: transparent; }
.tm-subj { font-weight: 600; margin-bottom: 4px; }
.tm-err { font-size: 12px; color: var(--bad); margin: 3px 4px 0; }
.reply { border-top: 1px solid var(--line); padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.reply-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reply-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.seg-sm a { padding: 4px 10px; font-size: 12.5px; }
.thread-note { padding: 14px 16px; border-top: 1px solid var(--line); }
.ai-row { display: flex; gap: 8px; align-items: center; }
.ai-row input { flex: 1; min-width: 0; }
.btn-ai { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn-ai:hover { border-color: var(--accent); }
.tl-booking .tl-dot { background: var(--info-bg); color: var(--info); }
.tl-booking_canceled .tl-dot { background: var(--bad-bg); color: var(--bad); }

@media (max-width: 900px) {
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .inbox.has-thread .inbox-list { display: none; }
  .inbox:not(.has-thread) .inbox-thread { display: none; }
  .inbox-thread { height: calc(100vh - 120px); min-height: 420px; }
  .thread-back { display: inline-block; }
  .tm { max-width: 92%; }
  .ai-row { flex-direction: column; align-items: stretch; }
}

/* automations */
.mt { margin-top: 14px; }
.cb { width: 34px; padding-right: 0 !important; }
.cb input { width: 16px; height: 16px; cursor: pointer; }
.bulk-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 14px; margin-bottom: 10px; background: var(--rail); color: #fff; border-radius: var(--radius); }
.bulk-bar[hidden] { display: none; }
.bulk-bar .btn { background: var(--rail-2); color: #fff; border-color: transparent; }
.sec-intro { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin: -4px 0 14px; flex-wrap: wrap; }
.sec-intro p { margin: 0; max-width: 72ch; }
.info-box { margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; background: var(--info-bg); color: var(--info); }
.warn-text { color: var(--warn); font-weight: 600; }
.seq-grid, .tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.seq-card, .tpl-card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.seq-card:hover, .tpl-card:hover { border-color: var(--muted); }
.seq-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.seq-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.seq-steps .ch { margin: 0; }
.seq-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seq-stats b { color: var(--ink); }
.seq-stats.big { font-size: 13px; margin-bottom: 12px; }
.seq-edit { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.switch { flex-direction: row; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.switch input { width: 40px; height: 22px; appearance: none; -webkit-appearance: none; background: var(--surface-3); border: 0; border-radius: 999px; position: relative; cursor: pointer; padding: 0; flex-shrink: 0; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 21px; }
.trigger-fields { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.check input { width: auto; }
.checks input[type=datetime-local] { width: auto; }
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; flex-direction: column; gap: 8px; }
.step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--rail); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.when { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 260px; }
.when input { width: 70px; }
.when select { width: auto; }
.step-tools { display: flex; gap: 2px; margin-left: auto; }
.icon-btn.sm { font-size: 17px; padding: 4px 7px; border-radius: 6px; }
.icon-btn.sm:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.step-subj { font-weight: 600; }
.var-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.var-chip { font: inherit; font-size: 11.5px; padding: 3px 8px; border-radius: 6px; border: 1px dashed var(--line); background: var(--surface-2); color: var(--ink-2); cursor: pointer; font-family: var(--font-mono); }
.var-chip:hover { border-color: var(--link); color: var(--link); }
.var-sep { flex: 1; }
.step-add { display: flex; gap: 8px; }
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.enroll-row { display: flex; gap: 8px; margin-bottom: 12px; }
.enroll-row select { flex: 1; }
.reach { font-size: 13px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.reach:empty { display: none; }
.tpl-pick { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.tpl-item { display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.tpl-item:hover { border-color: var(--link); }
.tpl-snip { font-size: 12.5px; color: var(--ink-2); white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.tpl-s { font-weight: 600; font-size: 13px; }
.pv-subj { font-weight: 600; padding: 10px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2); }
.pv-body { white-space: pre-wrap; padding: 12px; border: 1px solid var(--line); border-radius: 0 0 8px 8px; font-size: 13.5px; line-height: 1.5; max-height: 55vh; overflow: auto; }
.pv-body:first-child, p + .pv-body { border-radius: 8px; }
.f-group { margin: 12px 0; }
.f-label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { flex-direction: row; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick span { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); background: var(--surface); }
.pick input:checked + span { background: var(--rail); border-color: var(--rail); color: #fff; }
.pick input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.list-preview { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--info-bg); color: var(--info); font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.list-preview:empty { display: none; }
.danger-link { color: var(--bad); margin-top: 12px; display: inline-block; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { margin-left: 6px; }
#auto-card .sec-head h3 { margin: 0; }
@media (max-width: 900px) {
  .when { min-width: 0; flex-basis: 100%; }
  .when select:last-child { flex: 1; min-width: 0; }
  .step-tools { margin-left: 0; }
}

/* dark theme: primary buttons in gold so they stand out */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { background: var(--accent); border-color: var(--accent); color: #0f1b33; }
  :root:not([data-theme="light"]) .btn-primary:hover { background: #d9a85a; border-color: #d9a85a; }
  :root:not([data-theme="light"]) .pick input:checked + span { background: var(--accent); border-color: var(--accent); color: #0f1b33; }
}
:root[data-theme="dark"] .btn-primary { background: var(--accent); border-color: var(--accent); color: #0f1b33; }
:root[data-theme="dark"] .pick input:checked + span { background: var(--accent); border-color: var(--accent); color: #0f1b33; }
.zoom-box { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.zoom-box p { margin: 0; }
.zoom-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.zoom-row { display: flex; gap: 8px; }
.zoom-row input, .zoom-row select { flex: 1; min-width: 0; }
.tl-attended .tl-dot { background: var(--ok-bg); color: var(--ok); }
.tl-no_show .tl-dot { background: var(--bad-bg); color: var(--bad); }

/* tasks */
.task-add { display: flex; gap: 8px; flex-wrap: wrap; }
.task-add input[name=title] { flex: 1 1 260px; }
.task-add select, .task-add input[type=datetime-local] { width: auto; }
.task-groups { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; max-width: 900px; }
.task-groups h3.danger { color: var(--bad); }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.task-row:last-child { border-bottom: 0; }
.task-cb { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; cursor: pointer; accent-color: var(--ok); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-row .icon-btn { opacity: .35; }
.task-row:hover .icon-btn, .task-row .icon-btn.armed { opacity: 1; }
.icon-btn.armed { font-size: 12px; color: var(--bad); }
.due { font-weight: 600; color: var(--ink-2); }
.due.today { color: var(--warn); }
.due.over { color: var(--bad); }
details > summary { cursor: pointer; padding: 4px 0; }
#c-task-form { margin-top: 10px; }
#c-task-form .task-add input[name=title] { flex-basis: 100%; }
.ch-task { background: var(--ok-bg); color: var(--ok); }
.tl-task_done .tl-dot { background: var(--ok-bg); color: var(--ok); }
.pw-box { white-space: pre-wrap; font-family: var(--font-mono); font-size: 13px; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
button.me { display: block; text-align: left; color: var(--rail-ink); opacity: .85; word-break: break-all; }
button.me:hover { opacity: 1; text-decoration: underline; }

/* payments & call result */
.sort-row { display: flex; gap: 6px; flex-wrap: wrap; }
.sort-row select { width: auto; max-width: 180px; padding: 5px 8px; font-size: 12.5px; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.outcome { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; font: inherit; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; }
.outcome:hover { border-color: var(--link); background: var(--surface-2); }
.o-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; background: var(--surface-3); margin-bottom: 4px; }
.outcome[data-out=offer] .o-ico { background: var(--ok-bg); color: var(--ok); }
.outcome[data-out=noshow] .o-ico { background: var(--bad-bg); color: var(--bad); }
.outcome[data-out=notnow] .o-ico { background: var(--warn-bg); color: var(--warn); }
.outcome[data-out=paid] .o-ico { background: var(--info-bg); color: var(--info); }
.pkg-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line-2); }
.pkg-name { display: flex; flex-direction: column; }
@media (max-width: 900px) { .outcomes, .pkg-row { grid-template-columns: 1fr; } }

/* 018: packages + access */
.pkg-block { padding: 14px 0; border-top: 1px solid var(--line-2); }
.pkg-block .pkg-name { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.preview-box { border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; background: var(--bg-2, transparent); }
.preview-box pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; max-height: 260px; overflow: auto; }
.outcome[data-out="access"] { grid-column: 1 / -1; }
