* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header h1 { font-size: 22px; }
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.header-user { opacity: 0.9; font-size: 14px; }

/* ==================== BUTTONS ==================== */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s;
    font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { background: #4CAF50; color: white; }
.btn-primary:hover { background: #45a049; }
.btn-danger  { background: #f44336; color: white; }
.btn-danger:hover { background: #da190b; }
.btn-warning { background: #ff9800; color: white; }
.btn-warning:hover { background: #e68900; }
.btn-info    { background: #2196F3; color: white; }
.btn-info:hover { background: #0b7dda; }
.btn-success { background: #4CAF50; color: white; }
.btn-success:hover { background: #45a049; }
.btn-outline {
    background: transparent;
    border: 2px solid white;
    color: white;
    padding: 6px 16px;
}
.btn-outline:hover { background: white; color: #667eea; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ==================== CONTAINER / CARD ==================== */
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.card h3 { margin-bottom: 15px; color: #333; font-size: 18px; }

/* ==================== STATS ==================== */
.stats, .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}
.stat-card {
    background: white;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    text-align: center;
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: #667eea; }
.stat-card .stat-label { font-size: 12px; color: #666; margin-top: 4px; }
.stat-card.pending-card { background: #fff3e0; }
.stat-card.pending-card .stat-value { color: #e65100; }
.stat-card.approved-card { background: #e8f5e9; }
.stat-card.approved-card .stat-value { color: #2e7d32; }

/* ==================== USERS TABLE ==================== */
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th, .users-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.users-table th { background: #f5f5f5; font-weight: 600; font-size: 12px; }
.users-table tr:hover { background: #fafbff; }
.users-table .actions-cell { display: flex; flex-wrap: wrap; gap: 4px; }

.status-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    display: inline-block;
    font-weight: 600;
}
.status-badge.active   { background: #e8f5e9; color: #2e7d32; }
.status-badge.inactive { background: #fce4ec; color: #c62828; }
.status-badge.pending  { background: #fff3e0; color: #e65100; }

.role-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    color: white;
    font-weight: 600;
    display: inline-block;
}
.role-badge.admin { background: #667eea; }
.role-badge.user  { background: #4CAF50; }

/* ==================== SETTINGS ==================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.settings-grid .setting-item { display: flex; flex-direction: column; gap: 5px; }
.settings-grid .setting-item label { font-weight: 600; color: #555; font-size: 13px; }
.settings-grid .setting-item input,
.settings-grid .setting-item select {
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.settings-grid .setting-item input:focus,
.settings-grid .setting-item select:focus {
    outline: none;
    border-color: #667eea;
}
.settings-grid .setting-item input[type="color"] { height: 40px; padding: 2px; cursor: pointer; }
.settings-grid .setting-item input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }
.settings-grid .setting-item.checkbox-item { flex-direction: row; align-items: center; gap: 10px; }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 15px; }

/* ==================== LOGIN ==================== */
body.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-container h1 {
    text-align: center;
    color: #333;
    margin-bottom: 8px;
    font-size: 26px;
}
.login-container .subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 25px;
    font-size: 14px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    font-size: 13px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}
.form-group textarea { resize: vertical; min-height: 70px; }
.login-container .btn { width: 100%; padding: 12px; font-size: 15px; }

.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 22px;
    background: #f0f2f5;
    border-radius: 12px;
    padding: 5px;
}
.tab {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-family: inherit;
}
.tab.active { background: white; color: #667eea; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.tab:hover:not(.active) { background: rgba(255,255,255,0.5); }

.form-container { display: none; }
.form-container.active { display: block; }

.error-message, .success-message {
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 13px;
    display: none;
}
.error-message { background: #fce4ec; color: #c62828; }
.success-message { background: #e8f5e9; color: #2e7d32; }
.error-message.show, .success-message.show { display: block; }

.info-text {
    text-align: center;
    color: #888;
    font-size: 13px;
    margin-top: 12px;
}
.info-text a { color: #667eea; text-decoration: none; font-weight: 600; }
.info-text a:hover { text-decoration: underline; }
.password-hint { font-size: 12px; color: #888; margin-top: 4px; }

.requirements { font-size: 12px; margin-top: 5px; line-height: 1.6; }
.requirements .valid   { color: #4CAF50; }
.requirements .invalid { color: #f44336; }

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== CONTROLS / CALENDAR ==================== */
.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    align-items: center;
}
.controls select, .controls input {
    padding: 7px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.controls label { font-weight: 600; font-size: 14px; }

.view-mode { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.view-mode .btn { padding: 6px 14px; font-size: 13px; background: #f0f0f0; color: #666; }
.view-mode .btn.active { background: #667eea; color: white; }
.view-mode .btn:hover:not(.active) { background: #e0e0e0; }

.calendar-wrapper { display: grid; gap: 20px; width: 100%; overflow: hidden; }
.calendar-wrapper.mode-1  { grid-template-columns: 1fr; }
.calendar-wrapper.mode-6  { grid-template-columns: repeat(2, 1fr); }
.calendar-wrapper.mode-12 { grid-template-columns: repeat(3, 1fr); }

.calendar { background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); overflow: hidden; min-width: 0; }
.calendar-header {
    background: #667eea;
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.calendar-header h3 { font-size: 15px; margin: 0; }
.calendar-header .month-nav { display: flex; gap: 4px; }
.calendar-header .month-nav button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.calendar-header .month-nav button:hover { background: rgba(255,255,255,0.4); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
}
.calendar-day-header {
    background: #f5f5f5;
    padding: 5px 2px;
    text-align: center;
    font-weight: 700;
    font-size: 10px;
    color: #333;
}
.calendar-day { background: white; min-height: 55px; padding: 3px 2px; position: relative; overflow: hidden; }
.calendar-day.empty { background: #fafafa; }
.calendar-day .day-number { font-weight: 600; font-size: 11px; color: #333; margin-bottom: 2px; }
.calendar-day.today .day-number { color: #667eea; font-weight: 800; }
.calendar-day.weekend .day-number { color: #f44336; }
.calendar-day.birthday { background: #fff8e1; }

.vacation-badge {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 8px;
    font-size: 7px;
    color: white;
    margin: 1px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.vacation-badge:hover { opacity: 0.85; }
.vacation-badge.own-vacation { cursor: pointer; }
.vacation-badge.other-vacation { cursor: default; opacity: 0.75; }

/* ==================== LEGEND ==================== */
.legend { display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 0; margin-bottom: 15px; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; background: white; padding: 3px 8px; border-radius: 6px; }
.legend-color { width: 12px; height: 12px; border-radius: 3px; }

/* ==================== USERS LIST ==================== */
.user-list { background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); padding: 20px; margin-bottom: 20px; }
.user-list h3 { margin-bottom: 15px; color: #333; }
.user-item { display: flex; justify-content: space-between; align-items: center; padding: 8px; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; gap: 5px; }
.user-item:last-child { border-bottom: none; }
.user-item .user-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-item .user-color { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #ddd; }
.user-item .user-name { font-weight: 600; font-size: 14px; }
.user-item .user-days { font-size: 12px; color: #666; }
.user-status { padding: 2px 8px; border-radius: 10px; font-size: 11px; }

/* ==================== PROFILE ==================== */
.profile-settings { background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); padding: 20px; margin-bottom: 20px; }
.profile-settings h3 { margin-bottom: 15px; color: #333; }
.profile-settings .form-row { display: flex; gap: 15px; flex-wrap: wrap; align-items: end; }
.profile-settings .form-group { flex: 1; min-width: 140px; margin-bottom: 0; }
.profile-settings label { font-size: 12px; }

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: white;
    border-radius: 16px;
    padding: 28px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h2 { margin-bottom: 20px; color: #333; font-size: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .btn { min-width: 100px; }

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 2000;
    opacity: 0;
    transition: 0.3s;
    max-width: 90%;
    font-size: 14px;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: #4CAF50; }
.toast.error   { background: #f44336; }
.toast.warning { background: #ff9800; }
.toast.info    { background: #2196F3; }

/* ==================== LOADING ==================== */
.loading { display: none; text-align: center; padding: 20px; }
.loading.active { display: block; }
.loading .spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 8px;
}

/* ==================== NOTIFICATIONS ==================== */
.notif-wrap { position: relative; }
.notif-badge {
    background: #f44336;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    margin-left: 2px;
}
.notif-panel {
    display: none;
    position: absolute;
    right: 0;
    top: 44px;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 3000;
    color: #333;
}
.notif-panel.active { display: block; }
.notif-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-header button { background: none; border: none; color: #667eea; cursor: pointer; font-size: 12px; }
.notif-item {
    padding: 10px;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
    cursor: pointer;
}
.notif-item.unread { background: #f0f4ff; }
.notif-item:hover { background: #f5f5f5; }
.notif-item .notif-ts { font-size: 11px; color: #999; margin-top: 3px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .calendar-wrapper.mode-12 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 992px) {
    .calendar-wrapper.mode-6 { grid-template-columns: 1fr 1fr; }
    .calendar-wrapper.mode-12 { grid-template-columns: 1fr 1fr; }
    .calendar-day { min-height: 50px; }
}
@media (max-width: 768px) {
    .container { padding: 10px; }
    .calendar-wrapper.mode-1,
    .calendar-wrapper.mode-6,
    .calendar-wrapper.mode-12 { grid-template-columns: 1fr; }
    .calendar-day { min-height: 45px; }
    .calendar-day .day-number { font-size: 10px; }
    .vacation-badge { font-size: 7px; }
    .controls { flex-direction: column; align-items: stretch; }
    .stats, .stats-grid { grid-template-columns: 1fr 1fr; }
    .header { flex-direction: column; text-align: center; }
    .header h1 { font-size: 18px; }
    .profile-settings .form-row { flex-direction: column; }
    .view-mode { justify-content: center; }
    .modal-content { padding: 20px; }
    .users-table { font-size: 12px; }
    .users-table th, .users-table td { padding: 6px 4px; }
}
@media (max-width: 480px) {
    .calendar-day { min-height: 40px; padding: 1px; }
    .calendar-day .day-number { font-size: 8px; }
    .vacation-badge { font-size: 6px; padding: 0 2px; }
    .calendar-day-header { font-size: 7px; padding: 2px 0; }
    .calendar-header h3 { font-size: 12px; }
    .stats, .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 10px; }
    .stat-card .stat-value { font-size: 18px; }
    .stat-card .stat-label { font-size: 10px; }
    .login-container { padding: 25px; margin: 10px; }
}