/* ============================================================
   CSS ПЕРЕМЕННЫЕ — СВЕТЛАЯ ТЕМА
============================================================ */
:root,
[data-theme="light"] {
    --color-primary:       #1a3c5e;
    --color-primary-dark:  #122840;
    --color-primary-light: #2a5a8c;
    --color-accent:        #0abfbc;
    --color-accent-dark:   #089a97;
    --color-accent-light:  #e6fafa;

    --bg-app:              #f0f4f8;
    --bg-surface:          #ffffff;
    --bg-surface-2:        #f8fafc;
    --bg-sidebar:          #1a3c5e;
    --bg-topbar:           #ffffff;

    --text-primary:        #1a2332;
    --text-secondary:      #5a6a7a;
    --text-muted:          #8a9aaa;
    --text-inverse:        #ffffff;
    --text-sidebar:        rgba(255,255,255,0.85);
    --text-sidebar-muted:  rgba(255,255,255,0.5);

    --border-color:        #dde3ea;
    --border-light:        #eef1f5;

    --shadow-sm:           0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:           0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:           0 8px 24px rgba(0,0,0,0.12);
    --shadow-sidebar:      4px 0 20px rgba(0,0,0,0.15);

    --color-success:       #22c55e;
    --color-warning:       #f59e0b;
    --color-danger:        #ef4444;
    --color-info:          #3b82f6;

    --sidebar-width:       260px;
    --sidebar-collapsed:   72px;
    --topbar-height:       64px;
    --radius-sm:           6px;
    --radius-md:           10px;
    --radius-lg:           16px;

    --transition:          0.25s ease;
}

/* ============================================================
   CSS ПЕРЕМЕННЫЕ — ТЁМНАЯ ТЕМА
============================================================ */
[data-theme="dark"] {
    --color-primary:       #2a5a8c;
    --color-primary-dark:  #1a3c5e;
    --color-primary-light: #3a7ab0;
    --color-accent:        #0abfbc;
    --color-accent-dark:   #089a97;
    --color-accent-light:  #0d2f2f;

    --bg-app:              #0f1923;
    --bg-surface:          #172233;
    --bg-surface-2:        #1e2d42;
    --bg-sidebar:          #0f1923;
    --bg-topbar:           #172233;

    --text-primary:        #e8edf2;
    --text-secondary:      #8a9aaa;
    --text-muted:          #5a6a7a;
    --text-inverse:        #ffffff;
    --text-sidebar:        rgba(255,255,255,0.85);
    --text-sidebar-muted:  rgba(255,255,255,0.4);

    --border-color:        #2a3a4a;
    --border-light:        #1e2d42;

    --shadow-sm:           0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:           0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:           0 8px 24px rgba(0,0,0,0.5);
    --shadow-sidebar:      4px 0 20px rgba(0,0,0,0.4);
}


/* ============================================================
   СБРОС И BASE
============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ============================================================
   APP WRAPPER
============================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-sidebar);
    overflow: hidden;
    transition: width var(--transition);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Антивспышка sidebar */
[data-sidebar="collapsed"] .sidebar        { width: var(--sidebar-collapsed); }
[data-sidebar="collapsed"] .main-area      { margin-left: var(--sidebar-collapsed); }
[data-sidebar="collapsed"] .sidebar-toggle { left: calc(var(--sidebar-collapsed) - 13px); }
[data-sidebar="collapsed"] .nav-label      { opacity: 0; max-width: 0; }
[data-sidebar="collapsed"] .logo-text      { opacity: 0; }
[data-sidebar="collapsed"] .nav-item       { justify-content: center; padding: 11px 0; gap: 0; }
[data-sidebar="collapsed"] .sidebar-footer .nav-item { justify-content: center; padding: 11px 0; }

/* Toggle кнопка */
.sidebar-toggle {
    position: fixed;
    top: 22px;
    left: calc(var(--sidebar-width) - 13px);
    width: 26px;
    height: 26px;
    background: var(--color-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    box-shadow: var(--shadow-md);
    z-index: 200;
    border: none;
    cursor: pointer;
    transition: left var(--transition);
}

.sidebar.collapsed ~ .sidebar-toggle,
.sidebar-toggle.collapsed { left: calc(var(--sidebar-collapsed) - 13px); }

.sidebar-toggle i          { transition: transform var(--transition); }
.sidebar-toggle.collapsed i { transform: rotate(180deg); }

/* Лого */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 17px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 72px;
    white-space: nowrap;
    overflow: hidden;
}

