/* ===================================================
   Офтальмологическая клиника «Острое Зрение» — стили
   =================================================== */

:root {
    --bg: #f0f2f5;
    --bg-subtle: #f8f9fb;
    --card: #ffffff;
    --border: #e0e3e8;
    --border-light: #eceef1;
    --text: #1e293b;
    --text-secondary: #475569;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-glow: rgba(37, 99, 235, 0.12);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --slot-available: #ffffff;
    --slot-unavailable: repeating-linear-gradient(
        -45deg,
        #f7f7f7 0,
        #f7f7f7 5px,
        #e4e4e4 5px,
        #e4e4e4 6px
    );
    --color-green: #c8ebc8;
    --color-green-border: #9fd49f;
    --color-red: #f5c4c4;
    --color-red-border: #e8a0a0;
    --color-blue: #ddd4f3;
    --color-blue-border: #c4b5e8;
    --color-yellow: #f5e6b8;
    --color-yellow-border: #e8d49a;
    --color-gray: #e2e5ea;
    --color-gray-border: #c8cdd6;
    --color-orange: #f5dcc4;
    --color-orange-border: #e8c4a0;
    --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Скроллбар */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c8d0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0a8b4; }

/* ===================== Страница входа ===================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #7c3aed 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    top: -200px; right: -200px;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
    bottom: -100px; left: -100px;
}
.login-box {
    position: relative; z-index: 1;
    background: var(--card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-box .login-logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
}
.login-box h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}
.login-box .subtitle {
    margin: 0 0 2rem;
    color: var(--muted);
    font-size: 0.9rem;
}
.login-form { text-align: left; }
.login-form label { display: block; margin-bottom: 1.15rem; }
.login-form label span {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.login-form input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--bg-subtle);
}
.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--card);
}
.login-form .login-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: -0.2rem 0 0.7rem;
}
.login-form .login-remember input[type="checkbox"] {
    width: auto;
    margin: 0;
    padding: 0;
}
.login-form .login-remember span {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.login-form button {
    width: 100%;
    padding: 0.7rem;
    margin-top: 0.5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
}
.login-form button:hover { background: var(--primary-hover); }
.login-form button:active { transform: scale(0.98); }
.login-box .error {
    color: var(--danger);
    margin-bottom: 1rem;
    padding: 0.6rem 0.85rem;
    background: #fef2f2;
    border-radius: var(--radius-sm);
    border: 1px solid #fecaca;
    font-size: 0.9rem;
    text-align: left;
}
.login-box .hint {
    margin-top: 1.25rem;
    font-size: 0.8rem;
    color: var(--muted);
}

/* ===================== Шапка ===================== */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 56px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.logo {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.logo-icon { font-size: 1.25rem; line-height: 1; }
.logo-text { letter-spacing: -0.01em; }
.main-header nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
}
.main-header nav::-webkit-scrollbar { height: 4px; }
.main-header nav::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.87rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color var(--transition), background var(--transition);
}
.nav-link svg { flex-shrink: 0; opacity: 0.6; transition: opacity var(--transition); }
.nav-link:hover { color: var(--primary); background: var(--primary-light); }
.nav-link:hover svg { opacity: 0.85; }
.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}
.nav-link.active svg { opacity: 1; }
.header-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    background: var(--bg-subtle);
    border-radius: 20px;
    border: 1px solid var(--border-light);
}
.user-badge svg { opacity: 0.5; }
.user { color: var(--muted); font-size: 0.9rem; }
.btn-logout {
    color: var(--danger);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.btn-logout:hover { background: #fef2f2; }

/* Гамбургер-меню (мобильная) */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* Порог гамбургера поднят до 1180px: при полном наборе разделов меню
   (до 11 пунктов у администратора) даже сжатый инлайн-вариант ниже этой
   ширины не помещается и «уезжает» в незаметный горизонтальный скролл —
   тут надёжнее убрать меню в гамбургер. */
@media (max-width: 1180px) {
    .nav-toggle { display: flex; }
    .main-header nav {
        display: none;
        position: absolute;
        top: 56px; left: 0; right: 0;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.15rem;
        z-index: 100;
    }
    .main-header nav.open { display: flex; }
    .nav-link { padding: 0.6rem 0.85rem; width: 100%; }
}

/* Средние экраны (типичные ноутбуки 1181–1699px, включая 1366/1440/1536px):
   полное меню не помещается без сжатия — прячем иконки и уменьшаем
   отступы, чтобы пункты меню не «уезжали» в незаметный горизонтальный
   скролл навигации. */
@media (min-width: 1181px) and (max-width: 1699px) {
    .main-header { padding: 0 1rem; }
    .header-left { gap: 0.65rem; }
    .logo-text { font-size: 0.95rem; }
    .main-header nav { gap: 0; }
    .nav-link { padding: 0.4rem 0.5rem; font-size: 0.8rem; gap: 0.3rem; }
    .nav-link svg { display: none; }
    .header-right { gap: 0.5rem; }
    .user-badge { padding: 0.25rem 0.5rem; font-size: 0.82rem; }
}

/* ===================== Основной контент ===================== */
.schedule-main { padding: 1.25rem 1.5rem; max-width: 100%; overflow-x: auto; }
/* Большие мониторы: страницы-списки (пациенты, врачи, услуги, пользователи,
   логи, уведомления) не растягиваются на всю ширину 4K/ультраширокого экрана —
   иначе таблицы становятся разрежёнными и плохо читаются. Страницы с сеткой
   расписания/резерва/обзвона и управление расписанием сохраняют полную ширину. */
@media (min-width: 1700px) {
    .schedule-main:not(.schedule-main-with-calendar):not(.reserve-main) {
        max-width: 1600px;
        margin: 0 auto;
    }
}
.schedule-main-with-calendar { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: nowrap; }
.schedule-left { flex: 1; min-width: 0; overflow-x: auto; }
.schedule-calendar-aside { flex: 0 0 280px; position: sticky; top: 72px; }
.schedule-toolbar {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.schedule-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Навигация по дате */
.date-nav { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }
.date-nav input[type="date"] { flex: 1; min-width: 0; max-width: 180px; }
.date-nav input[type="date"] {
    padding: 0.45rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.date-nav input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.btn-nav {
    padding: 0.45rem 0.75rem;
    border: 1.5px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
}
.btn-nav:hover { background: var(--bg); border-color: #c5cad2; }

/* ===================== Виджет-календарь ===================== */
.calendar-widget {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    box-shadow: var(--shadow-sm);
}
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; gap: 0.5rem; }
.calendar-month-title { font-weight: 600; font-size: 1rem; text-align: center; flex: 1; }
.btn-calendar-nav { padding: 0.35rem 0.5rem; font-size: 0.95rem; }
.calendar-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.calendar-table th { padding: 0.35rem 0; text-align: center; font-weight: 600; color: var(--muted); border: none; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.04em; }
.calendar-table td { padding: 0.2rem; text-align: center; border: none; }
.calendar-table .day-cell {
    display: block; width: 100%; min-width: 2rem; padding: 0.4rem;
    border-radius: var(--radius-sm); background: none; border: none;
    cursor: pointer; font-size: 0.9rem; color: var(--text);
    transition: all 0.15s;
}
.calendar-table .day-cell:hover { background: var(--primary-light); color: var(--primary); }
.calendar-table .day-cell.other-month { color: var(--muted); opacity: 0.6; }
.calendar-table .day-cell.selected { background: var(--primary); color: #fff; font-weight: 600; }
.calendar-table .day-cell.selected:hover { background: var(--primary-hover); color: #fff; }
.calendar-table .day-cell.today { border: 2px solid var(--primary); font-weight: 600; }
.calendar-table .day-cell.today.selected { border-color: transparent; }
.calendar-table .day-cell.empty { cursor: default; visibility: hidden; }
.calendar-table .day-cell.cal-day-none { background: #e5e7eb; }
.calendar-table .day-cell.cal-day-free { background: #bbf7d0; }
.calendar-table .day-cell.cal-day-busy { background: #16a34a; color: #fff; }
.calendar-table .day-cell.cal-day-busy:hover { background: #15803d; color: #fff; }
.calendar-table .day-cell.cal-day-none.selected,
.calendar-table .day-cell.cal-day-free.selected,
.calendar-table .day-cell.cal-day-busy.selected { background: var(--primary); color: #fff; }
.calendar-table .day-cell.cal-day-none.selected:hover,
.calendar-table .day-cell.cal-day-free.selected:hover,
.calendar-table .day-cell.cal-day-busy.selected:hover { background: var(--primary-hover); color: #fff; }

/* Тоггл-кнопка видна только на мобильном */
.cal-toggle-btn { display: none; }

@media (max-width: 1024px) {
    .schedule-main-with-calendar { flex-wrap: wrap; }
    .schedule-calendar-aside { flex: 1 1 100%; max-width: 320px; margin: 0 auto; position: static; }
}

/* ===================== Сетка расписания ===================== */
.schedule-grid {
    --schedule-slot-h: 26px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: auto;     /* вместо hidden — позволяет скролл, но сохраняет border-radius */
    min-height: 400px;
    box-shadow: var(--shadow-sm);
}
.grid-loading {
    padding: 2.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
}
.grid-loading::before {
    content: '';
    display: block;
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Пустое состояние (нет врачей, нет слотов) — без спиннера, с крестиком */
.grid-empty {
    padding: 2.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
}
.grid-empty::before {
    content: '✕';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 auto 0.85rem;
}
.grid-error::before {
    content: '!';
    background: #fff7ed;
    color: #ea580c;
}
.schedule-scroll-stack {
    position: relative;
    display: inline-block;
    min-width: 100%;
    vertical-align: top;
}
.schedule-drag-preview {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    border: 2px dashed var(--primary);
    border-radius: var(--radius-sm);
    background: rgba(37, 99, 235, 0.16);
    box-sizing: border-box;
    min-height: 12px;
}
.schedule-drag-preview.schedule-drag-preview--invalid {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.14);
}
.schedule-drag-preview.schedule-drag-preview--break {
    border-style: dashed;
    background: repeating-linear-gradient(
        -45deg,
        rgba(148, 163, 184, 0.2),
        rgba(148, 163, 184, 0.2) 5px,
        rgba(241, 245, 249, 0.35) 5px,
        rgba(241, 245, 249, 0.35) 10px
    );
}
.schedule-grid table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* Колонки врачей сжимаются до 130px, растягиваясь на всю ширину экрана,
       если места достаточно; скролл появляется только когда врачей много. */
    min-width: max(100%, calc(40px + 130px * var(--doctor-count, 1)));
}
.schedule-grid th, .schedule-grid td { border: 1px solid var(--border-light); padding: 0; vertical-align: top; }
.schedule-grid .col-time { width: 40px; min-width: 40px; max-width: 40px; height: var(--schedule-slot-h); min-height: var(--schedule-slot-h); max-height: var(--schedule-slot-h); text-align: center; padding: 2px 4px !important; font-size: 8pt; color: #c4c4c4; background: var(--bg-subtle); }
.schedule-grid .col-time.hour { height: var(--schedule-slot-h); min-height: var(--schedule-slot-h); max-height: var(--schedule-slot-h); font-size: 8pt; color: #6b7280; border-left-width: 2px; box-shadow: inset 0 1px 0 0 #d1d5db; font-weight: 600; }
.schedule-grid tr.row-hour-start td { box-shadow: inset 0 1px 0 0 #d1d5db; }
.schedule-grid .col-doctor { width: auto; min-width: 130px; }
.schedule-grid .doctor-header {
    padding: 10px 8px;
    text-align: center;
    background: #fff;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}
.schedule-grid .doctor-avatar {
    display: block;
    width: 36px;
    height: 36px;
    margin: 0 auto 6px;
    border-radius: 50%;
    background: linear-gradient(145deg, #e8ecf1 0%, #d8dee6 100%);
    border: 1px solid var(--border);
}
.schedule-grid .doctor-name { font-weight: 600; display: block; font-size: 0.88rem; color: var(--text); line-height: 1.25; }
.schedule-grid .doctor-hours { font-size: 0.78rem; color: var(--muted); display: block; margin-top: 2px; }
.schedule-grid .cell-slot { height: var(--schedule-slot-h); min-height: var(--schedule-slot-h); position: relative; }
.schedule-grid .cell-slot.cell-free { height: var(--schedule-slot-h); min-height: var(--schedule-slot-h); max-height: var(--schedule-slot-h); }
/* Недоступное время — штриховка */
.schedule-grid .cell-outside {
    background: var(--slot-unavailable) !important;
    cursor: default;
}
/* Перерыв: штриховка + чашка */
.schedule-grid .cell-break {
    padding: 0 !important;
    vertical-align: top;
    position: relative;
    background: var(--slot-unavailable) !important;
}
.schedule-grid .break-block {
    position: absolute;
    left: 3px;
    right: 3px;
    top: 3px;
    bottom: 3px;
    min-height: 0;
    border-radius: 4px;
    cursor: grab;
    touch-action: none; /* desktop: точный drag */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(100, 116, 139, 0.45);
    background: rgba(248, 250, 252, 0.5);
    overflow: hidden;
    box-sizing: border-box;
    padding: 2px 2px 1px;
}
.schedule-grid .break-block:hover { border-color: rgba(37, 99, 235, 0.5); }
.schedule-grid .break-block.break-block-readonly { cursor: default; touch-action: auto; }
.schedule-grid .break-block.break-block-readonly:hover { border-color: inherit; }
.schedule-grid .break-block.is-dragging {
    cursor: grabbing;
    opacity: 0.35;
    z-index: 2;
}
.schedule-grid .cell-break-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    text-align: center;
    pointer-events: none;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}
.schedule-grid .cell-break-time {
    font-size: 0.58rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.schedule-grid .cell-break-cup {
    width: 16px;
    height: 14px;
    flex-shrink: 0;
    margin: 1px 0 -1px;
    background: center 70% / 16px 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 8h12v6a4 4 0 01-4 4H10a4 4 0 01-4-4V8z' stroke='%236b7c93' stroke-width='1.5'/%3E%3Cpath d='M18 9h1.5a2 2 0 010 4H18' stroke='%236b7c93' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M8 5V4M12 5V4M16 5V4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    opacity: 0.85;
}
.schedule-grid .cell-break-label {
    font-size: 0.58rem;
    font-weight: 600;
    color: #6b7280;
    line-height: 1;
    white-space: nowrap;
}
/* ≤30 мин: ещё плотнее */
.schedule-grid .break-block-short .cell-break-cup {
    width: 14px;
    height: 12px;
    margin: 0 0 -2px;
    background-size: 14px 14px;
    background-position: center 75%;
}
.schedule-grid .break-block-short .cell-break-label,
.schedule-grid .break-block-short .cell-break-time {
    font-size: 0.52rem;
    line-height: 1;
}
/* ≤15 мин: без подписи «Перерыв» */
.schedule-grid .break-block-tiny .cell-break-cup {
    width: 12px;
    height: 11px;
    margin: 0 0 -1px;
    background-size: 12px 12px;
}
.schedule-grid .break-block-tiny .cell-break-label { display: none; }
.schedule-grid .break-block-tiny .cell-break-time {
    font-size: 0.5rem;
}
/* Свободное время — белый фон */
.schedule-grid .cell-free { background: var(--slot-available); cursor: pointer; }
.schedule-grid .cell-free:hover { background: #f0f7ff; }
.schedule-grid .cell-free .btn-add {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 8pt; color: transparent; text-decoration: none;
    background: transparent; border: none; cursor: pointer; padding: 0;
    width: 100%; font-family: inherit;
    transition: color 0.15s, background 0.15s;
}
.schedule-grid .cell-free:hover .btn-add { color: var(--primary); font-weight: 600; }
.schedule-grid .cell-appointment { padding: 0 !important; vertical-align: top; position: relative; }
.schedule-grid .appointment-block {
    position: absolute; left: 3px; right: 3px; top: 3px; bottom: 3px;
    min-height: 24px; border-radius: 4px;
    padding: 5px 7px 4px; font-size: 0.78rem; cursor: grab;
    overflow: hidden; color: #1e293b;
    display: flex; flex-direction: column;
    gap: 1px;
    transition: transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(15, 23, 42, 0.12);
    touch-action: none;
    line-height: 1.25;
}
/* Телефон: вертикальная прокрутка страницы; перенос — долгим нажатием (~0.5 с) */
@media (pointer: coarse), (max-width: 768px) {
    .schedule-grid .appointment-block,
    .schedule-grid .break-block {
        touch-action: pan-y;
    }
    .schedule-grid .appointment-block.drag-longpress-ready,
    .schedule-grid .break-block.drag-longpress-ready {
        touch-action: none;
        box-shadow: 0 0 0 2px var(--primary);
    }
}
.schedule-grid .appointment-block:hover { transform: scale(1.01); box-shadow: var(--shadow-md); z-index: 2; }
.schedule-grid .appointment-block.is-dragging {
    cursor: grabbing;
    /* Через блок видна сетка; целевой интервал показывает .schedule-drag-preview */
    opacity: 0.35;
    transform: scale(1.01);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
    z-index: 50;
    user-select: none;
    transition: none;
    border-style: dashed;
    border-color: rgba(37, 99, 235, 0.65);
}
.schedule-grid .cell-free.is-drop-target { background: rgba(37, 99, 235, 0.18) !important; outline: 2px solid var(--primary); outline-offset: -2px; }
.schedule-grid .cell-free.is-drop-invalid { background: rgba(220, 38, 38, 0.12) !important; }
.schedule-grid .appointment-block .apt-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4px;
    flex-shrink: 0;
    min-height: 1.1em;
}
.schedule-grid .appointment-block .apt-header .apt-time {
    font-weight: 700;
    font-size: 0.8rem;
    color: inherit;
}
.schedule-grid .appointment-block .apt-icons {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
}
.schedule-grid .appointment-block .apt-icon { font-size: 0.72rem; line-height: 1; opacity: 0.9; }
.schedule-grid .appointment-block .apt-icon-new {
    background: #22a06b;
    color: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.58rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.2;
}
.schedule-grid .appointment-block .apt-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}
.schedule-grid .appointment-block .apt-body .apt-name,
.schedule-grid .appointment-block .apt-body .apt-phone,
.schedule-grid .appointment-block .apt-body .apt-service,
.schedule-grid .appointment-block .apt-body .apt-comment,
.schedule-grid .appointment-block .apt-body .apt-block-time-label {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.schedule-grid .appointment-block .apt-body .apt-name { font-weight: 600; font-size: 0.8rem; }
.schedule-grid .appointment-block .apt-body .apt-phone { font-size: 0.74rem; color: #334155; }
.schedule-grid .appointment-block .apt-body .apt-service { font-size: 0.72rem; color: #475569; }
.schedule-grid .appointment-block .apt-body .apt-comment { font-size: 0.7rem; color: #64748b; margin-top: 1px; }
.schedule-grid .appointment-block .apt-body .apt-block-time-label { font-weight: 600; }
/* Короткие приёмы (≤30 мин): сетка 2×2, услуга — полная строка как у длинных */
.schedule-grid .appointment-block.apt-compact {
    padding: 2px 4px 2px 5px;
    line-height: 1.15;
    font-size: 0.68rem;
    overflow: hidden;
}
.schedule-grid .appointment-block.apt-compact .apt-body {
    display: block;
    overflow: hidden;
    height: 100%;
    min-height: 0;
}
.schedule-grid .appointment-block.apt-compact .apt-compact-board {
    position: relative;
    display: grid;
    grid-template-columns: minmax(4.75rem, max-content) minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 1px;
    align-items: center;
    height: 100%;
    min-height: 0;
    padding-right: 1.25rem;
    overflow: hidden;
    box-sizing: border-box;
}
.schedule-grid .appointment-block.apt-compact .apt-compact-board--block {
    grid-template-rows: auto;
}
.schedule-grid .appointment-block.apt-compact .apt-compact-icons {
    position: absolute;
    top: 1px;
    right: 2px;
    display: flex;
    gap: 2px;
    align-items: flex-start;
    line-height: 1;
    z-index: 1;
}
.schedule-grid .appointment-block.apt-compact .apt-time {
    grid-column: 1;
    grid-row: 1;
    font-weight: 700;
    font-size: 0.74rem;
    white-space: nowrap;
}
.schedule-grid .appointment-block.apt-compact .apt-name {
    grid-column: 2;
    grid-row: 1;
    font-weight: 700;
    font-size: 0.7rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.schedule-grid .appointment-block.apt-compact .apt-phone {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.62rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.schedule-grid .appointment-block.apt-compact .apt-service {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.6rem;
    font-weight: 500;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    display: block;
}
.schedule-grid .appointment-block.apt-compact .apt-compact-board--block .apt-block-time-label {
    grid-column: 2;
    grid-row: 1;
    font-weight: 600;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.schedule-grid .appointment-block.apt-compact .apt-icon {
    font-size: 0.62rem;
    line-height: 1;
}
.schedule-grid .appointment-block.apt-compact .apt-icon-new {
    font-size: 0.5rem;
    padding: 0 2px;
}
.schedule-grid .appointment-block.apt-compact .apt-compact-extra {
    display: none;
}
.schedule-grid .appointment-block.color-green { background: var(--color-green); border-color: var(--color-green-border); }
.schedule-grid .appointment-block.color-red { background: var(--color-red); border-color: var(--color-red-border); }
.schedule-grid .appointment-block.color-blue { background: var(--color-blue); border-color: var(--color-blue-border); }
.schedule-grid .appointment-block.color-yellow { background: var(--color-yellow); border-color: var(--color-yellow-border); }
.schedule-grid .appointment-block.color-gray { background: var(--color-gray); border-color: var(--color-gray-border); }
.schedule-grid .appointment-block.color-orange { background: var(--color-orange); border-color: var(--color-orange-border); }

/* ===================== Модальные окна ===================== */
.modal {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
    animation: fadeIn 0.2s ease;
}
.modal[hidden] { display: none; }
.modal-confirm { max-width: 420px; }
.crm-confirm-message {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0 1.5rem 1.25rem;
    flex-wrap: wrap;
}

/* Карточка пациента ниже; запись/быстрая запись — поверх (см. также bringModalToFront в JS) */
#patientModal { z-index: 1050; }
#patientModal.modal-over-appointment { z-index: 5300; }
#appointmentModal,
#quickBookModal { z-index: 5000; }
#appointmentModal.modal-over-patient { z-index: 5200; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 480px; width: 100%;
    max-height: 90vh; overflow: auto;
    animation: slideUp 0.25s ease;
}
.modal-content.modal-appointment { max-width: 700px; width: 700px; }
.modal-content.modal-patient { max-width: 750px; width: 750px; }
.modal-content.modal-block-time { max-width: 520px; width: 520px; }
/* Очень широкие мониторы: чуть увеличиваем ключевые модалки, чтобы они
   не «терялись» на большом пустом фоне. */
@media (min-width: 1700px) {
    .modal-content.modal-appointment { max-width: 800px; width: 800px; }
    .modal-content.modal-patient { max-width: 850px; width: 850px; }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.modal-close {
    background: none; border: none;
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    font-size: 1.3rem; cursor: pointer;
    color: var(--muted); line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg); }
.modal-body { padding: 1.5rem; }
.modal-body .form-row { margin-bottom: 1rem; }
.modal-body .form-row label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; }
.modal-body .form-row .required { color: var(--danger); }

/* Табы в модалке пациента */
.patient-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); padding: 0 1.25rem 0 0; }
.patient-tabs .patient-tab {
    padding: 0.6rem 1rem; border: none; background: none; cursor: pointer;
    font-size: 0.95rem; color: var(--muted); font-family: inherit;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: all var(--transition);
}
.patient-tabs .patient-tab:hover { color: var(--text); }
.patient-tabs .patient-tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.patient-tab-panels { min-height: 120px; }
.patient-tab-panel { display: none; }
.patient-tab-panel.active { display: block; }
.patient-appointments-toolbar { margin-bottom: 0.75rem; }
.patient-appointments-list { max-height: 320px; overflow-y: auto; }
.patient-appointments-list table,
.patient-appointments-list .patient-appointments-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; table-layout: fixed; }
.patient-appointments-list th { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.78rem; color: var(--text-secondary); vertical-align: bottom; }
.patient-appointments-list td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.patient-appointments-list .col-datetime { width: 5.5rem; white-space: nowrap; }
.patient-appointments-list .col-datetime .apt-date { display: block; font-weight: 500; line-height: 1.25; }
.patient-appointments-list .col-datetime .apt-time { display: block; font-size: 0.82rem; color: var(--muted); line-height: 1.2; }
.patient-appointments-list .col-doctor { width: 20%; padding-left: 1rem; }
.patient-appointments-list .col-service { width: 22%; }
.patient-appointments-list .col-status { width: 6.5rem; }
.patient-appointments-list .col-cost { width: 5rem; text-align: left; white-space: nowrap; padding-right: 1.25rem; }
.patient-appointments-list .col-comment { width: auto; word-break: break-word; padding-left: 0.35rem; }
.patient-appointments-list .col-doctor,
.patient-appointments-list .col-service { overflow: hidden; text-overflow: ellipsis; }
.patient-appointments-list .apt-status-badge {
    display: inline-block;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}
.patient-appointments-list .apt-status-done { background: #dcfce7; color: #166534; }
.patient-appointments-list .apt-status-wait { background: #fef9c3; color: #854d0e; }
.patient-appointments-list .apt-status-cancel { background: #fee2e2; color: #991b1b; }
.patient-appointments-list tbody tr { cursor: pointer; transition: background var(--transition); }
.patient-appointments-list tbody tr:hover { background: var(--primary-light); }
.patient-reserves-list { max-height: 320px; overflow-y: auto; }
.patient-reserves-list .patient-reserves-table,
.patient-reserves-list table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.patient-reserves-list th { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.patient-reserves-list td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border-light); }
.patient-reserves-list tbody tr:hover { background: var(--primary-light); }

.patient-control-toolbar { margin-bottom: 0.75rem; }
.patient-control-add-form {
    margin-bottom: 0.85rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-subtle);
}
.patient-control-add-form .form-row-inline { margin-bottom: 0.65rem; }
.patient-control-add-form .modal-actions-inline {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.patient-control-list { max-height: 320px; overflow-y: auto; }
.patient-control-list .patient-control-table,
.patient-control-list table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.patient-control-list th { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.78rem; color: var(--text-secondary); }
.patient-control-list td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.patient-control-list tbody tr:hover { background: var(--primary-light); }
.patient-control-actions-th,
.patient-control-actions { text-align: right; white-space: nowrap; }
.patient-control-actions .btn { margin-left: 0.25rem; }
.patient-control-no-window { color: var(--muted); font-size: 0.78rem; margin-right: 0.25rem; }

/* Модалка пациента — строки */
.modal-patient .form-row-inline { display: flex; gap: 1rem; margin-bottom: 1rem; }
.modal-patient .form-row-inline .form-cell { flex: 1; min-width: 0; }
.modal-patient .form-row-inline:first-of-type .form-cell:nth-child(1) { flex: 0 0 350px; max-width: 350px; }
.modal-patient .form-row-inline:first-of-type .form-cell:nth-child(2) { flex: 0 0 150px; max-width: 150px; }
.modal-patient .form-row-inline:nth-of-type(2) .form-cell:nth-child(1) { flex: 0 0 300px; max-width: 300px; }
.modal-patient .form-row-inline:nth-of-type(2) .form-cell:nth-child(2) { flex: 0 0 120px; max-width: 120px; }
.modal-patient .form-row-inline .form-cell label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.modal-patient .form-row-inline .form-cell .required { color: var(--danger); }
.modal-patient .form-row-inline input,
.modal-patient .form-row-inline select { width: 100%; box-sizing: border-box; }
.modal-patient .form-row-full .form-cell label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.modal-patient .form-row-full textarea { width: 100%; min-height: 80px; box-sizing: border-box; resize: vertical; }

/* Модалка записи — блоки */
.modal-appointment .form-block { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; margin-bottom: 1rem; align-items: flex-end; }
.modal-appointment .form-block .form-cell { flex: 1; min-width: 100px; }
.modal-appointment .form-block:first-of-type .form-cell:nth-child(1) { flex: 0 0 360px; max-width: 360px; }
.modal-appointment .form-block:first-of-type .form-cell:nth-child(2) { flex: 0 0 140px; max-width: 140px; }
.modal-appointment .form-block:first-of-type .form-cell:nth-child(3) { flex: 0 0 50px; max-width: 50px; }
.modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(1) { flex: 1 1 280px; min-width: 0; max-width: none; }
.modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(2) { flex: 0 0 88px; max-width: 88px; }
.modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(3) { flex: 0 0 110px; max-width: 110px; }
.modal-appointment .form-block:nth-of-type(3) .form-cell:first-child { flex: 0 0 360px; max-width: 360px; }
.modal-appointment .form-block:nth-of-type(3) .form-cell:nth-child(2) { padding-top: 2rem; }
.modal-appointment .form-block .form-cell label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.modal-appointment .form-block .form-cell .required { color: var(--danger); }
.modal-appointment .form-block .form-cell input[type="text"],
.modal-appointment .form-block .form-cell input[type="number"],
.modal-appointment .form-block .form-cell input[type="date"],
.modal-appointment .form-block .form-cell select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.modal-appointment .form-block .form-cell select {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.modal-appointment .form-block .form-cell input:focus,
.modal-appointment .form-block .form-cell select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.modal-appointment .form-block .form-cell-grow { flex: 2; min-width: 180px; }
.modal-appointment .form-block .form-cell-shrink { flex: 0 1 auto; min-width: 0; }
.modal-appointment .form-block .form-cell-shrink .checkbox-option { margin-bottom: 0; }
.modal-appointment .form-block-full .form-cell { flex: 1 1 100%; }
.modal-appointment .form-block-full .form-cell textarea { width: 100%; padding: 0.5rem 0.65rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit; resize: vertical; transition: border-color var(--transition), box-shadow var(--transition); }
.modal-appointment .form-block-full .form-cell textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* Чекбоксы, радио, цветные кнопки */
.modal-body .reminder-checkboxes { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; }
.modal-body .reminder-option { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: normal; margin: 0; cursor: pointer; font-size: 0.9rem; }
.modal-body .reminder-option input { width: auto; margin: 0; accent-color: var(--primary); }
.modal-body .block-label { margin-bottom: 0.25rem; }
.modal-body .checkbox-option { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: normal; margin: 0; cursor: pointer; }
.modal-body .checkbox-option input { width: auto; margin: 0; accent-color: var(--primary); }
.modal-body .status-attendance { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; }
.modal-body .radio-option { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: normal; margin: 0; cursor: pointer; font-size: 0.9rem; }
.modal-body .radio-option input { width: auto; margin: 0; accent-color: var(--primary); }
.modal-body .color-buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.modal-body .color-btn {
    width: 32px; height: 32px; border-radius: 8px;
    border: 2.5px solid transparent; padding: 0; cursor: pointer;
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.modal-body .color-btn:hover { transform: scale(1.12); }
.modal-body .color-btn.selected { border-color: var(--text); box-shadow: 0 0 0 2px rgba(30,41,59,0.2); }
.modal-body .color-btn.color-btn-green { background: var(--color-green); }
.modal-body .color-btn.color-btn-red { background: var(--color-red); }
.modal-body .color-btn.color-btn-blue { background: var(--color-blue); }
.modal-body .color-btn.color-btn-yellow { background: var(--color-yellow); }
.modal-body .color-btn.color-btn-gray { background: var(--color-gray); }
.modal-body .color-btn.color-btn-orange { background: var(--color-orange); }

/* Общие стили инпутов в модалках */
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body select,
.modal-body textarea {
    width: 100%; padding: 0.5rem 0.65rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.95rem; font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--card);
}
.modal-body input[type="text"]:focus,
.modal-body input[type="number"]:focus,
.modal-body input[type="date"]:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.modal-body textarea { resize: vertical; }

/* Действия в модалке */
.apt-cancelled-notice {
    margin-top: 1rem;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.9rem;
    font-weight: 500;
}
#appointmentForm.appointment-form-readonly input:not([type="hidden"]),
#appointmentForm.appointment-form-readonly select,
#appointmentForm.appointment-form-readonly textarea {
    background: var(--bg);
    color: var(--text);
    cursor: default;
}
#appointmentForm.appointment-form-readonly .color-btn { opacity: 0.65; cursor: default; pointer-events: none; }
#appointmentForm.appointment-form-readonly .btn-patient-info { pointer-events: auto; }
.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.modal-actions-main { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.modal-actions-block { margin-left: auto; }

/* ===================== Кнопки ===================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem; border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-size: 0.92rem; font-weight: 500; font-family: inherit;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
}
button:focus-visible,
a:focus-visible,
.btn:focus-visible,
.modal-close:focus-visible,
.day-cell:focus-visible,
.color-btn:focus-visible,
.nav-link:focus-visible,
.patient-tab:focus-visible,
.notifications-tab:focus-visible,
.btn-nav:focus-visible,
.patient-photo-add:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25); }
.btn-primary:active { transform: scale(0.96); }
.btn-secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #c5cad2; }
.btn-secondary:active { transform: scale(0.96); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25); }
.btn-danger:active { transform: scale(0.96); }

/* ===================== Поиск пациента ===================== */
.patient-search-wrap { position: relative; }
.patient-search-row { display: flex; align-items: stretch; gap: 0.75rem; }
.patient-search-row input[type="text"] { flex: 1; min-width: 0; }
.patient-phone-display { display: block; margin-top: 0.3rem; font-size: 0.85rem; color: var(--muted); min-height: 1.25rem; }
.patient-phone-display:empty { display: none; }
.btn-patient-info {
    flex-shrink: 0; width: 32px; height: 32px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-subtle); color: var(--muted);
    font-style: italic; font-weight: 700; font-size: 0.95rem;
    cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.btn-patient-info:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-patient-info:disabled { opacity: 0.4; cursor: not-allowed; }
.patient-search-wrap.patient-readonly input[type="text"][readonly] { background: var(--bg); color: var(--muted); cursor: default; }
.search-results {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--card); border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px; overflow-y: auto; z-index: 10;
    box-shadow: var(--shadow-md);
}
.search-results:empty { display: none; }
.search-results .result-item {
    display: block; width: 100%; text-align: left;
    padding: 0.55rem 0.85rem; cursor: pointer;
    border: none; border-bottom: 1px solid var(--border-light);
    background: transparent; font: inherit; color: inherit;
    transition: background var(--transition);
}
.search-results .result-item:last-child { border-bottom: none; }
.search-results .result-item:hover,
.search-results .result-item:focus-visible { background: var(--primary-light); }
.search-results .result-item .name { font-weight: 600; font-size: 0.92rem; }
.search-results .result-item .phone { font-size: 0.85rem; color: var(--muted); }
.search-results .search-results-footer { padding: 0.5rem 0.75rem; border-top: 1px solid var(--border); }
.search-results .search-results-footer .btn { width: 100%; }
.selected-name { display: block; margin-top: 4px; font-size: 0.9rem; color: var(--primary); font-weight: 500; }

/* ===================== Тулбар страницы пациентов ===================== */
.patients-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.patients-search-group {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}
.patients-search-input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: border-color var(--transition);
    box-sizing: border-box;
}
.patients-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* ===================== Форма резерва ===================== */
.modal-content.modal-reserve {
    max-width: 750px;
    width: 100%;
}

/* ===================== Таблицы-списки (пациенты, врачи, услуги, логи) ===================== */
.page-list {
    background: var(--card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: visible; /* hidden обрезал колонку кнопок */
    border: 1px solid var(--border);
}
.page-list-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: auto; min-width: 0; }
.page-list-table thead th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600; text-align: left;
    padding: 13px 16px; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
}
.page-list-table tbody tr {
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-light);
}
.page-list-table tbody tr[data-id] { cursor: pointer; }
.page-list-table tbody tr:last-child { border-bottom: none; }
.page-list-table tbody tr:hover { background: var(--primary-light); }
.page-list-table tbody tr.page-row-alt { background: var(--bg-subtle); }
.page-list-table tbody tr.page-row-alt:hover { background: var(--primary-light); }
.page-list-table td { padding: 11px 16px; vertical-align: middle; }
.page-list-table .page-list-actions {
    width: 110px;
    min-width: 110px;    /* фиксируем минимальную ширину колонки */
    white-space: nowrap;
    text-align: right;
}
.btn-page-edit {
    padding: 0.3rem 0.7rem; font-size: 0.84rem;
    border: 1.5px solid var(--border); background: var(--card);
    color: var(--primary); border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none; display: inline-block;
    font-weight: 500;
    transition: all var(--transition);
}
.btn-page-edit:hover { background: var(--primary-light); color: var(--primary-hover); border-color: var(--primary); }
.btn-user-delete {
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--border); background: var(--card);
    color: var(--muted); border-radius: 6px; cursor: pointer;
    font-size: 0.9rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-user-delete:hover { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.page-list-table .log-json { max-width: 200px; font-size: 0.82rem; color: var(--muted); line-height: 1.3; }

.patient-photos-toolbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.patient-photos-toolbar input[type="file"] {
    flex: 1 1 100%;
    min-width: 0;
    font-size: 0.88rem;
}
.patient-photos-hint {
    flex: 1 1 100%;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.35;
}
.patient-upload-status {
    margin-bottom: 0.65rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--primary-light);
    color: var(--primary);
}
.patient-upload-status.is-error {
    background: #fee2e2;
    color: #991b1b;
}
.patient-upload-status.is-ok {
    background: #dcfce7;
    color: #166534;
}
.patient-photos-list {
    min-height: 120px;
}
.patient-photos-panel {
    border: 1px dashed #c5cad3;
    border-radius: 10px;
    padding: 0.85rem;
    background: #fff;
}
.patient-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 0.75rem;
}
.patient-photo-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-decoration: none;
    color: inherit;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f3f4f6;
    overflow: hidden;
    padding: 0.4rem 0.4rem 0.55rem;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.patient-photo-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
.patient-photo-delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.6);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.patient-photo-card:hover .patient-photo-delete-btn,
.patient-photo-delete-btn:focus-visible {
    opacity: 1;
}
.patient-photo-delete-btn:hover {
    background: var(--danger);
}
@media (hover: none) {
    .patient-photo-delete-btn { opacity: 1; }
}
.patient-photo-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: #e5e7eb;
}
.patient-photo-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.patient-photo-card.patient-file-card--document {
    text-decoration: none;
    color: inherit;
}
.patient-file-card-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 2rem;
    line-height: 1;
}
.patient-file-ext {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.patient-photo-meta {
    margin-top: 0.45rem;
    padding: 0;
    font-size: 0.85rem;
    color: #374151;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.patient-photo-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    aspect-ratio: 1 / 1;
    align-self: start;
    width: 100%;
    border: 1px dashed #c5cad3;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    color: #374151;
    padding: 0.75rem;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}
.patient-photo-add:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}
.patient-photo-add-icon {
    display: inline-flex;
    line-height: 0;
}
.patient-photo-add-label {
    font-size: 0.9rem;
    color: #1f2937;
    text-align: center;
    line-height: 1.2;
}
.patient-prescription-form .rx-short {
    max-width: 90px;
}
.patient-rx-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(56px, 90px));
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 0.75rem;
}
.patient-rx-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.patient-rx-side {
    width: 28px;
    min-width: 28px;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: right;
    line-height: 1;
}
.patient-prescription-form .modal-actions {
    margin-bottom: 1rem !important;
}
.patient-prescription-eye {
    width: 38px;
    min-width: 38px;
    text-align: center;
    font-weight: 700;
    color: var(--text-secondary);
}
.patient-prescriptions-table tbody tr:hover { background: transparent !important; }
.patient-prescriptions-table .rx-cell {
    transition: background var(--transition);
}
.patient-prescriptions-table tr.rx-row-hover .rx-cell {
    background: var(--primary-light);
}
.patient-prescriptions-table .rx-comment-cell {
    transition: background var(--transition);
}
.patient-prescriptions-table .rx-comment-cell:hover {
    background: var(--primary-light);
}
/* Фиксированная раскладка колонок таблицы рецептов — исключает
   горизонтальную прокрутку: комментарий и кнопки всегда помещаются в поле. */
.patient-prescriptions-table {
    table-layout: fixed;
    width: 100%;
}
.patient-prescriptions-table .rx-col-date { width: 78px; }
.patient-prescriptions-table .rx-col-eye { width: 32px; }
.patient-prescriptions-table .rx-col-num { width: 6%; }
.patient-prescriptions-table .rx-col-comment { width: 22%; }
.patient-prescriptions-table .rx-col-actions { width: 72px; }
.patient-prescriptions-table thead th {
    padding: 8px 4px;
    font-size: 0.68rem;
    text-align: center;
    white-space: normal;
    word-break: break-word;
}
.patient-prescriptions-table thead th:first-child { text-align: left; }
.patient-prescriptions-table td {
    padding: 7px 4px;
    vertical-align: middle;
}
.patient-prescriptions-table .rx-cell,
.patient-prescriptions-table .patient-prescription-eye {
    text-align: center;
    padding-left: 2px;
    padding-right: 2px;
    white-space: nowrap;
}
.patient-prescriptions-table td:first-child {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.patient-prescriptions-table .rx-comment-cell {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    text-align: left;
    vertical-align: middle;
}
/* Не ставить display:flex на <td> — ломает rowspan и границы строк */
.patient-prescription-actions {
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    padding-left: 2px;
    padding-right: 2px;
}
.patient-prescription-actions .btn-prescription-edit,
.patient-prescription-actions .btn-prescription-delete {
    vertical-align: middle;
    margin: 0 2px;
}
.btn-prescription-delete {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-prescription-edit {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-prescription-delete:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fecaca;
}
.btn-prescription-edit:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}
.patient-rx-cell {
    min-width: 0;
}
.patient-rx-cell label {
    display: block;
    margin-bottom: 0.3rem;
}
.patient-prescription-form .rx-short {
    width: 100%;
    max-width: 90px;
    text-align: center;
}

.patient-photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.patient-photo-lightbox[hidden] { display: none !important; }
.patient-photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
}
.patient-photo-lightbox-dialog {
    position: relative;
    z-index: 1;
    max-width: min(96vw, 1100px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.patient-photo-lightbox-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(15, 23, 42, 0.85);
    border-radius: 999px;
    padding: 0.3rem;
    align-self: flex-end;
}
.patient-photo-lightbox-toolbar button {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}
.patient-photo-lightbox-toolbar button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }
.patient-photo-lightbox-toolbar button:disabled { opacity: 0.35; cursor: default; }
.patient-photo-lightbox-toolbar .patient-photo-lightbox-close { font-size: 1.5rem; }
.patient-photo-lightbox-viewport {
    max-width: 96vw;
    max-height: calc(92vh - 4.5rem);
    overflow: auto;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.patient-photo-lightbox-img {
    display: block;
    max-width: 96vw;
    max-height: calc(92vh - 4.5rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    background: #111;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    transition: transform 0.15s ease;
    transform-origin: center center;
    cursor: zoom-in;
}
.patient-photo-lightbox-img.is-zoomed { cursor: zoom-out; }
.patient-photo-lightbox-caption {
    color: #f8fafc;
    font-size: 0.9rem;
    text-align: center;
    max-width: 90vw;
    word-break: break-word;
}

/* Тултип логов */
.log-row-tooltip {
    position: fixed; z-index: 9999;
    max-width: 90vw; max-height: 70vh; overflow: auto;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px; font-size: 0.85rem; line-height: 1.5;
    white-space: pre-wrap; word-break: break-word;
}
.log-row-tooltip strong { display: block; margin-top: 10px; color: var(--text); font-weight: 700; }
.log-row-tooltip strong:first-child { margin-top: 0; }
.log-row-tooltip pre { margin: 6px 0 0; padding: 10px; background: var(--bg); border-radius: var(--radius-sm); font-size: 0.8rem; overflow-x: auto; white-space: pre-wrap; }

#patientsTableWrap .grid-loading,
#doctorsTableWrap .grid-loading,
#servicesTableWrap .grid-loading,
#logsTableWrap .grid-loading { padding: 2.5rem; text-align: center; color: var(--muted); font-size: 0.95rem; }
.logs-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    /* Совпадает с горизонтальным padding ячеек .page-list-table (16px) */
    padding-left: 16px;
}
.logs-filter-select {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
}

/* ===================== Форма пользователя ===================== */
.modal-content.modal-user { max-width: 560px; width: 100%; }

/* ===================== Модалка «Занять время» ===================== */
.modal-block-time .form-block {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-bottom: 0.85rem;
}
.modal-block-time .form-cell { flex: 1 1 0; min-width: 110px; }
.modal-block-time .form-block-full .form-cell { flex: 1 1 100%; }
.modal-block-time .form-cell label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--muted);
}
.modal-block-time .form-cell select,
.modal-block-time .form-cell textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}
.modal-block-time .form-cell textarea { resize: vertical; min-height: 2.5rem; }
.modal-block-time .form-cell select:focus,
.modal-block-time .form-cell textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.modal-block-time .block-time-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.modal-block-time .block-created-meta {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.35;
    max-width: 55%;
}
.modal-block-time .block-time-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-left: auto;
}
.modal-block-time .block-time-actions .btn-danger { margin-right: auto; }
.modal-user .modal-user-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light); }
.modal-user .modal-user-title { margin: 0; font-size: 1.3rem; font-weight: 700; color: var(--text); }
.user-form { padding: 0; }
.user-form-section { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light); }
.user-form-section:last-of-type { border-bottom: none; }
.user-form-section-title { margin: 0 0 0.75rem; font-size: 0.95rem; font-weight: 700; color: var(--text); letter-spacing: 0.01em; }
.user-form-section-desc { margin: 0 0 1rem; font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.user-form-row { margin-bottom: 1rem; }
.user-form-row:last-child { margin-bottom: 0; }
.user-form-label { display: block; margin-bottom: 0.35rem; font-weight: 500; font-size: 0.9rem; color: var(--text); }
.user-form-label .required { color: var(--danger); }
.user-form-input {
    width: 100%; padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 1rem; font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}
.user-form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.user-form-input::placeholder { color: var(--muted); }
.user-form-hint { display: none; margin-top: 0.4rem; font-size: 0.8rem; color: var(--muted); }
.user-form-hint.visible { display: block; }
.user-permissions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.user-perm-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem;
    padding: 0.85rem 1rem; border: 1.5px solid var(--border); border-radius: var(--radius-md);
    background: var(--bg-subtle); cursor: pointer;
    transition: all var(--transition);
}
.user-perm-card:hover { border-color: var(--primary); background: var(--primary-light); }
.user-perm-card input { margin: 0; width: auto; accent-color: var(--primary); }
.user-perm-card input:checked + .user-perm-label { color: var(--primary); font-weight: 700; }
.user-perm-card:has(input:checked) { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 1px var(--primary); }
.user-perm-label { font-size: 0.95rem; font-weight: 500; color: var(--text); }
.user-perm-desc { font-size: 0.78rem; color: var(--muted); line-height: 1.3; }
.user-perm-card-admin { border-color: rgba(37, 99, 235, 0.3); background: linear-gradient(135deg, var(--bg-subtle) 0%, var(--primary-light) 100%); }
.user-perm-card-admin:has(input:checked) { border-color: var(--primary); background: linear-gradient(135deg, var(--primary-light) 0%, #dbeafe 100%); }
.user-form-actions {
    display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-subtle);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.user-form-actions .btn { padding: 0.55rem 1.25rem; font-weight: 600; }

/* ===================== Кнопка быстрой записи ===================== */
.btn-quick-book {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-quick-book:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35); }
.btn-quick-book:active { transform: scale(0.97); }
.btn-quick-book-icon {
    font-size: 1.3rem;
    font-weight: 300;
    line-height: 1;
}

/* ===================== Кнопка-значок резерва ===================== */
.btn-reserve-alert {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: var(--card);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    position: relative;
}
.btn-reserve-alert:hover { border-color: #f59e0b; background: #fffbeb; }
.btn-reserve-alert.has-matches {
    border-color: #f59e0b;
    color: #92400e;
    background: #fffbeb;
    animation: reserve-pulse 2.5s ease-in-out infinite;
}
@keyframes reserve-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
.btn-reserve-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #f59e0b;
    color: #fff;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

/* ===================== Панель совпадений резерва ===================== */
.reserve-matches-modal {
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.reserve-matches-body {
    overflow-y: auto;
    flex: 1;
    padding: 1rem 1.25rem 1.25rem;
}
.reserve-matches-empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
    font-size: 0.95rem;
}
.reserve-matches-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.reserve-match-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.rmc-top {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.rmc-patient {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}
.rmc-phone {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.rmc-service {
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.rmc-period {
    font-size: 0.82rem;
    color: var(--muted);
}
.rmc-dates {
    font-size: 0.88rem;
    color: #92400e;
    background: #fef3c7;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    display: inline-block;
    margin-top: 0.1rem;
}
.rmc-actions {
    margin-top: 0.4rem;
}
.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

/* ===================== Кнопка-значок контроля ===================== */
.btn-control-alert {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: var(--card);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    position: relative;
}
.btn-control-alert:hover { border-color: #16a34a; background: #f0fdf4; }
.btn-control-alert.has-matches {
    border-color: #16a34a;
    color: #166534;
    background: #f0fdf4;
    animation: control-pulse 2.5s ease-in-out infinite;
}
@keyframes control-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
}
.btn-control-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #16a34a;
    color: #fff;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.control-match-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 4px solid #16a34a;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.control-match-card .rmc-dates {
    color: #166534;
    background: #dcfce7;
}

/* ===================== Кнопка-значок обзвона ===================== */
.btn-callback-alert {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: var(--card);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    position: relative;
}
.btn-callback-alert:hover { border-color: #dc2626; background: #fef2f2; }
.btn-callback-alert.has-matches {
    border-color: #dc2626;
    color: #991b1b;
    background: #fef2f2;
    animation: callback-pulse 2.5s ease-in-out infinite;
}
@keyframes callback-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.btn-callback-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #dc2626;
    color: #fff;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

/* ===================== Страницы резерва и контроля ===================== */
.doctor-inactive { color: #c0392b; text-decoration: line-through; font-weight: 600; }
.phone-small { font-size: 0.85rem; color: var(--muted); }
.reserve-list { background: var(--card); border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); overflow: hidden; border: 1px solid var(--border); }
.reserve-list-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: auto; min-width: 0; }
.reserve-list-table thead th { background: linear-gradient(180deg, #f8f9fa 0%, #eef0f2 100%); color: var(--text); font-weight: 600; text-align: left; padding: 14px 16px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 2px solid var(--border); }
.reserve-list-table tbody tr { cursor: pointer; border-bottom: 1px solid var(--border); }
.reserve-list-table tbody tr:last-child { border-bottom: none; }
.reserve-list-table td { padding: 12px 16px; vertical-align: middle; }
.reserve-list-table .reserve-td-patient { min-width: 180px; }
.reserve-list-table .reserve-patient-name { display: block; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.reserve-list-table .reserve-patient-phone { display: block; font-size: 0.82rem; color: var(--muted); }
.reserve-list-table .reserve-td-age,
.reserve-list-table thead .reserve-th-age {
    width: 82px;
    min-width: 82px;
    max-width: 82px;
    text-align: left !important;
}
.reserve-list-table .reserve-td-age {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-align: left !important;
}
.reserve-list-table .reserve-td-period { white-space: nowrap; font-size: 0.85rem; color: var(--text); cursor: default; }
.reserve-list-table .reserve-td-period.reserve-period-red { font-weight: 700; color: #c0392b; }
.reserve-list-table .reserve-td-period.reserve-period-green { font-weight: 700; color: #1e5631; }
.reserve-list-table .reserve-td-period.control-period-due { font-weight: 700; color: #1e5631; }
.reserve-list-table .reserve-td-period.control-period-overdue { font-weight: 700; color: #c0392b; }
.reserve-list-table .reserve-td-period.control-period-upcoming { color: var(--text-secondary); }
.reserve-list-table .reserve-td-period.control-period-expired,
.patient-control-list .reserve-td-period.control-period-expired { color: var(--muted); text-decoration: line-through; }
.patient-control-list .reserve-td-period.control-period-due { font-weight: 700; color: #1e5631; }
.patient-control-list .reserve-td-period.control-period-overdue { font-weight: 700; color: #c0392b; }
.patient-control-list .reserve-td-period.control-period-upcoming { color: var(--text-secondary); }
.reserve-list-table .reserve-td-created { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.35; }
.reserve-list-table .reserve-th-created { min-width: 90px; }
.reserve-period-tooltip { position: fixed; z-index: 9999; padding: 0; pointer-events: none; }
.reserve-cal-wrap { display: flex; gap: 16px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); padding: 12px 14px; }
.reserve-cal-month { min-width: 160px; }
.reserve-cal-title { font-weight: 600; font-size: 0.9rem; text-align: center; margin-bottom: 8px; color: var(--text); }
.reserve-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; font-size: 0.7rem; color: var(--muted); text-align: center; }
.reserve-cal-days { display: grid; grid-template-columns: repeat(7, 22px); gap: 2px; font-size: 0.8rem; text-align: center; }
.reserve-cal-day, .reserve-cal-empty { width: 22px; height: 22px; line-height: 22px; border-radius: 4px; }
.reserve-cal-empty { visibility: hidden; }
.reserve-cal-day { color: var(--text); }
.reserve-cal-day.reserve-cal-highlight { background: var(--primary); color: #fff; font-weight: 600; }
.reserve-cal-day.reserve-cal-control-target { background: #16a34a; color: #fff; font-weight: 700; }
.reserve-cal-day.reserve-cal-expired { background: #c0392b; color: #fff; font-weight: 600; }
.reserve-cal-day.reserve-cal-today { background: #1e5631; color: #fff; font-weight: 600; }
.reserve-list-table .reserve-td-comment { max-width: 220px; color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
.reserve-list-table .reserve-td-actions { width: 48px; text-align: right; padding-right: 12px; }
.reserve-list-table .reserve-td-book { width: 110px; text-align: right; padding-right: 12px; }
.btn-reserve-delete { width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); background: var(--card); color: var(--muted); border-radius: 6px; cursor: pointer; font-size: 0.9rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.btn-reserve-delete svg { width: 14px; height: 14px; display: block; pointer-events: none; }
.btn-reserve-delete:hover { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.reserve-nav-links { display: flex; gap: 0.5rem; align-items: center; }
.reserve-nav-link { padding: 0.4rem 0.75rem; border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 500; transition: background 0.15s, color 0.15s; }
.reserve-nav-link:hover { background: var(--bg); color: var(--primary); }
.reserve-nav-link.active { background: var(--primary); color: #fff; }
.reserve-nav-link.active:hover { background: var(--primary-hover); color: #fff; }
.callback-toolbar-hint {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.callback-toolbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}
.callback-bulk-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.callback-main .reserve-toolbar { align-items: flex-start; }
.callback-select-all-head {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.callback-select-all-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.callback-kind {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
}
.callback-kind-no_show { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.callback-kind-reserve { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.callback-kind-control { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.callback-summary { font-size: 0.82rem; color: var(--muted); }
.callback-list-table .callback-th-select,
.callback-list-table .callback-td-select {
    width: 40px;
    min-width: 40px;
    text-align: center;
    padding-left: 12px;
    padding-right: 8px;
}
.callback-list-table .callback-th-actions,
.callback-list-table .callback-td-actions {
    width: auto;
    min-width: 170px;
    text-align: left;
    padding-right: 16px;
}
.callback-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.callback-actions .btn {
    white-space: nowrap;
}
.callback-td-phone { color: var(--text); font-variant-numeric: tabular-nums; }
.callback-period-overdue { color: #c0392b; font-weight: 600; }
.callback-td-details { min-width: 180px; }
.callback-list-table .callback-row.is-selected {
    background: #eff6ff;
}
.callback-list-table .callback-row.is-selected:hover {
    background: #dbeafe;
}
.callback-reserve-patient-name {
    font-weight: 600;
    color: var(--text);
    padding: 0.45rem 0.6rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.reserve-toolbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.section-toolbar-left { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; min-width: 0; }
.section-toolbar-right { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; }
.section-search-bar { width: 100%; }
.section-search-input { display: block; width: 100%; max-width: 400px; height: 36px; padding: 0.45rem 0.65rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); }
.reserve-toolbar-options { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.reserve-toolbar-options label { font-size: 0.85rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.35rem; cursor: pointer; user-select: none; }
.reserve-toolbar-options input[type="checkbox"] { width: auto; }
.reserve-by-doctors { background: var(--card); border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); overflow-x: auto; overflow-y: visible; border: 1px solid var(--border); scrollbar-width: thin; -ms-overflow-style: auto; }
.reserve-by-doctors::-webkit-scrollbar { height: 6px; }
.reserve-by-doctors::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.reserve-by-doctors-table { width: max-content; min-width: 100%; border-collapse: collapse; table-layout: auto; }
.reserve-by-doctors-table thead th,
.reserve-by-doctors-table tbody td { min-width: 250px; max-width: 360px; }
.reserve-by-doctors-table thead th { background: linear-gradient(180deg, #f8f9fa 0%, #eef0f2 100%); color: var(--text); font-weight: 600; padding: 12px 10px; font-size: 0.8rem; text-align: center; border-bottom: 2px solid var(--border); border-right: 1px solid var(--border); vertical-align: middle; }
.reserve-by-doctors-table thead th:last-child { border-right: none; }
.reserve-by-doctors-table tbody td { padding: 6px; border-right: 1px solid var(--border); vertical-align: top; }
.reserve-by-doctors-table tbody td:last-child { border-right: none; }
.reserve-by-doctors-cell { min-height: 64px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; overflow-y: auto; overflow-x: hidden; max-height: 70vh; scrollbar-width: thin; -ms-overflow-style: auto; background: #fff; box-sizing: border-box; }
.reserve-by-doctors-cell > .reserve-by-doctor-card,
.reserve-by-doctors-cell > .reserve-drop-slot { flex-shrink: 0; flex-grow: 0; }
.reserve-by-doctors-cell::-webkit-scrollbar { width: 6px; }
.reserve-by-doctors-cell::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.reserve-by-doctors-cell.reserve-cell-droppable { min-height: 100px; }
.reserve-by-doctors-cell.reserve-cell-source { opacity: 0.85; }
.reserve-drop-slot { flex-shrink: 0; display: flex; align-items: center; justify-content: center; border: 2px dashed #93b4dc; border-radius: 8px; background: #f0f6ff; transition: background 0.15s, border-color 0.15s; box-sizing: border-box; min-height: 56px; }
.reserve-drop-slot.reserve-drop-slot-active { border-color: var(--primary); background: #dbeafe; }
.reserve-drop-slot-label { font-size: 0.8rem; color: #4b7bbf; user-select: none; pointer-events: none; }
.reserve-by-doctor-card { position: relative; background: var(--card); border: 1px solid var(--border); border-left-width: 3px; border-left-color: #f59e0b; border-radius: 8px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s; min-height: 0; height: auto; }
.reserve-by-doctor-card[draggable="true"] { cursor: grab; }
.reserve-by-doctor-card.reserve-card-status-active { border-left-color: #16a34a; }
.reserve-by-doctor-card.reserve-card-status-expired { border-left-color: #dc2626; }
.reserve-by-doctor-card.reserve-card-status-upcoming { border-left-color: #2563eb; }
.reserve-by-doctor-card.reserve-color-orange { border-left-color: #f59e0b; }
.reserve-by-doctor-card.reserve-color-blue { border-left-color: #2563eb; }
.reserve-by-doctor-card.reserve-color-green { border-left-color: #16a34a; }
.reserve-by-doctor-card.reserve-color-red { border-left-color: #dc2626; }
.reserve-by-doctor-card.reserve-color-yellow { border-left-color: #eab308; }
.reserve-by-doctor-card.reserve-color-gray { border-left-color: #64748b; }
.reserve-list-table tr.reserve-color-orange td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.reserve-list-table tr.reserve-color-blue td:first-child { box-shadow: inset 4px 0 0 #2563eb; }
.reserve-list-table tr.reserve-color-green td:first-child { box-shadow: inset 4px 0 0 #16a34a; }
.reserve-list-table tr.reserve-color-red td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
.reserve-list-table tr.reserve-color-yellow td:first-child { box-shadow: inset 4px 0 0 #eab308; }
.reserve-list-table tr.reserve-color-gray td:first-child { box-shadow: inset 4px 0 0 #64748b; }
.reserve-by-doctor-card.control-card-status-due { border-left-color: #16a34a; }
.reserve-by-doctor-card.control-card-status-overdue { border-left-color: #dc2626; }
.reserve-by-doctor-card.control-card-status-upcoming { border-left-color: #2563eb; }
.reserve-by-doctor-card.control-card-status-expired { border-left-color: #94a3b8; opacity: 0.65; }
.reserve-by-doctor-card:hover { border-color: #93c5fd; box-shadow: 0 2px 10px rgba(37, 99, 235, 0.1); }
.reserve-by-doctor-card.reserve-card-dragging { opacity: 0.5; cursor: grabbing; box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18); }
.reserve-by-doctor-card.reserve-card-saving { opacity: 0.55; pointer-events: none; }
.reserve-by-doctors-cell[data-can-drop="0"] { background: #f5f5f5; }
.rbdc-inner { padding: 7px 8px 8px 9px; }
.rbdc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 3px; }
.rbdc-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.84rem; line-height: 1.3; color: var(--text); word-break: break-word; }
.rbdc-phone { font-size: 0.78rem; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow-wrap: normal; margin-bottom: 4px; }
.reserve-by-doctor-card .btn-reserve-delete { flex-shrink: 0; width: 22px; height: 22px; font-size: 0.78rem; margin: 0; }
.rbdc-details { display: flex; flex-direction: column; gap: 2px; font-size: 0.76rem; line-height: 1.35; }
.rbdc-service { display: block; color: var(--text-secondary); font-weight: 500; overflow-wrap: break-word; }
.rbdc-service-detail { display: block; color: var(--muted); font-size: 0.94em; overflow-wrap: break-word; }
.rbdc-period, .reserve-by-doctor-period { display: block; color: var(--text-secondary); font-variant-numeric: tabular-nums; cursor: default; word-break: break-word; }
.rbdc-period.reserve-period-red, .reserve-by-doctor-period.reserve-period-red { font-weight: 600; color: #c0392b; }
.rbdc-period.reserve-period-green, .reserve-by-doctor-period.reserve-period-green { font-weight: 600; color: #1e5631; }
.rbdc-period.control-period-due, .reserve-by-doctor-period.control-period-due { font-weight: 600; color: #1e5631; }
.rbdc-period.control-period-overdue, .reserve-by-doctor-period.control-period-overdue { font-weight: 600; color: #c0392b; }
.rbdc-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.4rem; margin-top: 4px; font-size: 0.72rem; color: var(--muted); line-height: 1.3; }
.rbdc-meta-comment { font-style: italic; word-break: break-word; }
.rbdc-book { margin-top: 6px; }
#reserveTableWrap .grid-loading, #reserveByDoctorsWrap .grid-loading,
#controlTableWrap .grid-loading, #controlByDoctorsWrap .grid-loading { padding: 2.5rem; text-align: center; color: var(--muted); font-size: 0.95rem; }
.modal-reserve .reserve-form-row { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: flex-end; flex-wrap: wrap; }
.modal-reserve .reserve-form-row[hidden] { display: none; }
.modal-reserve .reserve-form-row .form-cell { flex: 1; min-width: 120px; }
.modal-reserve .reserve-form-row .form-cell-patient { flex: 0 0 350px; width: 350px; max-width: 350px; }
.modal-reserve .reserve-form-row .form-cell-age { flex: 0 0 60px; width: 60px; max-width: 60px; }
.modal-reserve .reserve-form-row .form-cell-full { flex: 1 1 100%; }
.modal-reserve .reserve-form-row .form-cell label { display: block; margin-bottom: 0.25rem; font-weight: 500; }
.modal-reserve .reserve-form-row .form-cell .required { color: var(--danger); }
.modal-reserve .reserve-form-row input,
.modal-reserve .reserve-form-row select,
.modal-reserve .reserve-form-row textarea { width: 100%; box-sizing: border-box; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem; }
.modal-reserve .reserve-form-row .patient-search-wrap input { width: 100%; }

.reserve-weekdays-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.reserve-weekday-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fafc;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
}
.reserve-weekday-chip:has(input:checked) {
    background: #e0f2fe;
    border-color: #38bdf8;
}
.reserve-weekday-chip input {
    width: auto !important;
    margin: 0;
}
.reserve-specific-dates-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}
.reserve-specific-dates-controls input[type="date"] {
    width: auto;
    min-width: 160px;
}
.reserve-specific-dates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 1.75rem;
}
.reserve-specific-dates-empty {
    color: #64748b;
    font-size: 0.9rem;
}
.reserve-date-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.45rem 0.25rem 0.65rem;
    border-radius: 999px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    font-size: 0.9rem;
}
.reserve-date-chip-remove {
    border: none;
    background: transparent;
    color: #4338ca;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.15rem;
}
.reserve-date-chip-remove:hover {
    color: #dc2626;
}
.reserve-condition-hint {
    display: inline-block;
    margin-top: 0.15rem;
    color: #475569;
    font-size: 0.85em;
    font-weight: 500;
}

/* ===================== Мастер быстрой записи ===================== */
.qb-modal {
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.qb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.qb-nav { display: flex; align-items: center; gap: 0.5rem; }
.qb-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: inherit;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.qb-back-btn:hover { background: var(--bg); color: var(--text); }
/* CSS-свойство display перекрывает стандартный [hidden]{display:none}, поэтому явно */
.qb-back-btn[hidden] { display: none; }
.qb-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}
.qb-body {
    overflow-y: auto;
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}
/* Когда внутри вкладки дат — убираем верхний падинг */
.qb-body:has(.qb-date-tabs) {
    padding: 0;
}
.qb-body:has(.qb-date-tabs) .qb-date-tabs {
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 1;
}
.qb-body:has(.qb-date-tabs) .qb-doctor-rows {
    padding: 0 1.5rem 1rem;
}
.qb-hint {
    margin: 0 0 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.qb-match-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    padding: 0.7rem 1.5rem;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    line-height: 1.35;
}
.qb-match-banner-label {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}
.qb-match-banner-dates {
    color: var(--text-secondary);
    font-weight: 500;
}
.qb-empty-in-match {
    padding: 1.5rem;
}

/* Карточки выбора пути */
.qb-path-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.qb-path-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 1.75rem 1rem;
    background: var(--bg-subtle);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    transition: all var(--transition);
}
.qb-path-card:hover { border-color: var(--primary); background: var(--primary-light); }
.qb-path-card:hover .qb-path-icon { color: var(--primary); }
.qb-path-icon { color: var(--text-secondary); transition: color var(--transition); }
.qb-path-card strong { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.qb-path-card span { font-size: 0.85rem; color: var(--muted); }

/* Сетка карточек врачей/услуг */
.qb-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.65rem;
}
.qb-item-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.85rem 1rem;
    background: var(--bg-subtle);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all var(--transition);
}
.qb-item-card:hover { border-color: var(--primary); background: var(--primary-light); }
.qb-item-icon { color: var(--muted); }
.qb-item-name { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.qb-item-meta { font-size: 0.8rem; color: var(--muted); }

/* ── Вкладки дат ── */
.qb-date-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
    flex-shrink: 0;
}
.qb-date-tabs::-webkit-scrollbar { display: none; }
.qb-date-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.55rem 0.9rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all var(--transition);
    flex-shrink: 0;
}
.qb-date-tab:hover { background: var(--bg); }
.qb-tab-date { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.qb-tab-wd   { font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }
.qb-date-tab.active { border-bottom-color: var(--primary); }
.qb-date-tab.active .qb-tab-date { color: var(--primary); }
.qb-date-tab.active .qb-tab-wd   { color: var(--primary); opacity: 0.75; }

/* ── Строки врачей ── */
.qb-doctor-rows {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.qb-doctor-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-light);
}
.qb-doctor-row:last-child { border-bottom: none; }
.qb-doctor-avatar {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg);
    border: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; font-weight: 700;
    color: var(--text-secondary);
}
.qb-doctor-content { flex: 1; min-width: 0; }
.qb-doctor-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}
.qb-doctor-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
    align-items: center;
}
.qb-doctor-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.qb-time-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.qb-time-btn {
    padding: 0.3rem 0.55rem;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    transition: all var(--transition);
    white-space: nowrap;
}
.qb-time-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* Состояние загрузки / пусто */
.qb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    color: var(--muted);
    font-size: 0.95rem;
}
.qb-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.qb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 2.5rem 1rem;
    color: var(--muted);
    font-size: 0.95rem;
    text-align: center;
}
.qb-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    margin-top: 0.85rem;
    padding: 0.6rem 1rem;
    background: var(--bg-subtle);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.qb-more-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

@media (max-width: 480px) {
    .qb-path-cards { grid-template-columns: 1fr; }
    .btn-quick-book-label { display: none; }
    .btn-quick-book { padding: 0.45rem 0.65rem; }
    .btn-quick-book-icon { font-size: 1.5rem; }
}

/* ============================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ — ≤768px
   ============================================================ */
@media (max-width: 768px) {

    /* ── Шапка ── */
    .main-header { padding: 0 0.85rem; }
    .user-badge span:not(:first-child) { display: none; } /* скрываем логин, оставляем иконку */
    .btn-logout { font-size: 0.82rem; padding: 0.3rem 0.5rem; }

    /* ── Основной контент ── */
    .schedule-main { padding: 0.75rem 0.75rem; }
    .schedule-main-with-calendar {
        flex-direction: column;
        gap: 0.75rem;
    }
    .schedule-left { width: 100%; }
    .schedule-calendar-aside {
        flex: none;
        width: 100%;
        max-width: 100%;
        position: static;
        order: -1;
    }
    /* Календарь на мобильном скрывается, открывается по кнопке */
    .schedule-calendar-aside.cal-collapsed .calendar-widget { display: none; }
    .cal-toggle-btn {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        width: 100%;
        padding: 0.5rem 0.75rem;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-secondary);
        cursor: pointer;
        font-family: inherit;
        transition: all var(--transition);
        justify-content: space-between;
        box-shadow: var(--shadow-sm);
    }
    .cal-toggle-btn:hover { background: var(--bg); }
    .cal-toggle-btn .cal-toggle-arrow { transition: transform var(--transition); }
    .cal-collapsed .cal-toggle-btn .cal-toggle-arrow { transform: rotate(-90deg); }

    /* ── Тулбар расписания ── */
    .schedule-toolbar {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.5rem;
        align-items: center;
    }
    .schedule-toolbar .date-nav {
        grid-column: 1 / -1;
        width: 100%;
    }
    .schedule-toolbar .date-nav input[type="date"] {
        flex: 1;
        max-width: none;
        font-size: 0.9rem;
        padding: 0.4rem 0.5rem;
    }
    .schedule-toolbar-actions {
        grid-column: 2;
        justify-self: end;
    }

    /* ── Сетка расписания на мобильном ── */
    .schedule-grid {
        border-radius: var(--radius-sm);
        position: relative;
        -webkit-overflow-scrolling: touch;
    }
    .schedule-scroll-stack {
        display: block;
        min-width: 0;
        width: 100%;
    }
    .schedule-grid .schedule-table {
        width: 100%;
        min-width: max(100%, calc(52px + 148px * var(--doctor-count, 1)));
        table-layout: fixed;
    }
    .schedule-grid .schedule-table[data-doctor-count="1"] {
        min-width: 100%;
        width: 100%;
    }
    .schedule-grid .col-time {
        width: 52px !important;
        min-width: 52px !important;
        max-width: 52px !important;
        position: sticky;
        left: 0;
        z-index: 4;
        background: var(--bg-subtle);
        box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06);
        font-size: 0.68rem;
        padding: 2px 3px !important;
        vertical-align: middle;
    }
    .schedule-grid thead .col-time {
        z-index: 6;
        background: #fff;
    }
    .schedule-grid .col-time.hour {
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--text-secondary);
    }
    .schedule-grid .col-doctor {
        width: auto;
        min-width: 148px;
    }
    .schedule-grid .schedule-table[data-doctor-count="1"] .col-doctor {
        width: calc(100% - 52px);
        min-width: 0;
    }
    .schedule-grid thead .col-doctor {
        position: sticky;
        top: 0;
        z-index: 3;
        background: #fff;
        vertical-align: middle;
    }
    .schedule-grid .doctor-header {
        padding: 8px 6px;
        min-height: 64px;
    }
    .schedule-grid .doctor-avatar {
        width: 32px;
        height: 32px;
        margin-bottom: 4px;
    }
    .schedule-grid .doctor-name {
        font-size: 0.85rem;
        text-align: center;
        width: 100%;
    }
    .schedule-grid .doctor-hours {
        font-size: 0.72rem;
        text-align: center;
        width: 100%;
    }

    /* ── Модалки — полноэкранные ── */
    .modal { padding: 0; align-items: flex-end; }
    .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 95vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        animation: slideUpMobile 0.25s ease;
    }
    @keyframes slideUpMobile {
        from { opacity: 0; transform: translateY(60px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .modal-header { padding: 0.9rem 1rem; }
    .modal-header h2 { font-size: 1.05rem; }
    .modal-body { padding: 1rem; }

    /* ── Форма записи — стек полей ── */
    .modal-appointment .form-block {
        flex-direction: column;
        gap: 0.65rem;
    }
    .modal-appointment .form-block .form-cell,
    .modal-appointment .form-block .form-cell:nth-child(1),
    .modal-appointment .form-block .form-cell:nth-child(2),
    .modal-appointment .form-block .form-cell:nth-child(3),
    .modal-appointment .form-block .form-cell-grow,
    .modal-appointment .form-block .form-cell-shrink {
        flex: 1 1 100%;
        max-width: 100%;
        min-width: 0;
    }
    /* Врач+Дата+Время — горизонталь на мобильном (2+1) */
    .modal-appointment .form-block:first-of-type {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(1) {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(2) {
        flex: 1 1 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
    }
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(3) {
        flex: 1 1 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
    }
    /* Услуга+Длит+Стоимость — горизонталь */
    .modal-appointment .form-block:nth-of-type(2) {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(1) {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(2),
    .modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(3) {
        flex: 1 1 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
    }
    .modal-appointment .form-block:nth-of-type(3) .form-cell:first-child {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .modal-actions { flex-direction: column; gap: 0.5rem; }
    .modal-actions-main { flex-wrap: wrap; width: 100%; }
    .modal-actions-main .btn { flex: 1 1 auto; min-width: 0; text-align: center; }
    .modal-actions-block { margin-left: 0; width: 100%; }
    .modal-actions-block .btn { width: 100%; }
    .modal-actions > .btn-danger { width: 100%; order: 2; }
    .modal-actions > .modal-actions-block { order: 1; }

    /* ── Модалка пациента — полноэкранный лист ── */
    .modal-content.modal-patient {
        max-height: 92dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .modal-patient .modal-header { flex-shrink: 0; padding: 0.85rem 1rem; }
    .patient-tabs {
        flex-shrink: 0;
        overflow-x: auto;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding: 0 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    .patient-tabs::-webkit-scrollbar { height: 4px; }
    .patient-tabs::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
    .patient-tabs .patient-tab {
        white-space: nowrap;
        padding: 0.55rem 0.7rem;
        font-size: 0.84rem;
        flex-shrink: 0;
    }
    .patient-tab-panels {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-patient .patient-tab-panel .modal-body,
    .modal-patient #patientForm.modal-body {
        padding: 1rem 1rem 1.5rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 12px));
    }

    /* Форма профиля: сброс desktop flex-basis (иначе 350px = высота ячейки!) */
    .modal-patient .form-row-inline,
    .modal-patient .form-row-inline:first-of-type,
    .modal-patient .form-row-inline:nth-of-type(2) {
        flex-direction: column;
        gap: 0.65rem;
        margin-bottom: 0.75rem;
        align-items: stretch;
    }
    .modal-patient .form-row-inline .form-cell,
    .modal-patient .form-row-inline:first-of-type .form-cell:nth-child(1),
    .modal-patient .form-row-inline:first-of-type .form-cell:nth-child(2),
    .modal-patient .form-row-inline:nth-of-type(2) .form-cell:nth-child(1),
    .modal-patient .form-row-inline:nth-of-type(2) .form-cell:nth-child(2) {
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0;
    }
    /* Телефон и пол — в одну строку на узком экране */
    .modal-patient .form-row-inline:nth-of-type(2) {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .modal-patient .form-row-inline:nth-of-type(2) .form-cell:nth-child(1) {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
    .modal-patient .form-row-inline:nth-of-type(2) .form-cell:nth-child(2) {
        flex: 1 1 calc(50% - 0.35rem) !important;
        max-width: calc(50% - 0.35rem) !important;
        width: auto !important;
    }
    .modal-patient .form-row-inline input,
    .modal-patient .form-row-inline select,
    .modal-patient .form-row-full textarea {
        font-size: 16px; /* без зума на iOS */
    }
    .modal-patient .modal-actions {
        flex-direction: column-reverse;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    .modal-patient .modal-actions .btn { width: 100%; }

    /* ── Список приёмов в карточке пациента ── */
    .patient-appointments-list {
        font-size: 0.82rem;
        max-height: none;
    }
    .patient-appointments-list .col-doctor,
    .patient-appointments-list .col-cost,
    .patient-appointments-list .col-comment { display: none; }

    /* ── Рецепты ── */
    .patient-prescription-form .patient-rx-row {
        align-items: flex-start;
        gap: 0.4rem;
        margin-bottom: 0.65rem;
    }
    .patient-prescription-form .patient-rx-side {
        padding-top: 1.35rem;
        font-size: 0.8rem;
    }
    .patient-prescription-form .patient-rx-grid {
        flex: 1;
        min-width: 0;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.45rem;
        width: 100%;
        max-width: none;
    }
    .patient-prescription-form .rx-short {
        width: 100%;
        max-width: none;
        text-align: center;
        padding: 0.5rem 0.35rem;
        font-size: 1rem;
    }
    .patient-prescription-form .patient-rx-cell label {
        font-size: 0.72rem;
        text-align: center;
        margin-bottom: 0.2rem;
    }
    .patient-prescription-form .modal-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .patient-prescription-form .modal-actions .btn { width: 100%; }
    .patient-prescriptions-list { margin-top: 0.75rem; }

    /* ── Быстрая запись ── */
    .qb-body { padding: 1rem; }
    .qb-body:has(.qb-date-tabs) { padding: 0; }
    .qb-body:has(.qb-date-tabs) .qb-doctor-rows { padding: 0 1rem 1rem; }
    .qb-card-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

    /* ── Панель совпадений резерва ── */
    .reserve-matches-modal { max-height: 92vh; }
    .reserve-matches-body { padding: 0.75rem 0.85rem 1rem; }

    /* ── Кнопки резерва и быстрой записи ── */
    .btn-reserve-alert-label { display: none; }
    .btn-reserve-alert { padding: 0.45rem 0.65rem; }
    .btn-control-alert-label { display: none; }
    .btn-control-alert { padding: 0.45rem 0.65rem; }
    .btn-callback-alert-label { display: none; }
    .btn-callback-alert { padding: 0.45rem 0.65rem; }

    /* ── Форма резерва ── */
    .modal-reserve .reserve-form-row {
        flex-direction: column !important;
        gap: 0.65rem !important;
    }
    .modal-reserve .reserve-form-row .form-cell {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    /* ── Страницы-списки (пациенты, врачи и т.д.) ── */
    .schedule-main { padding: 0.75rem; }
    .page-list-table thead th { padding: 8px 10px; font-size: 0.74rem; }
    .page-list-table td { padding: 8px 10px; font-size: 0.88rem; }

    /* ── Модальные окна: адаптируем форму ── */
    .modal-patient .form-row-inline { flex-direction: column; gap: 0.6rem; }
    .modal-patient .form-row-inline .form-cell {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}

/* ============================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ — ≤480px (маленькие телефоны)
   ============================================================ */
/* ── Страницы-списки (пациенты, врачи, услуги, логи) — мобильная адаптация ── */
@media (max-width: 768px) {
    /* Тулбар страниц-списков */
    .schedule-toolbar { flex-wrap: wrap; }

    /* Обёртка таблицы — горизонтальный скролл */
    #patientsTableWrap,
    #servicesTableWrap,
    #logsTableWrap,
    #usersTableWrap,
    #journalWrap,
    #settingsWrap,
    #typesWrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

    /* Врачи: фиксированная раскладка — ФИО и статус помещаются без прокрутки */
    #doctorsTableWrap { overflow-x: hidden; max-width: 100%; }
    #doctorsTableWrap .page-list-table { table-layout: fixed; width: 100%; }
    #doctorsTableWrap .page-list-table td,
    #doctorsTableWrap .page-list-table th { white-space: normal; word-break: break-word; padding: 8px 8px; }

    /* Таблица рецептов — фиксированная раскладка (см. выше), без прокрутки */
    .patient-prescriptions-table thead th { padding: 6px 3px; font-size: 0.62rem; }
    .patient-prescriptions-table td { padding: 5px 3px; font-size: 0.78rem; }
    .patient-prescriptions-table .rx-col-date { width: 70px; }
    .patient-prescriptions-table .rx-col-actions { width: 56px; }
    .patient-prescription-actions .btn-prescription-edit,
    .patient-prescription-actions .btn-prescription-delete {
        display: block;
        width: 22px;
        height: 22px;
        font-size: 0.72rem;
        margin: 2px auto;
    }

    /* Пациенты: скрываем пол, оставляем ФИО+дата рождения+телефон */
    .patients-col-gender { display: none !important; }

    /* Врачи: если есть скрываемые колонки */
    .doctors-col-services { display: none !important; }

    /* Логи: скрываем «Было/Стало» */
    .logs-col-before,
    .logs-col-after { display: none !important; }

    /* Уведомления */
    .notifications-sending-toolbar { flex-direction: column; align-items: flex-start !important; }

    /* ── Тулбар пациентов ── */
    .patients-toolbar { gap: 0.5rem; }
    .patients-search-group { flex: 1 1 100%; }
    .patients-add-btn { flex: 1 1 100%; width: 100%; text-align: center; }

    /* ── Резерв: форма ── */
    .modal-content.modal-reserve { width: 100% !important; max-width: 100% !important; }
    .modal-reserve .reserve-form-row {
        flex-direction: column;
        gap: 0.6rem;
    }
    .modal-reserve .reserve-form-row .form-cell {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 400px) {
    .patient-prescription-form .patient-rx-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
}

@media (max-width: 480px) {

    /* ── Шапка ── */
    .main-header { padding: 0 0.65rem; height: 50px; }
    .logo-text { font-size: 0.95rem; }
    .user-badge { display: none; }

    /* ── Тулбар ── */
    .schedule-toolbar { gap: 0.35rem; }
    .date-nav { gap: 0.35rem; }
    .btn-nav { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
    .schedule-grid .col-time {
        width: 46px !important;
        min-width: 46px !important;
        max-width: 46px !important;
        font-size: 0.62rem;
    }
    .schedule-grid .schedule-table[data-doctor-count="1"] .col-doctor {
        width: calc(100% - 46px);
    }
    .schedule-grid .schedule-table {
        min-width: max(100%, calc(46px + 132px * var(--doctor-count, 1)));
    }

    /* Модалка пациента — табы чуть компактнее */
    .patient-tabs .patient-tab { padding: 0.5rem 0.6rem; font-size: 0.8rem; }

    /* ── Модалки ── */
    .modal-header { padding: 0.75rem 0.85rem; }
    .modal-body { padding: 0.85rem; }

    /* ── Форма записи — Дата и Время рядом ── */
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(2),
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(3) {
        flex: 1 1 calc(50% - 0.35rem);
        max-width: calc(50% - 0.35rem);
    }

    /* ── Быстрая запись ── */
    .qb-path-cards { grid-template-columns: 1fr; }
    .btn-quick-book-label { display: none; }
    .btn-quick-book { padding: 0.45rem 0.65rem; }
    .btn-quick-book-icon { font-size: 1.5rem; }

    /* ── Кнопки действий в модалке ── */
    .btn { font-size: 0.88rem; padding: 0.5rem 0.85rem; }

    /* ── Таблицы списков — упрощаем столбцы ── */
    .page-list-table .log-json { display: none; }

    /* ── Поля ввода и селекты ── */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
        padding: 0.6rem 0.65rem !important;
        border-radius: var(--radius-sm);
    }

    /* ── Форма пациента ── */
    .modal-patient .form-row-inline {
        flex-direction: column;
        gap: 0.65rem;
    }
    .modal-patient .form-row-inline .form-cell {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    /* ── Форма резерва ── */
    .reserve-form-row { flex-direction: column !important; }
    .reserve-form-row .form-cell { flex: 1 1 100% !important; max-width: 100% !important; }

    /* ── Форма пользователя ── */
    .modal-user .form-row { flex-direction: column; }
    .modal-user .form-row .form-cell { max-width: 100%; }

    /* ── Форма врача ── */
    .modal-doctor .form-row { flex-direction: column; }
    .modal-doctor .form-row .form-cell { flex: 1 1 100% !important; max-width: 100% !important; }

    /* ── Форма услуги ── */
    .modal-service .form-row { flex-direction: column; }

    /* ── Таблицы: делаем текст меньше, уменьшаем падинг ── */
    .page-list-table thead th { padding: 6px 8px; font-size: 0.72rem; }
    .page-list-table td { padding: 6px 8px; font-size: 0.82rem; }
    .page-list-table { font-size: 0.82rem; }

    /* ── Пациенты, Врачи, Услуги, Логи — пряч вспомогательные колонки ── */
    .patients-col-passport { display: none !important; }
    .doctors-col-description { display: none !important; }
    .services-col-description { display: none !important; }
    .logs-col-new_value { display: none !important; }

    /* ── Кнопки таблиц ── */
    .page-list-table .btn-table { padding: 0.4rem 0.55rem; font-size: 0.75rem; }

    /* ── Поиск по пациентам ── */
    .patient-search-row { flex-wrap: wrap; gap: 0.5rem; }
    .patient-search-row input[type="text"] { flex: 1 1 100%; min-width: 0; }
    .patient-search-row .btn { flex: 1 1 48%; }

    /* ── Тулбар пациентов ── */
    .patients-toolbar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .patients-search-group { flex: 1 1 auto; }
    .patients-search-input { font-size: 16px !important; }
    .patients-add-btn { width: 100%; text-align: center; }

    /* ── Пациенты: скрываем дату рождения ── */
    .patients-col-birthdate { display: none !important; }

    /* ── Резерв / контроль: toolbar и таблицы ── */
    .reserve-toolbar { flex-direction: column; align-items: flex-start !important; gap: 0.5rem !important; }
    .section-toolbar-left { width: 100%; }
    .section-toolbar-right { width: 100%; margin-left: 0; justify-content: flex-start; }
    .section-search-input { max-width: 100%; }
    .callback-main .callback-toolbar-right { width: 100%; align-items: flex-start; margin-left: 0; }
    .reserve-nav-links { width: 100%; }
    .reserve-nav-link { flex: 1; text-align: center; }
    .reserve-list { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .reserve-list-table .reserve-th-created,
    .reserve-list-table .reserve-td-created,
    .reserve-list-table .reserve-th-comment,
    .reserve-list-table .reserve-td-comment,
    .reserve-list-table .reserve-th-age,
    .reserve-list-table .reserve-td-age { display: none; }
    .reserve-list-table thead th,
    .reserve-list-table td { padding: 8px 10px; }
    .reserve-by-doctors { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
    .reserve-by-doctors::-webkit-scrollbar { height: 6px; }
    .reserve-by-doctors::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
    .modal-reserve .reserve-form-row {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .modal-reserve .reserve-form-row .form-cell,
    .modal-reserve .reserve-form-row .form-cell-patient,
    .modal-reserve .reserve-form-row .form-cell-age,
    .modal-reserve .reserve-form-row .form-cell-full {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .reserve-row-record-age {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }
    .reserve-row-record-age .form-cell:first-child { flex: 2 1 120px !important; }
    .reserve-row-record-age .form-cell-age { flex: 0 0 80px !important; max-width: 80px !important; }
    /* ── Резерв: форма — Возраст компактнее ── */
    .reserve-row-record-age { gap: 0.5rem !important; }
    .reserve-row-record-age .form-cell-age { flex: 0 1 auto !important; max-width: 100% !important; }


    /* ── Кнопки в модалке — одна строка ── */
    .modal-actions { flex-wrap: wrap; gap: 0.5rem; }
    .modal-actions .btn { flex: 1 1 auto; min-width: 120px; }

    /* ── Быстрая запись: карточки и макет ── */
    .qb-card { padding: 0.6rem; }
    .qb-card-title { font-size: 0.8rem; }
    .qb-doctor-content { font-size: 0.82rem; }
    .qb-body { padding: 0.75rem; }

    /* ── Напоминания: значки и текст ── */
    .notification-item { padding: 0.75rem; font-size: 0.85rem; }
    .notification-icon { font-size: 1.2rem; min-width: 32px; }

    /* ── Расписание: компактнее ── */
    .schedule-main { padding: 0.6rem; }

    /* ── Модалка резерва: компактнее ── */
    .reserve-matches-body { padding: 0.6rem 0.7rem 0.75rem; }
    .reserve-match-row { gap: 0.5rem; padding: 0.5rem; }
}

/* ============================================================
   MOBILE OVERRIDES - practical pass for phones 360-430px
   ============================================================ */
@media (max-width: 480px) {
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body {
        font-size: 14px;
        line-height: 1.45;
    }

    .schedule-main,
    .schedule-manage-main {
        width: 100%;
        max-width: 100%;
        padding: 0.6rem !important;
        overflow-x: hidden;
    }

    .main-header {
        height: auto;
        min-height: 50px;
        padding: 0.45rem 0.6rem;
        align-items: flex-start;
        gap: 0.45rem;
    }

    .header-left {
        flex: 1 1 auto;
        min-width: 0;
        gap: 0.55rem;
    }

    .logo {
        max-width: calc(100vw - 160px);
    }

    .logo-text {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-toggle {
        flex: 0 0 auto;
    }

    .main-header nav {
        top: 50px;
        left: 0.6rem;
        right: 0.6rem;
        width: auto;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }

    .main-header nav.open {
        display: flex;
    }

    .nav-link {
        min-height: 42px;
        padding: 0.65rem 0.75rem;
        font-size: 0.95rem;
    }

    .header-right {
        gap: 0.4rem;
        margin-left: auto;
    }

    .btn-logout {
        padding: 0.45rem 0.65rem;
        font-size: 0.85rem;
    }

    .schedule-toolbar,
    .patients-toolbar,
    .reserve-toolbar,
    .notifications-sending-toolbar {
        width: 100%;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    .schedule-toolbar,
    .patients-toolbar {
        flex-direction: column;
    }

    .schedule-toolbar-actions,
    .date-nav,
    .patients-search-group {
        width: 100%;
    }

    .date-nav {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .date-nav input[type="date"],
    .patients-search-input,
    .section-search-input,
    .patients-search-group input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .schedule-toolbar-actions {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.4rem;
    }

    .schedule-toolbar-actions .btn-quick-book,
    .schedule-toolbar-actions .btn-reserve-alert,
    .schedule-toolbar-actions .btn-control-alert,
    .schedule-toolbar-actions .btn-callback-alert {
        width: 100%;
        justify-content: center;
        min-height: 38px;
    }

    .btn,
    button,
    input,
    select,
    textarea {
        max-width: 100%;
    }

    .btn {
        min-height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }

    .schedule-grid,
    .page-list,
    .reserve-list,
    .reserve-by-doctors,
    .schedule-table-wrap,
    #patientsTableWrap,
    #servicesTableWrap,
    #logsTableWrap,
    #usersTableWrap,
    #journalWrap,
    #typesWrap {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #doctorsTableWrap { max-width: 100%; overflow-x: hidden; }

    .page-list-table,
    .reserve-list-table {
        min-width: 520px;
    }
    /* Врачи — таблица фиксированной раскладки, без нижнего порога ширины */
    #doctorsTableWrap .page-list-table {
        min-width: 0;
        table-layout: fixed;
        width: 100%;
    }
    #doctorsTableWrap .page-list-table td,
    #doctorsTableWrap .page-list-table th {
        white-space: normal;
        word-break: break-word;
        padding: 8px;
    }
    .doctors-col-status {
        width: 96px !important;
        min-width: 96px !important;
        max-width: 96px !important;
        white-space: normal !important;
        font-size: 0.76rem !important;
        text-align: right !important;
    }

    .modal {
        align-items: stretch;
        justify-content: center;
        padding: 0.4rem;
    }

    .modal-content,
    .modal-content.modal-patient,
    .modal-content.modal-appointment,
    .modal-content.modal-block-time,
    .modal-content.modal-reserve,
    .modal-content.modal-user {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 0.8rem) !important;
        margin: 0 !important;
        border-radius: var(--radius-md);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .modal-header {
        flex: 0 0 auto;
        gap: 0.75rem;
    }

    .modal-header h2,
    .modal-user-title {
        min-width: 0;
        font-size: 1.05rem;
        line-height: 1.25;
    }

    .modal-body,
    .user-form,
    .modal-content > form {
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-actions,
    .user-form-actions,
    .settings-actions,
    .template-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .modal-actions .btn,
    .user-form-actions .btn,
    .settings-actions .btn,
    .template-actions .btn {
        width: 100%;
    }
}

/* Mobile schedule refinements */
@media (max-width: 480px) {
    .schedule-main-with-calendar {
        display: flex;
        flex-direction: column;
        gap: 0.65rem;
        overflow-x: hidden;
    }

    .schedule-left {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .schedule-calendar-aside {
        width: 100%;
        max-width: 100%;
        position: static;
        flex: none;
        order: -1;
    }

    .calendar-widget {
        width: 100%;
        max-width: 100%;
        padding: 0.7rem;
    }

    .calendar-table th,
    .calendar-table td {
        width: 14.285%;
        min-width: 0;
        padding: 0.35rem 0.2rem;
        font-size: 0.78rem;
    }

    #scheduleGrid {
        width: 100%;
        overflow-x: auto;
        overflow-y: visible;
        border-radius: var(--radius-md);
    }

    .schedule-grid .schedule-table {
        min-width: max(100%, calc(48px + 136px * var(--doctor-count, 1))) !important;
    }

    .schedule-grid .col-time {
        width: 48px !important;
        min-width: 48px !important;
        max-width: 48px !important;
        padding: 4px 3px !important;
    }

    .schedule-grid .col-doctor {
        width: 136px;
        min-width: 136px;
        max-width: 136px;
    }

    .appointment-card {
        padding: 0.35rem 0.4rem;
        font-size: 0.74rem;
        line-height: 1.22;
    }

    .appointment-card .patient-name,
    .appointment-card .service-name {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .modal-appointment .form-block,
    .modal-appointment .form-block-full {
        display: flex;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.65rem;
        margin-bottom: 0.75rem;
    }

    .modal-appointment .form-block .form-cell,
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(1),
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(2),
    .modal-appointment .form-block:first-of-type .form-cell:nth-child(3),
    .modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(1),
    .modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(2),
    .modal-appointment .form-block:nth-of-type(2) .form-cell:nth-child(3),
    .modal-appointment .form-block:nth-of-type(3) .form-cell:first-child {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding-top: 0 !important;
    }

    .modal-appointment .color-options,
    .modal-appointment .reminder-options {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .qb-modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 0.8rem) !important;
    }

    .qb-header {
        padding: 0.75rem 0.85rem;
        gap: 0.55rem;
    }

    .qb-title {
        font-size: 1rem;
    }

    .qb-body,
    .qb-body:has(.qb-date-tabs) .qb-doctor-rows {
        padding: 0.75rem;
    }

    .qb-body:has(.qb-date-tabs) .qb-date-tabs {
        padding: 0 0.75rem;
    }

    .qb-card-grid {
        grid-template-columns: 1fr !important;
    }

    .qb-doctor-row {
        gap: 0.6rem;
        padding: 0.75rem 0;
    }

    .qb-time-btns {
        gap: 0.4rem;
    }

    .qb-time-btn {
        min-height: 34px;
        padding: 0.35rem 0.6rem;
    }
}

/* Mobile CRM refinements: reserve, control, callback */
@media (max-width: 480px) {
    .reserve-main {
        overflow-x: hidden;
    }

    .reserve-toolbar {
        margin-bottom: 0.75rem !important;
    }

    .section-toolbar-left {
        width: 100%;
        gap: 0.45rem;
    }

    .reserve-nav-links {
        display: flex;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.35rem;
        padding-bottom: 0.05rem;
    }

    .reserve-nav-links::-webkit-scrollbar {
        display: none;
    }

    .reserve-nav-link {
        flex: 0 0 auto !important;
        min-height: 36px;
        padding: 0.45rem 0.65rem;
        white-space: nowrap;
        text-align: center;
        font-size: 0.86rem;
    }

    .section-search-bar {
        width: 100%;
    }

    .section-search-input {
        height: 38px;
    }

    .callback-main .callback-toolbar-right {
        width: 100%;
        align-items: stretch;
        gap: 0.45rem;
    }

    .callback-toolbar-hint {
        text-align: left;
        font-size: 0.82rem;
    }

    .callback-bulk-bar,
    .callback-actions {
        width: 100%;
        gap: 0.4rem;
    }

    .callback-actions .btn,
    .callback-bulk-bar .btn {
        flex: 1 1 auto;
        min-width: 92px;
    }

    .reserve-list,
    .reserve-by-doctors {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-md);
    }

    .reserve-list-table {
        min-width: 560px;
        font-size: 0.82rem;
    }

    .callback-list-table {
        min-width: 680px;
    }

    .reserve-list-table thead th,
    .reserve-list-table td {
        padding: 8px 9px;
    }

    .reserve-list-table .reserve-td-patient {
        min-width: 150px;
    }

    .reserve-list-table .reserve-patient-name {
        font-size: 0.88rem;
    }

    .reserve-list-table .reserve-patient-phone,
    .callback-summary {
        font-size: 0.78rem;
    }

    .reserve-by-doctors-table thead th,
    .reserve-by-doctors-table tbody td {
        min-width: 164px;
        width: 164px;
        max-width: 164px;
    }

    .reserve-by-doctors-cell {
        max-height: 68vh;
        min-height: 72px;
        gap: 5px;
    }

    .reserve-by-doctor-card {
        border-radius: 7px;
    }

    .rbdc-inner {
        padding: 0.55rem;
    }

    .rbdc-name {
        font-size: 0.86rem;
        line-height: 1.2;
    }

    .rbdc-phone,
    .rbdc-details,
    .rbdc-meta {
        font-size: 0.76rem;
    }

    .rbdc-phone {
        /* На узких карточках телефону не хватает места в одну строку —
           разрешаем перенос, но не разрывая номер посередине (неразрывные дефисы из JS) */
        white-space: normal;
    }

    .rbdc-details,
    .rbdc-meta {
        gap: 0.25rem;
    }

    .btn-reserve-delete {
        width: 30px;
        height: 30px;
    }

    .callback-th-select,
    .callback-td-select {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--card);
    }

    .callback-list-table thead .callback-th-select {
        background: linear-gradient(180deg, #f8f9fa 0%, #eef0f2 100%);
    }
}

/* Mobile directory and table refinements */
@media (max-width: 480px) {
    .page-list {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-md);
    }

    .page-list-table {
        min-width: 500px;
        font-size: 0.82rem;
    }

    .page-list-table thead th,
    .page-list-table td {
        padding: 8px 9px !important;
        vertical-align: middle;
    }

    #patientsTableWrap .page-list-table {
        min-width: 420px;
    }

    #servicesTableWrap .page-list-table {
        min-width: 360px;
    }

    #usersTableWrap .page-list-table {
        min-width: 460px;
    }

    #logsTableWrap .page-list-table {
        min-width: 560px;
    }

    .patients-toolbar {
        margin-bottom: 0.75rem;
    }

    .patients-search-group {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.45rem;
    }

    .patients-add-btn,
    #btnAddDoctor,
    #btnAdd,
    #btnAddUser {
        width: 100%;
    }

    #pagination {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        font-size: 0.86rem;
        text-align: center;
    }

    #pagination .btn {
        flex: 0 0 auto;
        min-width: 44px;
    }

    .doctor-services-grid {
        max-height: 52vh !important;
    }

    .doctor-service-row {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 0.45rem !important;
        padding: 0.55rem !important;
    }

    .doctor-service-row label.svc-check {
        flex: 1 1 100%;
        width: 100%;
    }

    .doctor-service-row .svc-name {
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        line-height: 1.25;
        word-break: break-word;
    }

    .doctor-service-duration {
        width: 100%;
        margin-left: 0 !important;
        justify-content: flex-start;
    }

    .doctor-service-row .doc-svc-duration {
        width: 5rem;
        font-size: 16px !important;
    }

    .user-permissions-grid {
        grid-template-columns: 1fr !important;
        gap: 0.55rem !important;
    }

    .user-perm-card {
        min-height: 0;
        padding: 0.65rem !important;
    }

    .user-form-section {
        padding: 0.85rem !important;
    }

    .user-form-row {
        gap: 0.35rem;
    }

    .log-row-tooltip {
        display: none !important;
    }

    #filterTable,
    #btnRefresh {
        width: 100%;
    }
}

/* Mobile notifications refinements */
@media (max-width: 480px) {
    .notifications-tabs {
        display: flex !important;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.25rem !important;
        border-bottom: none !important;
        margin-bottom: 0.75rem !important;
    }

    .notifications-tabs::-webkit-scrollbar {
        display: none;
    }

    .notifications-tab {
        flex: 0 0 auto;
        min-height: 38px;
        padding: 0.5rem 0.7rem !important;
        border: 1px solid var(--border) !important;
        border-radius: 999px !important;
        background: var(--card) !important;
        white-space: nowrap;
        font-size: 0.86rem !important;
        margin-bottom: 0 !important;
    }

    .notifications-tab.active {
        border-color: var(--primary) !important;
        background: var(--primary-light) !important;
    }

    .notifications-section {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .notifications-bulk-actions,
    .settings-actions,
    .template-actions {
        width: 100%;
    }

    .notifications-bulk-actions .btn,
    .settings-actions .btn,
    .template-actions .btn {
        width: 100%;
    }

    #journalWrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #journalWrap .page-list-table,
    #journalWrap table {
        min-width: 640px;
    }

    .settings-card,
    .template-card {
        padding: 0.8rem !important;
        border-radius: var(--radius-md) !important;
    }

    .settings-toggle-row {
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .settings-toggle-label {
        line-height: 1.3;
    }

    .template-textarea {
        min-height: 140px !important;
        font-size: 16px !important;
    }

    .notifications-help {
        font-size: 0.82rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
}

/* Accessibility & status cues (audit follow-up) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
.section-toolbar-left { gap: 0.85rem; }
.reserve-nav-links { gap: 0.75rem; }
.reserve-by-doctor-card .btn-reserve-delete { width: 28px; height: 28px; }
.status-text-cue {
    display: inline-block;
    margin-inline-start: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.65rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.cal-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.cal-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.cal-legend-swatch.none { background: #e5e7eb; }
.cal-legend-swatch.free { background: #bbf7d0; }
.cal-legend-swatch.busy { background: #16a34a; }
.sr-only-search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
