/* ===== Токены ===== */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --accent: #0e8f86;
  --accent-hover: #0b7a72;
  --accent-soft: #e0f4f2;
  --accent-text: #0b6e67;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --ok: #15803d;
  --ok-soft: #e6f6eb;
  --focus: 0 0 0 3px rgba(14, 143, 134, .28);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, .22);
  --scrim: rgba(15, 23, 42, .45);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --msg-telegram: #229ed9;
  --msg-whatsapp: #1fa855;
  --msg-max: #7b4dff;
  --msg-viber: #7360f2;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-gray-1: #c3c2b7;
  --series-gray-2: #898781;
  --ortho-text: #c2410c;
  --chart-grid: #ebedf0;
  --heat-0: #e8f1fc; --heat-1: #cde2fb; --heat-2: #9ec5f4; --heat-3: #6da7ec; --heat-4: #3987e5; --heat-5: #256abf; --heat-6: #184f95;
  --delta-up: #006300;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1017;
    --surface: #121a24;
    --surface-2: #161f2b;
    --surface-3: #1c2734;
    --border: #243142;
    --border-strong: #33445a;
    --text: #e6edf5;
    --text-2: #b4c0cf;
    --muted: #8595a9;
    --accent: #2bb5aa;
    --accent-hover: #3cc7bc;
    --accent-soft: #10302f;
    --accent-text: #5fd6cc;
    --on-accent: #04201e;
    --danger: #f26363;
    --danger-soft: #3a1618;
    --warn: #f0a94a;
    --warn-soft: #36260f;
    --ok: #4cc77a;
    --ok-soft: #112c1c;
    --focus: 0 0 0 3px rgba(43, 181, 170, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    --scrim: rgba(0, 0, 0, .6);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-gray-1: #4a4a46;
    --series-gray-2: #898781;
    --ortho-text: #f0895a;
    --chart-grid: #222c3a;
    --heat-0: #16243a; --heat-1: #184f95; --heat-2: #1c5cab; --heat-3: #256abf; --heat-4: #3987e5; --heat-5: #6da7ec; --heat-6: #b7d3f6;
    --delta-up: #0ca30c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1017;
  --surface: #121a24;
  --surface-2: #161f2b;
  --surface-3: #1c2734;
  --border: #243142;
  --border-strong: #33445a;
  --text: #e6edf5;
  --text-2: #b4c0cf;
  --muted: #8595a9;
  --accent: #2bb5aa;
  --accent-hover: #3cc7bc;
  --accent-soft: #10302f;
  --accent-text: #5fd6cc;
  --on-accent: #04201e;
  --danger: #f26363;
  --danger-soft: #3a1618;
  --warn: #f0a94a;
  --warn-soft: #36260f;
  --ok: #4cc77a;
  --ok-soft: #112c1c;
  --focus: 0 0 0 3px rgba(43, 181, 170, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .6);
    --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-gray-1: #4a4a46;
  --series-gray-2: #898781;
  --ortho-text: #f0895a;
  --chart-grid: #222c3a;
  --heat-0: #16243a; --heat-1: #184f95; --heat-2: #1c5cab; --heat-3: #256abf; --heat-4: #3987e5; --heat-5: #6da7ec; --heat-6: #b7d3f6;
  --delta-up: #0ca30c;
  color-scheme: dark;
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.lead { margin: -8px 0 20px; max-width: 70ch; }

.ic { width: 18px; height: 18px; flex: none; }
.ic.xl { width: 40px; height: 40px; color: var(--muted); }
:root .only-light { display: inline; }
:root .only-dark { display: none; }
:root[data-theme="dark"] .only-light { display: none; }
:root[data-theme="dark"] .only-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-light { display: none; }
  :root:not([data-theme="light"]) .only-dark { display: inline; }
}

