/* dkclinic — фирменные цвета: глубокий фиолетовый и белый */
:root {
  --plum-950: #170630;
  --plum-900: #20093B;
  --plum-800: #2E1056;
  --plum-700: #45197F;
  --violet: #6B2EBF;
  --violet-600: #5B22A8;
  --violet-400: #9466DA;
  --lilac: #C9B3EE;
  --violet-100: #EFE7FB;
  --violet-50: #F8F4FE;
  --white: #FFFFFF;
  --ink: #1C1230;
  --ink-2: #4A3F62;
  --muted: #877D9E;
  --line: #ECE5F5;
  --line-strong: #DCD0EC;
  --danger: #CF2F5A;
  --danger-bg: #FDEEF2;
  --success: #17936D;
  --warn: #C97B10;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(32, 9, 59, .04), 0 6px 24px -8px rgba(32, 9, 59, .10);
  --shadow-lg: 0 24px 64px -16px rgba(23, 6, 48, .35);
  --font-display: 'Unbounded', 'Golos Text', sans-serif;
  --font: 'Golos Text', 'Segoe UI', sans-serif;
  --sidebar-w: 252px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font: 500 30px/1.15 var(--font-display); letter-spacing: -.02em; }
h2 { font-size: 17px; }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px/1.4 Consolas, monospace; background: var(--violet-50); padding: 1px 6px; border-radius: 5px; color: var(--plum-700); word-break: break-all; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--violet-400); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.eyebrow {
  margin: 0 0 6px; font: 600 11px/1 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--violet);
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--violet); color: #fff; box-shadow: 0 6px 16px -6px rgba(107, 46, 191, .6); }
.btn.primary:hover:not(:disabled) { background: var(--violet-600); }
.btn.ghost { background: var(--white); color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { border-color: var(--violet-400); color: var(--violet); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { border-color: var(--danger) !important; color: var(--danger) !important; }
.btn.small { height: 32px; padding: 0 13px; font-size: 13px; }
.btn.small .icon { width: 15px; height: 15px; }
.btn.big { height: 50px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: #fff #fff transparent transparent; animation: spin .7s linear infinite;
}
.btn.ghost.busy::after { border-color: var(--violet) var(--violet) transparent transparent; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 999px 0 0 999px; }
.btn-group .btn:last-child { border-radius: 0 999px 999px 0; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--violet-100); color: var(--violet); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn.on-dark { color: rgba(255, 255, 255, .6); }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.link-btn { border: 0; background: none; color: var(--violet); font: 500 13px var(--font); cursor: pointer; padding: 8px 0 0; }
.link-btn:hover { text-decoration: underline; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Оболочка ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.sidebar {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--plum-900); color: #fff; padding: 22px 14px 14px;
}
.sidebar::before {
  content: 'dk'; position: absolute; right: -34px; bottom: 58px; pointer-events: none;
  font: 700 190px/1 var(--font-display); letter-spacing: -.06em; color: rgba(255, 255, 255, .035);
}
.sidebar::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 60% at 0% 0%, rgba(148, 102, 218, .22), transparent 60%);
}
.sidebar > * { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; color: #fff; text-decoration: none !important; }
.brand-mark {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  background: #fff; color: var(--plum-900); font: 700 18px/1 var(--font-display); letter-spacing: -.04em;
}
.brand-text { font: 500 19px/1 var(--font-display); letter-spacing: -.02em; }
.brand-text small { display: block; margin-top: 5px; font: 500 10px/1 var(--font); letter-spacing: .2em; text-transform: uppercase; color: var(--lilac); }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-label { margin: 22px 12px 8px; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .38); }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px;
  color: rgba(255, 255, 255, .72); font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: #fff; color: var(--plum-900); box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5); }
.nav-item.active .icon { color: var(--violet); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-user-info { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-user-info strong { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 11.5px; color: rgba(255, 255, 255, .5); }
.sidebar-user .icon-btn { width: 30px; height: 30px; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--av, var(--violet)); color: #fff; font: 600 12.5px/1 var(--font); box-shadow: 0 0 0 2px rgba(255, 255, 255, .15);
}
.avatar.small { width: 32px; height: 32px; font-size: 11.5px; box-shadow: none; }

.main { overflow-y: auto; background: var(--white); scroll-behavior: smooth; }
.page { max-width: 1240px; margin: 0 auto; padding: 34px 40px 60px; animation: rise .35s ease both; }
.page.narrow { max-width: 920px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-loading { display: grid; place-items: center; height: 60vh; }
.page-loading span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--violet-100); border-top-color: var(--violet); animation: spin .8s linear infinite; }

