/* ====================================
   АСТРЕЯ - Кадровый сервис и аутсорсинг
   Современный дизайн с классическими элементами
   ==================================== */

:root {
    --primary-color: #246c6f;
    --primary-dark: #1a4f52;
    --primary-light: #3d8a8d;
    --secondary-color: #f5f4f4;
    --text-color: #202020;
    --text-light: #666666;
    --border-color: #b5c7c8;
    --shadow: 0 4px 12px rgba(36, 108, 111, 0.1);
    --shadow-hover: 0 12px 32px rgba(36, 108, 111, 0.18);
    --shadow-card: 0 6px 20px rgba(36, 108, 111, 0.12);
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --border-radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f4f4 0%, #e8f0ed 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    letter-spacing: 0.3px;
}

/* ====== NAVBAR ====== */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 2px solid var(--primary-color);
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-transform: uppercase;
}

.navbar-brand::before {
    content: '';
    display: inline-block;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background-color: white;
    background-image: url('/images/Astreya.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 0 0 1px rgba(36, 108, 111, 0.1);
}

.navbar-menu {
    display: flex;
    gap: 48px;
    align-items: center;
}

.navbar-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.navbar-menu a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.navbar-menu a:hover {
    color: var(--primary-color);
}

.navbar-menu a:hover::after {
    width: 100%;
}

.logout-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--border-radius-sm);
}

.logout-btn:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

/* ====== MAIN CONTAINER ====== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 40px;
}

/* ====== HERO/HEADER SECTION ====== */
.page-header {
    margin-bottom: 60px;
    padding: 0;
    border: none;
    background: none;
}

.page-header h1 {
    font-size: 42px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary-color);
    letter-spacing: -1px;
}

.page-header p {
    font-size: 16px;
    color: var(--text-light);
    margin: 0;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* ====== CARDS & SECTIONS ====== */
.card {
    background: white;
    margin-bottom: 32px;
    overflow: hidden;
    transition: var(--transition);
    border-radius: var(--border-radius);
    border: 1px solid rgba(36, 108, 111, 0.1);
    box-shadow: var(--shadow-card);
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

.card-header {
    padding: 32px 40px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(36, 108, 111, 0.03) 0%, rgba(36, 108, 111, 0.05) 100%);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 0.5px;
}

.card-body {
    padding: 32px 40px;
}

/* ====== FORMS ====== */
.form-group {
    margin-bottom: 28px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

input,
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    font-family: inherit;
    background: white;
    color: var(--text-color);
    letter-spacing: 0.3px;
    border-radius: var(--border-radius-sm);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(36, 108, 111, 0.1);
}

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--border-radius-sm);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.btn-danger {
    background: #c44444;
    color: white;
    border: 1px solid #c44444;
}

.btn-danger:hover {
    background: #a83333;
    border-color: #a83333;
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
    margin-top: 8px;
}

/* ====== TABLES ====== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    background: linear-gradient(135deg, rgba(36, 108, 111, 0.08) 0%, rgba(36, 108, 111, 0.12) 100%);
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: rgba(36, 108, 111, 0.05);
}

/* ====== STATISTICS ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
    margin-bottom: 60px;
}

.stat-card {
    background: white;
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(36, 108, 111, 0.1);
    transition: var(--transition);
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-8px);
}

.stat-icon {
    font-size: 40px;
    margin-bottom: 20px;
    opacity: 0.7;
}

.stat-value {
    font-size: 36px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    line-height: 1;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ====== ALERTS & MESSAGES ====== */
.alert {
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
    background: var(--secondary-color);
    border-radius: var(--border-radius-sm);
}

.alert-error {
    background: rgba(196, 68, 68, 0.08);
    border-color: rgba(196, 68, 68, 0.2);
    color: #8b3333;
}

.alert-success {
    background: rgba(36, 108, 111, 0.08);
    border-color: rgba(36, 108, 111, 0.2);
    color: #1a4f52;
}

