/* static/admin.css */

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --success: #4caf50;
    --success-dark: #45a049;
    --danger: #f44336;
    --danger-dark: #da190b;
    --warning: #ff9800;
    --warning-dark: #e68900;
    --info: #17a2b8;
    --info-dark: #138496;
    --secondary: #6c757d;
    --secondary-dark: #5a6268;

    --gray-light: #f8f9fa;
    --gray-lighter: #f5f5f5;
    --gray: #888;
    --gray-dark: #555;
    --border-light: #eee;
    --border: #ddd;

    --header-gradient-start: #6c7085;
    --header-gradient-end: #764ba2;
    --stat-gradient-start: #667eea;
    --stat-gradient-end: #764ba2;

    --font-base: 100%;
    --font-xs: 0.75rem;
    --font-sm: 0.875rem;
    --font-md: 1rem;
    --font-lg: 1.125rem;
    --font-xl: 1.25rem;
    --font-xxl: 1.5rem;
    --font-xxxl: 2rem;

    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.25rem;
    --spacing-xxl: 1.5rem;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-xxl: 20px;
    --radius-circle: 40px;
    --radius-round: 50%;

    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 2px 4px rgba(0,0,0,0.1);

    /* Skeleton */
    --skeleton-base: #e0e0e0;
    --skeleton-shine: #f5f5f5;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: var(--font-base); }



body {
    font-family: 'SF Pro Text', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 
                 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--gray-lighter);
    color: #000;
    font-size: var(--font-md);
    line-height: 1.5;
}

.container {
    max-width: 87.5rem;
    margin: 0 auto;
    padding: var(--spacing-xl);
}

/* ========== ШАПКА ========== */
.header {
    background: linear-gradient(135deg, var(--header-gradient-start) 0%, var(--header-gradient-end) 100%);
    color: white;
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    margin-bottom: var(--spacing-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.header h1 { font-size: var(--font-xxl); margin: 0; }
.header .time { font-size: var(--font-sm); opacity: 0.9; }

/* ========== УПРАВЛЕНИЕ БОТАМИ ========== */
.bot-controls {
    display: flex;
    gap: 1.875rem;
    flex-wrap: wrap;
    align-items: center;
}

.bot-control-group {
    background: rgba(44,45,46,0.823);
    border-radius: var(--radius-circle);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.bot-control-group span { color: white; font-size: var(--font-sm); font-weight: 500; }

.bot-control-group button {
    background: #e0e0e0;
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-xs);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.bot-control-group button:hover { background: #c0c0c0; transform: scale(1.05); }
.bot-control-group button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ========== СТАТУС-БЕЙДЖИ БОТОВ ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-xxl);
    font-size: var(--font-xs);
    background: rgba(255,255,255,0.2);
}

.status-badge.running { background: var(--success); }
.status-badge.stopped { background: hsl(4, 100%, 61%); }

/* ========== БЕЙДЖИ СТАТУСОВ ЗАПИСЕЙ ========== */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-xxl);
    font-size: var(--font-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-active   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.badge-completed{ background: #f5f5f5; color: #555;     border: 1px solid #ccc; }
.badge-cancelled{ background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.badge-unknown  { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }

/* ========== ВКЛАДКИ ========== */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-xl);
    background: white;
    padding: var(--spacing-sm);
    border-radius: var(--radius-xl);
}

.tab-btn {
    padding: var(--spacing-sm) var(--spacing-xl);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: var(--font-sm);
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    color: #666;
}

/* hover на неактивных — мягкий серый фон */
.tab-btn:not(.active):hover {
    background: #ebebf5;
    color: var(--primary);
    transform: translateY(-1px);
}

.tab-btn.active { background: var(--primary); color: white; }
.tab-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ========== КОНТЕНТ ВКЛАДОК ========== */
.tab-content {
    display: none;
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
}

.tab-content.active { display: block; }

/* ========== ТАБЛИЦЫ — sticky thead ========== */
.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;           /* ограничение для sticky */
    margin-bottom: var(--spacing-xl);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-size: var(--font-sm);
}

.data-table th,
.data-table td {
    padding: var(--spacing-md);
    text-align: left;
    line-height: 1.2;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background: var(--gray-light);
    color: var(--gray-dark);
    /* Sticky-заголовки */
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 1px 0 var(--border);
}

.data-table tr:hover { background: var(--gray-light); }
.data-table a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }

