:root {
  --accent: #0e7c86;
  --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --wa: #22b07d;
  --wa-soft: color-mix(in srgb, var(--wa) 14%, transparent);
  --warn: #e8a317;
  --danger: #e5484d;
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --ink: #1e2033;
  --muted: #6b6f86;
  --faint: #a3a6b8;
  --line: #e6e8f0;
  --bubble-in: #ffffff;
  --bubble-out: color-mix(in srgb, var(--accent) 14%, #ffffff);
  --shadow-1: 0 1px 2px rgba(30, 32, 51, .06);
  --shadow-2: 0 10px 30px -12px rgba(30, 32, 51, .18);
  --r-lg: 18px;
  --r: 12px;
  --r-sm: 8px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', 'Manrope', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161f; --surface: #1d1f2b; --surface-2: #232535; --ink: #e8e9f2; --muted: #9a9db3; --faint: #666980;
    --line: #2c2e40; --bubble-in: #262839; --bubble-out: color-mix(in srgb, var(--accent) 30%, #1d1f2b);
    --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 14px 34px -12px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15161f; --surface: #1d1f2b; --surface-2: #232535; --ink: #e8e9f2; --muted: #9a9db3; --faint: #666980;
  --line: #2c2e40; --bubble-in: #262839; --bubble-out: color-mix(in srgb, var(--accent) 30%, #1d1f2b);
  --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 14px 34px -12px rgba(0,0,0,.6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; position: relative; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.page { flex: 1; overflow-y: auto; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- primitives ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 650; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 20%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; justify-content: center; }
.btn.sm.icon { width: 30px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
label.field .hint { font-weight: 500; color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 14px; align-content: start; }
.grow { flex: 1; min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-1); }
.panel h2 { font-size: 15px; font-weight: 750; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel h2 .right { margin-left: auto; font-weight: 600; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 750; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--wa); background: var(--wa-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: transparent; }
.pill.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: transparent; }
.pill.acc { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.toggle { position: relative; display: inline-block; vertical-align: middle; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: .2s; }
.toggle span::after { content: ''; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: var(--shadow-1); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; font-weight: 650; color: var(--muted); cursor: pointer; font-size: 13px; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .cut { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; align-items: start; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; padding: 0; overflow: hidden; }
.stat { padding: 18px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .v { font-family: var(--display); font-size: 28px; font-weight: 500; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-weight: 600; font-size: 13px; }
.stat .d { font-size: 12px; color: var(--wa); font-weight: 700; }

.pulse-list { display: grid; gap: 10px; }
.pulse { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.ring { position: relative; width: 52px; height: 52px; }
.ring svg { transform: rotate(-90deg); }
.ring .t { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; }
.ring.live circle.fg { transition: stroke-dashoffset 1s linear; }
.pulse .name { font-weight: 750; }
.pulse .meta { color: var(--muted); font-size: 12.5px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wa); box-shadow: 0 0 0 0 var(--wa); animation: ping 2s infinite; display: inline-block; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--wa) 60%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; position: relative; height: 100%; }
.bars .b i { display: block; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .b i.s { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.bars .b i.r { background: var(--wa); }
.bars .b span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 10.5px; color: var(--faint); }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); font-size: 11.5px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.quick { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #2bb9a0)); color: #fff; border: 0; }
.quick h2 { color: #fff; }
.quick .input, .quick select.input { background: rgba(255,255,255,.95); color: #1e2033; border-color: transparent; }
.quick .btn.go { background: #fff; color: var(--accent); border-color: #fff; height: 42px; font-size: 15px; }
.quick .muted { color: rgba(255,255,255,.8); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.ava { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; }

/* ---------- chats ---------- */
.chat-layout { display: grid; grid-template-columns: 330px 1fr 300px; height: 100%; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--surface); min-height: 0; }
.chat-list .top { padding: 16px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.chat-list .top > * { min-width: 0; }
.chat-list .tabs button { padding-left: 2px; padding-right: 2px; font-size: 12px; }
.chat-items { overflow-y: auto; flex: 1; }
.ci { display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; padding: 11px 16px; cursor: pointer; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.ci:hover { background: var(--surface-2); }
.ci.on { background: var(--accent-soft); }
.ci .ava { width: 42px; height: 42px; border-radius: 14px; }
.ci .n { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci .p { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci.unread .p { color: var(--ink); font-weight: 650; }
.ci .tm { font-size: 11.5px; color: var(--faint); text-align: right; display: grid; gap: 4px; justify-items: end; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.msgs { flex: 1; overflow-y: auto; padding: 22px 8%; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 2px 10px; border-radius: 99px; margin: 10px 0; }
.bubble { max-width: 72%; padding: 9px 13px 6px; border-radius: 16px; background: var(--bubble-in); box-shadow: var(--shadow-1); white-space: pre-wrap; word-wrap: break-word; align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }
.bubble .meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); margin-top: 3px; }
.bubble .tag { font-size: 10.5px; font-weight: 750; color: var(--accent); }
.ticks.read { color: #3b9cf5; }
.composer { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); display: grid; gap: 8px; }
.composer .row textarea { flex: 1; min-height: 44px; max-height: 180px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest button { text-align: left; max-width: 100%; border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--ink); padding: 8px 12px; border-radius: 12px; cursor: pointer; font-size: 13px; }
.suggest b { color: var(--accent); display: block; font-size: 11.5px; }
.lead-pane { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.stage-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-picker button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 650; cursor: pointer; }
.stage-picker button.on { color: #fff; border-color: transparent; }
.no-chat { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }

/* ---------- board ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; min-height: calc(100vh - 170px); }
.col { flex: 0 0 272px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; max-height: calc(100vh - 170px); }
.col-head { padding: 12px 14px; display: flex; align-items: center; gap: 8px; font-weight: 750; border-bottom: 1px solid var(--line); }
.col-head .sw { width: 10px; height: 10px; border-radius: 4px; }
.col-head .c { margin-left: auto; color: var(--muted); font-weight: 650; font-size: 12.5px; }
.col-body { padding: 10px; display: grid; gap: 8px; overflow-y: auto; min-height: 80px; align-content: start; }
.col-body.over { background: var(--accent-soft); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-1); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .4; }
.card .t { font-weight: 700; font-size: 13.5px; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- campaigns ---------- */
.camp { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 18px 20px; }
.camp + .camp { border-top: 1px solid var(--line); }
.camp .title { font-weight: 750; font-size: 15px; }
.camp .nums { display: flex; gap: 22px; margin-top: 10px; }
.camp .nums div { font-size: 12px; color: var(--muted); }
.camp .nums b { display: block; font-family: var(--display); font-weight: 500; font-size: 18px; color: var(--ink); }
.variant { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface); display: grid; gap: 10px; }
.variant .vh { display: flex; align-items: center; gap: 10px; }
.vbar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.vbar i { display: block; height: 100%; background: var(--wa); }
.preview-box { background: var(--bg); border-radius: 14px; padding: 14px; display: grid; gap: 8px; }
.preview-box .bubble { max-width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-size: 12px; cursor: pointer; font-family: ui-monospace, monospace; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.acc-check { display: flex; gap: 8px; flex-wrap: wrap; }
.acc-check label { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; cursor: pointer; font-weight: 600; }
.acc-check input:checked + span { color: var(--accent); }

/* ---------- цепочка сообщений ---------- */
.chain { display: grid; gap: 0; }
.step { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--surface-2); display: grid; gap: 12px; }
.step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.step-gap { display: flex; align-items: center; gap: 8px; padding: 10px 0 10px 13px; color: var(--muted); position: relative; }
.step-line { width: 2px; align-self: stretch; background: repeating-linear-gradient(var(--accent) 0 4px, transparent 4px 8px); margin-right: 14px; min-height: 36px; }
.variant .vh { flex-wrap: wrap; }

/* ---------- accounts ---------- */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.acc-card { display: grid; gap: 14px; }
.acc-card .head { display: flex; gap: 12px; align-items: center; }
.qr-box { display: grid; place-items: center; gap: 10px; padding: 16px; background: #fff; border-radius: 14px; border: 1px solid var(--line); color: #1e2033; text-align: center; }
.qr-box img { width: 240px; height: 240px; }
.pair-code { font-family: var(--display); font-size: 28px; letter-spacing: .12em; }
.meter { display: grid; gap: 6px; }
.meter .row { justify-content: space-between; font-size: 12.5px; }

/* ---------- tasks & pomodoro ---------- */
.tasks-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.task { display: grid; grid-template-columns: 24px 1fr auto; gap: 12px; align-items: start; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .chk { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--faint); background: transparent; cursor: pointer; display: grid; place-items: center; color: #fff; padding: 0; }
.task.done .chk { background: var(--wa); border-color: var(--wa); }
.task.done .tt { text-decoration: line-through; color: var(--muted); }
.task .tt { font-weight: 650; }
.task .tm { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.task .tm .late { color: var(--danger); font-weight: 700; }
.prio { width: 4px; align-self: stretch; border-radius: 4px; }

.me { margin-top: auto; padding-top: 10px; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.me-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.cut { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-owner { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 8px 2px 6px; border-radius: 999px; background: color-mix(in srgb, var(--c) 13%, transparent); color: color-mix(in srgb, var(--c) 80%, var(--ink)); white-space: nowrap; }
.chip-owner i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip-owner.none { --c: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.ch { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; flex: none; vertical-align: -4px; }
.ch.wa { color: var(--wa); background: var(--wa-soft); }
.ch.ig { color: #d62976; background: color-mix(in srgb, #d62976 13%, transparent); }
.wait-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); flex: none; }
.owner-box { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.events { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 56px 1fr; gap: 8px; font-size: 12.5px; line-height: 1.4; }
.sec-h { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 0 0 12px; }
.ig-grad { background: linear-gradient(45deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5) !important; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot-online.on { background: var(--wa); box-shadow: 0 0 0 3px var(--wa-soft); }
.cred { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13.5px; white-space: pre-wrap; margin: 0; user-select: all; }
code.sel { user-select: all; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
.tabs .badge { min-width: 18px; height: 18px; font-size: 10.5px; margin-left: 4px; }
.pomo-big { text-align: center; display: grid; gap: 14px; justify-items: center; }
.pomo-big .clock { font-family: var(--display); font-size: 56px; font-weight: 400; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }

/* ---------- AI ---------- */
.md { line-height: 1.65; max-width: 78ch; }
.md h1, .md h2, .md h3 { margin: 22px 0 8px; font-size: 16px; }
.md h1 { font-size: 19px; }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 22px; margin: 8px 0; }
.md li { margin: 4px 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: 10px; white-space: pre-wrap; }
.md table { border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.md td, .md th { border: 1px solid var(--line); padding: 6px 10px; }
.md blockquote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- settings ---------- */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: 0; display: grid; gap: 2px; }
.settings-nav a { padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 650; }
.settings-nav a:hover { background: var(--surface); color: var(--ink); }
.set-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .lbl { flex: 1; }
.set-row .lbl b { display: block; font-weight: 650; }
.set-row .lbl span { color: var(--muted); font-size: 12.5px; }
.set-row .ctl { width: 220px; flex: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; }
.swatches button.on { border-color: var(--ink); }
.days { display: flex; gap: 4px; }
.days label { cursor: pointer; }
.days input { display: none; }
.days span { display: grid; place-items: center; width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted); }
.days input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 21, 34, .45); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 20px; width: min(640px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: var(--shadow-2); animation: pop .18s ease-out; }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 17px; font-weight: 750; }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 22px; display: grid; gap: 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-2); max-width: 360px; animation: pop .2s; cursor: pointer; font-weight: 600; }
.toast.err { background: var(--danger); color: #fff; }
.toast small { display: block; font-weight: 500; opacity: .8; margin-top: 2px; }

.dropzone { border: 2px dashed var(--line); border-radius: 16px; padding: 34px; text-align: center; cursor: pointer; transition: .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.region-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px; }
.region-list label { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.region-list label:hover { background: var(--surface-2); }

.mobile-bar { display: none; }
.mob-back { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .chat-layout { grid-template-columns: 300px 1fr; }
  .lead-pane { display: none; }
  .chat-layout.show-lead .lead-pane { display: grid; position: fixed; right: 0; top: 0; bottom: 0; width: 320px; z-index: 30; box-shadow: var(--shadow-2); }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(3) { border-right: 0; }
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; height: calc(100vh - 62px); }
  .side { display: none; }
  .page { padding: 18px 16px 40px; }
  .mobile-bar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 62px; background: var(--surface); border-top: 1px solid var(--line); z-index: 40; justify-content: space-around; align-items: center; }
  .mobile-bar a { display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: 10.5px; font-weight: 650; position: relative; padding: 4px 8px; }
  .mobile-bar a.active { color: var(--accent); }
  .mobile-bar svg { width: 22px; height: 22px; }
  .mobile-bar .badge { position: absolute; top: -2px; right: 2px; min-width: 17px; height: 17px; font-size: 10px; }
  .mob-back { display: inline-flex !important; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout.open .chat-list { display: none; }
  .chat-layout:not(.open) .thread { display: none; }
  .msgs { padding: 16px 12px; }
  .bubble { max-width: 86%; }
  .grid2, .grid3, .tasks-layout, .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { border-bottom: 1px solid var(--line); }
  .set-row { flex-wrap: wrap; }
  .set-row .ctl { width: 100%; }
  .page-head h1 { font-size: 20px; }
  .camp { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.set-row .ctl:has(.days), .set-row .ctl:has(.swatches) { width: auto; }

.ig-box { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, #d62976 7%, var(--surface)); border: 1px solid color-mix(in srgb, #d62976 25%, var(--line)); }
.ig-box .row, .ig-box { justify-items: start; }
.btn.ig-btn { background: linear-gradient(45deg, #fa7e1e, #d62976, #962fbf); color: #fff; border-color: transparent; }
