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

/* ========== LOGIN SCREEN ========== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1f16 0%, #2D3528 100%);
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.login-bg-pattern {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(232, 75, 30, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(232, 75, 30, 0.08) 0%, transparent 50%);
    animation: rotate 60s linear infinite;
}

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

.login-container {
    background: white;
    border-radius: 24px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    margin: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    margin-bottom: 20px;
}

.login-logo svg {
    filter: drop-shadow(0 4px 12px rgba(232, 75, 30, 0.3));
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.login-header p {
    color: #64748b;
    font-size: 15px;
}

.login-form .form-group {
    margin-bottom: 24px;
}

.login-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 10px;
}

.login-form label svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.login-form input {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s;
    background: #f8fafc;
}

.login-form input:focus {
    outline: none;
    border-color: #E84B1E;
    background: white;
    box-shadow: 0 0 0 4px rgba(232, 75, 30, 0.1);
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.toggle-password:hover {
    opacity: 1;
}

.toggle-password svg {
    width: 20px;
    height: 20px;
    stroke: #64748b;
    stroke-width: 2;
    fill: none;
}

.login-error {
    color: #dc2626;
    font-size: 13px;
    text-align: center;
    margin-bottom: 16px;
    min-height: 20px;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 16px;
}

.btn .btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loader {
    display: block;
}

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

.login-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.login-footer p {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.login-footer code {
    display: inline-block;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'SF Mono', monospace;
    font-size: 13px;
    color: #475569;
}

:root {
    --primary: #E84B1E;
    --primary-light: #ff6b42;
    --primary-dark: #c73d15;
    --secondary: #2D3528;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f8fafc;
    --card-bg: #fff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 280px;
    --header-height: 70px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--secondary) 0%, #1a1f16 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-weight: 500;
}

.nav-menu {
    flex: 1;
    padding: 8px 16px;
    overflow-y: auto;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 20px 12px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
    position: relative;
}

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

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(232, 75, 30, 0.4);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.nav-badge.danger {
    background: var(--danger);
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.version-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.4);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: white;
    padding: 0 32px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 10px;
    margin: -10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--bg);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    stroke: var(--text);
    stroke-width: 2;
    fill: none;
}

.header-title {
    flex: 1;
}

.header-title h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.header-date {
    font-size: 13px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-btn {
    position: relative;
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: none;
}

.notification-dot.visible {
    display: block;
}

.content {
    flex: 1;
    padding: 32px;
}

/* ========== WELCOME BANNER ========== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    right: -50px;
    top: -50px;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.welcome-content h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.welcome-content p {
    opacity: 0.85;
    font-size: 15px;
}

.welcome-illustration {
    position: relative;
    z-index: 1;
}

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card.alert {
    border-color: var(--danger);
    border-width: 2px;
}

.stat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    fill: none;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.blue svg { stroke: var(--info); }
.stat-icon.green { background: #d1fae5; }
.stat-icon.green svg { stroke: var(--success); }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.orange svg { stroke: var(--warning); }
.stat-icon.red { background: #fee2e2; }
.stat-icon.red svg { stroke: var(--danger); }

.stat-trend {
    padding: 4px;
    border-radius: 6px;
}

.stat-trend svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    fill: none;
}

.stat-trend.up { background: #d1fae5; }
.stat-trend.up svg { stroke: var(--success); }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-bar {
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    margin-top: 16px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.stat-bar-fill.blue { background: var(--info); }
.stat-bar-fill.green { background: var(--success); }
.stat-bar-fill.orange { background: var(--warning); }
.stat-bar-fill.red { background: var(--danger); }

/* ========== DASHBOARD GRID ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.dashboard-grid .full-width {
    grid-column: 1 / -1;
}

/* ========== CARDS ========== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

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

.card-body.no-padding {
    padding: 0;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ========== LISTS ========== */
