:root {
    --bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent: #38bdf8;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #facc15;
    --dod: #ffd700; /* Золотой для ДОД */
}

/* --- БАЗА И ОБНУЛЕНИЕ --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(30, 41, 59, 0.4) 0px, transparent 50%);
    color: var(--text);
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    padding: 20px;
}

.container { max-width: 1100px; margin: 0 auto; }

/* Стеклянные карточки */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

/* --- ОПЕРАТИВНАЯ СВОДКА (Summary) --- */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 2.5fr;
    gap: 30px;
    align-items: start;
}

.duty-column {
    border-right: 1px solid var(--border);
    padding-right: 20px;
}

.summary-section-title {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    display: block;
}

.presence-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.presence-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    position: relative; /* Для метки 0.5 */
}

.presence-item:hover { background: rgba(255, 255, 255, 0.07); }

/* Метка 0.5 в сводке */
.presence-item[data-contract="0.5"] {
    border-left: 3px solid var(--warning);
}

/* Состояния в сводке */
.presence-item.is-online { border-color: rgba(34, 197, 94, 0.3); }

.presence-item.is-late {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
}

.presence-item.is-late .presence-time {
    color: var(--danger);
    font-weight: 900;
}

.status-dot { font-size: 0.8rem; margin-right: 8px; }
.presence-name { font-size: 0.85rem; font-weight: 500; display: flex; align-items: center; }
.presence-time { font-size: 0.75rem; color: var(--accent); font-family: 'Courier New', monospace; font-weight: bold; }

/* --- КАЛЕНДАРЬ --- */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-grid { 
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 10px; 
}

.weekdays-bar { margin-bottom: 10px; opacity: 0.7; }
.weekday-label { text-align: center; font-size: 0.75rem; font-weight: bold; color: var(--muted); text-transform: uppercase; }
.weekday-label.weekend { color: var(--danger); }

.calendar-day { 
    min-height: 110px; 
    padding: 12px; 
    position: relative; 
    transition: all 0.2s ease; 
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
}

.calendar-day:not(.day-disabled):hover { 
    transform: translateY(-3px); 
    border-color: var(--accent) !important; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.4); 
    cursor: pointer;
}

.day-disabled { opacity: 0.25; pointer-events: none; background: rgba(0,0,0,0.2); }
.empty-cell { background: transparent; border: none; }
.day-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.day-number { font-weight: bold; font-size: 0.9rem; }
.text-danger { color: var(--danger) !important; }

.is-dod { 
    border: 2px solid var(--dod) !important; 
    background: rgba(255, 215, 0, 0.05) !important; 
}
.dod-badge { 
    font-size: 0.6rem; 
    background: var(--dod); 
    color: #000; 
    padding: 2px 5px; 
    border-radius: 4px; 
    font-weight: 800; 
}

/* --- ИНТЕРФЕЙС И КНОПКИ --- */
.user-badge { 
    font-size: 0.75rem; 
    padding: 4px 8px; 
    background: rgba(255, 255, 255, 0.05); 
    border-radius: 6px; 
    margin-top: 4px; 
    border-left: 3px solid var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}