/* ===== Каркас ===== */
.shell .main {
  margin-left: var(--sidebar-w);
  padding: 28px 32px 48px;
  max-width: calc(1480px + var(--sidebar-w));
}
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 16px 20px; }
.sidebar .nav-close { display: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 800; font-size: 20px; line-height: 1;
}
.brand-mark.lg { width: 48px; height: 48px; border-radius: 14px; font-size: 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent-text); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 14px 12px 14px 16px; display: flex; align-items: center; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2); font-weight: 600;
}
.me-name { display: flex; flex-direction: column; min-width: 0; font-size: 14px; font-weight: 550; }
.me-name, .me-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-name small { color: var(--muted); font-weight: 400; font-size: 12px; }
.foot-actions { display: flex; gap: 2px; }
.foot-actions form { margin: 0; }
.topbar { display: none; }
.scrim { display: none; }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; font-size: 14px;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, .input-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.small .ic { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .7; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ===== Страница ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs {
  display: inline-flex; gap: 2px; padding: 4px;
  background: var(--surface-3); border-radius: 10px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 7px;
  color: var(--text-2); font-weight: 550; font-size: 14px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.count {
  min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--border); color: var(--text-2);
  font-size: 12px; font-weight: 600; text-align: center;
}
.tabs a.on .count { background: var(--accent-soft); color: var(--accent-text); }
.search { position: relative; display: block; width: 340px; max-width: 100%; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 38px !important; }

.flash {
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 500; font-size: 14px;
}
.flash.error { background: var(--danger-soft); color: var(--danger); }
.form-error { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }

.empty, .empty-page {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 56px 16px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty p { margin: 0; }
.empty.small { padding: 24px; border: 0; background: none; }
.empty-page { max-width: 480px; margin: 10vh auto; border-style: solid; }
.empty-page h1 { color: var(--text); }

/* ===== Таблица ===== */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; padding-top: 0; box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 11px 12px; text-align: left; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th[data-sort]::after { content: "↕"; margin-left: 6px; opacity: .35; }
.table th[data-dir="asc"]::after { content: "↑"; opacity: 1; color: var(--accent-text); }
.table th[data-dir="desc"]::after { content: "↓"; opacity: 1; color: var(--accent-text); }
.table td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.rows-clickable tbody tr { cursor: pointer; transition: background .1s; }
.rows-clickable tbody tr:hover { background: var(--surface-2); }
.rows-clickable tbody tr:focus-visible { outline: none; background: var(--accent-soft); }
.c-id { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-2); }
.c-name { min-width: 190px; }
.c-name .name { font-weight: 600; color: var(--text); }
/* врач без заказов N+ месяцев: едва заметная красноватая заливка и тонкая полоска слева */
.table tbody tr.stale > td { background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.table tbody tr.stale > td:first-child { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--danger) 80%, transparent); }
.rows-clickable tbody tr.stale:hover > td { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.table tbody tr.stale .name[data-tip] { cursor: help; text-decoration: underline dotted color-mix(in srgb, var(--danger) 55%, transparent); text-underline-offset: 3px; }
.stale-note { display: none; font-size: 12.5px; color: var(--danger); margin-top: 2px; }
.stale-legend { display: flex; align-items: flex-start; gap: 8px; margin: -4px 0 10px; }
.stale-legend i { margin-top: 2px; }
.stale-legend i { flex: none; width: 22px; height: 14px; border-radius: 3px; background: color-mix(in srgb, var(--danger) 7%, var(--surface)); box-shadow: inset 3px 0 0 color-mix(in srgb, var(--danger) 80%, transparent); border: 1px solid var(--border); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* всплывающая подсказка для [data-tip]: позиционируется поверх страницы, не обрезается таблицей */
.tip {
  white-space: pre-line;
  position: fixed; z-index: 200; max-width: 300px; padding: 8px 10px; border-radius: 8px;
  background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 500; line-height: 1.4;
  box-shadow: var(--shadow); pointer-events: none;
}
.row-note { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); line-height: 1.35; max-width: 320px; }
.c-email { overflow-wrap: anywhere; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.role-admin { background: var(--accent-soft); color: var(--accent-text); }
.tag.role-med_rep { background: var(--warn-soft); color: var(--warn); }
tr.dim td { opacity: .55; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.msg-icons { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; }
.msg-ic {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  color: #fff; background: var(--msg, var(--muted));
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.msg-ic svg { width: 17px; height: 17px; }
a.msg-ic:hover { transform: translateY(-1px); box-shadow: 0 4px 12px color-mix(in srgb, var(--msg) 45%, transparent); text-decoration: none; }
a.msg-ic:focus-visible { outline: none; box-shadow: var(--focus); }
.msg-ic.off { filter: grayscale(1); opacity: .45; cursor: not-allowed; }
.msg-ic.msg-telegram { --msg: var(--msg-telegram); }
.msg-ic.msg-whatsapp { --msg: var(--msg-whatsapp); }
.msg-ic.msg-viber { --msg: var(--msg-viber); }
.msg-ic.msg-max { --msg: #3c22fe; background: none; border-radius: 8px; }
.msg-ic img { width: 100%; height: 100%; display: block; }
.msg-write { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; }
.tag.msg-telegram { color: var(--msg-telegram); }
.tag.msg-whatsapp { color: var(--msg-whatsapp); }
.tag.msg-max { color: var(--msg-max); }
.tag.msg-viber { color: var(--msg-viber); }
:root[data-theme="dark"] .tag[class*="msg-"] { filter: brightness(1.35); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag[class*="msg-"] { filter: brightness(1.35); } }

/* ===== Поля ===== */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child, .field > label:first-child { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field-switch { margin-top: 4px; }
.field p { margin: 0; }
.req { color: var(--danger); font-style: normal; }
input:not([type="checkbox"]):not([type="radio"]), select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
textarea {
  width: 100%; min-height: 76px; padding: 9px 12px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; line-height: 1.45;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="date"] { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); } }
.invalid input, .invalid select, input.invalid { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 12.5px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { flex: 1; padding-right: var(--pr, 12px) !important; }
.input-actions { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
.input-btn {
  display: grid; place-items: center;
  height: 32px; min-width: 32px; padding: 0 6px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); cursor: pointer; font: inherit; font-size: 13px;
}
.input-btn:hover { background: var(--surface-3); color: var(--text); }
.input-btn.text { color: var(--accent-text); font-weight: 550; padding: 0 8px; }
.input-wrap.suffix em { position: absolute; right: 12px; color: var(--muted); font-style: normal; pointer-events: none; }

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { position: relative; cursor: pointer; }
.check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.check-chip span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 14px; color: var(--text-2); transition: all .12s;
}
.check-chip span::before {
  content: ""; width: 14px; height: 14px; border-radius: 4px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  transition: all .12s;
}
.check-chip:hover span { border-color: var(--accent); }
.check-chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 550; }
.check-chip input:checked + span::before {
  border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/10px no-repeat;
}
.check-chip input:focus-visible + span { box-shadow: var(--focus); }
.check-chip.off span { opacity: .65; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.seg { display: flex; padding: 4px; gap: 2px; background: var(--surface-3); border-radius: 10px; }
.seg button {
  flex: 1; height: 34px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text-2); font: inherit; font-weight: 550; font-size: 14px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.mini { display: inline-flex; padding: 3px; border-radius: 8px; }
.seg.mini button { flex: none; width: 34px; height: 30px; border-radius: 6px; }

/* ===== Модальное окно ===== */
.modal {
  width: min(820px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal.sm { width: min(480px, calc(100vw - 32px)); }
.modal.md { width: min(640px, calc(100vw - 32px)); }
.modal::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-box { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); margin: 0; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 19px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 20px 24px 8px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 4px; }
.modal-body.stack { gap: 16px; padding-bottom: 20px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.spacer { flex: 1; }
.modal.loading .modal-body { opacity: .5; pointer-events: none; }

.fs { padding: 16px 0 20px; border-bottom: 1px solid var(--border); }
.fs:last-child { border-bottom: 0; }
.fs:first-of-type { padding-top: 4px; }
.fs h3 { margin-bottom: 14px; }
.fs > p.muted { margin: -6px 0 14px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.col-2 { grid-column: 1 / -1; }

.qr-row { display: flex; gap: 20px; align-items: flex-start; }
.qr-fields { flex: 1; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.qr-fields .field { width: 100%; max-width: 280px; }
.qr-fields p { margin: 0; }
.code-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 40px; }
.code-value { font-size: 22px; font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; color: var(--text); }
.code-value.is-empty { font-size: 15px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.code-value.is-pending { font-size: 14px; font-weight: 550; letter-spacing: 0; color: var(--accent-text); }
.qr-preview {
  flex: none; width: 148px; height: 148px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  border: 1px dashed var(--border-strong); background: var(--surface-2); padding: 10px;
}
.qr-preview img { width: 100%; height: 100%; background: #fff; border-radius: 6px; padding: 4px; }
.qr-preview.has { border-style: solid; background: #fff; padding: 6px; }

.mot-blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.mot-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mot-block h4 { margin: 0; font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; color: var(--text); }
.mot-dot { width: 10px; height: 10px; border-radius: 3px; }
.mot-dot.glasses { background: var(--series-1); }
.mot-dot.ortho { background: var(--series-2); }
.mot-block .tiers { margin-top: 0; }
.mot-block .tier { background: var(--surface); }
.mot-block .tiers-head { margin-bottom: 8px; }
.reward-kind button { font-size: 13px; padding: 0 8px; }
.tiers { margin-top: 16px; }
.tiers-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 13px; font-weight: 550; color: var(--text-2); flex-wrap: wrap; }
.tiers-list { display: flex; flex-direction: column; gap: 8px; }
.tiers-list:empty { display: none; }
.tiers > p { margin: 0; }
.tier {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 8px 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.tier input { height: 34px !important; font-size: 14px !important; }
.tier-min { width: 80px !important; }
.tier-val { width: 110px !important; }
.tier-lbl { font-size: 14px; color: var(--text-2); white-space: nowrap; }
.tier [data-tier-remove] { margin-left: auto; width: 32px; height: 32px; }
.tier-error { flex-basis: 100%; color: var(--danger); font-size: 12.5px; }

.pw-state { align-self: end; padding-bottom: 10px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pw-state .btn { height: 28px; }

/* ===== Тосты ===== */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: 10px; max-width: 360px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); animation: toast-in .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ===== Вход ===== */
.bare { min-height: 100dvh; }
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  padding: 32px 28px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 20px;
}
.auth-card .flash { margin: 0; }
.auth-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.auth-head h1 { margin-top: 10px; font-size: 22px; }
.auth-head p { margin: 0; }
.auth-theme { position: fixed; top: 16px; right: 16px; }
.code-input { text-align: center; letter-spacing: .5em; font-size: 22px !important; height: 48px !important; font-variant-numeric: tabular-nums; }
.auth .stack p { margin: 0; }

/* ===== Кабинет ===== */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.setting-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.setting-input { max-width: 200px; }
.settings-actions { display: flex; justify-content: flex-start; }
/* ===== Таблица выплат: врач слева и итог справа закреплены, месяцы прокручиваются ===== */
.toolbar-right { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.switch.small { font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.pgrid td.mid, .lg-cell.mid { background: var(--warn-soft); }
.pgrid td.hi, .lg-cell.hi { background: var(--ok-soft); }
.grid-count { margin: 0 0 8px; }
.legend-box { margin-top: 16px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.legend-box h3 { margin-bottom: 12px; }
.legend-box > ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px 24px; }
.legend-box > ul > li { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-2); line-height: 1.4; }
.lg-cell {
  flex: none; width: 72px; height: 40px; padding: 4px 8px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-variant-numeric: tabular-nums;
}
.lg-cell b, .lg-cell span, .lg-cell em { display: block; line-height: 1.2; }
.lg-cell:has(em) { height: 54px; }
.lg-cell.big { width: 96px; height: 72px; padding: 8px 12px; font-size: 1.15em; }
.lg-cell.big b { font-size: 17px; } .lg-cell.big span, .lg-cell.big em { font-size: 14px; }
.lg-anatomy { display: flex; gap: 16px; align-items: center; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.lg-anatomy ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); line-height: 1.45; }
.lg-anatomy ol b { color: var(--text); }
.lg-amount { color: var(--text-2); font-variant-numeric: tabular-nums; }
.lg-cell b { font-size: 13.5px; font-weight: 650; color: var(--text); }
.lg-cell span { font-size: 11.5px; color: var(--text-2); }
.lg-cell.ys { border-left: 2px solid var(--border-strong); border-radius: 0 6px 6px 0; }
.lg-cell.tot { background: var(--surface-2); }
.grid-wrap {
  overflow: auto; max-height: calc(100dvh - 230px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overscroll-behavior-x: contain;
}
.pgrid { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.pgrid th, .pgrid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
.pgrid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  padding: 6px 4px; text-align: center; white-space: nowrap;
}
.pgrid thead tr:nth-child(2) th { top: 29px; }
.pgrid thead th.year { color: var(--text-2); font-size: 12.5px; text-align: left; padding-left: 0; }
/* подпись года остаётся видна, пока виден хотя бы один месяц года */
.pgrid thead th.year span { position: sticky; left: 242px; right: 108px; padding: 0 10px; }
.pgrid td { min-width: 76px; height: 52px; text-align: right; vertical-align: middle; }
.pgrid td.has, .pgrid td.tot { padding: 4px 8px; }
.pgrid td b, .pgrid td span, .pgrid td em { display: block; line-height: 1.2; white-space: nowrap; }
.pgrid td em, .lg-cell em, .lg-payout { font-style: normal; font-size: 11.5px; font-weight: 650; color: var(--accent-text); }
.doc-pct { color: var(--accent-text); font-weight: 650; }
.pgrid td b i, .lg-cell b i, .lg-anatomy i { font-style: normal; }
.pgrid td b .sl, .lg-cell b .sl { margin: 0 3px; color: var(--muted); font-weight: 400; }
.or { color: var(--ortho-text); }
.pgrid td b .z, .lg-cell b .z { color: var(--muted); font-weight: 400; opacity: .7; }
.pgrid td b { font-size: 13.5px; font-weight: 650; color: var(--text); }
.pgrid td span { font-size: 11.5px; color: var(--text-2); }
.pgrid .ys { border-left: 2px solid var(--border-strong); }
.sticky-l { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; }
.pgrid thead .sticky-l, .pgrid thead .sticky-r { z-index: 3; }
.pgrid th.sticky-l { min-width: 230px; max-width: 230px; padding: 6px 12px; box-shadow: 1px 0 0 var(--border-strong); }
.pgrid .sticky-r { position: sticky; right: 0; z-index: 1; background: var(--surface-2); min-width: 96px; box-shadow: -1px 0 0 var(--border-strong); }
.pgrid tbody tr:hover > * { background-color: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.pgrid tbody tr:hover > .sticky-l { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.doc { font-weight: 500; }
.doc-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--text); font-weight: 600; }
.doc-id { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.pgrid tfoot > tr > * { position: sticky; bottom: 0; background: var(--surface-2); border-top: 1px solid var(--border-strong); z-index: 2; }
.pgrid tfoot th.sticky-l { z-index: 3; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pgrid tfoot .sticky-r { z-index: 3; }
.pgrid tfoot td span { color: var(--text-2); }
/* ===== Статистика ===== */
.period-note { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.2; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi-foot { font-size: 12.5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; min-height: 18px; }
.delta { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--delta-up); }
.delta.down { color: var(--danger); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-grid > .card, main > .card { margin: 0; }
.stat-grid > * { min-width: 0; }
main > .card { margin-bottom: 16px; }
.card-head { display: flex; flex-direction: column; gap: 2px; }
.card-head p, .chart-card header p { margin: 0; }
.chart-card header { display: flex; flex-direction: column; gap: 2px; }
.chart-box { position: relative; height: 260px; }
.section-title { margin: 28px 0 12px; font-size: 19px; }
.note { margin-top: 8px !important; }
.data-table { padding: 0; }
.data-table summary { padding: 14px 20px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.data-table[open] summary { border-bottom: 1px solid var(--border); }
.data-table .table-scroll { padding: 4px 8px 8px; }
.table-scroll { overflow-x: auto; }
.stable { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.stable th, .stable td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
.stable thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stable td:nth-child(2) { white-space: normal; }
.stable .n, .num-table td { text-align: right; }
.stable tbody tr:last-child > * { border-bottom: 0; }
.stable.compact td, .stable.compact th { padding: 7px 8px; }
.strong { font-weight: 650; color: var(--text); }
.share { min-width: 140px; }
.share .sbar { display: inline-block; vertical-align: middle; width: 80px; height: 8px; border-radius: 4px; background: var(--surface-3); margin-right: 8px; overflow: hidden; }
.share .sbar i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
.heat { border-collapse: separate; border-spacing: 3px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.heat th { color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 4px 6px; text-transform: uppercase; }
.heat tbody th { text-align: left; color: var(--text-2); font-size: 13px; }
.heat td { width: 56px; min-width: 48px; height: 34px; text-align: center; border-radius: 6px; color: var(--text); }
.heat td.na { background: transparent; border: 1px dashed var(--border); }
.heat td.tot { background: none; font-weight: 650; text-align: right; padding-left: 10px; }
.h0 { background: var(--heat-0); } .h1 { background: var(--heat-1); } .h2 { background: var(--heat-2); } .h3 { background: var(--heat-3); }
.h4 { background: var(--heat-4); } .h5 { background: var(--heat-5); } .h6 { background: var(--heat-6); }
.heat td.h4, .heat td.h5, .heat td.h6 { color: #fff; }
:root[data-theme="dark"] .heat td.h6 { color: #0b1017; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .heat td.h6 { color: #0b1017; } }
.heat-scale { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.heat-scale i { width: 22px; height: 10px; border-radius: 3px; }
.heat-scale span { margin: 0 4px; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 90px 1fr 56px; align-items: center; gap: 10px; font-size: 13px; }
.hbar:has(.wide) { grid-template-columns: minmax(120px, 190px) 1fr 56px; }
.hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.hbar-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-track i.s1 { background: var(--series-1); }
.hbar-track i.gray { background: var(--series-gray-1); }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.facts { display: flex; flex-direction: column; gap: 14px; }
.fact { display: flex; align-items: baseline; gap: 12px; }
.fact b { font-size: 26px; min-width: 84px; font-variant-numeric: tabular-nums; color: var(--text); }
.fact span { color: var(--text-2); font-size: 13.5px; }
/* ===== Загрузка заказов ===== */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.import-last { margin: -10px 0 14px; }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 28px 16px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s; color: var(--text-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has { border-style: solid; border-color: var(--accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-text { font-weight: 550; font-size: 14px; }
.kpi-value.bad { color: var(--danger); }
.import-totals, .import-errors { margin-bottom: 16px; }
.import-errors { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.import-errors ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--text-2); }
.import-errors h2 { color: var(--danger); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.stable td.chg { background: color-mix(in srgb, var(--warn) 9%, transparent); }
.stable s { text-decoration-thickness: 1px; }
.import-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 14px; }
.card p { margin: 0; }
.props { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; font-weight: 500; word-break: break-word; }
.qr-big { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.qr-big img { width: 220px; height: 220px; max-width: 100%; }
.stat { display: flex; align-items: baseline; gap: 10px; }
.stat b { font-size: 28px; color: var(--accent-text); white-space: nowrap; }
.tier-view, .plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tier-view li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }

/* ===== Планшет ===== */
/* ===== Кабинет врача ===== */
.head-sub { margin: 4px 0 0; }
.ic.xs { width: 14px; height: 14px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15.5px; }
.tag.accent { background: var(--accent-soft); color: var(--accent-text); }
.tag .ic.xs { margin-right: 4px; }
.payout-hero { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px 24px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.ph-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ph-sum { font-size: 34px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--accent-text); line-height: 1.15; }
.ph-sum small { font-size: 20px; font-weight: 600; }
.ph-sum.zero { color: var(--muted); }
.ph-requests { grid-column: 1 / -1; list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.ph-requests .tag { margin-right: 6px; }
.section-title .muted { font-weight: 400; margin-left: 6px; }
.history { padding: 4px 0; gap: 0; }
.year { border-bottom: 1px solid var(--border); }
.year:last-child { border-bottom: 0; }
.year summary { display: flex; align-items: center; gap: 14px; padding: 12px 20px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.year summary::-webkit-details-marker { display: none; }
.year summary > b { font-size: 16px; min-width: 44px; }
.year summary .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.year[open] summary .chev { transform: rotate(180deg); }
.year summary:hover { background: var(--surface-2); }
.year .table-scroll { padding: 0 12px 10px; }
.hist td:nth-child(2) { white-space: nowrap; }
.hist .or { font-weight: 600; }
.stable tfoot th { border-bottom: 0; padding-top: 10px; font-size: 14px; color: var(--text); }
/* инструкция СБП в кабинете */
.sbp-guide { gap: 12px; }
.sbp-guide p { max-width: 80ch; }
.sbp-status { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.sbp-status.on { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); color: var(--ok); }
.sbp-status .ic { margin-top: 1px; }
.sbp-rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.banks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.bank { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.bank[open] { border-color: var(--border-strong); }
.bank summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.bank summary::-webkit-details-marker { display: none; }
.bank summary .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.bank[open] summary .chev { transform: rotate(180deg); }
.bank ol { margin: 0; padding: 0 14px 0 34px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.bank > p { padding: 8px 14px 12px; }
.bank-mark { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 750; }
.bank-mark.vtb { background: #0a2896; }
.bank-mark.sber { background: #21a038; }
.bank-mark.tbank { background: #ffdd2d; color: #111; }
.bank-mark.alfa { background: #ef3124; }
.bank-mark.psb { background: #f26b22; }
.sbp-send { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font-size: 14px; }
/* ===== К оплате ===== */
/* только просмотр: поля карточки блокируются, прокрутку даёт .modal-body */
.form-lock { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.payer-sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: var(--warn-soft); }
.kpi.warn .kpi-label { color: var(--warn); }
.months-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
.months-list li { display: flex; justify-content: space-between; gap: 12px; max-width: 260px; white-space: nowrap; }
.topay .sum { font-size: 15.5px; font-variant-numeric: tabular-nums; }
.topay td.actions { min-width: 300px; }
.actions-in { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.actions-in form, .inline-form { margin: 0; }
.pay-doctor { margin: 0; font-size: 16px; font-weight: 650; }
.pay-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pay-qr img { width: 220px; height: 220px; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pay-fields { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 0; align-items: center; }
.pay-fields dt { color: var(--muted); font-size: 13px; }
.pay-fields dd { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.pay-fields dd > span, .pay-fields dd > b { overflow-wrap: anywhere; }
.pay-amount { font-size: 20px; font-variant-numeric: tabular-nums; }
.pay-phone { white-space: nowrap; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.receipt-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.receipt-form label.btn { cursor: pointer; }
.btn.primary:disabled { background: var(--surface-3); border-color: var(--border); color: var(--muted); opacity: 1; }
.filter-select { width: auto; min-width: 220px; max-width: 280px; }
tr.filtered-out { display: none !important; }
.rep-card .rep-name { font-size: 17px; font-weight: 650; }
.rep-card .rep-phone { font-size: 16px; font-weight: 550; font-variant-numeric: tabular-nums; }
.rep-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rep-actions .btn { flex: 1; min-width: 120px; }
.inline-form select { min-width: 190px; max-width: 230px; height: 34px; font-size: 13.5px; }
.repeat-warn { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; padding: 6px 8px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 550; line-height: 1.35; max-width: 340px; }
.repeat-warn .ic { margin-top: 1px; }
/* ===== Роли пользователя ===== */
.role-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.role-check { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.role-check:hover { border-color: var(--border-strong); }
.role-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-check:has(input:disabled) { cursor: not-allowed; opacity: .75; }
.role-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.role-check span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-check b { font-size: 14px; font-weight: 600; }
.role-check small { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.role-checks.invalid .role-check { border-color: var(--danger); }
.role-checks .field-error { grid-column: 1 / -1; }
.tag.role-payer { background: var(--ok-soft); color: var(--ok); }

@media (max-width: 1100px) {
  .shell .main { margin-left: 0; padding: 20px 24px 40px; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 8px;
    height: 56px; padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { flex: 1; font-size: 15px; }
  .topbar .brand-mark { width: 26px; height: 26px; font-size: 17px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: none; width: min(300px, 86vw); }
  .nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar .nav-close { display: inline-grid; }
  .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .nav-open { overflow: hidden; }
  .search { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tabs { align-self: flex-start; }
}

/* ===== Телефон ===== */
@media (max-width: 720px) {
  body { font-size: 15px; }
  h1 { font-size: 21px; }
  .shell .main { padding: 16px 16px 32px; }
  .page-head { margin-bottom: 14px; }
  .page-head .btn span { display: none; }
  .page-head .btn { width: 40px; padding: 0; }
  .page-head .head-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .page-head .head-actions .btn { width: auto; padding: 0 10px; font-size: 13.5px; }
  .page-head .head-actions .btn span { display: inline; }
  .tabs { align-self: stretch; }
  .tabs a { flex: 1; justify-content: center; padding: 7px 6px; font-size: 13.5px; }
  @media (max-width: 480px) {
    .tabs a { flex-direction: column; gap: 2px; padding: 6px 4px; }
    .count { min-width: 0; padding: 0 6px; font-size: 11px; }
  }

  /* таблица → карточки */
  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tbody { display: flex; flex-direction: column; gap: 10px; }
  .table tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; box-shadow: var(--shadow-sm);
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
  }
  .table td { padding: 0; border: 0; display: grid; grid-template-columns: 128px 1fr; gap: 8px; font-size: 14px; grid-column: 1 / -1; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  .table td.c-name { grid-column: 1; grid-row: 1; display: block; font-size: 16px; margin-bottom: 4px; min-width: 0; }
  .table td.c-email { overflow-wrap: anywhere; }
  .table td.c-name::before, .table td.c-id::before { display: none; }
  .table td.c-id { grid-column: 2; grid-row: 1; display: block; width: auto; text-align: right; }
  .table td.c-id:not(:empty)::after { content: ""; }
  .table td:has(> .muted:only-child) { display: none; }
  .table td[data-label="Мессенджеры"] { align-items: center; }
  .msg-ic { width: 34px; height: 34px; }
  .msg-ic svg { width: 19px; height: 19px; }
  .table .num { text-align: left; }
  .payout-hero { grid-template-columns: 1fr; }
  .payout-hero .btn { width: 100%; }
  .ph-sum { font-size: 30px; }
  .role-checks { grid-template-columns: 1fr; }
  .filter-select { max-width: none; width: 100%; }
  .pay-fields { grid-template-columns: 1fr; gap: 2px; }
  .banks { grid-template-columns: 1fr; }
  .pay-fields dd { margin-bottom: 10px; }
  .topay .actions { grid-column: 1 / -1; display: block; min-width: 0; }
  .topay .actions::before { display: none; }
  .actions-in { justify-content: stretch; }
  .actions-in form { flex: 1; }
  .actions-in .btn { width: 100%; height: 40px; }
  .actions-in .receipt-link { width: 100%; justify-content: center; }
  .year summary { padding: 12px 14px; }
  .rows-clickable tbody tr:hover { background: var(--surface); }
  .table tbody tr.stale { background: color-mix(in srgb, var(--danger) 7%, var(--surface)); box-shadow: inset 3px 0 0 color-mix(in srgb, var(--danger) 80%, transparent), var(--shadow-sm); }
  .table tbody tr.stale > td, .rows-clickable tbody tr.stale:hover > td { background: transparent; box-shadow: none; }
  .stale-note { display: block; }
  .table tbody tr.stale .name[data-tip] { text-decoration: none; }
  .hide-touch { display: none; }

  .grid { grid-template-columns: 1fr; }
  .mot-blocks { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .kpis, .kpis.small { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .chart-box { height: 230px; }
  .hbar:has(.wide) { grid-template-columns: 110px 1fr 48px; }
  .legend-box { padding: 14px 16px; }
  .legend-box > ul { grid-template-columns: 1fr; }
  .lg-anatomy { flex-direction: column; align-items: flex-start; }
  .grid-wrap { max-height: calc(100dvh - 250px); margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0; }
  .pgrid th.sticky-l { min-width: 136px; max-width: 136px; padding: 6px 8px; }
  .pgrid .doc-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12.5px; line-height: 1.25; }
  .pgrid thead th.year span { left: 144px; right: 88px; }
  .pgrid .sticky-r { min-width: 80px; }
  .pgrid td { min-width: 64px; }
  .toolbar-right { flex-direction: column-reverse; align-items: stretch; }
  .qr-row { flex-direction: column-reverse; align-items: stretch; }
  .qr-preview { align-self: center; width: 180px; height: 180px; }
  .qr-fields { align-items: stretch; }
  .qr-fields .field { max-width: none; }

  .modal, .modal.sm, .modal.md {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    margin: 0; border-radius: 0;
  }
  .modal.sm { height: auto; margin-top: auto; border-radius: 16px 16px 0 0; }
  .modal[open] { animation: sheet-in .22s ease-out; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
  .modal-box { height: 100%; max-height: 100dvh; }
  .modal-head { padding: 12px 12px 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .modal-body { padding: 16px 16px 8px; flex: 1; }
  .modal-foot { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-foot .btn.ghost:not(.danger) { display: none; }
  .modal-foot .btn.primary { flex: 1; }
  .modal-foot .btn.danger span { display: none; }
  .modal-foot .btn.danger { width: 40px; padding: 0; }

  .tier { display: grid; grid-template-columns: 56px auto minmax(0, 1fr) auto auto; gap: 6px; padding: 8px; }
  .tier-min, .tier-val { width: 100% !important; }
  .tier-lbl:first-child { display: none; }
  .tier [data-tier-remove] { margin-left: 0; }
  .tier-error { grid-column: 1 / -1; }
  .seg.mini button { width: 30px; }

  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  .auth-card { padding: 24px 20px; }
  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.masked { color: var(--muted); letter-spacing: .02em; font-variant-numeric: tabular-nums; }

/* ===== Звонок и взаимодействие с врачом ===== */
.table th.c-act, .table td.c-act { width: 1%; white-space: nowrap; padding-left: 4px; padding-right: 8px; }
.row-acts { display: inline-flex; gap: 2px; }
.icon-btn.act { position: relative; width: 34px; height: 34px; color: var(--accent-text); }
.icon-btn.act:hover:not(:disabled) { background: var(--accent-soft); }
.icon-btn.act:disabled { color: var(--muted); opacity: .45; cursor: not-allowed; }
.ix-count { position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--accent); color: var(--on-accent); font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }
.head-acts { display: inline-flex; gap: 6px; margin-left: auto; }
.modal-head .head-acts + .icon-btn { margin-left: 0; }
.ix-form { display: flex; flex-direction: column; gap: 8px; }
.ix-form textarea { width: 100%; resize: vertical; min-height: 76px; }
.ix-form-acts { display: flex; gap: 8px; align-items: center; }
.ix-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ix { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.ix-ic { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.ix.call .ix-ic { background: var(--accent-soft); color: var(--accent-text); }
.ix.call.missed .ix-ic, .ix.call.failed .ix-ic { background: var(--danger-soft); color: var(--danger); }
.ix-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.ix-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 14px; }
.ix-head .muted { font-size: 12.5px; }
.ix-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.ix-call { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13.5px; color: var(--text-2); align-items: center; }
.ix.call.missed .ix-state, .ix.call.failed .ix-state { color: var(--danger); }
.ix-rec { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.ix-empty { padding: 12px 0; border-top: 1px solid var(--border); }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--danger); }
dialog .toasts { position: fixed; }
@media (max-width: 720px) {
  .table td.c-act { grid-column: 1 / -1; display: block; width: auto; padding: 4px 0 0; }
  .table td.c-act::before { display: none; }
  .head-acts .btn span { display: none; }
  .head-acts .btn { width: 36px; padding: 0; }
}