.logo-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    flex-shrink: 0;
    background: var(--color-accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.logo-text {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition);
    opacity: 1;
}

.logo-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-inverse);
}

.logo-sub {
    display: block;
    font-size: 11px;
    color: var(--text-sidebar-muted);
    margin-top: 1px;
}

.sidebar.collapsed .logo-text { opacity: 0; }

/* Навигация */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar       { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
    position: relative;
    transition: background var(--transition), color var(--transition),
                padding var(--transition), justify-content var(--transition);
}

.nav-item i {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
    color: var(--text-sidebar-muted);
    transition: color var(--transition);
}

.nav-item:hover          { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item:hover i        { color: var(--color-accent); }
.nav-item.active         { background: rgba(10,191,188,0.15); color: #fff; font-weight: 500; }
.nav-item.active i       { color: var(--color-accent); }

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%;
    height: 60%; width: 3px;
    background: var(--color-accent);
    border-radius: 0 3px 3px 0;
}

.nav-label {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition), max-width var(--transition);
    max-width: 200px;
    opacity: 1;
}

.sidebar.collapsed .nav-label { opacity: 0; max-width: 0; }

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
}

/* Tooltip */
.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-collapsed) + 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-primary-dark);
    color: #fff;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    box-shadow: var(--shadow-md);
    z-index: 300;
}