.user-badge.spec { border-left-color: #ff00ff; }
.user-badge.tech { border-left-color: #00ffff; }
.user-badge.admin { border-left-color: var(--accent); }

.btn-ui {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-ui:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-ui:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-presence {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 8px 18px;
    font-weight: 800;
    animation: pulse-notify 2s infinite ease-in-out;
}

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content { 
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--accent);
    animation: modal-slide-up 0.3s ease-out;
}

.modal-select { 
    width: 100%; padding: 10px; margin: 8px 0;  
    background: var(--bg); color: white; border: 1px solid var(--border);  
    border-radius: 8px;
    color-scheme: dark;
}

@keyframes modal-slide-up {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- ПЛАНИРОВЩИК (НОВОЕ) --- */
.weekly-row {
    transition: all 0.3s ease;
}

.sch-input {
    text-align: center;
}

/* --- СЧЕТЧИК СЕРИИ --- */
.streak-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; margin-bottom: 20px; background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(255, 230, 0, 0.1)); border: 1px solid rgba(255, 230, 0, 0.2); }
.streak-value { font-size: 3rem; font-weight: 900; line-height: 1; background: linear-gradient(to bottom, #fff, var(--warning)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 5px; filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.5)); }
.streak-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; }
.streak-fire { font-size: 1.5rem; margin-bottom: 10px; }

/* --- ПРОФИЛЬ И АВАТАРКИ --- */
.work-time-display { font-size: 1.3rem; font-weight: bold; color: var(--accent); margin: 5px 0; }
.profile-info-block { border-top: 1px solid var(--border); padding: 15px 0; text-align: center; }

.avatar-container { position: relative; width: 100px; height: 100px; margin: 0 auto 15px; }
.avatar-img, .avatar-placeholder { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); box-shadow: 0 0 15px rgba(56, 189, 248, 0.3); }
.avatar-placeholder { background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; font-weight: bold; }
.avatar-edit-label { position: absolute; bottom: 0; right: 0; background: var(--bg); border: 1px solid var(--accent); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 0.9rem; transition: transform 0.2s; }
.avatar-edit-label:hover { transform: scale(1.1); background: var(--accent); }

/* --- АДАПТИВНОСТЬ --- */
@media (max-width: 768px) {
    .summary-grid { grid-template-columns: 1fr; }
    .duty-column { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
    .calendar-grid { gap: 5px; }
}

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ --- */
@media (max-width: 768px) {
    /* 1. Навигация */
    header.glass-card {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        text-align: center;
    }
    .header-nav nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    .btn-ui {
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    /* 2. Сетка профиля и страниц */
    .main-grid {
        grid-template-columns: 1fr !important; /* Столбцы встают друг под друга */
    }

    /* 3. Магия трансформации таблиц */
    .discipline-table thead, .tickets-table thead {
        display: none; /* Скрываем заголовки таблиц */
    }

    .discipline-table tr, .tickets-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        padding: 10px;
        background: rgba(255, 255, 255, 0.02);
    }

    .discipline-table td, .tickets-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none !important;
        padding: 8px 5px !important;
        text-align: right;
    }

    /* Добавляем подписи к данным через псевдоэлементы */
    .discipline-table td::before, .tickets-table td::before {
        content: attr(data-label); /* Берет текст из атрибута data-label */
        font-weight: bold;
        color: var(--accent);
        text-align: left;
        font-size: 0.8rem;
    }

    .time-val {
        font-size: 1.1rem;
    }
    
    .status-tag {
        margin-left: auto;
    }
}

/* --- ГЛАВНАЯ ШАПКА (Универсал) --- */
.main-header {
    display: flex;
    flex-direction: column; /* Всегда два ряда: топ и навигация */
    padding: 12px 16px;
    gap: 12px;
    margin-bottom: 25px;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-right-zone {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-quick-nav {
    display: flex;
    align-items: center; /* Выравнивает 👤 и 🚪 строго в ряд */
    gap: 12px;
}

.icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem; /* Размер под палец */
    line-height: 1;
}

.logout-icon {
    margin-left: 5px; /* Небольшой отступ от профиля */
}
.nav-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
	padding-top: 5px;

}

.nav-scroll::-webkit-scrollbar { display: none; }

.nav-scroll .btn-ui { white-space: nowrap; } /* Кнопки не ломаются */

/* Контейнер-якорь для кнопок/ссылок с уведомлениями */
.nav-badge-wrapper {
    position: relative; /* Обязательно! */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Красный кружок (Заявки, Профиль и т.д.) */
.notif-badge {
    position: absolute;
    top: -5px;      /* Смещение вверх от иконки */
    right: -5px;    /* Смещение вправо от иконки */
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    min-width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg); /* Отделяем от основного цвета, чтобы не сливалось */
    z-index: 10;
    pointer-events: none; /* Чтобы клик проходил сквозь бейдж на кнопку */
    line-height: 1;
}

/* Специфический цвет для заявок (желтый/оранжевый), если нужно */
.warning-badge {
    background: var(--warning);
    color: #000;
}

/* --- АДАПТАЦИЯ ШАПКИ --- */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    
    .main-header { padding: 10px !important; }

    .nav-scroll {
        width: calc(100% + 20px);
        margin-left: -10px;
        padding: 5px 10px;
    }

    .btn-ui { padding: 8px 12px; font-size: 0.9rem; }
}