/* ---------- Панели, таблицы ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-actions, .row-actions { display: flex; gap: 8px; align-items: center; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 13px 18px; font: 600 11px/1 var(--font); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: var(--violet-50); border-bottom: 1px solid var(--line);
}
.table td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-id] { cursor: pointer; transition: background .12s; }
.table tbody tr[data-id]:hover, .table tbody tr[data-id]:focus-visible { background: var(--violet-50); outline: none; }
.table tr.dim { opacity: .55; }
.table-foot { display: flex; justify-content: center; padding: 0 0 14px; }
.table-foot:has(.btn[hidden]) { display: none; }
.row-name { margin-right: 8px; font-weight: 600; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .muted { display: block; }

.card-chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px;
  background: var(--violet-100); color: var(--plum-700); font: 600 12px/1 var(--font-display); letter-spacing: -.01em; white-space: nowrap;
}
.card-chip.big { height: 28px; padding: 0 11px; font-size: 12.5px; background: var(--plum-900); color: #fff; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; vertical-align: middle; white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warn { background: #FFF3DC; color: #9A5D05; font-style: normal; }

.status-pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-scheduled { background: var(--violet-100); color: var(--violet-600); }
.st-confirmed { background: #E5F0FD; color: #1D64B8; }
.st-arrived { background: #FFF3DC; color: #9A5D05; }
.st-done { background: #DFF5EC; color: #0F7655; }
.st-cancelled { background: #F1EEF4; color: #8F879C; text-decoration: line-through; }
.st-questionnaire { background: #E3F3F9; color: #0E6A87; }
.st-ready { background: #16A34A; color: #fff; }
.st-inchair { background: var(--plum-800); color: #fff; }
.st-noshow { background: var(--danger-bg); color: var(--danger); }

.empty-state { display: grid; justify-items: center; gap: 10px; padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-state > .icon { width: 38px; height: 38px; color: var(--lilac); stroke-width: 1.3; }
.empty-state p { margin: 0; }
.empty-state.error > .icon { color: var(--danger); }
.empty-state.full { height: 100vh; align-content: center; }

/* ---------- Формы ---------- */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field > span .icon { width: 15px; height: 15px; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 42px; padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: 15px/1.4 var(--font); color: var(--ink); background: var(--white); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: #B3AAC4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(107, 46, 191, .12); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236B2EBF' stroke-width='1.8'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 13px center; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; }
fieldset + fieldset { padding-top: 22px; border-top: 1px dashed var(--line-strong); }
legend { padding: 0 0 14px; font: 500 15px/1 var(--font-display); color: var(--plum-800); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--violet); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.form-actions.split { justify-content: space-between; }
.form-actions.sticky { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 16px 22px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.alert-field textarea { border-color: #F2C3D0; background: #FFFAFB; }
.alert-field > span { color: var(--danger); }

.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--violet-50); border: 1px solid var(--line); height: 42px; }
.segmented label { flex: 1; display: flex; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { flex: 1; display: grid; place-items: center; padding: 0 16px; border-radius: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s; white-space: nowrap; }
.segmented input:checked + span { background: var(--white); color: var(--violet); font-weight: 600; box-shadow: 0 1px 4px rgba(32, 9, 59, .12); }
.segmented input:focus-visible + span { outline: 2px solid var(--violet-400); }
.segmented.small { height: 36px; }
.segmented.small span { font-size: 13px; padding: 0 12px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches input { position: absolute; opacity: 0; }
.swatches i { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.swatches input:checked + i { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); transform: scale(.92); }

/* ---------- Модальные окна и уведомления ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(23, 6, 48, .45); backdrop-filter: blur(3px); animation: fade .16s ease both;
}
.modal-overlay.leaving { animation: fade .16s ease reverse both; }
.modal {
  width: min(620px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--white); border-radius: 20px; box-shadow: var(--shadow-lg); animation: rise .2s ease both;
}
.modal.small { width: min(440px, 100%); }
.modal.wide { width: min(860px, 100%); }
.modal.viewer { width: min(1180px, 100%); height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 14px 26px; }
.modal-head h2 { font: 500 18px/1.25 var(--font-display); letter-spacing: -.01em; }
.modal-body { padding: 4px 26px 24px; overflow-y: auto; flex: 1; }
.confirm-text { margin: 0 0 14px; }

#toasts { position: fixed; right: 24px; bottom: calc(24px + var(--dock-h, 0px)); transition: bottom .2s; z-index: 100; display: grid; gap: 10px; justify-items: end; }
.toast {
  max-width: 420px; padding: 13px 18px 13px 16px; border-radius: 12px; background: var(--plum-900); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s ease both; border-left: 4px solid var(--lilac);
}
.toast:has(.toast-action) { display: flex; align-items: center; gap: 16px; }
.toast-action {
  flex: none; padding: 5px 12px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; background: none;
  color: #fff; font: 600 13px var(--font); cursor: pointer;
}
.toast-action:hover { background: rgba(255, 255, 255, .12); }
.toast-error { background: #fff; color: var(--danger); border: 1px solid #F4C7D3; border-left: 4px solid var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: .35s; }

/* ---------- Вход ---------- */
.auth { display: grid; grid-template-columns: minmax(380px, 46%) 1fr; min-height: 100vh; }
.auth-art { position: relative; overflow: hidden; background: var(--plum-900); color: #fff; }
.auth-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 70%; animation: fade 1.2s ease both; }
.auth-art::after { content: ''; position: absolute; inset: 0 0 45% 0; background: linear-gradient(var(--plum-900) 35%, transparent); pointer-events: none; }
.auth-art-inner { position: relative; z-index: 1; padding: 52px 56px; }
.auth-mark {
  display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 19px; background: #fff;
  color: var(--plum-900); font: 700 27px/1 var(--font-display); letter-spacing: -.05em;
}
.auth-tagline { margin: 40px 0 16px; font: 500 40px/1.08 var(--font-display); letter-spacing: -.03em; animation: rise .6s .1s ease both; }
.auth-sub { max-width: 360px; margin: 0; color: var(--lilac); font-size: 16px; animation: rise .6s .2s ease both; }
.auth-form-wrap { display: grid; place-items: center; padding: 40px; background: var(--white); }
.auth-form { width: min(400px, 100%); animation: rise .5s .1s ease both; }
.auth-form h1 { font-size: 28px; }
.auth-form > p { margin: -4px 0 8px; }

/* ---------- Главная ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; flex-wrap: wrap; }
.hero h1 { font-size: 34px; }
.hero-search, .searchbar, .patient-picker { position: relative; display: flex; align-items: center; }
.hero-search { width: min(460px, 100%); }
.hero-search > .icon, .searchbar > .icon, .patient-picker > .icon { position: absolute; left: 16px; color: var(--violet); pointer-events: none; }
.hero-search input, .searchbar input { height: 50px; padding-left: 46px !important; border-radius: 999px !important; background: var(--violet-50) !important; border-color: transparent !important; font-size: 15px; }
.hero-search input:focus, .searchbar input:focus { background: #fff !important; border-color: var(--violet) !important; }
.patient-picker input { padding-left: 42px !important; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; padding: 6px; max-height: 380px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.search-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.search-item strong { display: block; font-weight: 600; }
.search-item .muted { display: block; }
.search-item.active, .search-item:hover { background: var(--violet-50); }
.search-more { padding: 10px 12px; }
.search-empty { color: var(--violet); font-weight: 600; }
.search-empty .icon { width: 16px; height: 16px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 26px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { display: grid; gap: 6px; padding: 20px 24px; border-left: 1px solid var(--line); animation: rise .4s ease both; }
.stat:first-child { border-left: 0; background: var(--plum-900); color: #fff; }
.stat:first-child .stat-label { color: var(--lilac); }
.stat:nth-child(2) { animation-delay: .05s; } .stat:nth-child(3) { animation-delay: .1s; } .stat:nth-child(4) { animation-delay: .15s; }
.stat-num { font: 500 34px/1 var(--font-display); letter-spacing: -.03em; }
.stat-label { font-size: 13px; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item {
  display: grid; grid-template-columns: 54px 14px 1fr auto auto; align-items: center; gap: 12px;
  padding: 12px 10px; border-radius: 12px; cursor: pointer; transition: background .12s;
}
.timeline-item + .timeline-item { border-top: 1px solid var(--line); }
.timeline-item:hover, .timeline-item:focus-visible { background: var(--violet-50); outline: none; }
.timeline-item.dim { opacity: .5; }
.tl-time { font: 500 15px/1 var(--font-display); color: var(--plum-800); }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--dc) 18%, transparent); }
.tl-body { min-width: 0; }
.tl-body strong { display: block; font-weight: 600; }
.tl-proc { display: block; font-size: 13.5px; font-weight: 600; color: var(--plum-700); }
.tl-body .muted { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list a { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 11px 10px; border-radius: 12px; color: inherit; text-decoration: none; }
.recent-list a:hover { background: var(--violet-50); }
.recent-list .card-chip { grid-row: span 2; }
.recent-name { font-weight: 600; }

/* ---------- Картотека ---------- */
.searchbar { margin-bottom: 18px; gap: 14px; }
.searchbar input { flex: 1; }
.searchbar > .small { position: absolute; right: 22px; }

/* ---------- Карта пациента ---------- */
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.back-link .icon { width: 16px; height: 16px; }
.patient-head { display: grid; grid-template-columns: 1fr auto; gap: 18px 24px; align-items: center; margin-bottom: 26px; }
.patient-id { display: flex; align-items: center; gap: 20px; min-width: 0; }
.patient-monogram {
  flex: none; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px;
  background: var(--plum-900); color: #fff; font: 500 25px/1 var(--font-display); letter-spacing: -.03em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 14px 30px -14px rgba(32, 9, 59, .6);
}
.patient-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-bottom: 8px; font-size: 14px; color: var(--ink-2); }
.patient-meta a { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
.patient-meta .icon { width: 15px; height: 15px; color: var(--violet); }
.patient-actions { display: flex; gap: 10px; align-items: center; }
.allergy-banner {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 12px;
  background: var(--danger-bg); color: #8E1B3C; border: 1px solid #F4C7D3;
}
.allergy-banner .icon { color: var(--danger); width: 20px; height: 20px; }

.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px 14px; border: 0; background: none;
  font: 500 14.5px var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; transition: color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--violet); }
.tab.active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--violet); }
.tab em { font-style: normal; font-size: 11.5px; font-weight: 600; min-width: 20px; padding: 2px 6px; border-radius: 999px; background: var(--violet-100); color: var(--violet-600); }
.tab em:empty { display: none; }
.tab-body { animation: rise .25s ease both; }

