:root {
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #f0f3f9; --border: #e2e7f0;
  --text: #0f172a; --muted: #5b6780; --accent: #2563eb; --accent-text: #ffffff;
  --ok: #0f8a5f; --warn: #b45309; --bad: #c2410c; --chip: #e8eefc;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 12px; --sidebar: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #121a2e; --surface-2: #18223a; --border: #24304d;
    --text: #e6ebf5; --muted: #94a3c0; --accent: #4f8cff; --accent-text: #08101f;
    --ok: #34d399; --warn: #fbbf24; --bad: #fb7185; --chip: #1d2a48;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #121a2e; --surface-2: #18223a; --border: #24304d;
  --text: #e6ebf5; --muted: #94a3c0; --accent: #4f8cff; --accent-text: #08101f;
  --ok: #34d399; --warn: #fbbf24; --bad: #fb7185; --chip: #1d2a48;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button { font: inherit; }
.boot { padding: 40px; color: var(--muted); }

.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 14px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 13px; }
.nav-group { margin: 10px 0 2px; padding: 0 10px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--chip); color: var(--accent); font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.scrim { display: none; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.content { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--muted); padding: 6px 10px; cursor: pointer; }
.seg button.on { background: var(--chip); color: var(--accent); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .lbl { color: var(--muted); font-size: 12px; }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.pill.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; max-width: 100%; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.row > input[type=search], .row > input[type=text] { flex: 1 1 200px; }
label.chk { display: inline-flex; gap: 6px; align-items: center; }

.msg { padding: 8px 12px; border-radius: 10px; margin: 6px 0; max-width: 86%; white-space: pre-wrap; word-break: break-word; }
.msg.in { background: var(--surface-2); }
.msg.out { background: var(--chip); margin-left: auto; }
.msg.system { background: transparent; border: 1px dashed var(--border); color: var(--muted); }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 10px; border-radius: 8px; font-size: 12px; margin: 0; }
audio { width: 100%; max-width: 360px; height: 34px; }
.alert { border: 1px solid var(--border); border-left: 4px solid var(--warn); background: var(--surface); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.alert.bad { border-left-color: var(--bad); }
.empty { color: var(--muted); padding: 18px 4px; }
.toast { position: fixed; bottom: 16px; right: 16px; max-width: min(420px, calc(100vw - 32px)); background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 14px; z-index: 50; box-shadow: var(--shadow); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; grid-column: 1 / -1; }
.login form { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.login form h1 { font-size: 20px; margin: 0 0 4px; }
.login form label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.login form input { width: 100%; }
.login .err { color: var(--bad); min-height: 20px; margin-top: 10px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); transform: translateX(-100%); transition: transform .2s; z-index: 30; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }

  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .val { font-size: 20px; }
  .cols { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
.full { width: 100%; }
.mt { margin-top: 10px; }
.mb { margin-bottom: 8px; }
.center { justify-content: center; }
h2.grow { margin: 0; flex: 1; }

.row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#voice-audio { width: 100%; margin-top: 10px; }

/* Ручной обзвон */
.row.between { justify-content: space-between; align-items: flex-start; }
a.btn { display: inline-block; text-decoration: none; }
.mc-card .row:last-child { margin-bottom: 0; }
.pitch-text { white-space: pre-wrap; line-height: 1.5; font-size: 14px; background: var(--chip); border-radius: 8px; padding: 10px 12px; }
dl.pitch { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; }
dl.pitch dt { color: var(--muted); }
dl.pitch dd { margin: 0; }
@media (max-width: 600px) { dl.pitch { grid-template-columns: 1fr; } dl.pitch dd { margin-bottom: 6px; } }

/* SaaS & human-friendly panel polish */
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-weight: 500; }
.nav-more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 8px; }
.nav-more summary { cursor: pointer; padding: 7px 10px; font-size: 12px; color: var(--muted); list-style: none; user-select: none; border-radius: 8px; }
.nav-more summary:hover { background: var(--surface-2); color: var(--text); }
.nav-more[open] summary { color: var(--text); font-weight: 600; }
.nav-more a { font-size: 13px; padding: 6px 10px; font-weight: 400; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.subtabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 13px; background: var(--surface); border: 1px solid var(--border); }
.subtabs a:hover { background: var(--surface-2); color: var(--text); }
.subtabs a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.qr-box { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-top: 12px; }
.qr-img { width: 220px; height: 220px; border-radius: 8px; background: #ffffff; padding: 8px; display: block; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 10px; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid input, .form-grid select { width: 100%; }