.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* Footer */
.sidebar-footer {
    padding: 10px 8px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar.collapsed .sidebar-footer .nav-item { justify-content: center; padding: 11px 0; }

.nav-logout               { color: rgba(255,255,255,0.6); }
.nav-logout:hover         { background: rgba(239,68,68,0.15); color: #ef4444; }
.nav-logout:hover i       { color: #ef4444; }

/* ============================================================
   MAIN AREA
============================================================ */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.main-area.expanded { margin-left: var(--sidebar-collapsed); }

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition);
}

.topbar-datetime {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
}

.topbar-time {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

.topbar-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Тариф */
.tariff-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.tariff-basic   { background: rgba(59,130,246,0.12);  color: #3b82f6; }
.tariff-pro     { background: rgba(10,191,188,0.12);  color: var(--color-accent-dark); }
.tariff-premium { background: rgba(245,158,11,0.12);  color: #f59e0b; }

/* Кнопки иконки */
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text-secondary);
    font-size: 15px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
    background: var(--color-accent-light);
    color: var(--color-accent-dark);
    border-color: var(--color-accent);
}

/* Язык */
.lang-switcher  { position: relative; }

.lang-btn {
    width: auto;
    padding: 0 10px;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    overflow: hidden;
    display: none;
    z-index: 200;
}

.lang-dropdown.open { display: block; }

.lang-option {
    display: block;
    width: 100%;
    padding: 9px 14px;
    text-align: left;
    font-size: 13px;
    color: var(--text-primary);
    transition: background var(--transition);
}

.lang-option:hover  { background: var(--bg-surface-2); }
.lang-option.active { color: var(--color-accent-dark); font-weight: 600; }

/* Пользователь */
.user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: background var(--transition);
}

.user-info:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

.user-name  { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role  { display: block; font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ============================================================
   MAIN CONTENT
============================================================ */
.main-content {
    flex: 1;
    padding: 24px;
    background: var(--bg-app);
    transition: background var(--transition);
}

/* ============================================================
   ОБЩИЕ КОМПОНЕНТЫ (используются на всех страницах)
============================================================ */

/* Заголовок страницы */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i  { color: var(--color-accent); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; display: block; }

/* Кнопки */
.btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.btn-accent:hover {
    background: var(--color-accent-dark);
    transform: translateY(-1px);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-outline:hover { background: var(--color-accent); color: #fff; }

/* Фильтры */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group   { display: flex; align-items: center; gap: 4px; }

.filter-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover  {
    background: var(--color-accent-light);
    color: var(--color-accent-dark);
    border-color: var(--color-accent);
}

.filter-btn.active {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.filter-divider { width: 1px; height: 28px; background: var(--border-color); margin: 0 4px; }

/* Дата */
.filter-dates   { display: flex; align-items: center; gap: 8px; }

.date-input-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
}

.date-input-wrap i { color: var(--text-muted); font-size: 13px; }

.date-input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.date-sep { color: var(--text-muted); font-size: 13px; }

/* Статусы-фильтры */
.filter-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-status:hover  { background: var(--bg-app); }
.filter-status.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.status-dot        { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.wait   { background: #f59e0b; }
.status-dot.active { background: #0abfbc; }
.status-dot.done   { background: #22c55e; }
.status-dot.cancel { background: #ef4444; }

/* View panel */
.view-panel {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

[data-theme="light"] .view-panel {
    border-color: #d0d7e2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* Таблицы */
.dash-table-wrap { overflow-x: auto; }

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.dash-table thead tr  { border-bottom: 2px solid var(--border-color); }

.dash-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.dash-table td {
    padding: 12px 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr { transition: background var(--transition); }
.dash-table tbody tr:hover { background: var(--bg-surface-2); }

/* Сортировка */
.sortable           { cursor: pointer; user-select: none; }
.sortable:hover     { color: var(--color-accent); }
.sortable i         { margin-left: 4px; font-size: 11px; }

/* Статус badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-done   { background: rgba(34,197,94,0.12);  color: #22c55e; }
.status-active { background: rgba(10,191,188,0.12); color: var(--color-accent-dark); }
.status-wait   { background: rgba(245,158,11,0.12); color: #f59e0b; }
.status-cancel { background: rgba(239,68,68,0.12);  color: #ef4444; }

/* Time badge */
.time-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
}

/* Client cell */
.client-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action buttons */
.action-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--color-accent-light);
    color: var(--color-accent-dark);
    border-color: var(--color-accent);
}

.action-btn.danger:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    border-color: #ef4444;
}

.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Debt badge */
.debt-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: rgba(239,68,68,0.10);
    color: #ef4444;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* Filter label */
.filter-label { font-size: 12px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

/* Search */
.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    min-width: 260px;
}

.search-wrap i { color: var(--text-muted); font-size: 13px; }

.search-input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    width: 100%;
}

.search-input::placeholder { color: var(--text-muted); }

/* Универсальный скролл */
.scroll-panel {
    overflow-y: auto;
    overflow-x: auto;
    max-height: calc(100vh - 310px);
    min-height: 300px;
}

.scroll-panel table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 5;
    box-shadow: 0 2px 0 var(--border-color);
}

[data-theme="light"] .scroll-panel table thead th { background: #ffffff; }

/* Модальные окна */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: modalIn 0.2s ease;
}

.modal-lg { max-width: 760px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title  { font-size: 16px; font-weight: 600; color: var(--text-primary); }

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    border-color: #ef4444;
}

.modal-body { padding: 22px; }

/* Формы */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.form-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus { border-color: var(--color-accent); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.modal-footer-btns {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

/* Cal nav (общий для записей и платежей) */
.cal-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
}

.cal-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.cal-nav-btn:hover  { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.cal-nav-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 200px;
    text-align: center;
}

.cal-today-btn {
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    margin-left: 4px;
}

.cal-today-btn:hover {
    background: var(--color-accent-light);
    color: var(--color-accent-dark);
    border-color: var(--color-accent);
}

/* Расписание (общее для сотрудников и настроек) */
.sched-form      { display: flex; flex-direction: column; gap: 10px; }

.sched-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    gap: 16px;
}

.sched-row-day  { display: flex; align-items: center; gap: 10px; min-width: 80px; }
.sched-day-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }

.sched-row-times {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity var(--transition);
}

.sched-times-hidden { opacity: 0.2; pointer-events: none; }

.sched-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.sched-toggle input { display: none; }

.sched-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 20px;
    transition: background var(--transition);
}

.sched-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}

.sched-toggle input:checked + .sched-slider              { background: var(--color-accent); }
.sched-toggle input:checked + .sched-slider::before      { transform: translateX(16px); }

/* Отключение анимации при инициализации */
.no-transition,
.no-transition * { transition: none !important; }

/* Глобальный скроллбар */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   TOAST УВЕДОМЛЕНИЯ — ГЛОБАЛЬНЫЕ
============================================================ */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    min-width: 260px;
    max-width: 380px;
}

.toast.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast i:first-child { font-size: 16px; flex-shrink: 0; }

.toast span { flex: 1; line-height: 1.4; }

.toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 13px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.toast-close:hover { color: #fff; }

/* Типы */
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info    { background: #2563eb; }

/* ============================================================
   ПРОГРЕСС-БАР ЗАГРУЗКИ СТРАНИЦЫ
============================================================ */
#pageProgress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--color-accent);
    z-index: 9999;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(10,191,188,0.6);
    border-radius: 0 2px 2px 0;
}

#pageProgress.progress-start {
    width: 70%;
    transition: width 0.8s cubic-bezier(0.1, 0.4, 0.6, 1);
}

#pageProgress.progress-done {
    width: 100%;
    transition: width 0.2s ease;
}

#pageProgress.progress-hide {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ============================================================
   БЛОК КОММЕНТАРИЯ В КАРТОЧКЕ
============================================================ */
.cc-comment-block {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: var(--radius-md);
    border-left: 3px solid #f59e0b;
}

.cc-comment-label {
    font-size: 11px;
    font-weight: 600;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cc-comment-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ============================================================
   ГЛОБАЛЬНАЯ КАРТОЧКА КЛИЕНТА
============================================================ */
.client-card-tabs-global {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cc-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.cc-tab:hover  { color: var(--text-primary); }
.cc-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.cc-tab i      { font-size: 12px; }

.cc-panel        { display: none; }
.cc-panel.active { display: block; }

/* Профиль в глобальной карточке */
#globalClientCardModal .cc-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
}

#globalClientCardModal .cc-avatar {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

#globalClientCardModal .cc-name { display: block; font-size: 16px; font-weight: 700; color: var(--text-primary); }
#globalClientCardModal .cc-meta { display: block; font-size: 12px; color: var(--text-muted); margin-top: 3px; }

#globalClientCardModal .view-appt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

#globalClientCardModal .view-appt-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

#globalClientCardModal .view-appt-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#globalClientCardModal .view-appt-card-label i { color: var(--color-accent); }

#globalClientCardModal .view-appt-card-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Зубная формула в глобальной карточке */
#globalClientCardModal .tf-row-right .tf-tooth i,
#globalClientCardModal .tf-row-left .tf-tooth i {
    transform: rotate(180deg);
}

#globalClientCardModal .tf-lower .tf-tooth i {
    transform: rotate(0deg);
}

#globalClientCardModal .tf-tooth::after {
    content: attr(data-label);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a2332;
    color: #fff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 100;
}