/* Ширины колонок */
#users .data-table th:nth-child(1) { width: 8%; }
#users .data-table th:nth-child(2) { width: 15%; }
#users .data-table th:nth-child(3) { width: 15%; }
#users .data-table th:nth-child(4) { width: 25%; }
#users .data-table th:nth-child(5) { width: 15%; }
#users .data-table th:nth-child(6) { width: 10%; }

#masters .data-table th:nth-child(1) { width: 5%; }
#masters .data-table th:nth-child(2) { width: 15%; }
#masters .data-table th:nth-child(3) { width: 10%; }
#masters .data-table th:nth-child(4) { width: 10%; }
#masters .data-table th:nth-child(5) { width: 12%; }
#masters .data-table th:nth-child(6) { width: 12%; }
#masters .data-table th:nth-child(7) { width: 15%; }
#masters .data-table th:nth-child(8) { width: 7%; }
#masters .data-table th:nth-child(9) { width: 20%; }


/* ========== ТОСТЫ ========== */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: all;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    min-width: 18rem;
    max-width: 26rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
    font-size: var(--font-sm);
    line-height: 1.4;
    animation: toast-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    border-left: 4px solid var(--secondary);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger);  }
.toast.toast-info    { border-left-color: var(--info);    }
.toast.toast-warning { border-left-color: var(--warning); }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color var(--transition-fast);
}
.toast-close:hover { color: #333; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(2rem) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); max-height: 6rem; margin-bottom: 0.5rem; }
    to   { opacity: 0; transform: translateX(2rem); max-height: 0; margin-bottom: 0; padding: 0; }
}

.toast.removing {
    animation: toast-out 0.22s ease forwards;
}

/* ========== ПРЕВЬЮ ФОТО ========== */
.photo-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.photo-preview-item {
    position: relative;
    width: 5rem;
    height: 5rem;
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    display: block;
}

.photo-preview-item .preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.55);
    color: white;
    font-size: 0.6rem;
    padding: 2px 4px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== МОДАЛЬНОЕ ОКНО ПОДТВЕРЖДЕНИЯ УДАЛЕНИЯ ========== */
#confirmModal .modal-content {
    max-width: 420px;
    text-align: center;
}

#confirmModal .confirm-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    display: block;
}

#confirmModal .confirm-title {
    font-size: var(--font-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

#confirmModal .confirm-msg {
    color: var(--gray-dark);
    margin-bottom: var(--spacing-xl);
    font-size: var(--font-sm);
}

#confirmModal .confirm-subject {
    font-weight: 700;
    color: #000;
}

#confirmModal .confirm-btns {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

/* ========== МОДАЛЬНЫЕ ОКНА ========== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active { display: flex; }

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row .form-group { flex: 1; margin-bottom: 0; }

@media (max-width: 600px) {
    .form-row { flex-direction: column; gap: 10px; }
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--spacing-xxl);
    width: 90%;
    max-width: 600px;
    max-height: 80%;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.modal-header h3 { margin: 0; }

.close-btn {
    background: none;
    border: none;
    font-size: var(--font-xxl);
    cursor: pointer;
    color: #999;
    transition: color var(--transition-fast);
}

.close-btn:hover { color: #333; }
.close-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-round); }

/* ========== НАСТРОЙКИ ========== */
.settings-table-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
}

.settings-card {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.settings-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.settings-card h3 {
    margin: 0 0 var(--spacing-sm) 0;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--gray-lighter);
    font-size: var(--font-md);
}