.list-item {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 14px;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.list-item-icon.blue { background: #dbeafe; color: var(--info); }
.list-item-icon.green { background: #d1fae5; color: var(--success); }
.list-item-icon.orange { background: #ffedd5; color: var(--warning); }
.list-item-icon.red { background: #fee2e2; color: var(--danger); }

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 2px;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.badge-success { background: #d1fae5; color: #059669; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #2563eb; }

/* ========== FESTIVOS TIMELINE ========== */
.festivos-timeline {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 0;
}

.festivo-card {
    flex-shrink: 0;
    width: 140px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}

.festivo-card.nacional { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); }
.festivo-card.autonomico { background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); }
.festivo-card.local { background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%); }

.festivo-date {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.festivo-month {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.festivo-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

/* ========== CALENDAR ========== */
.calendar-container {
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    min-width: 100%;
}

.calendar-day {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-height: 140px;
    padding: 12px;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.calendar-day-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.calendar-day-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
}

.calendar-day.today .calendar-day-number {
    background: var(--primary);
    color: white;
}

.calendar-day.festivo {
    background: #fef3c7;
}

.calendar-day.festivo .calendar-day-number {
    background: var(--warning);
    color: white;
}

.calendar-event {
    background: white;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    margin-bottom: 6px;
    border-left: 3px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.calendar-event .event-ruta {
    font-weight: 700;
    color: var(--text);
}

.calendar-event .event-gestor {
    color: var(--text-muted);
    font-size: 11px;
}

.calendar-event.sustitucion {
    border-left-color: var(--warning);
    background: #fffbeb;
}

.week-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.week-label {
    font-size: 14px;
    font-weight: 600;
    min-width: 180px;
    text-align: center;
}

.legend {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.normal { background: var(--primary); }
.legend-dot.sustitucion { background: var(--warning); }
.legend-dot.festivo { background: #fef3c7; border: 1px solid #fde68a; }

/* ========== VIEW HEADER ========== */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.view-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.view-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ========== TABLES ========== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg);
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: var(--bg);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
}

.user-avatar.titular { background: var(--info); }
.user-avatar.reten { background: var(--warning); }
.user-avatar.formacion { background: #8b5cf6; }

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-email {
    font-size: 12px;
    color: var(--text-muted);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.tag-titular { background: #dbeafe; color: #2563eb; }
.tag-reten { background: #fef3c7; color: #d97706; }
.tag-formacion { background: #ede9fe; color: #7c3aed; }

.capability-icons {
    display: flex;
    gap: 8px;
}

.capability-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.capability-icon.yes { background: #d1fae5; }
.capability-icon.no { background: #fee2e2; }

/* ========== RUTAS GRID ========== */
.rutas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.ruta-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.ruta-card:hover {
    box-shadow: var(--shadow);
}

.ruta-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.ruta-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.ruta-title {
    font-size: 16px;
    font-weight: 700;
}

.ruta-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.ruta-stats {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.ruta-stat {
    flex: 1;
}

.ruta-stat-value {
    font-size: 18px;
    font-weight: 700;
}

.ruta-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ========== FESTIVOS LIST ========== */
.festivos-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.festivo-item {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
}

.festivo-item-date {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.festivo-item-date.nacional { background: #dbeafe; color: var(--info); }
.festivo-item-date.autonomico { background: #d1fae5; color: var(--success); }
.festivo-item-date.local { background: #fce7f3; color: #db2777; }

.festivo-item-day {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.festivo-item-month {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.festivo-item-info {
    flex: 1;
}

.festivo-item-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.festivo-item-type {
    font-size: 12px;
    color: var(--text-muted);
}

/* ========== AUSENCIAS LAYOUT ========== */
.ausencias-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 75, 30, 0.1);
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232, 75, 30, 0.3);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.btn-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--text);
    stroke-width: 2;
    fill: none;
}

/* ========== VIEWS ========== */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

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

.modal {
    background: white;
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.btn-close {
    width: 36px;
    height: 36px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
}

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

.modal-body {
    padding: 24px;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--secondary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); color: var(--text); }
.toast.error { background: var(--danger); }

.toast svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    stroke: var(--border);
    stroke-width: 1.5;
    fill: none;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ausencias-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .welcome-banner {
        padding: 20px;
    }
    
    .welcome-content h2 {
        font-size: 20px;
    }
    
    .welcome-illustration {
        display: none;
    }
    
    .header {
        padding: 0 16px;
    }
    
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .view-header .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container {
        padding: 32px 24px;
    }
}

/* ========== USER MENU ========== */
.user-menu {
    position: relative;
}

.user-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.user-avatar-header {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.user-dropdown.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
}

.dropdown-header span:first-child {
    font-weight: 600;
    font-size: 15px;
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bg);
}

.user-dropdown a svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.user-dropdown a.text-danger {
    color: var(--danger);
}

.text-muted {
    color: var(--text-muted);
    font-size: 12px !important;
}

/* ========== SIDEBAR USER INFO ========== */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.user-name-small {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    text-transform: capitalize;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-icon-sm:hover {
    background: var(--danger);
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
    stroke: rgba(255,255,255,0.7);
    stroke-width: 2;
    fill: none;
}

.btn-icon-sm:hover svg {
    stroke: white;
}

/* ========== ADMIN ONLY ========== */
.admin-only {
    display: none;
}

body.is-admin .admin-only {
    display: flex;
}

body.is-admin .nav-section.admin-only {
    display: block;
}

/* ========== SESSION EXPIRED OVERLAY ========== */
.session-expired {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.session-expired-content {
    background: white;
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
}

.session-expired h3 {
    margin-bottom: 12px;
}

.session-expired p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ================================================================
   TEMA ARBITRADE v7 — crema cálido, sidebar clara, naranja como joya
   (capa de overrides: gana la cascada sobre el tema oscuro anterior)
   ================================================================ */
:root {
    --primary: #EC5420;
    --primary-light: #F97316;
    --primary-dark: #C93E12;
    --secondary: #201B16;
    --bg: #F7F2EA;               /* papel cálido, como el póster */
    --card-bg: #FFFFFF;
    --text: #201B16;
    --text-muted: #8A8074;       /* neutro teñido de cálido, no gris frío */
    --border: #EBE2D6;
    --shadow-sm: 0 1px 2px rgba(72, 48, 24, 0.06);
    --shadow: 0 8px 22px -8px rgba(72, 48, 24, 0.14);
}
body { background: var(--bg); color: var(--text); }

/* Sidebar clara al estilo del ERP */
.sidebar {
    background: #FFFFFF;
    color: var(--text);
    border-right: 1px solid var(--border);
}
.sidebar-header { border-bottom: 1px solid var(--border); }
.logo-title { color: var(--text); }
.logo-subtitle { color: var(--text-muted); }
.nav-section { color: #B9AC9B; }
.nav-item { color: #5C5346; border-radius: 12px; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
    background: #FDECE3;         /* píldora naranja suave */
    color: var(--primary);
    box-shadow: none;
    font-weight: 600;
}
.sidebar-footer { border-top: 1px solid var(--border); }
.version-info { color: var(--text-muted); }
.user-role { color: var(--text-muted); }
.btn-icon-sm { background: var(--bg); }
.btn-icon-sm svg { stroke: #5C5346; }
.btn-icon-sm:hover svg { stroke: #fff; }

/* Botones píldora */
.btn, .btn-primary, .btn-block { border-radius: 999px; }
.btn-primary {
    background: var(--primary);
    box-shadow: 0 6px 16px -6px rgba(236, 84, 32, 0.5);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-icon { border-radius: 999px; }

/* Tarjetas y tablas sobre papel cálido */
.card { border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.table th { background: #FBF6EF; color: var(--text-muted); }
.table td { border-color: #F1EAE0; }
.table tbody tr:hover { background: #FBF6EF; }

/* Formularios */
input, select, textarea { border-radius: 10px; }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(236, 84, 32, 0.12);
}

/* Login: papel cálido con resplandor naranja inferior, como el póster */
.login-screen {
    background:
        radial-gradient(120% 55% at 50% 118%,
            #E85412 0%, rgba(242, 107, 33, 0.55) 32%, rgba(247, 242, 234, 0) 64%),
        #F5EFE6;
}
.login-bg-pattern { display: none; }
.login-container {
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 30px 60px -20px rgba(90, 40, 10, 0.25);
}
.login-header h1 { color: var(--text); }

/* Modales y chips */
.modal { border-radius: 18px; }
.modal-header { border-bottom: 1px solid var(--border); }
.badge { border-radius: 999px; }

/* Cabecera */
.header { background: #FFFFFF; border-bottom: 1px solid var(--border); }

/* ================================================================
   MICRO-ARTESANÍA v7.4 — los detalles que hacen caro lo barato
   ================================================================ */
/* Selección de texto y scrollbar teñidos de marca */
::selection { background: #F6D9CC; color: #1A1712; }
* { scrollbar-width: thin; scrollbar-color: #D8CDBD transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #D8CDBD; border-radius: 999px; border: 2px solid #F7F2EA; }
*::-webkit-scrollbar-track { background: transparent; }

/* Tipografía de cabeceras con carácter */
.view-header h2 { letter-spacing: -0.6px; font-weight: 700; }
.view-header p { color: var(--text-muted); }
.table th { text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.8px; font-weight: 700; }

/* Botones: respuesta táctil */
.btn, .btn-icon, .modo-mapa {
    transition: background 180ms cubic-bezier(0.22,1,0.36,1),
                color 180ms, border-color 180ms, transform 120ms, box-shadow 180ms;
}
.btn:active, .btn-icon:active { transform: scale(0.97); }
.btn-primary:hover { box-shadow: 0 8px 20px -6px rgba(236,84,32,0.55); }

/* Entrada del modal: aparece, no se teletransporta */
@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}
.modal-overlay.visible .modal { animation: modal-in 240ms cubic-bezier(0.22,1,0.36,1); }

/* Tarjetas: elevación al pasar (solo tarjetas clicables de rejillas) */
.rutas-grid .card { transition: box-shadow 200ms, transform 200ms; }
.rutas-grid .card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* Toasts cálidos */
.toast { border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }

/* Badges del nav con marca */
.nav-badge { background: #FDECE3; color: #C93E12; font-weight: 700; border-radius: 999px; }
.nav-item.active .nav-badge { background: #EC5420; color: #fff; }

/* Popups de Leaflet acordes al tema */
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-content { font-family: 'DM Sans', sans-serif; font-size: 13px; }

/* Estados vacíos con aire */
.empty-state { color: var(--text-muted); padding: 28px; text-align: center; }

/* Todo quieto si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
    .btn, .btn-icon, .modo-mapa, .rutas-grid .card { transition: none; }
    .modal-overlay.visible .modal { animation: none; }
}