/* ====== FORM GRID ====== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 32px;
}

/* ====== EMPTY STATE ====== */
.empty-state {
    text-align: center;
    padding: 80px 40px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-color);
    margin-bottom: 8px;
    font-weight: 600;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .container {
        padding: 40px 24px;
    }

    .navbar-container {
        padding: 16px 24px;
        flex-direction: column;
        gap: 16px;
    }

    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 24px;
    }

    .page-header {
        margin-bottom: 40px;
    }

    .page-header h1 {
        font-size: 32px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .card-header,
    .card-body {
        padding: 24px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .btn {
        padding: 12px 24px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .navbar-brand {
        font-size: 16px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .stat-value {
        font-size: 28px;
    }

    .card-header h2 {
        font-size: 16px;
    }
}

/* ════════════════════════════════════════════════
   SIDEBAR APP LAYOUT
   Используется на страницах Admin и Manager
   ════════════════════════════════════════════════ */

.app-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

/* ── Сайдбар ── */
.sidebar {
    background: linear-gradient(180deg, #0d2325 0%, #152e30 60%, #0d2325 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
}

.sidebar-logo {
    padding: 26px 20px 22px;
    font-size: 14px;
    font-weight: 800;
    color: white;
    letter-spacing: 3px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo .logo-icon {
    width: 24px;
    height: 24px;
    padding: 3px;
    border-radius: 6px;
    background: white;
    object-fit: contain;
    box-sizing: border-box;
    flex-shrink: 0;
}

.sidebar-badge {
    margin: 14px 16px 4px;
    padding: 7px 12px;
    background: rgba(36,108,111,.2);
    border: 1px solid rgba(36,108,111,.35);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,.6);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    text-align: center;
}

.sidebar-section-label {
    padding: 18px 20px 5px;
    font-size: 9.5px;
    font-weight: 700;
    color: rgba(255,255,255,.25);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 20px;
    color: rgba(255,255,255,.5);
    cursor: pointer;
    transition: all .15s ease;
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    user-select: none;
}
.sidebar-item .item-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.8); }
.sidebar-item.active {
    background: rgba(36,108,111,.22);
    color: white;
    border-left-color: #3d8a8d;
    font-weight: 600;
}

/* ── Группы ролей (сворачиваемые) ── */
.sidebar-group { display: flex; flex-direction: column; }
.sidebar-role { justify-content: space-between; }
.sidebar-role-label { flex: 1; }
.sidebar-role-arrow {
    font-size: 10px;
    opacity: .4;
    transition: transform .2s ease;
    flex-shrink: 0;
}
.sidebar-group.open .sidebar-role-arrow { transform: rotate(90deg); }

.sidebar-subnav {
    max-height: 0;
    overflow: hidden;
    transition: max-height .2s ease;
}
.sidebar-group.open .sidebar-subnav { max-height: 600px; }
.sidebar-subnav .sidebar-item { padding-left: 40px; font-size: 12px; }
.sidebar-item-contractor { padding-left: 40px !important; font-size: 12px; }
.sidebar-subnav .sidebar-item-contractor { padding-left: 56px !important; }
.sidebar-item-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ── Аватары ── */
.avatar-circle {
    border-radius: 50%;
    background: rgba(36,108,111,.12); color: #246c6f;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0; overflow: hidden;
    text-transform: uppercase;
}
.avatar-circle img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 38px; height: 38px; font-size: 15px; }
.avatar-lg { width: 96px; height: 96px; font-size: 36px; }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-avatar { margin-bottom: 10px; }
.sidebar-avatar .avatar-circle {
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
    border: 1px solid rgba(255,255,255,.12);
}
.sidebar-user-name {
    font-size: 12px; font-weight: 600; color: rgba(255,255,255,.75);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 2px;
}
.sidebar-user-role {
    font-size: 10px; color: rgba(255,255,255,.3);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px;
}
.sidebar-logout {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.55);
    border-radius: 8px; text-decoration: none;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    transition: all .2s;
}
.sidebar-logout:hover { background: rgba(196,68,68,.3); color: white; }

/* ── Основная область ── */
.main-content {
    background: #f0f4f5;
    overflow-y: auto;
    min-height: 100vh;
}

