:root {
  --bg: #f4f6f5; --panel: #ffffff; --ink: #18211f; --muted: #66726f; --line: #dfe5e3;
  --accent: #0f5c4d; --accent-ink: #ffffff; --accent-soft: #e3f0ec;
  --ok: #1f7a3a; --ok-soft: #e4f4e8; --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #8a5a00; --warn-soft: #fff4dc;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 15px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button:hover { background: var(--bg); color: var(--ink); }
.tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 20px; }
.tab { display: block; }
.bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.grow { flex: 1 1 260px; }
.bar .field { margin-bottom: 0; }
.grid3 .field { justify-content: flex-end; }
.muted { color: var(--muted); }
small.muted { display: block; margin-top: 4px; font-size: 12.5px; }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; font: 12px ui-monospace, monospace; text-align: center; background: #fff; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-weight: 550; }
.field .muted { font-weight: 400; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; font-weight: 400; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; cursor: pointer; }

.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: #c4cdca; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; width: fit-content; font-weight: 400; }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.alert { padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--warn-soft); color: var(--warn); }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); padding: 22px; }
.empty p { margin: 8px 0 0; }
.note { background: var(--accent-soft); color: var(--accent); padding: 10px 12px; border-radius: 8px; font-size: 13px; }

/* Карточка звонка */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.kind { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card h2 { margin: 2px 0 4px; font-size: 20px; }
.sub { color: var(--muted); }
.phones { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; }
.phone { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; font: 600 16px ui-monospace, "SF Mono", monospace; }
.phone input { margin: 0; }
.phone:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.phone small { font: 12px system-ui; color: var(--muted); }

.status { margin: 12px 0; padding: 12px 14px; border-radius: 10px; background: var(--bg); min-height: 46px; display: flex; align-items: center; gap: 10px; }
.status.calling { background: var(--warn-soft); color: var(--warn); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.status.calling .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.results { border: 0; padding: 0; margin: 16px 0 0; }
.results legend { font-weight: 650; margin-bottom: 8px; padding: 0; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 14px; }
.res { display: block; cursor: pointer; }
.res input { position: absolute; opacity: 0; }
.res span { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; height: 100%; }
.res input:focus-visible + span { outline: 2px solid var(--accent); }
.res input:checked + span { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.res.ok input:checked + span { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.res.bad input:checked + span { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

/* Очереди */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.qlist #qList { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.qlist #qList li { padding: 10px 12px; border-radius: 9px; cursor: pointer; background: var(--panel); border: 1px solid var(--line); }
.qlist #qList li.on { border-color: var(--accent); background: var(--accent-soft); }
.qlist #qList li small { display: block; color: var(--muted); }
.qlist #qList li.off { opacity: .6; }
.qform { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; }
.qform h2 { margin: 0 0 16px; font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; background: #fff; }
.chip input { margin: 0; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* Таблицы */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfb; position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td:first-child, .tbl td.num { white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl a { color: var(--accent); cursor: pointer; text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; background: var(--bg); white-space: nowrap; }
.tag.reached { background: var(--ok-soft); color: var(--ok); }
.tag.wrong, .tag.nophone { background: var(--bad-soft); color: var(--bad); }
.tag.callback { background: var(--warn-soft); color: var(--warn); }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  main { padding: 14px; }
  .card-head { flex-direction: column; }
}
.cb-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-weight: 400; }
.cb-row .time { width: 80px; text-align: center; font-variant-numeric: tabular-nums; }
#cCbQuick button.on { background: none; color: inherit; }
.qlist .settings { margin-top: 14px; padding: 10px 12px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; align-items: flex-start; }
.qlist #qList li.group { margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: none; border: 0; padding: 4px 2px; cursor: default; }
.note.subtle { background: var(--bg); color: var(--muted); margin-top: -4px; }
.empty .btn { margin-left: 6px; }
.tag .sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
#lTable td:nth-child(3) { min-width: 280px; }
#lTable td:nth-child(7) { min-width: 220px; }

.qlist .editors { display: block; }
.qlist .editors b { display: block; font-size: 13px; margin-bottom: 4px; }
.qlist .editors p { margin: 0 0 8px; font-size: 12px; line-height: 1.35; }
.chips { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--bg, #fff); border: 1px solid var(--line); font-size: 12px; cursor: default; }
.chips li.muted { border: 0; padding: 0; background: none; }
.chips .x { border: 0; background: none; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; color: inherit; opacity: .6; }
.chips .x:hover { opacity: 1; }
.btn.small { padding: 6px 10px; font-size: 12px; }
