/* Система расчета заработной платы - Адаптивные стили */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Сайдбар */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--dark);
    color: white;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-header small {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.sidebar-nav { padding: 15px 0; }

.nav-section {
    padding: 10px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    border-left: 3px solid var(--primary);
    background: rgba(37, 99, 235, 0.2);
}

.nav-link i {
    width: 24px;
    margin-right: 12px;
    font-size: 18px;
}

/* Overlay для мобильного меню */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Основной контент */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.header {
    background: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dark);
    padding: 5px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    text-align: right;
}

.user-info .name { font-weight: 600; font-size: 14px; }
.user-info .role { font-size: 12px; color: var(--secondary); }

.content { padding: 20px; }

/* Карточки */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 15px 20px; }

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .icon {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-card .icon.blue { background: #dbeafe; color: var(--primary); }
.stat-card .icon.green { background: #dcfce7; color: var(--success); }
.stat-card .icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-card .icon.red { background: #fee2e2; color: var(--danger); }

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
    word-break: break-all;
}

.stat-card .label {
    color: var(--secondary);
    font-size: 13px;
}

/* Таблицы */
.table-responsive { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--secondary);
}

tr:hover { background: #f8fafc; }

/* Мобильные карточки для таблиц */
.mobile-cards {
    display: none;
}

.mobile-card {
    background: white;
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.mobile-card-title {
    font-weight: 600;
    font-size: 15px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
}

.mobile-card-row .label {
    color: var(--secondary);
}

.mobile-card-row .value {
    font-weight: 500;
}

.mobile-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Бейджи */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #e2e8f0; color: var(--dark); }
.btn-secondary:hover { background: #cbd5e1; }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-group { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap;
}

.btn-block {
    width: 100%;
}

/* Формы */
.form-group { margin-bottom: 15px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control { 
    cursor: pointer; 
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.form-inline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-inline .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 120px;
}

/* Прогресс бар */
.progress {
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--secondary);
    line-height: 1;
    padding: 5px;
}

.modal-body { padding: 20px; }
.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: white;
}

/* Алерты */
.alert {
    padding: 12px 15px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Логин */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--dark);
    font-size: 24px;
}

.login-box .btn { width: 100%; }

/* Графики область */
.chart-container {
    height: 300px;
    position: relative;
}

/* Табы */
.tabs { 
    border-bottom: 1px solid var(--border); 
    margin-bottom: 20px; 
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.tab-link {
    display: inline-block;
    padding: 12px 16px;
    color: var(--secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
    font-size: 14px;
}

.tab-link:hover { color: var(--dark); }
.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Действия в строке */
.actions { 
    display: flex; 
    gap: 5px; 
    flex-wrap: wrap;
}

.action-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: #f1f5f9;
    color: var(--secondary);
}

.action-btn:hover { background: #e2e8f0; color: var(--dark); }
.action-btn.edit:hover, .action-btn:hover.text-primary { background: #dbeafe; color: var(--primary); }
.action-btn.delete:hover, .action-btn:hover.text-danger { background: #fee2e2; color: var(--danger); }
.action-btn:hover.text-success { background: #dcfce7; color: var(--success); }

/* Грид для инфо-блоков */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    text-align: center;
}

.info-grid > div {
    padding: 10px;
}

/* Утилиты */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--secondary); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 600; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.d-none { display: none; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }

/* =====================================================
   МЕДИА-ЗАПРОСЫ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ
   ===================================================== */

/* Планшеты (до 1024px) */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 250px;
    }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    /* Сайдбар скрыт по умолчанию */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Контент на всю ширину */
    .main-content {
        margin-left: 0;
    }
    
    /* Показываем кнопку меню */
    .menu-toggle {
        display: block;
    }
    
    .header {
        padding: 12px 15px;
    }
    
    .header-title {
        font-size: 16px;
    }
    
    .user-info .name {
        font-size: 13px;
    }
    
    .user-info .role {
        display: none;
    }
    
    .content {
        padding: 15px;
    }
    
    /* Статистика в 2 колонки */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-card .value {
        font-size: 18px;
    }
    
    .stat-card .icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    /* Карточки */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .card-header .btn {
        width: 100%;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Таблицы горизонтальный скролл */
    table {
        min-width: 500px;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    /* Формы */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-inline .form-group {
        width: 100%;
    }
    
    .form-inline .btn {
        width: 100%;
    }
    
    /* Модальные окна */
    .modal-content {
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Графики */
    .chart-container {
        height: 200px;
    }
    
    /* Грид инфо */
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* Кнопки */
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
    
    /* Действия */
    .actions {
        justify-content: flex-start;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
    }
}

/* Маленькие мобильные (до 480px) */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .stat-card .icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .stat-card .value {
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    .header-title {
        font-size: 14px;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    .tabs {
        display: flex;
        overflow-x: auto;
    }
    
    .tab-link {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .login-box {
        padding: 25px 20px;
    }
    
    .login-box h1 {
        font-size: 20px;
    }
}

/* Печать */
@media print {
    .sidebar,
    .header,
    .menu-toggle,
    .btn,
    .actions,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    table {
        min-width: auto;
    }
}