.compact-table { width: 100%; border-collapse: collapse; }
.compact-table td { padding: var(--spacing-xs) 0; border-bottom: 1px solid var(--gray-lighter); }
.compact-table td:first-child { width: 42%; color: var(--gray-dark); }
.compact-table tr:last-child td { border-bottom: none; }
.compact-table .subtitle td { padding-top: var(--spacing-sm); padding-bottom: var(--spacing-xs); color: #444; background: #fafafa; }

.compact-table input[type="text"],
.compact-table input[type="number"],
.compact-table textarea,
.compact-table select {
    font-size: var(--font-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.compact-table input[type="checkbox"] { width: 0.875rem; height: 0.875rem; margin: 0; cursor: pointer; }
.compact-table textarea { resize: vertical; min-height: 2.5rem; }
.compact-table input:focus-visible,
.compact-table textarea:focus-visible,
.compact-table select:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

@media (max-width: 62.5rem) {
    .settings-table-compact { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 37.5rem) {
    .settings-table-compact { grid-template-columns: 1fr; }
}
@media (min-width: 100rem) {
    .settings-table-compact { grid-template-columns: repeat(4, 1fr); }
}

/* ========== КНОПКИ ========== */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--font-sm);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-sm);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-sm:hover { transform: translateY(-1px); }
.btn-sm:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary  { background: var(--primary);   color: white; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success);   color: white; }
.btn-success:hover  { background: var(--success-dark); }
.btn-danger   { background: var(--danger);    color: white; }
.btn-danger:hover   { background: var(--danger-dark); }
.btn-warning  { background: var(--warning);   color: white; }
.btn-warning:hover  { background: var(--warning-dark); }
.btn-secondary{ background: var(--secondary); color: white; }
.btn-secondary:hover{ background: var(--secondary-dark); }
.btn-info     { background: var(--info);      color: white; }
.btn-info:hover     { background: var(--info-dark); }

/* ========== ФОРМЫ ========== */
.form-group { margin-bottom: var(--spacing-md); }
.form-group label { display: block; margin-bottom: var(--spacing-xs); font-weight: 500; color: var(--gray-dark); }
.form-group label input[type="checkbox"] { display: inline; width: auto; margin-right: var(--spacing-sm); }

.form-control {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    transition: border-color var(--transition-fast);
}

.form-control:focus { outline: none; border-color: var(--primary); }
.form-control:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea.form-control { resize: vertical; }

/* ========== СТАТИСТИКА ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xxl);
}

.stat-card {
    background: linear-gradient(135deg, var(--stat-gradient-start) 0%, var(--stat-gradient-end) 100%);
    color: white;
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    text-align: center;
}

.stat-value { font-size: var(--font-xxxl); }
.stat-label { font-size: var(--font-sm); margin-top: var(--spacing-xs); opacity: 0.9; }

/* ========== ЛОГИ ========== */
.logs-container {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    font-family: 'Courier New', Consolas, monospace;
    font-size: var(--font-xs);
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
    margin: 0;
}

/* ========== ФОТО МАСТЕРА ========== */
.photo-item {
    position: relative;
    width: 5rem;
    height: 5rem;
}

.photo-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

.photo-item button {
    position: absolute;
    top: -5px; right: -5px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-round);
    width: 1.25rem; height: 1.25rem;
    cursor: pointer;
    font-size: var(--font-xs);
    transition: background var(--transition-fast);
}

.photo-item button:hover { background: var(--danger-dark); }

#current_photos_container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

/* ========== ПРОЧЕЕ ========== */
.config-section {
    background: var(--gray-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.config-section h3 { margin-bottom: var(--spacing-md); color: #333; }

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.search-bar {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}
.search-bar .form-control { flex: 1; }

.data-table a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
.data-table a:hover { color: var(--header-gradient-end); text-decoration: underline; }

/* status-bar оставляем для обратной совместимости, но он больше не используется */
.status-bar { display: none !important; }

/* ── Тулбар над таблицей ─────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border-light);
    background: var(--gray-light);
    gap: 8px;
    flex-wrap: wrap;
}
 
.toolbar-title {
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--gray-dark);
}
 
.toolbar-right {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
 
/* Таблетки-фильтры */
.pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--radius-circle);
    font-size: var(--font-xs);
    font-weight: 500;
    border: 1px solid var(--border);
    background: white;
    color: var(--gray);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
 
.pill-btn:hover {
    background: var(--gray-lighter);
    color: var(--gray-dark);
}
 
.pill-btn.active {
    background: #EEEDFE;
    color: #534AB7;
    border-color: #AFA9EC;
}
 
/* Счётчик рядом с заголовком */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: var(--font-xs);
    font-weight: 500;
    background: var(--border-light);
    color: var(--gray);
}
 

/* Только ячейки с .inner-обёрткой теряют дефолтный padding — он внутри .inner */
.data-table td:has(.inner) {
    padding: 0;
}
 
.data-table td .inner {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    gap: 0;
    transition: background var(--transition-fast);
    min-height: 42px;
}
 
.data-table tr:hover td .inner {
    background: var(--gray-lighter);
}
 

 
/* ── Кнопки действий в таблице ───────────────────────────── */
.act-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: var(--radius-md);
    font-size: var(--font-xs);
    font-weight: 500;
    border: 1px solid var(--border);
    background: white;
    color: var(--gray-dark);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}
 
.act-btn:hover { background: var(--gray-lighter); }
 