.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.dl { margin: 0; }
.dl-row { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.dl-row:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-size: 13.5px; }
.dl dd { margin: 0; font-weight: 500; white-space: pre-wrap; }
.record-meta { margin: 16px 0 0; }
.med-block { padding: 14px 16px; border-radius: 12px; background: var(--violet-50); }
.med-block + .med-block { margin-top: 10px; }
.med-block h3 { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.med-block h3 .icon { display: none; width: 16px; height: 16px; }
.med-block p { margin: 0; white-space: pre-wrap; }
.med-block.alert { background: var(--danger-bg); }
.med-block.alert h3 { color: var(--danger); }
.med-block.alert h3 .icon { display: block; }
.med-block.ok h3 .icon { display: block; color: var(--success); }

/* ---------- Зубная формула ---------- */
.teeth-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.chart-panel { overflow-x: auto; }
.dental-chart { display: grid; justify-content: center; gap: 0; padding: 10px 0 6px; min-width: 720px; }
.dental-chart.child { min-width: 480px; }
.jaw { display: flex; justify-content: center; align-items: stretch; }
.jaw-side { display: flex; gap: 2px; }
.jaw-mid { width: 2px; margin: 0 8px; background: linear-gradient(var(--line-strong), var(--line-strong)) center / 2px 100% no-repeat; }
.jaw.upper .tooth { justify-content: flex-end; }
.jaw.lower .tooth { justify-content: flex-start; }
.occlusal-line { position: relative; height: 1px; margin: 10px 0; background: var(--line-strong); }
.occlusal-line span { position: absolute; top: -9px; padding: 0 8px; background: #fff; font: 600 11px/18px var(--font-display); color: var(--muted); }
.occlusal-line span:first-child { left: 0; } .occlusal-line span:last-child { right: 0; }
.tooth {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; min-width: 42px;
  border: 0; border-radius: 11px; background: none; cursor: pointer; font: inherit; color: inherit; transition: background .12s, transform .12s;
}
div.tooth { cursor: default; }
button.tooth:hover { background: var(--violet-50); }
button.tooth:hover .tooth-svg { transform: translateY(-1px); }
.tooth.selected { background: var(--violet-100); box-shadow: inset 0 0 0 2px var(--violet); }
.tooth-svg { display: block; transition: transform .15s; overflow: visible; }
.tooth-num { font: 500 12px/1 var(--font-display); color: var(--ink-2); }
.tooth.selected .tooth-num { color: var(--violet); }
.tooth-code {
  display: grid; place-items: center; min-width: 22px; height: 18px; padding: 0 4px; border-radius: 6px;
  font: 700 10.5px/1 var(--font); color: #fff; background: var(--c);
}
.tooth-code:empty { background: none; }
.tooth.has-note .tooth-num::after { content: '•'; color: var(--violet); margin-left: 1px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; list-style: none; margin: 18px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.legend li, .problems li { display: flex; align-items: center; gap: 7px; }
.legend i, .status-btn i, .problems i {
  display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 4px; border-radius: 6px;
  font: 700 10.5px/1 var(--font); font-style: normal; color: #fff; background: var(--c);
}
.tooth-panel { position: sticky; top: 20px; display: grid; gap: 14px; }
.sel-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sel-teeth { font: 500 24px/1.15 var(--font-display); letter-spacing: -.02em; color: var(--plum-800); word-break: break-word; }
.sel-hint { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.sel-hint .icon { width: 36px; height: 36px; color: var(--lilac); stroke-width: 1.3; }
.sel-hint p { margin: 0; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.status-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: 500 12.5px/1.2 var(--font); color: var(--ink); cursor: pointer; text-align: left; transition: border-color .12s, background .12s;
}
.status-btn:hover { border-color: var(--violet-400); background: var(--violet-50); }
.status-btn.current { border-color: var(--violet); background: var(--violet-100); }
.status-btn i { flex: none; }
.status-btn[data-status="healthy"] i { background: #fff; color: var(--success); box-shadow: inset 0 0 0 1px var(--line-strong); }
.problems { border-top: 1px solid var(--line); padding-top: 14px; }
.tooth-files { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.tooth-files h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.tooth-files p { margin: 0; }
.tooth-files .btn { justify-self: start; }
.tooth-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tooth-thumb {
  display: grid; gap: 2px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--plum-950); cursor: pointer; color: var(--lilac); font: 500 10.5px var(--font);
}
.tooth-thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.tooth-thumb > .icon { width: 28px; height: 28px; margin: 14px auto 6px; }
.tooth-thumb span { padding: 2px 6px 4px; background: #fff; color: var(--ink-2); text-align: left; }
.tooth-thumb:hover { border-color: var(--violet-400); }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; font: 600 11px var(--font); background: #fff; }
.note-state { margin-left: auto; font-style: normal; font-weight: 500; font-size: 11.5px; color: var(--success); }
.tooth.has-files .tooth-num::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 3px; border-radius: 50%; background: #3B82D6; vertical-align: 2px; }
.legend i.legend-files { min-width: 8px; width: 8px; height: 8px; padding: 0; border-radius: 50%; background: #3B82D6; }

/* Файлы: зубы на миниатюре, фильтр по зубу, правка подписи в просмотре */
.tooth-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.chip { height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--violet-400); }
.chip.active { background: var(--violet); border-color: var(--violet); color: #fff; }
.file-thumb { position: relative; }
.file-teeth { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--plum-800); font: 600 11.5px var(--font); }
.upload-preview { border-radius: 12px; overflow: hidden; background: var(--plum-950); max-height: 220px; display: grid; place-items: center; }
.upload-preview img { max-width: 100%; max-height: 220px; object-fit: contain; }
.viewer-edit { display: flex; gap: 8px; flex: 1; min-width: 280px; }
.viewer-edit input { min-height: 34px; padding: 6px 10px; font-size: 13.5px; }
.viewer-edit .teeth-input { max-width: 150px; }
.problems h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.problems ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 300px; overflow-y: auto; }
.problems li { padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.problems li:hover { background: var(--violet-50); }
.problems li b { font: 500 13px var(--font-display); min-width: 22px; }
.problems small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Приёмы ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.list-head p { margin: 0; }
.visits { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.visit { display: grid; grid-template-columns: 76px 1fr; gap: 20px; padding: 20px 22px; }
.visit-date { display: grid; align-content: start; justify-items: center; padding: 10px 0; border-radius: 14px; background: var(--plum-900); color: #fff; height: max-content; }
.vd-day { font: 500 28px/1 var(--font-display); letter-spacing: -.03em; }
.vd-month { font-size: 11.5px; color: var(--lilac); margin-top: 4px; }
.visit-main header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.visit-main h3 { font-size: 16.5px; font-weight: 600; }
.visit-main header p { margin: 2px 0 0; }
.teeth-ref { color: var(--violet); }
.visit-secs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 22px; }
.visit-sec h4 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.visit-sec p { margin: 0; white-space: pre-wrap; font-size: 14.5px; }

/* ---------- Файлы ---------- */
.dropzone {
  display: grid; justify-items: center; gap: 6px; padding: 30px; margin-bottom: 22px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--violet-50); color: var(--ink-2); transition: border-color .15s, background .15s;
}
.dropzone .icon { width: 30px; height: 30px; color: var(--violet); }
.dropzone:hover, .dropzone.drag { border-color: var(--violet); background: var(--violet-100); }
.dropzone.uploading { pointer-events: none; opacity: .6; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.file-card { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; background: #fff; transition: transform .15s, box-shadow .15s; }
.file-card:hover, .file-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: none; }
.file-thumb { display: grid; place-items: center; height: 150px; background: var(--plum-950); color: var(--lilac); gap: 4px; align-content: center; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .icon { width: 36px; height: 36px; }
.file-thumb span { font: 600 12px var(--font-display); }
.file-card figcaption { padding: 10px 12px; display: grid; gap: 2px; }
.file-card strong { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer { flex: 1; display: grid; place-items: center; min-height: 0; height: calc(100% - 56px); background: var(--plum-950); border-radius: 12px; overflow: hidden; }
.modal.viewer .modal-body { display: flex; flex-direction: column; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer .empty-state { color: var(--lilac); }
.viewer-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; flex-wrap: wrap; }

/* ---------- Записи пациента ---------- */
.list-title { padding: 14px 20px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); background: var(--violet-50); border-bottom: 1px solid var(--line); }
.panel.flush + .panel.flush { margin-top: 16px; }
.appt-list { list-style: none; margin: 0; padding: 0; }
.appt-row { display: grid; grid-template-columns: 170px 220px 1fr auto; gap: 16px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.appt-row:last-child { border-bottom: 0; }
.appt-row:hover, .appt-row:focus-visible { background: var(--violet-50); outline: none; }

/* ---------- Расписание ---------- */
.schedule-page { max-width: none; }
.sched-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-input { width: auto !important; min-height: 40px !important; padding: 7px 12px !important; border-radius: 999px !important; }
.sched-summary { margin: -10px 0 14px; }
/* Сетка прокручивается сама по себе: шапка с врачами и колонка времени остаются на месте. */
.sched {
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: auto; max-height: calc(100vh - 168px); position: relative;
}
.sched-head, .sched-body { display: grid; grid-template-columns: 64px repeat(var(--cols), minmax(210px, 1fr)); }
.sched-head { position: sticky; top: 0; z-index: 6; background: var(--white); border-bottom: 1px solid var(--line); }
.sched-corner { position: sticky; left: 0; z-index: 1; background: var(--white); border-right: 1px solid var(--line); }
.lane-head { position: relative; display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--line); background: var(--white); }
.lane-head.draggable { cursor: grab; }
/* «Ручка» перетаскивания появляется при наведении на шапку. */
.lane-grip {
  position: absolute; left: 2px; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  width: 14px; height: 30px; color: var(--muted); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.lane-grip .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.lane-head.draggable:hover .lane-grip { opacity: .8; }
.lane-head.draggable:hover { background: var(--violet-50); }
.lane-head > .sched-doc { border-left: 0; flex: 1; }
.lane-head.merged > .sched-doc { padding-top: 7px; padding-bottom: 7px; }
.lane-head.merged > .sched-doc + .sched-doc { border-top: 1px dashed var(--line); }
.lane-head.merged > .sched-doc i { height: 26px; }
.lane-split {
  position: absolute; top: 6px; right: 6px; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font: 600 11px var(--font); color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
.lane-split .icon { width: 12px; height: 12px; }
.lane-head:hover .lane-split, .lane-split:focus-visible { opacity: 1; }
.lane-split:hover { color: var(--danger); border-color: var(--danger); }
/* Перетаскивание колонки: она «приподнимается» целиком — шапка и записи — и едет за курсором. */
.sched.is-col-dragging, .sched.is-col-dragging * { cursor: grabbing !important; user-select: none; }
.sched.is-col-dragging .appt { pointer-events: none; }
.lane-head.lane-lifted {
  z-index: 9; background: var(--white); border-radius: 12px 12px 0 0;
  box-shadow: 0 -2px 0 var(--violet) inset, 0 10px 30px -8px rgba(32, 9, 59, .35);
}
.lane-head.lane-lifted .lane-grip { opacity: 1; color: var(--violet); }
.sched-col.lane-lifted {
  z-index: 5; background-color: var(--white);
  box-shadow: 0 24px 50px -12px rgba(32, 9, 59, .4), 0 0 0 2px var(--violet);
}
.lane-head.lane-merging, .sched-col.lane-merging { opacity: .32; }
.lane-badge {
  position: fixed; transform: translateX(-50%); z-index: 500;
  padding: 7px 14px; border-radius: 999px; background: var(--plum-900); color: #fff; white-space: nowrap;
  font: 600 12.5px var(--font); box-shadow: 0 10px 24px -8px rgba(23, 6, 48, .6); pointer-events: none;
  animation: fade .15s ease both;
}
.lane-badge.merge { background: var(--violet); }
.lane-badge.bad { background: var(--danger); }
/* Колонка, с которой объединяем, — подсвечена рамкой; красной, если записи пересекаются. */
.lane-head.merge-target { background: var(--violet-100); box-shadow: inset 0 0 0 3px var(--violet); }
.sched-col.merge-target { background-color: rgba(107, 46, 191, .1); box-shadow: inset 0 0 0 3px var(--violet); }
.lane-head.merge-bad { background: var(--danger-bg); box-shadow: inset 0 0 0 3px var(--danger); }
.sched-col.merge-bad { background-color: rgba(207, 47, 90, .09); box-shadow: inset 0 0 0 3px var(--danger); }
.merge-pulse { animation: merge-pulse .5s ease; }
@keyframes merge-pulse { 40% { box-shadow: inset 0 0 0 4px var(--violet); } }
.split-warn { color: var(--danger); }
.sched-doc {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-width: 0; border: 0; border-left: 1px solid var(--line);
  background: var(--white); font: inherit; color: inherit; text-align: left; cursor: pointer; transition: background .12s;
}
.sched-doc:hover { background: var(--violet-50); }
.sched-doc > span { min-width: 0; }
.sched-doc i { flex: none; width: 10px; height: 34px; border-radius: 5px; background: var(--dc); }
.sched-doc b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-doc small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.off-label { color: var(--danger); font-weight: 600; }
.changed { font-style: normal; font-size: 10.5px; font-weight: 600; color: #9A5D05; background: #FFF3DC; padding: 1px 7px; border-radius: 999px; }
.sched-body { position: relative; }
.sched-times { position: sticky; left: 0; z-index: 4; border-right: 1px solid var(--line); background: var(--violet-50); }
.sched-times span { position: absolute; right: 10px; transform: translateY(-50%); font: 500 11.5px/1 var(--font-display); color: var(--muted); }
.sched-times span:first-child { transform: translateY(4px); }
.sched-col {
  position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image:
    linear-gradient(to bottom, var(--line-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 100% calc(var(--row) * 4), 100% var(--row);
}
.sched-col:hover { background-color: rgba(248, 244, 254, .6); }
.off-hours {
  position: absolute; left: 0; right: 0; pointer-events: none;
  background: repeating-linear-gradient(-45deg, rgba(135, 125, 158, .10) 0 5px, transparent 5px 11px), rgba(241, 238, 244, .55);
}
.appt {
  position: absolute; z-index: 2; left: 4px; right: 4px; display: grid; align-content: start; gap: 1px; padding: 4px 10px 4px 12px;
  border: 0; border-radius: 9px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; overflow: hidden;
  background: color-mix(in srgb, var(--dc) 13%, #fff); box-shadow: inset 3px 0 0 var(--dc), 0 1px 2px rgba(32, 9, 59, .08);
  transition: transform .12s, box-shadow .12s;
}
.appt:has(.appt-alert) { padding-right: 26px; }
/* Перетаскивание: блок тянется за курсором, нижний край меняет длительность. */
.appt { cursor: grab; touch-action: none; user-select: none; }
.appt.dragging {
  z-index: 10; cursor: grabbing; opacity: .94; transition: none; transform: none;
  box-shadow: inset 3px 0 0 var(--dc), 0 16px 32px -10px rgba(32, 9, 59, .5), 0 0 0 2px var(--dc);
}
.sched.is-dragging, .sched.is-dragging .sched-col { cursor: grabbing; }
.sched.is-dragging .appt:not(.dragging) { pointer-events: none; }
.appt-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.appt-resize::after {
  content: ''; position: absolute; left: 50%; bottom: 2px; width: 30px; height: 3px; margin-left: -15px;
  border-radius: 2px; background: var(--dc); opacity: 0; transition: opacity .12s;
}
.appt:hover .appt-resize::after, .appt.dragging .appt-resize::after { opacity: .55; }
.appt:hover { transform: translateY(-1px); box-shadow: inset 3px 0 0 var(--dc), 0 6px 14px -6px rgba(32, 9, 59, .35); z-index: 3; }
.appt-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.appt-time { flex: none; font: 500 11px/1.35 var(--font-display); color: var(--plum-700); }
/* Процедура — главное в блоке: её видно сразу, без открытия записи. */
.appt-proc { min-width: 0; font-size: 13px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-name { min-width: 0; font-size: 12.5px; font-weight: 500; line-height: 1.3; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-line:not(:has(.appt-proc)) + .appt-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.appt-name em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--warn); }
/* Первичный пациент: при визите нужно завести карту. */
.appt-new {
  display: inline-block; padding: 1px 7px; border-radius: 999px; vertical-align: 1px; white-space: nowrap;
  background: #FEF0C7; color: #9A5800 !important; font: normal 700 10.5px/1.45 var(--font) !important;
}
.appt-new.match { background: #E5F0FD; color: #1D64B8 !important; }
.appt-new.lost { background: #FDE8EF; color: #B4234E !important; }
.appt-new.paper { background: #F1E9DA; color: #7A5A1E !important; }
.guest-kind { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.now-who .appt-new { margin: 2px 0; }
.idle-new { margin-left: 10px; padding: 1px 8px; border-radius: 999px; background: rgba(254, 240, 199, .16); color: #FCD68A; font: normal 600 12px/1.5 var(--font); }
.match-hint {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: #E5F0FD; color: #154C8C; font-size: 13.5px;
}
.match-hint > .icon { flex: none; color: #1D64B8; }
.match-hint > span { flex: 1; }
.appt.tall .appt-line { display: grid; gap: 1px; }
.appt.tall .appt-proc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* Запись «до следующего приёма» растягивается — пунктирный нижний край. */
.appt.elastic { border-bottom: 2px dashed color-mix(in srgb, var(--dc) 55%, transparent); border-radius: 9px 9px 4px 4px; }
.appt.compact { display: flex; align-items: center; gap: 8px; padding-top: 0; padding-bottom: 0; }
.appt.compact .appt-line { flex: 0 1 auto; max-width: 70%; }
.appt.compact .appt-name { flex: 1 1 0; }
.appt-alert { position: absolute; top: 4px; right: 6px; color: var(--danger); }
.appt-alert .icon { width: 14px; height: 14px; }
.appt.st-cancelled { opacity: .45; background: repeating-linear-gradient(-45deg, #fff, #fff 5px, #F4F1F7 5px, #F4F1F7 10px); text-decoration: none; }
.appt.st-cancelled .appt-proc, .appt.st-cancelled .appt-name { text-decoration: line-through; }
.appt.st-noshow { background: var(--danger-bg); box-shadow: inset 3px 0 0 var(--danger); }
.appt.st-done { background: color-mix(in srgb, var(--dc) 6%, #fff); }
.appt.st-done .appt-time::before { content: '✓ '; color: var(--success); }
.appt.st-arrived { box-shadow: inset 3px 0 0 var(--dc), inset 0 0 0 2px #F2B65A; }
.appt.st-questionnaire { box-shadow: inset 3px 0 0 var(--dc), inset 0 0 0 2px #7CC6DE; }
.appt.st-ready { box-shadow: inset 3px 0 0 var(--dc), 0 0 0 2px #16A34A; animation: ready-pulse 1.8s ease-in-out infinite; }
.appt.st-inchair { background: color-mix(in srgb, var(--dc) 24%, #fff); }
@keyframes ready-pulse { 50% { box-shadow: inset 3px 0 0 var(--dc), 0 0 0 4px rgba(22, 163, 74, .35); } }
/* Текущий приём: красная рамка, прошедшая часть закрашена плотнее. */
.appt.is-now {
  z-index: 3; animation: none;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--dc) 32%, #fff) var(--p), color-mix(in srgb, var(--dc) 12%, #fff) var(--p));
  box-shadow: inset 3px 0 0 var(--dc), 0 0 0 2px var(--danger), 0 10px 24px -10px rgba(207, 47, 90, .55);
}
.appt-now {
  position: absolute; right: 8px; bottom: 9px; padding: 1px 8px; border-radius: 999px;
  background: var(--danger); color: #fff; font: 600 10.5px/1.5 var(--font);
}
/* Линия «сейчас» идёт под записями, чтобы не перечёркивать текст; подпись — в колонке времени. */
.now-line { position: absolute; left: 64px; right: 0; height: 2px; background: var(--danger); pointer-events: none; z-index: 1; opacity: .8; }
.now-label {
  position: absolute; right: 6px; z-index: 1; transform: translateY(-50%); padding: 2px 6px; border-radius: 6px;
  background: var(--danger); color: #fff; font: 600 10.5px/1.3 var(--font-display); font-style: normal;
}

/* Тихое обновление расписания: без анимации появления, чтобы ничего не мигало. */
.no-anim, .no-anim .now-card { animation: none !important; }

/* Выбор врача для этого компьютера */
.view-filter {
  position: relative; display: inline-flex; align-items: center; height: 40px; padding-left: 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--white); color: var(--violet);
}
.view-filter select {
  width: auto; min-height: 38px; border: 0; border-radius: 999px; padding: 0 34px 0 8px;
  font-size: 14px; font-weight: 500; color: var(--ink-2); background-color: transparent;
}
.view-filter select:focus { box-shadow: none; }
.view-filter:focus-within { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(107, 46, 191, .12); }
.icon-btn.bordered { width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: 999px; }
.link-btn.inline { padding: 0; font-size: inherit; }

/* ---------- Контекстное меню записи (правый клик) ---------- */
.ctx-menu {
  position: fixed; z-index: 400; min-width: 250px; max-width: 320px; padding: 6px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: ctx-in .12s ease both;
}
@keyframes ctx-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.ctx-head { display: grid; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ctx-head b, .ctx-head span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-head b { font-size: 13px; font-weight: 600; }
.ctx-head span { font-size: 12.5px; color: var(--muted); }
.ctx-label { margin: 6px 10px 4px; font: 600 10.5px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px;
  background: none; font: 500 13.5px/1.2 var(--font); color: var(--ink); text-align: left; cursor: pointer;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--violet-50); outline: none; }
.ctx-item.current { color: var(--violet); font-weight: 600; }
.ctx-item > .icon { width: 16px; height: 16px; color: var(--muted); }
.ctx-check { margin-left: auto; display: inline-flex; }
.ctx-check .icon { width: 16px; height: 16px; color: var(--violet); }
.ctx-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(28, 18, 48, .14); }
.ctx-menu hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--line); }

/* ---------- Панель «Сейчас» ---------- */
.now-wrap { margin-bottom: 18px; }
.now-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.now-head .eyebrow { margin: 0; }
.now-head .link-btn { padding: 0; color: var(--muted); }
.now-head .link-btn:hover { color: var(--violet); }
.now-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.now-card {
  display: grid; align-content: start; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-top: 3px solid var(--dc);
  border-radius: 14px; background: var(--white); box-shadow: var(--shadow); animation: rise .3s ease both;
}
.now-card.busy { background: linear-gradient(color-mix(in srgb, var(--dc) 7%, #fff), #fff 70%); }
.now-card header { display: flex; align-items: center; gap: 8px; }
.now-card header i { width: 10px; height: 10px; border-radius: 50%; background: var(--dc); }
.now-card header b { font-weight: 600; }
.now-card header .muted { margin-left: auto; }
.now-current { display: grid; gap: 2px; }
.now-current strong { font-size: 15.5px; font-weight: 600; }
.now-tag { display: flex; align-items: center; gap: 7px; margin: 0 0 4px; font: 700 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--danger); }
.now-tag.free { color: var(--success); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(207, 47, 90, .5); } 70%, 100% { box-shadow: 0 0 0 8px rgba(207, 47, 90, 0); } }
.now-proc { font-size: 13.5px; font-weight: 600; color: var(--plum-700); }
.now-progress { height: 6px; margin: 8px 0 4px; border-radius: 3px; background: var(--violet-100); overflow: hidden; }
.now-progress span { display: block; height: 100%; border-radius: 3px; background: var(--dc); }
.now-left { margin: 0; font-size: 13px; color: var(--ink-2); }
.now-left.soon { color: var(--warn); font-weight: 600; }
.now-left.over { color: var(--danger); font-weight: 600; }
.now-warn { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; color: var(--danger); font-size: 13px; font-weight: 600; }
.now-warn .icon { width: 15px; height: 15px; }
.now-current .status-select { justify-self: start; margin-top: 8px; }
.now-next { padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.now-sub { margin: 0 0 6px; font: 600 10.5px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.now-next ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.now-next li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 10px; align-items: start; }
.now-state { grid-column: 2; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.now-time { font: 500 12.5px/1.6 var(--font-display); color: var(--plum-700); }
.now-who { min-width: 0; }
.now-who b, .now-who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-who b { font-size: 13.5px; font-weight: 600; }
.now-who small { font-size: 12px; color: var(--muted); }
.now-note { font-style: normal; font-size: 12px; color: var(--muted); }
.now-note.late { color: var(--danger); font-weight: 600; }
.status-select {
  width: auto !important; min-height: 30px !important; height: 30px; padding: 3px 28px 3px 11px !important;
  border: 0 !important; border-radius: 999px !important; font-size: 12.5px !important; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' fill='none' stroke='%23888' stroke-width='1.8'%3E%3Cpath d='m1 1.2 4 4 4-4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 10px center !important;
}
.status-select option { background: #fff; color: var(--ink); }

.shift-hint { margin: -4px 0 0; padding: 10px 14px; border-radius: 10px; background: #FFF6E6; color: #8A5300; font-size: 13.5px; }
.shift-intro { margin: 0 0 14px; }
.shift-list { display: grid; gap: 6px; margin-bottom: 8px; }
.shift-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 150px; align-items: center; gap: 14px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; transition: background .12s;
}
.shift-row.focus { border-color: var(--violet-400); background: var(--violet-50); }
.shift-row > i { width: 10px; height: 30px; border-radius: 5px; background: var(--dc); }
.shift-row.is-off > i { opacity: .35; }
.shift-who b { display: block; font-weight: 600; font-size: 14px; }
.shift-who small { color: var(--muted); font-size: 12px; }
.shift-row.is-off .shift-who b { color: var(--muted); }
.shift-hours { display: flex; align-items: center; gap: 6px; }
.shift-hours input { width: 104px !important; min-height: 36px !important; padding: 6px 10px !important; }
.shift-row.is-off .shift-hours { opacity: .35; }
.shift-state { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.shift-state .link-btn { padding: 0; font-size: 12.5px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + span { background: var(--violet); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--violet-400); outline-offset: 2px; }
.switch input:disabled { cursor: default; }

.paste-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: 12px;
  background: var(--violet-100); color: var(--plum-800); font-size: 13.5px; animation: rise .2s ease both;
}
.paste-bar > .icon { color: var(--violet); }
.paste-bar > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-form .picked { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--violet-50); border: 1px solid var(--line); flex-wrap: wrap; }
.picked .spacer { flex: 1; }
.guest { display: grid; gap: 8px; }
.guest-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.guest-foot .muted { flex: 1; }
.guest-foot .spacer { flex: 1; }

/* ---------- Заставка при бездействии ---------- */
.idle-screen {
  position: fixed; inset: 0; z-index: 300; overflow: hidden auto; cursor: pointer;
  background: #12052A; color: #fff; animation: idle-fade .9s ease both;
  --glass: rgba(255, 255, 255, .055);
  --glass-line: rgba(255, 255, 255, .12);
}
@keyframes idle-fade { from { opacity: 0; } }

/* Медленно плывущие световые пятна, зерно и монограмма — фон, который не перерисовывается. */
.idle-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.idle-bg .blob {
  position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%; filter: blur(90px); opacity: .5;
  animation: idle-drift 26s ease-in-out infinite alternate;
}
.idle-bg .b1 { background: #6B2EBF; top: -24vmax; left: -14vmax; }
.idle-bg .b2 { background: #9F7AEA; bottom: -30vmax; right: -18vmax; opacity: .32; animation-duration: 34s; animation-delay: -8s; }
.idle-bg .b3 { background: #C2367B; width: 34vmax; height: 34vmax; top: 34%; left: 52%; opacity: .16; animation-duration: 41s; animation-delay: -15s; }
@keyframes idle-drift { to { transform: translate(9vmax, 7vmax) scale(1.14); } }
.idle-bg::after {
  content: ''; position: absolute; inset: 0; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.idle-mono {
  position: absolute; right: -3vw; bottom: -12vh; font: 700 46vmin/1 var(--font-display); letter-spacing: -.07em;
  color: transparent; -webkit-text-stroke: 1px rgba(255, 255, 255, .06);
}

.idle-content { position: relative; min-height: 100%; display: grid; place-items: center; padding: 56px 48px 80px; }
.idle-inner { width: min(1320px, 100%); display: grid; gap: 40px; }

.idle-top { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
/* Сплошной цвет и мигание цветом (а не прозрачностью): иначе при появлении заставки браузер
   рисует двоеточие отдельным слоем и оно на секунду «отстаёт» от цифр. */
.idle-clock {
  font: 500 clamp(88px, 12vw, 190px)/.9 var(--font-display); letter-spacing: -.055em; color: #fff;
  text-shadow: 0 0 42px rgba(183, 148, 244, .45), 0 0 90px rgba(107, 46, 191, .35);
}
.idle-clock .colon { margin: 0 .02em; color: #E6D7FC; animation: idle-blink 2s steps(1) infinite; }
@keyframes idle-blink { 50% { color: rgba(230, 215, 252, .25); } }
.idle-date { display: grid; gap: 6px; padding-bottom: .9vw; }
.idle-date b { font: 500 clamp(18px, 1.7vw, 26px)/1 var(--font-display); text-transform: capitalize; }
.idle-date span { font-size: clamp(15px, 1.3vw, 19px); letter-spacing: .14em; text-transform: uppercase; color: var(--lilac); }

.idle-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; }
/* Несколько врачей: кольцо справа от шапки, текст — на всю ширину под ним. */
.idle-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "head ring" "ready ready" "title title" "sub sub" "next next";
  align-items: center; align-content: start; gap: 0 24px; padding: 30px 30px 26px; overflow: hidden;
  border-radius: 34px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(26px) saturate(140%); -webkit-backdrop-filter: blur(26px) saturate(140%);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.idle-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--dc), transparent);
}
.idle-head { grid-area: head; display: grid; gap: 10px; align-self: start; min-width: 0; }
.idle-card > .idle-ready { grid-area: ready; margin-top: 18px; }
.idle-card > .idle-title { grid-area: title; margin-top: 16px; }
.idle-card > .idle-sub { grid-area: sub; margin-top: 8px; }
.idle-card > .idle-next { grid-area: next; margin-top: 22px; }
.idle-doctor { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 16px; color: rgba(255, 255, 255, .7); }
.idle-doctor i { width: 11px; height: 11px; border-radius: 50%; background: var(--dc); box-shadow: 0 0 12px var(--dc); }
.idle-state { display: flex; align-items: center; gap: 12px; margin: 8px 0 0; font: 700 14px/1 var(--font); letter-spacing: .18em; text-transform: uppercase; }
.idle-state.busy { color: #FF9DB7; }
.idle-state.free { color: #8DEBBE; }
.idle-state.ready { color: #8DEBBE; }
.idle-state.ready .dot { animation: dock-blink 1.2s ease-in-out infinite; }
.idle-state.wait { color: #FCD68A; }
.idle-state .pulse { width: 11px; height: 11px; }
.idle-state .dot { width: 11px; height: 11px; border-radius: 50%; background: currentColor; box-shadow: 0 0 14px currentColor; }
.idle-title { margin: 0; font: 500 clamp(24px, 2vw, 34px)/1.12 var(--font-display); letter-spacing: -.02em; overflow-wrap: break-word; }
.idle-sub { margin: 0; font-size: clamp(16px, 1.3vw, 20px); color: rgba(255, 255, 255, .72); }

/* Кольцо прогресса */
.idle-ring { grid-area: ring; position: relative; width: clamp(120px, 8.5vw, 150px); aspect-ratio: 1; --ring-a: var(--dc); --ring-b: #E9D8FD; }
.idle-ring.soon { --ring-a: #F6AD55; --ring-b: #FDE68A; }
.idle-ring.over { --ring-a: #F43F5E; --ring-b: #FDA4AF; }
.idle-ring.calm { --ring-a: #34D399; --ring-b: #C4F1E0; }
.idle-ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 12; }
.ring-bar {
  fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s ease;
  filter: drop-shadow(0 0 10px var(--ring-a));
}
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; }
.ring-center b { font: 500 clamp(30px, 2.4vw, 40px)/1 var(--font-display); letter-spacing: -.04em; }
.ring-center b small { font-size: .45em; margin: 0 .12em; color: rgba(255, 255, 255, .6); letter-spacing: 0; }
.ring-center span { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .6); }
.ring-center .ring-icon { width: 46px; height: 46px; margin: 0 auto; color: #8DEBBE; stroke-width: 2.2; }

/* «Пациента можно забирать» — главное, что должен заметить врач. */
.idle-ready {
  display: flex; align-items: center; gap: 14px; margin: 4px 0; padding: 14px 20px 14px 14px; border-radius: 20px;
  background: linear-gradient(135deg, #16A34A, #22C55E); box-shadow: 0 0 0 0 rgba(34, 197, 94, .5), 0 18px 40px -16px rgba(34, 197, 94, .8);
  animation: idle-ready 1.8s ease-in-out infinite;
}
.idle-ready-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: rgba(255, 255, 255, .22); }
.idle-ready-icon .icon { width: 24px; height: 24px; }
.idle-ready b { display: block; font: 500 clamp(17px, 1.4vw, 22px)/1.2 var(--font-display); }
.idle-ready small { font-size: 15px; color: rgba(255, 255, 255, .88); }
@keyframes idle-ready { 50% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0), 0 18px 40px -16px rgba(34, 197, 94, .8); } }

.idle-next {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 20px; min-width: 0;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .07);
}
.idle-next-label { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .5); }
.idle-next-time { font: 500 20px/1 var(--font-display); color: var(--lilac); }
.idle-next-who { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idle-next-who small { margin-left: 10px; font-weight: 400; color: rgba(255, 255, 255, .6); }
.idle-next .status-pill { flex: none; height: 28px; padding: 0 12px; font-size: 13px; }

.idle-hint {
  position: fixed; left: 0; right: 0; bottom: 22px; margin: 0; text-align: center; font-size: 14px;
  color: rgba(255, 255, 255, .38); animation: idle-fade 1s 2.5s ease both;
}

/* Один врач (кабинет): часы и карточка крупнее. */
.idle-inner.single { width: min(1080px, 100%); }
.idle-inner.single .idle-cards { grid-template-columns: 1fr; }
/* Один врач (кабинет): большое кольцо справа на всю высоту текста. */
.idle-inner.single .idle-card {
  padding: 40px 44px; gap: 0 40px;
  grid-template-areas: "head ring" "ready ring" "title ring" "sub ring" "next next";
}
.idle-inner.single .idle-title { font-size: clamp(36px, 4.6vw, 72px); line-height: 1.06; }
.idle-inner.single .ring-center span { font-size: 13px; letter-spacing: .1em; }
.idle-inner.single .idle-ring { width: clamp(220px, 21vw, 300px); }
.idle-inner.single .ring-center b { font-size: clamp(56px, 5.6vw, 84px); }
.idle-inner.single .ring-center span { font-size: 13px; }
.idle-inner.single .idle-ready b { font-size: clamp(20px, 1.8vw, 26px); }

/* Появление: часы, затем карточки по очереди. */
.idle-screen.entering .idle-top { animation: idle-in .9s cubic-bezier(.2, .7, .2, 1) .1s both; }
.idle-screen.entering .idle-card { animation: idle-in .9s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(.3s + var(--i) * .12s); }
@keyframes idle-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }

@media (max-width: 700px) {
  .idle-content { padding: 32px 18px 70px; }
  .idle-cards { grid-template-columns: 1fr; }
  .idle-card, .idle-inner.single .idle-card { grid-template-columns: 1fr; grid-template-areas: "head" "ring" "ready" "title" "sub" "next"; justify-items: start; }
}

/* ---------- Сотрудники и копии ---------- */
.week-days { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chip input { position: absolute; opacity: 0; pointer-events: none; }
.day-chip span {
  display: grid; place-items: center; width: 46px; height: 38px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #fff; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.day-chip input:checked + span { background: var(--violet); border-color: var(--violet); color: #fff; }
.day-chip input:focus-visible + span { outline: 2px solid var(--violet-400); outline-offset: 2px; }
.week-field { padding: 14px 16px; border-radius: 12px; background: var(--violet-50); }
.week-grid { display: grid; gap: 6px; }
.week-row { display: grid; grid-template-columns: 70px 120px auto 120px; align-items: center; gap: 8px; }
.week-row input[type=time] { min-height: 36px; padding: 6px 10px; background: #fff; }
.week-row.is-off input[type=time] { opacity: .35; }
.week-field .link-btn { justify-self: start; padding-top: 4px; }
.week-field p { margin: 0; }
.role-help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.role-help div { display: grid; gap: 2px; padding: 14px 16px; border-radius: 12px; background: var(--violet-50); font-size: 13px; }
.role-help b { font-size: 14px; color: var(--plum-800); }
.role-help span { color: var(--ink-2); }
.note-panel { margin-bottom: 20px; }
.note-panel p { margin: 0 0 10px; }
.note-panel p:last-child { margin: 0; }

/* ---------- Печать ---------- */
body.print-mode { background: #EEEAF3; }
.print-toolbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: center; align-items: center; gap: 14px; padding: 14px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.print-page { width: 210mm; min-height: 297mm; margin: 24px auto; padding: 16mm 15mm; background: #fff; box-shadow: var(--shadow); font-size: 12.5px; color: #111; }
.print-head { display: flex; align-items: center; gap: 22px; padding-bottom: 14px; border-bottom: 2px solid var(--plum-900); }
.print-brand { display: flex; align-items: center; gap: 10px; font: 500 16px/1 var(--font-display); }
.print-brand .brand-mark { width: 38px; height: 38px; background: var(--plum-900); color: #fff; font-size: 15px; border-radius: 11px; }
.print-brand small { display: block; font: 500 8.5px var(--font); letter-spacing: .18em; text-transform: uppercase; color: var(--violet); margin-top: 3px; }
.print-title h1 { font: 500 15px/1.25 var(--font-display); }
.print-title p { margin: 4px 0 0; }
.print-sec { padding: 12px 0; border-bottom: 1px solid #ddd; break-inside: avoid-page; }
.print-sec h2 { font: 500 12.5px var(--font-display); text-transform: uppercase; letter-spacing: .06em; color: var(--plum-800); margin-bottom: 8px; }
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.pf-grid.one { grid-template-columns: 1fr; }
.pf { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.pf span { color: #666; }
.pf b { font-weight: 500; white-space: pre-wrap; }
.formula-table { border-collapse: collapse; margin: 0 auto 10px; font: 500 11px var(--font-display); }
.formula-table td { width: 26px; height: 20px; text-align: center; border: 1px solid #bbb; }
.formula-table tr:nth-child(2) td { border-bottom: 2px solid #333; }
.formula-table td.mid { border-left: 2px solid #333; }
.formula-table tr:nth-child(1) td, .formula-table tr:nth-child(4) td { color: var(--danger); font-family: var(--font); font-weight: 700; }
.print-chart .dental-chart { min-width: 0; transform: scale(.82); transform-origin: top center; margin-bottom: -40px; }
.print-chart .tooth { min-width: 36px; padding: 2px 0; }
.print-legend { font-size: 10.5px; color: #555; margin: 6px 0 0; }
.print-notes { margin: 6px 0 0; padding-left: 18px; }
.print-visit { padding: 8px 0; border-top: 1px dashed #ccc; break-inside: avoid; }
.print-visit:first-of-type { border-top: 0; }
.pv-head { display: flex; gap: 16px; margin-bottom: 4px; }
.print-visit p { margin: 2px 0; white-space: pre-wrap; }
.print-visit i { color: #666; }
.pv-sign { text-align: right; margin-top: 8px; color: #666; }
.print-foot { padding-top: 12px; font-size: 10px; color: #888; text-align: right; }

.consent-tools { flex-wrap: wrap; }
.consent-tools select, .consent-tools input:not([type=checkbox]) { width: auto; min-height: 38px; padding: 6px 12px; font-size: 14px; }
.consent-tools select { padding-right: 32px; }
.consent-warn { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px auto 0; color: #9A5800; font-size: 14px; }
.print-page.consent { font: 13px/1.55 'Times New Roman', Georgia, serif; color: #111; }
.consent-head { display: grid; gap: 2px; padding-bottom: 10px; margin-bottom: 18px; border-bottom: 1px solid #333; text-align: center; font-size: 12px; }
.consent-head b { font-size: 14px; }
.print-page.consent h1 { margin: 0 0 4px; font: 700 16px/1.3 'Times New Roman', Georgia, serif; text-align: center; text-transform: uppercase; letter-spacing: .02em; }
.consent-card { margin: 0 0 16px; text-align: center; font-size: 12px; color: #444; }
.print-page.consent p { margin: 0 0 10px; }
.consent-points { margin: 0 0 14px; padding-left: 20px; text-align: justify; }
.consent-points li { margin-bottom: 6px; }
.blank { display: inline-block; border-bottom: 1px solid #222; height: 1em; vertical-align: -2px; }
.consent-rep { margin-top: 14px !important; }
.consent-signs { display: grid; gap: 18px; margin-top: 28px; }
.consent-signs > div { display: grid; grid-template-columns: 170px 190px auto 1fr auto; align-items: end; gap: 0 10px; }
.consent-signs span { font-weight: 700; }
.consent-signs small { grid-row: 2; font-size: 10px; color: #666; text-align: center; }
.consent-signs small:first-of-type { grid-column: 2; }
.consent-signs small:last-of-type { grid-column: 4; }
.consent-signs .blank { width: 100%; }

@media print {
  @page { size: A4; margin: 12mm; }
  body.print-mode { background: #fff; }
  .print-toolbar, #toasts { display: none !important; }
  .print-page { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .print-chart .tooth-code { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Адаптивность ---------- */
@media (max-width: 1100px) {
  .dash-grid, .overview-grid, .teeth-layout { grid-template-columns: 1fr; }
  .tooth-panel { position: static; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .appt-row { grid-template-columns: 150px 1fr auto; }
  .appt-row > .muted { display: none; }
}
@media (max-width: 860px) {
  .shift-row { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .shift-hours, .shift-state { grid-column: 2 / -1; }
  :root { --sidebar-w: 74px; }
  .brand-text, .nav-item span, .nav-label, .sidebar-user-info, .sidebar::before { display: none; }
  .brand { padding: 4px 0 24px; justify-content: center; }
  .nav-item { justify-content: center; }
  .sidebar-user { flex-direction: column; }
  .page { padding: 24px 18px 48px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 300px; }
  .grid-3, .grid-4, .role-help { grid-template-columns: 1fr 1fr; }
  .span-3 { grid-column: span 1; }
  .patient-head { grid-template-columns: 1fr; }
  .patients-table th:nth-child(4), .patients-table td:nth-child(4), .patients-table th:nth-child(5), .patients-table td:nth-child(5) { display: none; }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4, .role-help { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .visit { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Плавающая панель «В клинике» (справа внизу, на всех страницах) ---------- */
/* Анимация — только когда панель появляется: содержимое обновляется каждые несколько секунд и не должно прыгать. */
.dock { position: fixed; right: 24px; bottom: 24px; z-index: 45; display: grid; justify-items: end; animation: rise .22s ease both; }
.print-mode .dock { display: none; }
.dock-panel {
  width: 400px; max-width: calc(100vw - 48px); display: grid; overflow: hidden;
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px); border: 1px solid var(--line-strong);
  border-radius: 18px; box-shadow: var(--shadow-lg);
}
.dock-panel.has-ready { border-color: #86D7A6; }
.dock-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 16px;
  background: linear-gradient(135deg, var(--plum-900), var(--violet-600)); color: #fff;
}
.dock-title { font: 500 13px/1 var(--font-display); letter-spacing: -.01em; }
.dock-title b {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 6px; padding: 0 6px;
  border-radius: 999px; background: rgba(255, 255, 255, .18); font: 600 12px/1 var(--font);
}
.dock-ready-count {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  background: #16A34A; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.dock-ready-count i, .dock-pill i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: dock-blink 1.4s ease-in-out infinite; }
@keyframes dock-blink { 50% { opacity: .35; } }
.dock-icon {
  display: grid; place-items: center; width: 30px; height: 30px; margin-left: auto; border: 0; border-radius: 9px;
  background: none; color: rgba(255, 255, 255, .85); cursor: pointer;
}
.dock-icon + .dock-icon { margin-left: 0; }
.dock-icon:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.dock-icon .icon { width: 17px; height: 17px; }
.dock-unlock {
  display: flex; align-items: center; gap: 8px; margin: 10px 12px 0; padding: 8px 12px; border: 0; border-radius: 10px;
  background: #FFF3DC; color: #8A5300; font: 600 12.5px/1.3 var(--font); text-align: left; cursor: pointer;
}
.dock-unlock .icon { width: 15px; height: 15px; }
.dock-scroll { max-height: min(56vh, 520px); overflow-y: auto; }
.dock-list { list-style: none; margin: 0; padding: 8px; display: grid; gap: 6px; }
.dock-sub { margin: 6px 16px -2px; font: 600 10.5px/1.4 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.dock-list + .dock-sub { margin-top: 0; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.dock-record-count { padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: 12px; font-weight: 600; white-space: nowrap; }
.dock-row.dock-record { background: #FBF9FE !important; box-shadow: inset 3px 0 0 var(--dc), inset 0 0 0 1px var(--line-strong); }
.dock-next.primary {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 0; border-color: var(--violet); background: var(--violet);
  color: #fff; text-decoration: none;
}
.dock-next.primary:hover { background: var(--violet-600); text-decoration: none; }
.dock-next.primary .icon { width: 14px; height: 14px; }
.dock-skip {
  margin-left: auto; height: 28px; padding: 0 10px; border: 0; border-radius: 999px; background: none;
  color: var(--muted); font: 500 12.5px/1 var(--font); cursor: pointer;
}
.dock-skip:hover { background: var(--violet-50); color: var(--ink-2); }
.dock-skip:disabled { opacity: .5; cursor: wait; }
.dock-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 2px 10px; align-items: baseline;
  padding: 9px 10px 10px 12px; border-radius: 12px; background: var(--white) !important; color: var(--ink) !important;
  box-shadow: inset 3px 0 0 var(--dc), inset 0 0 0 1px var(--line); text-decoration: none !important;
}
.dock-row.st-ready {
  background: #F0FBF4 !important; box-shadow: inset 3px 0 0 var(--dc), inset 0 0 0 2px #16A34A;
  animation: dock-ready 1.8s ease-in-out infinite;
}
@keyframes dock-ready { 50% { box-shadow: inset 3px 0 0 var(--dc), inset 0 0 0 2px #16A34A, 0 0 0 4px rgba(22, 163, 74, .18); } }
.dock-row.st-inchair { background: var(--violet-50) !important; }
.dock-time { font: 500 12.5px/1.5 var(--font-display); color: var(--plum-700); }
.dock-who { min-width: 0; }
/* ФИО целиком — длинное переносится на вторую строку, а не обрезается. */
.dock-who a, .dock-who b { display: block; font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; }
.dock-who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-who a:hover { color: var(--violet); }
.dock-who small { font-size: 12px; color: var(--muted); }
.dock-since { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dock-row.st-ready .dock-since { color: #15803D; font-weight: 600; }
.dock-actions { grid-column: 1 / -1; min-width: 0; display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.dock-actions .status-select { height: 28px; min-height: 28px !important; font-size: 12px !important; }
.dock-next {
  margin-left: auto; height: 28px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--white); color: var(--violet); font: 600 12.5px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.dock-next:hover { border-color: var(--violet); background: var(--violet-50); }
.dock-row.st-ready .dock-next { border-color: #16A34A; background: #16A34A; color: #fff; }
.dock-row.st-ready .dock-next:hover { background: #128A3E; }
.dock-next:disabled, .dock-actions select:disabled { opacity: .5; cursor: wait; }
.dock-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px 0 16px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--plum-900), var(--violet-600)); color: #fff; box-shadow: var(--shadow-lg);
  font: 500 13.5px/1 var(--font); cursor: pointer;
}
.dock-pill b { font-weight: 700; }
.dock-pill i { background: var(--lilac); animation: none; }
.dock-pill em { padding: 4px 9px; border-radius: 999px; background: #16A34A; font: normal 600 12px/1 var(--font); }
.dock-pill em.record { background: rgba(255, 255, 255, .2); }
.dock-pill.has-ready { animation: dock-pill-ready 1.8s ease-in-out infinite; }
.dock-pill.has-ready i { background: #4ADE80; animation: dock-blink 1.4s ease-in-out infinite; }
@keyframes dock-pill-ready { 50% { box-shadow: var(--shadow-lg), 0 0 0 6px rgba(22, 163, 74, .28); } }
.dock-muted { display: inline-flex; opacity: .8; }
.dock-muted .icon { width: 15px; height: 15px; }

/* ---------- Автозаполнение приёма нейросетью ---------- */
.ai-fill {
  display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(135deg, var(--violet-50), #fff); border: 1px solid var(--violet-100);
}
.ai-fill .field > span { color: var(--violet-600); font-weight: 600; }
.ai-fill .field > span .icon { color: var(--violet); }
.ai-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-actions .btn .icon { width: 16px; height: 16px; }

/* ---------- Вкладыш приёма в бумажную карту ---------- */
.slip-hint { text-align: center; margin: 18px 0 0; }
.visit-slip {
  --slip-w: 130mm;
  width: var(--slip-w); margin: 14px auto 40px; padding: 5mm 6mm; background: #fff; color: #111;
  border: 1px dashed #9A92A8; font: 11pt/1.4 'Times New Roman', Times, serif; box-shadow: var(--shadow);
}
.visit-slip p { margin: 0 0 1.5mm; white-space: pre-line; }
.visit-slip b { font-weight: 700; }
.slip-when { margin-right: 2mm; }
.visit-slip .slip-sign { margin: 3mm 0 0; display: flex; align-items: flex-end; gap: 3mm; }
.slip-sign span { flex: 0 0 35mm; border-bottom: 1px solid #111; height: 1em; }
@media print {
  .slip-hint { display: none; }
  .visit-slip { margin: 0; box-shadow: none; }
}