/* --- АДАПТАЦИЯ КАЛЕНДАРЯ --- */
@media (max-width: 768px) {
    /* Скрываем Пн, Вт... на мобилках */
    .weekdays-bar { display: none; }

    .main-calendar {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* Скрываем пустые клетки другого месяца */
    .empty-cell { display: none; }

    .calendar-day {
        min-height: auto !important;
        flex-direction: row !important; /* Число слева, люди справа */
        align-items: center;
        padding: 12px 16px !important;
        gap: 15px;
    }

    .day-top {
        margin-bottom: 0 !important;
        min-width: 45px;
        flex-direction: column;
        align-items: center;
        border-right: 1px solid var(--border);
        padding-right: 12px;
    }

    .day-number { font-size: 1.3rem; }

    .day-content {
        flex: 1;
    }

    .shift-list {
        display: flex;
        flex-wrap: wrap; /* Бейджи встают в ряд и переносятся */
        gap: 6px;
    }

    .user-badge {
        margin-top: 0 !important;
        padding: 5px 10px !important;
        font-size: 0.8rem !important;
    }

    /* Подсветка сегодня */
    .is-today {
        border-left: 4px solid var(--accent) !important;
        background: rgba(56, 189, 248, 0.05);
    }
}

/* Бейджи должностей в чате */
.user-badge.admin {
    background: rgba(231, 76, 60, 0.2) !important; /* Красный оттенок для Заведующего */
    color: #e74c3c !important;
    border: 1px solid rgba(231, 76, 60, 0.4);
}

.user-badge.spec {
    background: rgba(46, 204, 113, 0.2) !important; /* Зеленый для Специалистов */
    color: #2ecc71 !important;
    border: 1px solid rgba(46, 204, 113, 0.4);
}

.user-badge.tech {
    background: rgba(241, 196, 15, 0.15) !important; /* Желтый/Золотой для Техников */
    color: #f1c40f !important;
    border: 1px solid rgba(241, 196, 15, 0.3);
}

/* --- СТИЛИ ДЛЯ СТРАНИЦЫ АВТОРИЗАЦИИ (LOGIN) --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 35px 30px;
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-field-group {
    margin-bottom: 20px;
}

.login-field-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
}

.input-control {
    width: 100%;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
    color-scheme: dark;
}

.input-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
    background: rgba(15, 23, 42, 0.8);
}

.input-control:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #fca5a5;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: center;
}

.alert-info {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid var(--accent);
    color: #7dd3fc;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: center;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.remember-group {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 20px;
    user-select: none;
}

.remember-group input[type="checkbox"] {
    accent-color: var(--accent);
    width: 17px;
    height: 17px;
    cursor: pointer;
}

/* --- ЛОГОТИП (SVG + Gradient) --- */
.header-logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.header-logo-link:hover {
    opacity: 0.85;
}

.header-logo-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.header-logo-text {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

/* Логотип для страницы авторизации (чуть крупнее) */
.login-logo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 6px;
}

.login-logo-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4));
}

/* --- Выравнивание верхнего блока шапки --- */
.header-top-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 12px;
}

/* Ссылка логотипа */
.header-logo-link,
.header-logo-link:visited {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
    color: inherit !important;
}

.header-logo-link:hover {
    opacity: 0.85;
}

/* Иконка SVG */
.header-logo-icon {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0 !important;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

/* Текст логотипа (сброс фиолетового цвета ссылок) */
.header-logo-text {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    letter-spacing: 1px !important;
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}