/* ── Панели (section) ── */
.panel { display: none; padding: 36px 44px 64px; animation: panelIn .18s ease; }
.panel.active { display: block; }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
    margin-bottom: 28px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.panel-title { font-size: 24px; font-weight: 700; color: #0d2325; letter-spacing: -.5px; margin-bottom: 3px; }
.panel-subtitle { font-size: 13px; color: #8fa6a8; }

/* ── Обзорные карточки ── */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.ov-card {
    background: white; border-radius: 14px; padding: 22px 20px;
    border: 1px solid #dce8ea; box-shadow: 0 2px 8px rgba(14,35,37,.04);
    display: flex; align-items: center; gap: 16px;
}
.ov-icon {
    width: 48px; height: 48px; border-radius: 13px;
    background: rgba(36,108,111,.09);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.ov-value { font-size: 26px; font-weight: 700; color: #0d2325; line-height: 1; margin-bottom: 3px; }
.ov-label { font-size: 11px; color: #8fa6a8; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ── Белая карточка в панели ── */
.c-card {
    background: white;
    border-radius: 14px;
    border: 1px solid #dce8ea;
    box-shadow: 0 2px 8px rgba(14,35,37,.04);
    overflow: hidden;
    margin-bottom: 20px;
}
.c-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid #edf3f4;
    display: flex; align-items: center; gap: 8px;
}
.c-card-header h3 { font-size: 14px; font-weight: 700; color: #0d2325; margin: 0; }
.c-card-body { padding: 22px 24px; }

/* ── Split layout ── */
.split-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

/* ── 3-column grid ── */
.tri-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

/* ── Компактные формы внутри панелей ── */
.panel .form-group { margin-bottom: 16px; }
.panel label { font-size: 11px; margin-bottom: 7px; }
.panel input, .panel select, .panel textarea {
    padding: 10px 13px; font-size: 13px;
    border-radius: 8px; border-color: #cddcde;
}

/* ── Inline tabs ── */
.inline-tabs {
    display: flex; gap: 3px;
    background: #edf3f4; padding: 4px;
    border-radius: 10px; margin-bottom: 22px;
}
.inline-tab {
    flex: 1; padding: 9px; text-align: center;
    font-size: 11px; font-weight: 700; color: #8fa6a8;
    cursor: pointer; border-radius: 7px; transition: all .15s;
    text-transform: uppercase; letter-spacing: .3px; user-select: none;
}
.inline-tab:hover { color: #246c6f; background: white; }
.inline-tab.active { background: white; color: #246c6f; box-shadow: 0 2px 6px rgba(14,35,37,.07); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Бейдж роли в таблице ── */
.role-badge {
    display: inline-block; padding: 3px 9px;
    font-size: 10px; font-weight: 700; border-radius: 6px;
    text-transform: uppercase; letter-spacing: .4px;
}
.role-admin  { background: rgba(36,108,111,.12); color: #1a4f52; border: 1px solid rgba(36,108,111,.2); }
.role-manager { background: rgba(59,130,246,.1);  color: #1d4ed8; border: 1px solid rgba(59,130,246,.2); }
.role-user   { background: rgba(181,199,200,.2);  color: #5a7a7c; border: 1px solid #cddcde; }
.role-blacklist { background: rgba(196,68,68,.12); color: #8b3333; border: 1px solid rgba(196,68,68,.35); font-weight: 800; }
.role-success { background: rgba(34,140,90,.1); color: #1d6b46; border: 1px solid rgba(34,140,90,.22); }
.role-fine { background: rgba(217,119,6,.1); color: #92400e; border: 1px solid rgba(217,119,6,.25); }

/* ── Ссылка-кнопка (Settings) ── */
.link-btn {
    font-size: 11px; font-weight: 700; color: #246c6f; text-decoration: none;
    padding: 4px 10px; border: 1px solid rgba(36,108,111,.3);
    border-radius: 6px; transition: all .15s; white-space: nowrap;
}
.link-btn:hover { background: #246c6f; color: white; }

/* ── Мобильный toggle ── */
.sidebar-toggle {
    display: none;
    position: fixed; top: 14px; left: 14px; z-index: 999;
    background: #152e30; color: white; border: none; border-radius: 8px;
    width: 40px; height: 40px; font-size: 20px; cursor: pointer;
    align-items: center; justify-content: center;
}
@media (max-width: 1024px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: -220px; width: 220px;
        transition: left .22s ease;
    }
    .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
    .sidebar-toggle { display: flex; }
    .main-content { padding-top: 56px; }
    .panel { padding: 20px 18px 48px; }
    .split-layout { grid-template-columns: 1fr; }
    .tri-grid { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 900;
    background: rgba(13,35,37,.55);
    backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: white;
    border-radius: 18px;
    width: 100%; max-width: 500px;
    margin: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,.22);
    animation: modalIn .2s ease;
}
@keyframes modalIn {
    from { opacity:0; transform:scale(.96) translateY(8px); }
    to   { opacity:1; transform:scale(1)  translateY(0); }
}

.modal-header {
    position: sticky; top: 0; z-index: 1;
    background: white;
    display: flex; align-items: center; justify-content: space-between;
    padding: 22px 26px;
    border-bottom: 1px solid #edf3f4;
}
.modal-title { font-size: 16px; font-weight: 700; color: #0d2325; }
.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: #8fa6a8; padding: 4px 8px;
    border-radius: 6px; transition: all .15s;
}
.modal-close:hover { background: #edf3f4; color: #0d2325; }

.modal-body { padding: 24px 26px; }
.modal-footer {
    position: sticky; bottom: 0; z-index: 1;
    background: white;
    padding: 16px 26px;
    border-top: 1px solid #edf3f4;
    display: flex; gap: 10px; justify-content: flex-end;
}

/* Период: строка с датами */
.modal-body .form-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}

/* Превью расчёта */
.period-preview {
    margin-top: 18px; padding: 14px 16px;
    background: #edf8f8; border: 1px solid rgba(36,108,111,.18);
    border-radius: 10px; font-size: 13px; color: #246c6f; line-height: 1.5;
}

/* Чекбокс-строка */
.check-row {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; margin-bottom: 4px;
    font-size: 13px; color: #4a6a6c; font-weight: 500;
    text-transform: none; letter-spacing: 0;
}
.check-row input[type="checkbox"] {
    width: 18px; height: 18px; flex-shrink: 0;
    accent-color: #246c6f; cursor: pointer;
}

/* ════════════════════════════════════════════════
   ДОПОЛНИТЕЛЬНЫЕ КОМПОНЕНТЫ ПАНЕЛЕЙ
   ════════════════════════════════════════════════ */

/* Пилюля зарплаты */
.salary-pill {
    display: inline-block; padding: 4px 12px;
    background: rgba(36,108,111,.1); color: #1a4f52;
    border-radius: 20px; font-size: 12px; font-weight: 700;
    border: 1px solid rgba(36,108,111,.18);
}

/* Условия компании */
.conditions-list { display: flex; flex-direction: column; gap: 12px; }
.condition-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid #edf3f4;
}
.condition-row:last-child { border-bottom: none; }
.cond-label { font-size: 12px; font-weight: 600; color: #8fa6a8; text-transform: uppercase; letter-spacing: .5px; }
.cond-val   { font-size: 15px; font-weight: 700; color: #0d2325; }

/* Кнопки предупреждения и призрак */
.btn-warning {
    background: #d97706; color: white; border: 1px solid #d97706;
}
.btn-warning:hover { background: #b45309; border-color: #b45309; transform: translateY(-2px); }

.btn-ghost {
    background: white; color: #8fa6a8;
    border: 1px solid #cddcde;
}
.btn-ghost:hover { background: #edf3f4; color: #0d2325; }

/* ════════════════════════════════════════════════
   ЧАТ
   ════════════════════════════════════════════════ */

/* Бейдж непрочитанных в сайдбаре */
.chat-nav-badge {
    margin-left: auto;
    background: #c44444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Двухколоночный лейаут: контакты + переписка */
.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
    height: calc(100vh - 180px);
    min-height: 460px;
}

/* ── Список контактов ── */
.chat-contacts {
    background: white;
    border-radius: 14px;
    border: 1px solid #dce8ea;
    box-shadow: 0 2px 8px rgba(14,35,37,.04);
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #edf3f4;
    text-decoration: none;
    color: inherit;
    transition: background .15s;
}
.chat-contact-item:last-child { border-bottom: none; }
.chat-contact-item:hover { background: #f0f4f5; }
.chat-contact-item.active { background: rgba(36,108,111,.08); }

.chat-contact-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(36,108,111,.12); color: #246c6f;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; flex-shrink: 0;
    text-transform: uppercase; overflow: hidden;
}
.chat-contact-avatar img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name { font-size: 13px; font-weight: 700; color: #0d2325; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-role { font-size: 11px; color: #8fa6a8; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-preview { font-size: 12px; color: #5a7a7c; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-unread-badge {
    background: #246c6f; color: white;
    font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ── Окно переписки ── */
.chat-conversation {
    background: white;
    border-radius: 14px;
    border: 1px solid #dce8ea;
    box-shadow: 0 2px 8px rgba(14,35,37,.04);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-conversation-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-conversation-header {
    padding: 16px 22px;
    border-bottom: 1px solid #edf3f4;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    max-width: 60%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}
.chat-bubble-content { white-space: pre-wrap; }
.chat-bubble-time { font-size: 10px; opacity: .6; margin-top: 4px; text-align: right; }

.chat-bubble.theirs {
    align-self: flex-start;
    background: #edf3f4;
    color: #0d2325;
    border-bottom-left-radius: 4px;
}
.chat-bubble.mine {
    align-self: flex-end;
    background: #246c6f;
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-bubble.mine .chat-bubble-time { color: rgba(255,255,255,.75); }

.chat-input-row {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #edf3f4;
}
.chat-input-row input[type="text"] {
    flex: 1;
    margin: 0;
}
.chat-input-row .btn {
    margin: 0;
}

/* ══════════════════════════════════════════════════════════════
   ТЁМНАЯ ТЕМА
   Включается добавлением атрибута data-theme="dark" на <html>
   ══════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
    --primary-color: #3d9ea1;
    --primary-dark: #246c6f;
    --primary-light: #5bbbbe;
    --secondary-color: #1e2e30;
    --text-color: #e0ecec;
    --text-light: #8fa6a8;
    --border-color: #2e4446;
    --shadow: 0 4px 12px rgba(0,0,0,.4);
    --shadow-hover: 0 12px 32px rgba(0,0,0,.5);
    --shadow-card: 0 6px 20px rgba(0,0,0,.35);
}
[data-theme="dark"] body {
    background: linear-gradient(135deg, #0d1e20 0%, #0a1a1c 100%);
    color: var(--text-color);
}
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #091416 0%, #0d1e20 100%);
}
[data-theme="dark"] .main-content {
    background: #0f1f21 !important;
}
[data-theme="dark"] .c-card,
[data-theme="dark"] .cal-wrapper,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .period-card,
[data-theme="dark"] .company-field,
[data-theme="dark"] .portal-card {
    background: #142527 !important;
    border-color: rgba(61,158,161,.15) !important;
    color: var(--text-color);
}
[data-theme="dark"] .c-card-header { border-bottom-color: rgba(61,158,161,.12); }
[data-theme="dark"] table { color: var(--text-color); }
[data-theme="dark"] thead tr { background: rgba(61,158,161,.1); }
[data-theme="dark"] tbody tr:hover { background: rgba(61,158,161,.07); }
[data-theme="dark"] td, [data-theme="dark"] th { border-color: rgba(61,158,161,.1); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
    background: #1c3033;
    color: var(--text-color);
    border-color: rgba(61,158,161,.25);
}
[data-theme="dark"] input:focus, [data-theme="dark"] select:focus, [data-theme="dark"] textarea:focus {
    border-color: var(--primary-color);
}
[data-theme="dark"] .ov-card { background: rgba(61,158,161,.08) !important; }
[data-theme="dark"] .panel-header { border-bottom-color: rgba(61,158,161,.12); }
[data-theme="dark"] .alert-success { background: rgba(28,107,70,.25); border-color: rgba(40,167,69,.3); }
[data-theme="dark"] .alert-error { background: rgba(120,30,30,.25); border-color: rgba(196,68,68,.3); }
[data-theme="dark"] .salary-row { border-bottom-color: rgba(61,158,161,.1); }
[data-theme="dark"] .salary-row.total { background: rgba(61,158,161,.1); }
[data-theme="dark"] .cal-cell.no-work { background: rgba(61,158,161,.04); border-color: rgba(61,158,111,.1); }
[data-theme="dark"] .cal-cell.worked { background: rgba(61,158,161,.2); }
[data-theme="dark"] .modal-box { background: #142527; border-color: rgba(61,158,161,.2); }
[data-theme="dark"] .modal-header { border-bottom-color: rgba(61,158,161,.15); }
[data-theme="dark"] .modal-footer { border-top-color: rgba(61,158,161,.15); }
[data-theme="dark"] .link-btn { color: var(--primary-color); }
[data-theme="dark"] .badge-status { background: rgba(61,158,161,.15); }
[data-theme="dark"] .announce-bar { background: rgba(61,158,161,.08); border-color: rgba(61,158,161,.2); }

/* ── Кнопка переключения темы ── */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.15);
    background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,.7); font-size: 16px;
    transition: all .2s; margin-top: auto; margin-bottom: 8px;
}
.theme-toggle:hover { background: rgba(255,255,255,.1); color: white; }

/* ── Статусы заявок ── */
.badge-pending  { background: rgba(200,150,0,.15);  color: #c89600; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-approved { background: rgba(40,167,69,.15);  color: #28a745; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-rejected { background: rgba(196,68,68,.15);  color: #c44444; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-open     { background: rgba(36,108,111,.12); color: #246c6f; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-resolved { background: rgba(40,167,69,.15);  color: #28a745; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-closed   { background: rgba(100,100,100,.12); color: #888; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-fit      { background: rgba(40,167,69,.15);  color: #28a745; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-unfit    { background: rgba(196,68,68,.15);  color: #c44444; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-warn     { background: rgba(200,100,0,.12);  color: #c86400; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.overdue-row td { background: rgba(196,68,68,.05) !important; }
.expiring-row td { background: rgba(200,150,0,.05) !important; }

/* ── Кнопки прикрепления файла и записи голоса ── */
.chat-attach-btn {
    border: 1px solid #dce8ea;
    background: white;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.chat-attach-btn:hover { background: #f0f4f5; }
.chat-attach-btn.recording {
    background: #c44444;
    border-color: #c44444;
    color: white;
    animation: chat-recording-pulse 1s infinite;
}
@keyframes chat-recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(196,68,68,.4); }
    50% { box-shadow: 0 0 0 6px rgba(196,68,68,.15); }
}

/* ── Панель выбранного файла перед отправкой ── */
.chat-attach-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 20px;
    background: #f0f4f5;
    border-top: 1px solid #edf3f4;
    font-size: 12px;
    color: #5a7a7c;
}
.chat-attach-preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach-preview-remove {
    border: none;
    background: none;
    cursor: pointer;
    color: #8fa6a8;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.chat-attach-preview-remove:hover { color: #c44444; }

/* ── Вложения в сообщениях ── */
.chat-attachment-wrap { margin: 4px 0; }
.chat-attachment-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 10px;
    display: block;
}
.chat-attachment-audio { margin: 4px 0; max-width: 240px; display: block; }
.chat-attachment-video {
    margin: 4px 0;
    max-width: 280px;
    max-height: 280px;
    border-radius: 10px;
    display: block;
}
.chat-attachment-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 10px;
    background: rgba(255,255,255,.6);
    color: inherit;
    text-decoration: none;
}
.chat-bubble.mine .chat-attachment-file { background: rgba(255,255,255,.15); color: white; }
.chat-attachment-file-icon { font-size: 20px; }
.chat-attachment-file-info { display: flex; flex-direction: column; min-width: 0; }
.chat-attachment-file-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.chat-attachment-file-size { font-size: 10px; opacity: .7; }

@media (max-width: 1024px) {
    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .chat-contacts { max-height: 280px; }
    .chat-conversation { height: 60vh; }
    .chat-attachment-image, .chat-attachment-video { max-width: 100%; }
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ════════════════════════════════════════════════
   ЧАТ — РАЗДЕЛЫ КОНТАКТОВ, ГРУППЫ, РАССЫЛКА
   ════════════════════════════════════════════════ */

/* Заголовок раздела в панели контактов */
.chat-section-label {
    font-size: 11px; font-weight: 700; color: #8fa6a8;
    text-transform: uppercase; letter-spacing: .6px;
    padding: 14px 16px 6px;
}

/* Аватар группового чата */
.chat-group-avatar {
    background: linear-gradient(135deg, #246c6f, #1a4f52);
    color: #fff; font-weight: 700;
}
.chat-group-avatar-lg {
    background: linear-gradient(135deg, #246c6f, #1a4f52);
    color: #fff; font-size: 18px; font-weight: 700;
}

/* Контрагент-группа в контактах (менеджер) */
.chat-contractor-group { border-bottom: 1px solid #f0f5f5; }
.chat-contractor-toggle {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 16px; cursor: pointer; user-select: none;
    font-size: 13px; font-weight: 600; color: #0d2325;
    background: #f8fafa;
    transition: background .15s;
}
.chat-contractor-toggle:hover { background: #edf5f5; }
.chat-contractor-arrow { font-size: 10px; color: #8fa6a8; width: 12px; }
.chat-contractor-count { margin-left: auto; font-size: 11px; color: #8fa6a8; font-weight: 400; }
.chat-contractor-workers { background: #fcfefe; }
.chat-worker-item { padding-left: 28px !important; }

/* Имя отправителя в групповом чате */
.chat-bubble-sender {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700; color: #246c6f;
    margin-bottom: 4px;
}
.chat-mini-avatar {
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(36,108,111,.15); color: #246c6f;
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden;
}
.chat-mini-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── SVG icon system ── */
.icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 48px; height: 48px; stroke-width: 1.4; }
.item-icon.icon { width: 16px; height: 16px; }

