/* ============================================================
   HR Automation — Единый стиль
   Деловой женский дизайн: мягкие цвета, плавные формы
   ============================================================ */

:root {
    /* Основная палитра — тёплый беж + глубокий бордо */
    --primary: #7b2d4e;          /* бордо-розовый */
    --primary-light: #a24b6e;
    --primary-dark: #5c1a38;
    --primary-bg: #fdf6f9;       /* нежный розоватый фон */
    --accent: #c9957b;           /* тёплый золотисто-бежевый */
    --accent-light: #e8cfc0;
    --surface: #ffffff;
    --surface-hover: #faf5f7;
    --border: #e8dde2;
    --border-focus: #a24b6e;
    --text-primary: #3d2033;
    --text-secondary: #7a6572;
    --text-muted: #a8939f;
    --success: #4a8c6f;
    --success-bg: #edf7f1;
    --warning: #c0873a;
    --warning-bg: #fdf5e9;
    --error: #b5364b;
    --error-bg: #fdf0f2;
    --shadow-sm: 0 1px 3px rgba(123,45,78,0.06);
    --shadow-md: 0 4px 16px rgba(123,45,78,0.08);
    --shadow-lg: 0 8px 32px rgba(123,45,78,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===================== ШАПКА + НАВИГАЦИЯ ===================== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0 32px;
    display: flex;
    align-items: center;
    min-height: 64px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 9999;
}

.header-brand {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    flex-shrink: 0;
}

.header-brand h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header-brand .subtitle {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 1px;
    font-weight: 400;
}

/* Навигация */
.nav-links {
    display: flex;
    gap: 4px;
    margin-left: 32px;
    height: 64px;
    align-items: stretch;
}

.nav-links a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: color var(--transition), background var(--transition);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.nav-links a:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.nav-links a.active {
    color: white;
    border-bottom-color: var(--accent);
    background: rgba(255,255,255,0.1);
}

/* Утилитные кнопки в шапке */
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    pointer-events: auto;
}

.header-actions:empty {
    display: none;
}

.header-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}

.header-btn:hover { background: rgba(255,255,255,0.22); }
.header-btn:disabled { opacity: 0.4; cursor: wait; }

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    opacity: 0.75;
    white-space: nowrap;
}

.header-badge .dot {
    width: 7px; height: 7px;
    background: #6fcf97;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ===================== КОНТЕЙНЕР / ЛЭЙАУТ ===================== */
.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
}

/* ===================== ПАНЕЛИ / КАРТОЧКИ ===================== */
.panel {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface);
}

/* ===================== КНОПКИ ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(123,45,78,0.3);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-bg);
}

.btn-danger {
    color: var(--error);
    border: 1px solid var(--error);
    background: transparent;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error);
    color: white;
}

/* ===================== ФОРМЫ ===================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-input,
.form-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(162,75,110,0.1);
}

.form-input::placeholder { color: var(--text-muted); }

/* ===================== ПОИСК ===================== */
.search-bar {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    gap: 14px;
    align-items: center;
}

/* ===================== СТАТ-КАРТОЧКИ ===================== */
.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    flex: 1;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 4px;
}

/* ===================== МОДАЛЬНЫЕ ОКНА ===================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(61,32,51,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-header .close-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}

.modal-header .close-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.modal-body {
    padding: 16px 24px;
    overflow-y: auto;
    flex: 1;
}

/* ===================== СТАТУС-БАРЫ ===================== */
.status-bar {
    padding: 12px 20px;
    text-align: center;
    font-size: 13px;
    display: none;
    border-radius: var(--radius-sm);
}

.status-bar.success { display: block; background: var(--success-bg); color: var(--success); }
.status-bar.error { display: block; background: var(--error-bg); color: var(--error); }

/* ===================== КОМПАНИЯ-АККОРДЕОН ===================== */
.company-section {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 12px;
    overflow: hidden;
}

.company-header {
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background var(--transition);
}

.company-header:hover { background: var(--surface-hover); }

.company-header .arrow {
    transition: transform 0.2s;
    font-size: 10px;
    color: var(--text-muted);
}

.company-header.open .arrow { transform: rotate(90deg); }

.company-header .company-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.company-header .company-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--primary-bg);
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.company-body { display: none; }
.company-body.open { display: block; }

/* ===================== СОТРУДНИК-СТРОКА ===================== */
.employee-row {
    padding: 11px 20px 11px 36px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background var(--transition);
}

.employee-row:hover { background: var(--surface-hover); }
.employee-row:last-child { border-bottom: none; }

.employee-row .emp-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.employee-row .emp-name { font-size: 13px; font-weight: 500; }
.employee-row .emp-files-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* ===================== ФАЙЛ-ИТЕМ ===================== */
.file-item {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    gap: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.file-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(201,149,123,0.15); }

.file-icon {
    width: 38px; height: 38px;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    color: var(--primary);
}