.act-btn.act-primary { color: #3C3489; border-color: #AFA9EC; }
.act-btn.act-primary:hover { background: #EEEDFE; }
 
.act-btn.act-danger { color: #791F1F; border-color: #F7C1C1; }
.act-btn.act-danger:hover { background: #FCEBEB; }
 
/* ── Временная шкала ─────────────────────────────────────── */
.tl-section { padding: 16px; }
 
.tl-master-block {
    margin-bottom: 20px;
}
 
.tl-master-block:last-child { margin-bottom: 0; }
 
.tl-master-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}
 
.tl-master-name {
    font-size: var(--font-sm);
    font-weight: 500;
    color: #000;
}
 
.tl-master-sub {
    font-size: var(--font-xs);
    color: var(--gray);
}
 
/* Строка с подписями часов */
.tl-tick-row {
    display: flex;
    margin-bottom: 3px;
}
 
.tl-tick {
    flex: 1;
    font-size: 10px;
    color: var(--gray);
    text-align: left;
}
 
.tl-tick:last-child { text-align: right; }
 
/* Сам бар */
.tl-bar {
    position: relative;
    height: 34px;
    background: var(--gray-lighter);
    border-radius: var(--radius-md);
    overflow: visible;
}
 
/* Слоты */
.tl-slot {
    position: absolute;
    top: 4px;
    height: 26px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    cursor: default;
    transition: filter var(--transition-fast);
    z-index: 1;
}
 
.tl-slot:hover { filter: brightness(.93); z-index: 3; }
 
.tl-booked    { background: #E1F5EE; color: #085041; border: 0.5px solid #9FE1CB; }
.tl-cancelled { background: #FCEBEB; color: #791F1F; border: 0.5px solid #F7C1C1; }
.tl-free {
    background: none;
    border: 0.5px dashed var(--border);
    color: var(--gray);
}
 
/* Линия «сейчас» */
.tl-now-line {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 1.5px;
    background: #E24B4A;
    z-index: 4;
    pointer-events: none;
}
 
.tl-now-pip {
    position: absolute;
    top: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #E24B4A;
    transform: translateX(-3px);
}
 
.tl-now-label {
    position: absolute;
    top: -20px;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 500;
    color: #791F1F;
    background: #FCEBEB;
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
 
/* Тултип при наведении */
.tl-tip {
    position: absolute;
    bottom: 38px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 7px 10px;
    font-size: var(--font-xs);
    color: #000;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    display: none;
    box-shadow: var(--shadow-md);
}
 
.tl-tip.visible { display: block; }
 
.tl-tip-name { font-weight: 500; margin-bottom: 2px; color: #000; }
.tl-tip-status { font-size: 10px; font-weight: 500; margin-top: 3px; }
 
/* Легенда шкалы */
.tl-legend {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    flex-wrap: wrap;
}
 
.tl-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--font-xs);
    color: var(--gray);
}
 
.tl-legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
 
.tl-legend-line {
    width: 16px;
    height: 1.5px;
    background: #E24B4A;
    border-radius: 1px;
    flex-shrink: 0;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 48rem) {
    .container { padding: var(--spacing-sm); }
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn { white-space: nowrap; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .bot-controls { width: 100%; justify-content: center; }
    #toast-container { right: 0.5rem; bottom: 0.5rem; min-width: 0; max-width: calc(100vw - 1rem); }
    .toast { min-width: 0; max-width: 100%; }
}

/* ========== ЛОГИ — цветной вывод ========== */
#logsContent {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    max-height: 65vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

#logsContent span[style*="display:block"] {
    padding: 1px 4px;
    margin: 0 -4px;
    border-radius: 2px;
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .skeleton-cell { animation: none; background: var(--skeleton-base); }
    .btn:hover, .btn-sm:hover, .settings-card:hover, .tab-btn:hover { transform: none; }
}
/* ========== КНОПКА ВЫХОДА В ШАПКЕ ========== */
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-circle);
    background: rgba(244,67,54,0.18);
    color: white;
    font-size: var(--font-sm);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast);
    border: 1px solid rgba(255,255,255,0.25);
}
.btn-logout:hover { background: rgba(244,67,54,0.38); }

/* ========== КАРТОЧКА ПОДПИСКИ ========== */
.sub-card {
    max-width: 640px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
}

.sub-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.sub-status {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 3px 12px;
    border-radius: var(--radius-xxl);
    font-size: var(--font-sm);
    font-weight: 600;
}
.sub-status-active    { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.sub-status-expired   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.sub-status-cancelled { background: #fafafa; color: #555;    border: 1px solid #ccc; }
.sub-status-trial     { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }

.sub-tariff-badge {
    padding: 0.4rem 1rem;
    border-radius: var(--radius-circle);
    background: linear-gradient(135deg, var(--stat-gradient-start), var(--stat-gradient-end));
    color: white;
    font-size: var(--font-sm);
    font-weight: 600;
    white-space: nowrap;
}

.sub-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gray-lighter);
    border-radius: var(--radius-lg);
}

.sub-info-label {
    font-size: var(--font-xs);
    color: var(--gray);
    margin-bottom: 0.2rem;
}
.sub-info-value {
    font-size: var(--font-md);
    font-weight: 600;
    color: #000;
}

.sub-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
/* ═══════════════════════════════════════════════════════
   СТАТИСТИКА — тулбар выбора периода
═══════════════════════════════════════════════════════ */
.stats-toolbar { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }

.stats-period-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.period-pill {
    padding: 6px 16px;
    border-radius: var(--radius-circle);
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--gray-dark);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
}
.period-pill:hover { border-color: var(--primary); color: var(--primary); background: rgba(102,126,234,0.06); }
.period-pill--active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(102,126,234,0.35); }
.period-pill--active:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.period-pill--custom { margin-left: 4px; border-style: dashed; }

