:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f1f3f6; --text: #1b1f24; --muted: #667085;
  --line: #e4e7ec; --accent: #3b5bdb; --accent-soft: #e7ecfd; --accent-text: #fff;
  --hot: #d9480f; --hot-soft: #fff0e6; --ok: #2b8a3e; --ok-soft: #e9f7ec;
  --warn: #b08800; --warn-soft: #fff8db; --err: #c92a2a; --err-soft: #fdecec;
  --order: #3b5bdb; --vacancy: #9c36b5; --resume: #0b7285;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #191d23; --panel-2: #20252d; --text: #e6e8eb; --muted: #98a2b3;
    --line: #2b313a; --accent: #7b93f5; --accent-soft: #232b45; --accent-text: #0d1020;
    --hot: #ff8a4c; --hot-soft: #3a2418; --ok: #69db7c; --ok-soft: #1c2f22;
    --warn: #ffd43b; --warn-soft: #34301a; --err: #ff8787; --err-soft: #3a1f1f;
    --order: #91a7ff; --vacancy: #e599f7; --resume: #66d9e8;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.brand .dot.paused { background: var(--warn); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar form { margin: 0; }
.main { padding: 24px 32px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.order { background: var(--accent-soft); color: var(--order); }
.pill.vacancy { background: color-mix(in srgb, var(--vacancy) 14%, transparent); color: var(--vacancy); }
.pill.resume { background: color-mix(in srgb, var(--resume) 14%, transparent); color: var(--resume); }
.pill.hot { background: var(--hot-soft); color: var(--hot); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.s-high { color: var(--hot); } .score.s-mid { color: var(--warn); } .score.s-low { color: var(--muted); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); margin-bottom: 16px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 16px 0 0; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
textarea { min-height: 90px; resize: vertical; }
textarea.tall { min-height: 160px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; }
.filters input[type=search] { min-width: 220px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* lead cards */
.leads { display: flex; flex-direction: column; gap: 10px; }
.lead { padding: 14px 16px; }
.lead-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-head .src { color: var(--muted); font-size: 13px; }
.lead-head .time { margin-left: auto; color: var(--muted); font-size: 12px; }
.lead-title { font-weight: 600; margin: 6px 0 2px; font-size: 15px; }
.lead-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.lead-text { white-space: pre-wrap; word-break: break-word; max-height: 4.5em; overflow: hidden; position: relative; color: var(--text); }
.lead-text.open { max-height: none; }
.lead-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.lead-actions .done { font-weight: 600; color: var(--ok); }
.lead .reason { font-size: 12px; color: var(--muted); font-style: italic; }
.lead.acted { opacity: .75; }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.chart .bars { flex: 1; width: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; border-radius: 4px; overflow: hidden; }
.chart .bars span { display: block; width: 100%; }
.chart .b-order { background: var(--order); } .chart .b-vacancy { background: var(--vacancy); } .chart .b-resume { background: var(--resume); }
.chart .day { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel .step { display: grid; grid-template-columns: 150px 1fr 60px; align-items: center; gap: 10px; font-size: 13px; }
.funnel .bar { height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }

/* status list */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-item { display: flex; align-items: center; gap: 10px; }
.status-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-item .dot.on { background: var(--ok); } .status-item .dot.err { background: var(--err); } .status-item .dot.off { background: var(--warn); }
.status-item .name { font-weight: 600; }
.check-result { margin-top: 8px; font-size: 13px; }

/* dynamic rows */
.rows-editor .item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--panel-2); }
.rows-editor .item .row { align-items: flex-end; }
.dialogs { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.dialogs table td { padding: 6px 10px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login h1 { margin-bottom: 4px; }

/* sandbox */
.verdict { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 14px; }
.verdict dt { color: var(--muted); } .verdict dd { margin: 0; }

.mobile-nav { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { display: flex; gap: 4px; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; position: sticky; top: 0; z-index: 5; }
  .mobile-nav a { padding: 6px 10px; border-radius: 8px; color: var(--text); white-space: nowrap; }
  .mobile-nav a.active { background: var(--accent-soft); color: var(--accent); }
  .main { padding: 16px; }
  .grid.k4, .grid.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k2 { grid-template-columns: 1fr; }
  .funnel .step { grid-template-columns: 110px 1fr 50px; }
}

/* onboarding & help */
.nav a .badge { margin-left: auto; background: var(--hot); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.side-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel-2); font-size: 13px; }
.side-box code { font-size: 11px; }
.side-title { font-weight: 600; margin-bottom: 6px; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.progress span { display: block; height: 100%; background: var(--ok); }
.help { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: var(--radius); padding: 0; margin-bottom: 16px; }
.help summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; }
.help summary::-webkit-details-marker { display: none; }
.help summary::after { content: "свернуть"; float: right; font-weight: 400; font-size: 12px; color: var(--muted); }
.help:not([open]) summary::after { content: "показать"; }
.help-body { padding: 0 16px 12px; }
.help-body ol, .help-body ul { margin: 4px 0; padding-left: 20px; }
.help-body li { margin: 3px 0; }
.help-body p { margin: 6px 0; }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: start; }
.step .mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.step.done .mark { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.step.todo.req .mark { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.step h3 { margin: 3px 0 2px; font-size: 15px; }
.step.done h3 { color: var(--muted); }
.step ol { margin: 8px 0 0; padding-left: 20px; } .step li { margin: 3px 0; }
.step details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-top: 4px; }
.cmd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-x: auto; margin: 6px 0; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