.file-info { flex: 1; min-width: 0; }
.file-info .file-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info .file-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.file-item a {
    color: var(--primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.file-item a:hover { background: var(--primary); color: white; }

.file-item .btn-delete {
    color: var(--error);
    border: 1px solid var(--error);
    background: none;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.file-item .btn-delete:hover { background: var(--error); color: white; }

/* ===================== ПУСТОЕ СОСТОЯНИЕ ===================== */
.empty-msg, .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-msg .icon, .empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }

/* ===================== ЗАГРУЗКА ===================== */
.loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.loading .spinner {
    display: inline-block;
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== СКРОЛЛБАР ===================== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--accent-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===================== АДАПТИВНОСТЬ ===================== */
@media (max-width: 768px) {
    .header { padding: 0 16px; flex-wrap: wrap; min-height: auto; }
    .nav-links { margin-left: 0; height: auto; gap: 2px; overflow-x: auto; width: 100%; padding: 8px 0; }
    .nav-links a { padding: 8px 12px; font-size: 12px; }
    .header-actions { width: 100%; justify-content: flex-end; padding: 8px 0; }
    .stats-row { flex-direction: column; }
    .search-bar { flex-direction: column; }
    .container { padding: 0 12px; }
}

/* ============================================================
   DASHBOARD STYLE (общий для всех страниц аналитики)
   ============================================================ */

body.dash-bg { background: linear-gradient(180deg, #fbf3f7 0%, #f7fafc 400px); }

.dash-container { max-width: 1600px; margin: 28px auto; padding: 0 24px; }

.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.dash-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; color: var(--text-primary); }
.dash-head .subline { font-size: 12px; color: var(--text-muted); }
.dash-head .crumbs { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.dash-head .crumbs a { color: var(--primary); text-decoration: none; }

/* Period bar */
.dash-period {
    background: var(--surface); border-radius: 14px; padding: 14px 18px;
    margin-bottom: 22px; box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.dash-period label { font-size: 12px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.dash-period input[type="date"] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; outline: none; font-family: inherit; }
.dash-period input[type="date"]:focus { border-color: var(--primary); }
.dash-period .preset-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-left: 6px; }
.dash-period .preset-btn {
    padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
    background: white; cursor: pointer; font-size: 12px; font-weight: 500;
    color: var(--text-primary); transition: all 0.15s;
}
.dash-period .preset-btn:hover { border-color: var(--primary); color: var(--primary); }
.dash-period .preset-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Hero KPI cards (gradient) */
.dash-hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 22px; }
.dash-hero {
    position: relative; border-radius: 18px; padding: 22px 24px;
    color: white; min-height: 130px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}
.dash-hero[data-static="1"] { cursor: default; }
.dash-hero:hover:not([data-static="1"]) { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(0,0,0,0.15); }
.dash-hero .hero-icon {
    position: absolute; top: 18px; right: 18px;
    width: 38px; height: 38px; border-radius: 11px;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.dash-hero .hero-label { font-size: 12px; font-weight: 600; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; padding-right: 50px; }
.dash-hero .hero-value { font-size: 30px; font-weight: 700; line-height: 1.05; letter-spacing: -0.5px; }
.dash-hero .hero-sub { margin-top: 8px; font-size: 12px; opacity: 0.85; line-height: 1.5; }
.dash-hero.hero-blue   { background: linear-gradient(135deg, #5b8def 0%, #3b5fd0 100%); }
.dash-hero.hero-teal   { background: linear-gradient(135deg, #2bc7c1 0%, #129a99 100%); }
.dash-hero.hero-green  { background: linear-gradient(135deg, #3fc080 0%, #16a063 100%); }
.dash-hero.hero-purple { background: linear-gradient(135deg, #9b5de5 0%, #6234c5 100%); }
.dash-hero.hero-rose   { background: linear-gradient(135deg, #c43b65 0%, #7b2d4e 100%); }
.dash-hero.hero-amber  { background: linear-gradient(135deg, #f6a154 0%, #c9802b 100%); }

/* Secondary KPI tiles */
.dash-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 22px; }
.dash-kpi {
    background: var(--surface); border-radius: 12px;
    padding: 14px 16px 14px 18px; box-shadow: var(--shadow-sm);
    border: 1px solid var(--border); border-left: 3px solid var(--primary-light);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.dash-kpi.clickable { cursor: pointer; }
.dash-kpi.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.07); border-left-color: var(--primary); }
.dash-kpi .kpi-label { font-size: 10.5px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.dash-kpi .kpi-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.dash-kpi .kpi-sub   { margin-top: 4px; font-size: 11.5px; color: var(--text-secondary); line-height: 1.4; }

/* Generic card containers */
.dash-card {
    background: var(--surface); border-radius: 14px; padding: 20px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    margin-bottom: 18px;
}
.dash-card h3 { margin: 0 0 14px 0; font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* Charts grid */
.dash-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 22px; }
.dash-charts .dash-card { margin-bottom: 0; }
.dash-chart-wrap { position: relative; height: 260px; }
.dash-chart-wrap.tall { height: 340px; }

/* Table styling inside dash-card */
.dash-card table.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-card table.dash-table th {
    background: #faf5f7; text-align: left; padding: 11px 12px;
    border-bottom: 1px solid var(--border); font-weight: 600;
    color: var(--text-secondary); text-transform: uppercase;
    font-size: 11px; letter-spacing: 0.4px;
}
.dash-card table.dash-table th.num { text-align: right; }
.dash-card table.dash-table td { padding: 11px 12px; border-bottom: 1px solid #f1edf0; }
.dash-card table.dash-table tr:last-child td { border-bottom: none; }
.dash-card table.dash-table tr:hover td { background: #fbf6f8; }
.dash-num { text-align: right; font-variant-numeric: tabular-nums; }

.dash-loading { text-align: center; color: var(--text-secondary); padding: 40px; font-size: 14px; }
