:root {
  --bg: #f5f7f8; --panel: #fff; --line: #e3e7ea; --text: #1d2a33; --muted: #6b7a85;
  --accent: #0f7b6c; --accent-2: #e7f4f1; --ok: #16794a; --ok-bg: #e3f5ea;
  --bad: #b3261e; --bad-bg: #fdecea; --mid: #8a5a00; --mid-bg: #fff4dc;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.warn { color: var(--bad); }
.nw { white-space: nowrap; }

.top { display: flex; align-items: center; gap: 22px; padding: 0 20px; height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--accent); white-space: nowrap; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 7px 12px; border-radius: 6px; color: var(--text); }
.top nav a.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.top nav a:hover { text-decoration: none; background: var(--bg); }
.me { display: flex; align-items: center; gap: 14px; color: var(--muted); white-space: nowrap; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 18px 20px 60px; }

.btn { display: inline-block; padding: 8px 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: var(--panel); color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfd6db; border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }

.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.filters label.chk { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 8px; color: var(--text); font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.cards .card span { color: var(--muted); font-size: 12px; }
.cards .card b { display: block; font-size: 22px; margin-top: 2px; }
.cards .card b small { font-size: 13px; color: var(--muted); font-weight: 400; }
b.ok { color: var(--ok); } b.bad { color: var(--bad); }

.tbl { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #fafbfb; color: var(--muted); font-size: 12px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.off td { opacity: .5; }
td.dir { font-size: 16px; width: 24px; text-align: center; }
td.dir.in { color: #1565c0; } td.dir.out { color: var(--accent); } td.dir.int { color: var(--muted); }
audio { height: 30px; width: 210px; vertical-align: middle; }

.st { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.st.ok { background: var(--ok-bg); color: var(--ok); }
.st.bad { background: var(--bad-bg); color: var(--bad); }
.st.mid { background: var(--mid-bg); color: var(--mid); }

.call { border: 1px solid var(--line); background: var(--accent-2); color: var(--accent); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 13px; line-height: 1; vertical-align: middle; }
.call:hover { background: var(--accent); color: #fff; }
.call:disabled { opacity: .4; cursor: wait; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.tabs a.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tabs a b { margin-left: 4px; }
form.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
form.inline input, form.inline select { padding: 5px 7px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; }
.note { background: var(--mid-bg); color: var(--mid); padding: 6px 10px; border-radius: 6px; font-size: 13px; }

.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 14px; align-items: start; }
.form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.form label input, .form label select { width: 100%; }
.form.narrow { max-width: 420px; }
.row { display: flex; align-items: center; gap: 12px; }
.side form { margin-top: 18px; }

/* Всплывающие карточки звонков */
#popups { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 20; width: 300px; }
.popup { position: relative; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid #1565c0; border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.14); animation: pop .25s ease-out; }
.popup.up { border-left-color: var(--ok); }
.popup.ended { opacity: .65; border-left-color: var(--muted); }
.popup .state { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.popup .num { font-size: 19px; font-weight: 700; margin: 2px 0 6px; }
.popup .pname { display: block; font-size: 15px; font-weight: 600; margin: 2px 0; }
.popup .btn { margin-top: 6px; }
.popup .x { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; visibility: hidden; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; transition: transform .25s, opacity .25s, visibility .25s; z-index: 30; max-width: 90vw; }
#toast.show { transform: translateX(-50%); opacity: 1; visibility: visible; }
#toast.bad { background: var(--bad); }

/* Записи и плеер */
button.play { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--accent); cursor: pointer; font-size: 11px; line-height: 1; vertical-align: middle; }
button.play:hover, button.play.on { background: var(--accent); color: #fff; border-color: var(--accent); }
tr.playing td { background: var(--accent-2); }
tr.heard td { color: var(--muted); }
tr.heard td a { color: var(--muted); }
.heard-mark { color: var(--ok); }
td.pcell { width: 36px; }
.rec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

body.has-player { padding-bottom: 86px; }
#player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
#player[hidden] { display: none; }
#player button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; height: 34px; min-width: 38px; padding: 0 8px; cursor: pointer; font: inherit; font-size: 13px; }
#player button:hover { border-color: var(--accent); color: var(--accent); }
#player .pl-main { background: var(--accent); color: #fff; border-color: var(--accent); min-width: 46px; height: 40px; border-radius: 50%; font-size: 15px; }
#player .pl-main:hover { color: #fff; filter: brightness(1.1); }
.pl-btns, .pl-opts { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pl-opts label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); cursor: pointer; }
.pl-opts a { font-size: 17px; padding: 0 6px; }
.pl-info { flex: 1; min-width: 0; }
#plTitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.pl-seek { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pl-seek input[type=range] { flex: 1; accent-color: var(--accent); padding: 0; border: 0; }
#popups { bottom: 18px; }
body.has-player #popups { bottom: 100px; }
body.has-player #toast { bottom: 100px; }

body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.loginbox { width: 320px; padding: 26px; }
.loginbox h1 { margin: 0; color: var(--accent); }
.loginbox label { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; font-size: 13px; color: var(--muted); }
.loginbox .btn { width: 100%; margin-top: 6px; padding: 10px; }

@media (max-width: 800px) {
  .top { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  .me { width: 100%; justify-content: space-between; }
  .cols { grid-template-columns: 1fr; }
  .wrap { padding: 14px; }
  #popups { left: 14px; right: 14px; width: auto; }
  #player { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .pl-info { order: -1; flex-basis: 100%; }
  body.has-player { padding-bottom: 140px; }
  body.has-player #popups, body.has-player #toast { bottom: 150px; }
}

/* Итог разговора */
.oc-btn { border: 1px dashed #b9c3ca; background: none; color: var(--muted); border-radius: 12px; padding: 2px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.oc-btn:hover { border-color: var(--accent); color: var(--accent); }
.oc-btn.set { border-style: solid; color: var(--text); background: #f1f3f4; }
.oc-btn.oc-booked { background: var(--ok-bg); border-color: #b9dfc8; color: var(--ok); font-weight: 600; }
.oc-btn.oc-refused { background: var(--mid-bg); border-color: #efd9a6; color: var(--mid); }
.oc-btn.oc-spam { color: var(--muted); }

#ocDlg { border: 0; border-radius: 12px; padding: 22px; width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
#ocDlg::backdrop { background: rgba(20,30,40,.35); }
#ocDlg h3 { margin: 0 0 2px; font-size: 17px; }
#ocDlg label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.oc-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
#ocDlg .oc-choice { flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
#ocDlg .oc-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-2); font-weight: 600; }
.oc-actions { margin-top: 16px; flex-wrap: wrap; }
.oc-clear { margin-left: auto; }

.oc-quick { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.oc-quick .muted { flex-basis: 100%; }
.oc-quick .q { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 5px 9px; font: inherit; font-size: 13px; cursor: pointer; }
.oc-quick .q:hover { border-color: var(--accent); color: var(--accent); }
.oc-quick .q-booked { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.oc-quick .q-booked:hover { color: #fff; filter: brightness(1.1); }
button.link { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }

/* Приёмы */
.filters .inline { display: inline-flex; }
.btn.ghost.on { border-color: var(--accent); background: var(--accent-2); }
.visit-btns { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.visit-btns .muted { flex-basis: 100%; }
.vb { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 4px 9px; font: inherit; font-size: 12px; cursor: pointer; color: var(--text); }
.vb:hover { border-color: var(--accent); }
.vb-came.on { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.vb-noshow.on { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 600; }
.vb-cancelled.on { background: var(--mid-bg); border-color: var(--mid); color: var(--mid); font-weight: 600; }
tr.visit-came td, tr.visit-noshow td, tr.visit-cancelled td { background: #fbfcfc; }

/* Статистика */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin: 14px 0; }
.panel h2 { margin: 0 0 12px; }
.panel h3 { font-size: 14px; margin: 14px 0 8px; color: var(--muted); font-weight: 600; }
.panel .cards { margin: 0 0 6px; }
.panel .card { background: #fafbfb; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }

.funnel { display: grid; gap: 8px; }
.fn-row { display: grid; grid-template-columns: 170px 1fr 210px; align-items: center; gap: 12px; }
.fn-label { font-weight: 600; }
.fn-track { height: 30px; background: #f1f4f6; border-radius: 4px; overflow: hidden; }
.fn-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.fn-val b { font-size: 17px; }
.fn-val small { color: var(--muted); }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e9edf0; stroke-width: 1; }
.chart .base { stroke: #c9d1d7; stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .s-ans { fill: #2a78d6; }
.chart .s-miss { fill: #eb6834; }
.chart .hit { fill: transparent; }
.chart .bar-g:hover .hit { fill: rgba(15,123,108,.06); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .sw.s-ans { background: #2a78d6; }
.legend .sw.s-miss { background: #eb6834; }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-top: 8px; }
details .tbl { margin-top: 8px; max-height: 320px; overflow: auto; }

.heat-wrap { border: 0; }
table.heat { width: auto; border-collapse: separate; border-spacing: 2px; }
table.heat th { background: none; padding: 2px 4px; font-weight: 500; text-align: center; }
table.heat td { width: 34px; height: 30px; padding: 0; text-align: center; border: 0; border-radius: 3px; font-size: 12px; color: var(--text); position: relative; }
table.heat td.zero { background: #f4f6f7 !important; }
table.heat td.on-dark { color: #fff; }
table.heat td sup { color: #c0392b; font-weight: 700; font-size: 10px; margin-left: 1px; }
table.heat td.on-dark sup { color: #ffd2c2; }
table.heat tr.heat-sum td { height: 22px; color: var(--muted); font-size: 11px; background: none; }
table.heat tr.heat-sum td.hot { color: var(--bad); font-weight: 700; }
.heat-scale { display: flex; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.heat-scale i { width: 22px; height: 10px; border-radius: 2px; }
.heat-scale span { margin: 0 6px; }

.hbars { display: grid; gap: 6px; }
.hb-row { display: grid; grid-template-columns: 120px 1fr 80px; align-items: center; gap: 10px; font-size: 13px; }
.hb-track { height: 16px; background: #f1f4f6; border-radius: 3px; overflow: hidden; }
.hb-bar { display: block; height: 100%; border-radius: 0 3px 3px 0; }
.hb-val small { color: var(--muted); }
small.warn { color: var(--bad); font-weight: 600; }

@media (max-width: 800px) {
  .cols2 { grid-template-columns: 1fr; }
  .fn-row { grid-template-columns: 110px 1fr; }
  .fn-val { grid-column: 2; }
}

/* Интеграции */
.form label.chk-line { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form label.chk-line input { width: auto; }
ol.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
ol.steps li { line-height: 1.5; }
code { background: #f1f3f4; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.form label .st { align-self: flex-start; }
.top { gap: 14px; }
.top nav a { padding: 7px 9px; }
.me { gap: 10px; }
@media (max-width: 1350px) { #notifBtn { display: none; } }

/* Связь */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #c9d1d7; vertical-align: middle; }
.dot.on { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.dot.off { background: #dc2626; box-shadow: 0 0 0 3px #fee2e2; }
.nav-alert { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #dc2626; margin-left: 5px; vertical-align: 2px; }
.phones { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.phone { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fafbfb; }
.phone.off { opacity: .65; }
.ph-ext { font-weight: 700; font-size: 16px; }
.ph-name { font-size: 13px; margin: 2px 0; min-height: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.workhours { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 4px 0 14px; }
.workhours label.chk-line { margin: 0; }
.workhours input[size] { width: 46px; }
.cards .card small { display: block; margin-top: 2px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Направления обращений ---------- */
.dir-badge { display: inline-block; padding: 1px 7px; border-radius: 9px; font-size: 11px; font-weight: 600; white-space: nowrap; vertical-align: 1px; }
.dir-detox      { background: #e8f0fe; color: #1a56c4; }
.dir-coding     { background: #f3e8fd; color: #7b2fbf; }
.dir-rehab      { background: #e6f4ea; color: #1e7e43; }
.dir-outpatient { background: #fff3e0; color: #a85d00; }
#ocDir { margin: 10px 0 2px; }
.dir-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.dir-choice { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; }
.dir-choice:has(input:checked) { border-color: currentColor; font-weight: 600; }
.dir-choice.dir-detox, .dir-choice.dir-coding, .dir-choice.dir-rehab, .dir-choice.dir-outpatient { background: none; }
.dir-choice.dir-detox:has(input:checked) { background: #e8f0fe; color: #1a56c4; }
.dir-choice.dir-coding:has(input:checked) { background: #f3e8fd; color: #7b2fbf; }
.dir-choice.dir-rehab:has(input:checked) { background: #e6f4ea; color: #1e7e43; }
.dir-choice.dir-outpatient:has(input:checked) { background: #fff3e0; color: #a85d00; }
.oc-quick .dq { font-size: 12px; padding: 4px 8px; background: var(--panel); color: var(--text); }
.oc-quick .dq.on.dir-detox { background: #e8f0fe; color: #1a56c4; border-color: #1a56c4; font-weight: 600; }
.oc-quick .dq.on.dir-coding { background: #f3e8fd; color: #7b2fbf; border-color: #7b2fbf; font-weight: 600; }
.oc-quick .dq.on.dir-rehab { background: #e6f4ea; color: #1e7e43; border-color: #1e7e43; font-weight: 600; }
.oc-quick .dq.on.dir-outpatient { background: #fff3e0; color: #a85d00; border-color: #a85d00; font-weight: 600; }

/* ---------- Напоминания о приёмах ---------- */
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; border-radius: 9px; background: #dc2626; color: #fff; font-size: 11px; line-height: 18px; text-align: center; vertical-align: 1px; animation: navpulse 1.6s ease-in-out infinite; }
@keyframes navpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.55); } 50% { box-shadow: 0 0 0 5px rgba(220,38,38,0); } }
.appt-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 20px; background: #fff4e5; border-bottom: 1px solid #f5c98a; color: #7a4200; font-size: 14px; }
.appt-bar .btn { margin-left: auto; }
.appt-bar-ico { font-size: 17px; animation: ring 2.5s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes ring { 0%,80%,100% { transform: rotate(0); } 84% { transform: rotate(14deg); } 88% { transform: rotate(-12deg); } 92% { transform: rotate(8deg); } 96% { transform: rotate(-4deg); } }
.rem-pop { border-left-color: #f59e0b; }
.rem-h { font-weight: 600; margin: 8px 0 4px; font-size: 14px; }
.rem-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.rem-list li { padding: 5px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.rem-acts { margin-left: auto; display: inline-flex; gap: 4px; }
.rem-acts .btn { margin-top: 0; padding: 3px 8px; }
.rem-foot { margin-top: 10px; gap: 6px; }
.vb-confirm { border-color: #f59e0b; color: #a85d00; background: #fff8eb; font-weight: 600; }
.filters .need { border-color: #dc2626; color: #dc2626; }
.filters .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.dir-bar { display: block; height: 100%; }
.fn-bar.dir-detox { background: #4a7fe0; } .fn-bar.dir-coding { background: #9a5bd6; }
.fn-bar.dir-rehab { background: #34a065; } .fn-bar.dir-outpatient { background: #e08a1e; } .fn-bar.dir-none { background: #c5cbd0; }
.tbl .fn-track { display: block; height: 14px; }
#ocDlg .dir-choice { flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 8px 12px; color: var(--text); }
#ocDlg .dir-choice input { width: auto; margin: 0; }
#ocDlg #ocDir .muted { margin-top: 4px; }

/* ---------- Авито ---------- */
.src-avito { display: inline-block; padding: 1px 6px; border-radius: 4px; background: #00aaff; color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.nav-count.static { animation: none; }
.av-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.av-list { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-height: calc(100vh - 190px); overflow-y: auto; position: sticky; top: 10px; }
.av-filt { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.av-filt a { flex: 1; text-align: center; padding: 5px 4px; border-radius: 6px; font-size: 12px; color: var(--text); text-decoration: none; }
.av-filt a.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.av-filt b.hot { color: #dc2626; }
.av-chat { display: grid; gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.av-chat:hover { background: #f6f8f9; }
.av-chat.on { background: var(--accent-2); }
.av-chat.unread .av-last { font-weight: 600; }
.av-top { display: flex; justify-content: space-between; gap: 8px; }
.av-item, .av-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-tags { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; min-height: 0; }
.av-tags:empty { display: none; }
.av-tags .oc-btn { cursor: default; font-size: 11px; padding: 1px 7px; }
.av-chatbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-height: 300px; }
.av-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.av-head h2 { margin: 4px 0 2px; font-size: 18px; }
.av-head h2 a { font-weight: 400; margin-left: 8px; }
.av-msgs { max-height: 46vh; overflow-y: auto; padding: 12px 4px; display: flex; flex-direction: column; gap: 6px; }
.av-day { align-self: center; font-size: 11px; color: var(--muted); background: #f1f4f6; border-radius: 10px; padding: 2px 10px; margin: 6px 0; }
.av-msg { max-width: 78%; display: flex; flex-direction: column; }
.av-msg.in { align-self: flex-start; }
.av-msg.out { align-self: flex-end; align-items: flex-end; }
.av-bubble { padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: normal; word-wrap: break-word; }
.av-msg.in .av-bubble { background: #f1f4f6; border-bottom-left-radius: 4px; }
.av-msg.out .av-bubble { background: #e3f4fd; border-bottom-right-radius: 4px; }
.av-meta { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.av-reply { display: flex; gap: 8px; align-items: flex-end; padding: 10px 0; border-top: 1px solid var(--line); }
.av-reply textarea { flex: 1; resize: vertical; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.av-mark { border-top: 1px solid var(--line); padding-top: 10px; }
.av-mark h3 { margin: 0 0 8px; font-size: 15px; }
.av-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: flex-end; }
.av-row[hidden] { display: none; }
.av-mark .oc-choice, .av-mark .dir-choice { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13px; }
.av-mark .oc-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-2); font-weight: 600; }
.av-mark label:not(.oc-choice):not(.dir-choice) { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.av-mark label input:not([type=radio]) { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; color: var(--text); }
.av-mark > label { margin-bottom: 8px; }
.av-mark .btn { margin-right: 8px; }
.sm-select { padding: 3px 6px; font-size: 12px; }
@media (max-width: 860px) {
  .av-wrap { grid-template-columns: 1fr; }
  .av-wrap.has-sel .av-list { display: none; }
  .av-wrap:not(.has-sel) .av-chatbox { display: none; }
  .av-list { max-height: none; position: static; }
}
/* шапка: пунктов меню стало больше — переносим, а не вылезаем за экран */
.top { height: auto; min-height: 54px; }
.top nav { flex-wrap: wrap; min-width: 0; row-gap: 2px; padding: 4px 0; }
.top nav a { white-space: nowrap; padding: 7px 8px; }
.top .me { white-space: nowrap; }
@media (max-width: 1500px) { #notifBtn { display: none; } .top nav a { padding: 7px 6px; } .top { gap: 10px; } }

/* ---------- Обязательная отметка, контроль пропущенных ---------- */
.need { animation: shake .45s ease-in-out; outline: 2px solid #dc2626; outline-offset: 3px; border-radius: 8px; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }
.rem-hot { color: #b91c1c; }
.rem-list .oc-btn { font-size: 12px; }
.appt-bar-parts a { color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor; }
.appt-bar-parts a:hover { border-bottom-style: solid; }

/* ---------- Вход: окно всегда по центру (браузеры добавляют в body свои элементы) ---------- */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.login-wrap .loginbox { max-width: 100%; }

/* ---------- Телефон ---------- */
@media (max-width: 800px) {
  /* шапка: название и «Выйти» в одну строку, меню — одной полосой с прокруткой пальцем */
  .top { display: grid; grid-template-columns: 1fr auto; padding: 8px 12px 0; gap: 4px 8px; position: sticky; top: 0; }
  .top .brand { grid-column: 1; font-size: 15px; align-self: center; }
  .top .me { grid-column: 2; grid-row: 1; width: auto; font-size: 12px; gap: 8px; white-space: nowrap; }
  .top .me span { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .top nav { grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 2px 0 6px; margin: 0 -12px; padding-left: 8px; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { flex: none; padding: 7px 10px; }
  .appt-bar { padding: 8px 12px; font-size: 13px; }
  .appt-bar-ico { display: none; }
  h1 { font-size: 22px; }
  #popups { max-height: 72vh; overflow-y: auto; }
  .filters { gap: 8px; }
  .filters label { flex: 1 1 40%; }
  .filters input[type=date] { width: 100%; }
}
/* таблицы на телефоне превращаются в карточки: всё видно без прокрутки вбок */
@media (max-width: 700px) {
  .tbl { overflow: visible; border: 0; background: none; }
  .tbl table:not(.heat), .tbl table:not(.heat) tbody { display: block; }
  .tbl table:not(.heat) tr:has(> th) { display: none; }
  .tbl table:not(.heat) tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; margin-bottom: 8px;
                             background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
  .tbl table:not(.heat) td { display: block; padding: 0; border: 0; max-width: 100%; }
  .tbl table:not(.heat) td:empty { display: none; }
  .tbl table:not(.heat) td.nw { white-space: normal; }
  .tbl table:not(.heat) td:first-child { font-weight: 600; }
  .visit-btns { display: flex; flex-wrap: wrap; gap: 4px; }
  .vb { padding: 7px 10px; font-size: 13px; }
  .oc-btn { padding: 5px 12px; font-size: 13px; }
  button.call { width: 34px; height: 34px; }
  .heat-wrap { overflow-x: auto; }
}
@media (max-width: 700px) {
  .av-reply { flex-direction: column; align-items: stretch; }
  .av-reply textarea { width: 100%; }
  .av-chatbox { padding: 12px; }
}

/* «Я не робот» на странице входа */
.nr { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
      background: #f9fafb; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.nr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nr-box { position: relative; width: 26px; height: 26px; border: 2px solid #9aa5ad; border-radius: 4px; background: #fff; flex: none; }
.nr-text { font-size: 15px; color: var(--text); }
.nr-tick { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px; }
.nr-spin { position: absolute; inset: 2px; border: 3px solid #cfd8dc; border-top-color: var(--accent); border-radius: 50%; display: none; animation: nrspin .8s linear infinite; }
@keyframes nrspin { to { transform: rotate(360deg); } }
.nr-work .nr-box { border-color: transparent; background: none; }
.nr-work .nr-spin { display: block; }
.nr-ok { cursor: default; border-color: #b9dfc8; background: var(--ok-bg); }
.nr-ok .nr-box { background: var(--ok); border-color: var(--ok); }
.nr-ok .nr-tick { display: flex; }