#globalClientCardModal .tf-tooth:hover::after { opacity: 1; }

/* Зубная формула */
.teeth-formula-wrap { display: flex; flex-direction: column; gap: 16px; }

.teeth-svg {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    display: block;
}

.tooth-rect {
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.tooth-group:hover .tooth-rect { opacity: 0.75; }

.teeth-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
}

.teeth-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================================
   ЗУБНАЯ ФОРМУЛА — ИКОНКИ
============================================================ */
.tf-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tf-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px;
}

.tf-jaw {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 10px 8px;
}

.tf-row {
    display: flex;
    gap: 3px;
}

.tf-mid-line {
    width: 1px;
    background: var(--border-color);
    margin: 0 6px;
    align-self: stretch;
}

.tf-gap { height: 12px; }

.tf-tooth {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition), transform var(--transition);
    min-width: 28px;
}

.tf-tooth:hover {
    background: var(--bg-surface);
    transform: translateY(-2px);
}

/* Верхняя челюсть — корни вверх */
.tf-row-right .tf-tooth i,
.tf-row-left .tf-tooth i {
    transform: rotate(180deg);
}

/* Нижняя челюсть — корни вниз */
.tf-lower .tf-tooth i {
    transform: rotate(0deg);
}

.tf-tooth i {
    font-size: 20px;
    transition: color var(--transition);
}

.tf-num {
    font-size: 9px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* Модалка редактирования зуба */
.tf-edit-modal {
    position: relative;
    margin-top: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.tf-edit-inner  { padding: 14px 16px; }

.tf-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tf-edit-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.tf-edit-statuses {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tf-status-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    border: 1.5px solid;
    cursor: pointer;
    transition: all var(--transition);
}

.tf-status-btn i { font-size: 12px; }

/* Badge номера зуба в таблице визитов */
.tooth-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    background: rgba(177,151,252,0.15);
    color: #b197fc;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ========== ПРЕЛОАДЕР ========== */
#appPreloader {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 25, 35, 0.85);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    opacity: 1;
}

#appPreloader.hiding {
    opacity: 0;
    pointer-events: none;
}

.preloader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preloader-logo {
    width: 64px;
    height: 64px;
    background: rgba(10,191,188,0.12);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--color-accent);
}

.preloader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}