.stats-custom-range { max-height: 0; overflow: hidden; transition: max-height 0.28s ease, opacity 0.22s ease; opacity: 0; }
.stats-custom-range.open { max-height: 80px; opacity: 1; }

.custom-range-inner {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: #fff; border: 1.5px solid var(--border);
    border-radius: var(--radius-lg); padding: 10px 14px; box-shadow: var(--shadow-sm);
}
.custom-range-label { font-size: var(--font-sm); color: var(--gray); font-weight: 500; }
.stats-date-input { width: auto !important; min-width: 140px; font-size: var(--font-sm) !important; }

/* ═══════════════════════════════════════════════════════
   СТАТИСТИКА — дашборд с графиками
═══════════════════════════════════════════════════════ */
.stats-dashboard { display: flex; flex-direction: column; gap: 20px; }
.stats-period-label { text-align: center; color: var(--gray); font-size: var(--font-sm); }

.stats-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }

.stat-kpi-card {
    background: #fff; border-radius: var(--radius-xl); padding: 18px 14px 14px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.stat-kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-kpi-icon {
    width: 42px; height: 42px; border-radius: var(--radius-circle);
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-kpi-value { font-size: var(--font-xxl); font-weight: 700; line-height: 1; }
.stat-kpi-label { font-size: var(--font-xs); color: var(--gray); text-align: center; }

.stats-charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }

.stats-chart-card {
    background: #fff; border-radius: var(--radius-xl); padding: 18px 18px 14px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
}
.stats-chart-card--wide { grid-column: span 2; }
.stats-chart-title { font-size: var(--font-sm); font-weight: 600; margin-bottom: 14px; color: #333; }
.stats-chart-wrap { width: 100%; }

.stats-donut-legend { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.sdl-item { display: flex; align-items: center; gap: 5px; font-size: var(--font-xs); color: var(--gray-dark); }
.sdl-dot { width: 10px; height: 10px; border-radius: var(--radius-round); flex-shrink: 0; }

@media (max-width: 700px) {
    .stats-charts-row { grid-template-columns: 1fr; }
    .stats-chart-card--wide { grid-column: span 1; }
    .stats-kpi-row { grid-template-columns: repeat(2, 1fr); }
}


.stats-masters-pie-wrap {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}

/* Легенда */
.stats-masters-legend {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sml-item {
    display: grid;
    grid-template-columns: 12px 1fr auto auto;
    align-items: center;
    gap: 8px;
    font-size: var(--font-sm);
}

.sml-dot {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-round);
    flex-shrink: 0;
}

.sml-name {
    color: var(--gray-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sml-count {
    font-weight: 700;
    color: #333;
    text-align: right;
    white-space: nowrap;
}

.sml-pct {
    color: var(--gray);
    font-size: var(--font-xs);
    text-align: right;
    min-width: 36px;
}

@media (max-width: 560px) {
    .stats-masters-pie-wrap { flex-direction: column; align-items: center; }
    .stats-masters-pie-wrap .stats-chart-wrap { width: 200px !important; height: 200px !important; }
}
/* ── Нижний ряд диаграмм (мастера + лояльность) ── */
.stats-charts-row-bottom {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0;
}

/* Карточка лояльности */
.stats-loyalty-card {
    flex: 1;
    min-width: 280px;
}
.stats-loyalty-wrap {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.5rem 0;
}
.stats-loyalty-legend {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}
.sml-item--total {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
    font-weight: 600;
}