:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-light: #6366f1;
    --brand-soft: #eef2ff;
    --sidebar-from: #1e1b4b;
    --sidebar-to: #312e81;
    --bg-app: #f4f5fa;
    --text-main: #1f2330;
    --text-muted: #6b7280;
    --border-soft: #e7e8f0;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-soft: 0 2px 10px rgba(30, 27, 75, 0.06);
    --shadow-card: 0 6px 24px rgba(30, 27, 75, 0.08);
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---------- Shell layout ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    padding: 0 0.5rem 1.5rem;
    letter-spacing: 0.2px;
}

.sidebar-brand i { color: #a5b4fc; font-size: 1.3rem; }
.sidebar-brand img { border-radius: 7px; flex-shrink: 0; }
.topbar-brand img { border-radius: 6px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

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

.nav-link-item.active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: inset 3px 0 0 #a5b4fc;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.9rem 0.6rem 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 0.75rem;
}

.avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #818cf8, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; flex-grow: 1; }
.sidebar-user-name {
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role { color: rgba(255, 255, 255, 0.55); font-size: 0.76rem; }

.sidebar-logout {
    color: rgba(255, 255, 255, 0.65);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.sidebar-logout:hover { color: #fff; }

.sidebar-offcanvas { background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to)); width: 270px; }
.sidebar-offcanvas .sidebar-brand { color: #fff; }
.sidebar-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255, 255, 255, 0.12); }

.app-main {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border-soft);
    padding: 0.75rem 1.25rem;
    gap: 0.75rem;
}
.topbar-toggle { border: none; font-size: 1.3rem; color: var(--brand); padding: 0 0.25rem; }
.topbar-brand { font-weight: 800; color: var(--brand-dark); display: flex; align-items: center; gap: 0.4rem; }

.app-content {
    flex-grow: 1;
    padding: 1.75rem 2rem 1rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.app-footer {
    text-align: center;
    padding: 1.25rem 0 0.5rem;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.01em; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}
.card-body { padding: 1.25rem 1.4rem; }

/* Dashboard stat cards */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    color: #fff;
    overflow: hidden;
    position: relative;
}
.stat-card .card-body { padding: 1.4rem 1.5rem; }
.stat-card-icon {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2.4rem;
    opacity: 0.25;
}
.stat-card-label { font-size: 0.85rem; font-weight: 600; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card-value { font-size: 2.1rem; font-weight: 800; margin: 0.15rem 0 0; }
.stat-card-hint { font-size: 0.8rem; opacity: 0.85; }

.stat-card.stat-brand { background: linear-gradient(135deg, var(--brand-light), var(--brand-dark)); }
.stat-card.stat-success { background: linear-gradient(135deg, #34d399, #059669); }
.stat-card.stat-warning { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-card.stat-danger { background: linear-gradient(135deg, #f87171, #dc2626); }
.stat-card.stat-neutral { background: linear-gradient(135deg, #94a3b8, #475569); }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 600; font-size: 0.9rem; }
.btn-primary {
    background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
    border: none;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.btn-outline-primary { color: var(--brand); border-color: var(--brand-light); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

/* ---------- Tables ---------- */
table.table {
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.table-responsive {
    border-radius: var(--radius-md);
    scrollbar-width: auto;
}
.table-responsive::-webkit-scrollbar { height: 12px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--brand-light); border-radius: 6px; }
.table-responsive::-webkit-scrollbar-track { background: var(--border-soft); }
table.table { border-color: var(--border-soft); margin-bottom: 0; }
table.table thead th {
    background: #f8f9fc;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border-soft);
}
table.table td, table.table th { padding: 0.7rem 0.85rem; vertical-align: middle; }

/* Scrollbar siempre visible y más gruesa para tablas anchas (ej. Usuarios) */
.users-table-scroll { overflow-x: auto; scrollbar-width: auto; }
.users-table-scroll::-webkit-scrollbar { height: 12px; }
.users-table-scroll::-webkit-scrollbar-thumb { background: var(--brand-light); border-radius: 6px; }
.users-table-scroll::-webkit-scrollbar-track { background: var(--border-soft); }
.users-table-scroll table th:first-child,
.users-table-scroll table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}
.users-table-scroll table thead th:first-child { background: #f8f9fc; }
table.table tbody tr:hover { background-color: var(--brand-soft); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; padding: 0.42em 0.7em; border-radius: 8px; }
.hours-badge-overtime { background-color: #ef4444 !important; }
.hours-badge-ok { background-color: #10b981 !important; }

/* ---------- Alerts / flash ---------- */
.alert { border: none; border-radius: var(--radius-md); font-size: 0.92rem; }

/* ---------- Week navigator ---------- */
.week-nav a { text-decoration: none; }

/* ---------- Schedules grid ---------- */
td.schedule-cell {
    min-width: 140px;
    vertical-align: top;
}
td.schedule-cell .shift-chip {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    cursor: pointer;
    transition: background 0.15s ease;
}
td.schedule-cell .shift-chip:hover { background: #dfe4fd; }
td.schedule-cell .shift-chip .badge { font-size: 0.65rem; margin-left: 3px; vertical-align: middle; }

.day-marker-badge {
    display: inline-block;
    min-width: 26px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 3px 6px;
    margin-bottom: 4px;
    border-radius: 8px;
    background: #fef3c7;
    color: #92400e;
    cursor: pointer;
}

.permiso-badge {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 6px;
    margin-bottom: 4px;
    border-radius: 8px;
    background: #ede9fe;
    color: #5b21b6;
}
.permiso-badge i { font-size: 0.7rem; margin-right: 2px; }

.cell-actions { display: flex; gap: 4px; align-items: center; }

/* ---------- Login ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #4338ca 0%, #1e1b4b 55%, #0f0e2a 100%);
    padding: 1.5rem;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(15, 14, 42, 0.35);
    overflow: hidden;
    max-width: 400px;
    width: 100%;
}
.auth-card-body { padding: 2.25rem 2rem; }
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--brand-dark);
    margin-bottom: 0.25rem;
}
.auth-brand i { color: var(--brand); font-size: 1.5rem; }
.auth-brand img { border-radius: 10px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }
.auth-card .form-control { border-radius: 10px; padding: 0.6rem 0.9rem; border-color: var(--border-soft); }
.auth-card .form-control:focus { border-color: var(--brand-light); box-shadow: 0 0 0 3px var(--brand-soft); }
.auth-card .btn-primary { width: 100%; padding: 0.65rem; margin-top: 0.5rem; }

/* ---------- Misc ---------- */
.form-select, .form-control { border-radius: 10px; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
