/* ===== VARIABLES ===== */
:root {
    --bg:           #1a1a2e;
    --bg2:          #16213e;
    --bg3:          #0f3460;
    --accent:       #e94560;
    --accent2:      #f5a623;
    --success:      #2ecc71;
    --danger:       #e74c3c;
    --text:         #eaeaea;
    --text2:        #a0a0b0;
    --border:       rgba(255,255,255,0.08);
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
    --radius:       16px;
    --radius-sm:    8px;
    --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition:   0.2s ease;

    /* Colores calendario — configurables desde panel de gestión */
    --cal-fichaje-ok:      #2ecc71;
    --cal-fichaje-inc:     #f5a623;
    --cal-vacacion:        #3498db;
    --cal-ausencia:        #e67e22;
    --cal-baja:            #7f8c8d;
    --cal-festivo:         #9b59b6;
    --cal-incidencia:      #e74c3c;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ===== LAYOUT ===== */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.screen.active { display: flex; }

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

/* ===== HEADER ===== */
.header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.header-logo {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.5px;
}

/* ===== MAIN CONTENT ===== */
.content {
    flex: 1;
    padding: 20px;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
}

/* ===== LOGIN ===== */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    padding: 40px 24px;
    overflow: hidden;
}

.login-logo {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.login-subtitle {
    color: var(--text2);
    font-size: 0.9rem;
    margin-bottom: 40px;
    text-align: center;
}

.login-form {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text2);
    margin-bottom: 16px;
}

/* ===== BOTÓN FICHAR ===== */
.btn-fichar {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: transform var(--transition), box-shadow var(--transition);
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.btn-fichar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-fichar:hover::after { opacity: 1; }
.btn-fichar:active { transform: scale(0.96); }

.btn-fichar.entrada {
    background: radial-gradient(circle at 30% 30%, #2ecc71, #27ae60);
    box-shadow: 0 8px 32px rgba(46,204,113,0.4);
    color: white;
}

.btn-fichar.salida {
    background: radial-gradient(circle at 30% 30%, #e94560, #c0392b);
    box-shadow: 0 8px 32px rgba(233,69,96,0.4);
    color: white;
}

.btn-fichar.pausa {
    background: radial-gradient(circle at 30% 30%, #f5a623, #d4891a);
    box-shadow: 0 8px 32px rgba(245,166,35,0.4);
    color: white;
}

.btn-fichar.loading {
    background: var(--bg3);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-fichar-icon { font-size: 2.5rem; }
.btn-fichar-text { font-size: 1rem; font-weight: 700; }

/* ===== STATUS BADGE ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 24px;
}

.status-badge.activo {
    background: rgba(46,204,113,0.15);
    color: var(--success);
    border: 1px solid rgba(46,204,113,0.3);
}

.status-badge.inactivo {
    background: rgba(160,160,176,0.1);
    color: var(--text2);
    border: 1px solid var(--border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-dot.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(1.3); }
}

/* ===== HORAS ===== */
.horas-display {
    text-align: center;
    margin-bottom: 8px;
}

.horas-numero {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.horas-label {
    font-size: 0.8rem;
    color: var(--text2);
    margin-top: 4px;
}

/* ===== FICHAJES LIST ===== */
.fichaje-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.fichaje-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.fichaje-icon.entrada {
    background: rgba(46,204,113,0.15);
    color: var(--success);
}

.fichaje-icon.salida {
    background: rgba(233,69,96,0.15);
    color: var(--accent);
}

.fichaje-info { flex: 1; }
.fichaje-tipo { font-size: 0.85rem; font-weight: 600; text-transform: capitalize; }
.fichaje-hora { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }
.fichaje-origen {
    font-size: 0.7rem;
    color: var(--text2);
    background: var(--bg3);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ===== INPUTS ===== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
    width: 100%;
    transition: border-color var(--transition);
    -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

input::placeholder { color: var(--text2); }

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

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

.btn-primary:hover { background: #d63651; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text2);
    padding: 8px 12px;
}

.btn-ghost:hover { color: var(--text); }

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

/* ===== NAV BOTTOM ===== */
.nav-bottom {
    background: var(--bg2);
    border-top: 1px solid var(--border);
    display: flex;
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    gap: 4px;
    cursor: pointer;
    transition: color var(--transition);
    color: var(--text2);
    border: none;
    background: none;
    font-family: var(--font);
}

.nav-item.active { color: var(--accent); }
.nav-item:hover  { color: var(--text); }

.nav-icon { font-size: 1.3rem; }
.nav-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger);  }
.toast.info    { border-color: var(--accent2); color: var(--accent2); }

/* ===== OFFLINE BANNER ===== */
.offline-banner {
    background: var(--accent2);
    color: #1a1a2e;
    text-align: center;
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    display: none;
}

.offline-banner.show { display: block; }

/* ===== CALENDARIO ===== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 12px;
}

.cal-header {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text2);
    padding: 4px 0;
    text-transform: uppercase;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    position: relative;
    transition: background var(--transition);
}

.cal-day:hover         { background: var(--bg3); }
.cal-day.today         { background: var(--accent); color: white; font-weight: 700; }
.cal-day.has-fichaje   { background: rgba(46,204,113,0.15); color: var(--success); }
.cal-day.ausencia      { background: rgba(245,166,35,0.15); color: var(--accent2); }
.cal-day.festivo       { background: rgba(233,69,96,0.1); color: var(--accent); }
.cal-day.otro-mes      { opacity: 0.3; }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text2);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== SPINNER ===== */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text2);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-text { font-size: 0.9rem; }

/* ===== UTILITIES ===== */
.text-center  { text-align: center; }
.text-muted   { color: var(--text2); font-size: 0.85rem; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.w-100 { width: 100%; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }

/* ===== CALENDARIO HISTORIAL ===== */
.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cal-mes-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-weekday {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text2);
    padding: 6px 0;
    text-transform: uppercase;
}

.cal-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    gap: 3px;
}

.cal-cell:hover { background: var(--bg3); }
.cal-cell.otro-mes { opacity: 0.25; pointer-events: none; }

.cal-cell.hoy {
    background: var(--bg3);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.cal-cell.seleccionado { background: var(--accent); }
.cal-cell.seleccionado .cal-num { color: white; }

.cal-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.cal-dots {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 28px;
}

.cal-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== SHEET MODAL ===== */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.sheet-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-radius: 20px 20px 0 0;
    z-index: 201;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 75vh;
    overflow-y: auto;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.sheet.show { transform: translateY(0); }

.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto 0;
}

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

.sheet-fecha {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}

.sheet-close {
    background: var(--bg3);
    border: none;
    color: var(--text2);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sheet-content { padding: 16px 20px; }

.sheet-seccion { margin-bottom: 20px; }

.sheet-seccion-titulo {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text2);
    margin-bottom: 10px;
}

/* ===== LEYENDA CALENDARIO ===== */
.leyenda-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 12px;
    padding: 0 4px;
}

.leyenda-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text2);
    justify-content: flex-start;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
}

.leyenda-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

.leyenda-item.activo {
    border-color: currentColor;
    background: rgba(255,255,255,0.08);
    color: var(--text);
    font-weight: 600;
}

.leyenda-item.inactivo {
    opacity: 0.3;
}

.cal-cell.filtro-inactivo {
    opacity: 0.2;
}

.leyenda-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== ADMIN TABS ===== */
.admin-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text2);
    padding: 12px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font);
    transition: all var(--transition);
}

.admin-tab:hover { color: var(--text); }

.admin-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.admin-tab-content { animation: fadeIn 0.2s ease; }

/* ===== LOGIN FIJO ===== */
#screen-login {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* Resumen — centrado en móvil */
#card-resumen .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    width: 100%;
}

#card-resumen .stat-card {
    min-width: 0;
    padding: 12px 8px;
}

#card-resumen .stat-value {
    font-size: 1.4rem;
}

/* ===== SAFE AREAS — solo móvil ===== */
@media (max-width: 767px) {
    @supports (padding: max(0px)) {
        .header {
            padding-top: max(16px, env(safe-area-inset-top));
        }
        .login-container {
            padding-top:    max(40px, env(safe-area-inset-top));
            padding-bottom: max(40px, env(safe-area-inset-bottom));
        }
        .nav-bottom {
            padding-bottom: max(8px, env(safe-area-inset-bottom));
        }
        .content {
            padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 8px));
        }
        .offline-banner {
            padding-top: max(8px, env(safe-area-inset-top));
        }
    }

    .os-ios .header    { background: var(--bg2); }
    .os-android .header { padding-top: max(16px, env(safe-area-inset-top)); }
}

/* Selector mes historial — solo visible en el calendario */
#screen-historial .header input#hist-mes { display: none; }

/* ===== DESKTOP LAYOUT ≥ 768px — Linear/Notion style ===== */
@media (min-width: 768px) {

    /* ── Variables desktop ── */
    :root {
        --desk-sidebar-w:   200px;
        --desk-header-h:    52px;
        --desk-bg:          #161b27;
        --desk-card:        #1e2433;
        --desk-sidebar:     #13171f;
        --desk-text:        #e2e4e9;
        --desk-text2:       #8b92a5;
        --desk-border:      #2a3142;
        --desk-accent:      #e94560;
        --desk-item-hover:  rgba(255,255,255,0.05);
        --desk-item-active: rgba(233,69,96,0.12);
    }

    /* ── Reset mobile ── */
    body {
        overflow: auto;
        background: var(--desk-bg);
        color: var(--desk-text);
    }

    #app { display: block; min-height: 100vh; }

    /* ── Header ── */
    .header {
        position: fixed;
        top: 0;
        left: var(--desk-sidebar-w);
        right: 0;
        height: var(--desk-header-h);
        background: var(--desk-card);
        border-bottom: 1px solid var(--desk-border);
        padding: 0 24px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        z-index: 100;
        box-shadow: none;
    }

    /* Logo oculto en header — ya aparece en sidebar */
    .header-logo { display: none; }

    /* ── Sidebar ── */
    .nav-bottom {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--desk-sidebar-w);
        background: var(--desk-sidebar);
        border-right: none;
        border-top: none;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 0;
        gap: 0;
        overflow-y: auto;
        z-index: 200;
        /* Reset safe-area móvil */
        padding-bottom: 0 !important;
    }

    /* Logo en sidebar */
    .nav-bottom::before {
        content: '⏱ Kronos';
        display: block;
        padding: 16px 20px;
        font-size: 1.1rem;
        font-weight: 900;
        color: var(--desk-accent);
        letter-spacing: -0.5px;
        border-bottom: 1px solid rgba(255,255,255,0.06);
        margin-bottom: 8px;
    }

    /* Nav items */
    .nav-item {
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        padding: 8px 12px;
        margin: 1px 8px;
        border-radius: 6px;
        gap: 10px;
        color: rgba(255,255,255,0.55);
        background: none;
        border: none;
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.15s ease;
        width: calc(100% - 16px);
    }

    .nav-item:hover {
        background: var(--desk-item-hover);
        color: rgba(255,255,255,0.9);
    }

    .nav-item.active {
        background: var(--desk-item-active);
        color: #ffffff;
        font-weight: 600;
    }

    .nav-icon {
        font-size: 1rem;
        opacity: 0.7;
        width: 20px;
        text-align: center;
        flex-shrink: 0;
    }

    .nav-item.active .nav-icon,
    .nav-item:hover .nav-icon { opacity: 1; }

    .nav-label {
        font-size: 0.85rem;
        text-transform: none;
        letter-spacing: 0;
        font-weight: inherit;
    }

    /* ── Screens ── */
    .screen {
        display: none;
        flex-direction: column;
        margin-left: var(--desk-sidebar-w);
        margin-top: var(--desk-header-h);
        min-height: calc(100vh - var(--desk-header-h));
        background: var(--desk-bg);
        animation: none;
    }

    .screen.active { display: flex; }

    /* ── Login — sin sidebar ── */
    #screen-login {
        margin-left: 0;
        margin-top: 0;
        min-height: 100vh;
        height: 100vh;
        background: var(--desk-bg);
        overflow: auto;
    }

    #screen-login .nav-bottom { display: none !important; }

    .login-logo { color: var(--desk-accent); }

    .login-form input {
        background: var(--desk-card);
        border-color: var(--desk-border);
        color: var(--desk-text);
    }

    /* ── Contenido ── */
    .content {
        max-width: 900px;
        width: 100%;
        padding: 24px 32px;
        margin: 0;
        padding-bottom: 24px !important;
    }

    /* ── Cards ── */
    .card {
        background: var(--desk-card);
        border: 1px solid var(--desk-border);
        border-radius: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        padding: 20px 24px;
    }

    /* Dashboard — cards igual altura */
    .dashboard-grid {
        align-items: stretch;
    }

    .dashboard-grid .card {
        height: 100%;
    }

    .card-title { color: var(--desk-text2); }

    /* ── Textos ── */
    .horas-numero { color: var(--desk-text); }
    .horas-label  { color: var(--desk-text2); }
    .text-muted   { color: var(--desk-text2); }
    .fichaje-tipo { color: var(--desk-text); }
    .fichaje-hora { color: var(--desk-text2); }

    .fichaje-origen {
        background: var(--desk-bg);
        color: var(--desk-text2);
        border: 1px solid var(--desk-border);
    }

    /* ── Fichajes — más compactos ── */
    .fichaje-item {
        padding: 8px 0;
        gap: 10px;
    }

    .fichaje-icon {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .fichaje-tipo { font-size: 0.85rem; }
    .fichaje-hora { font-size: 0.75rem; }

    .fichaje-origen {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* ── Status badge ── */
    .status-badge.inactivo {
        background: rgba(107,114,128,0.1);
        color: var(--desk-text2);
        border-color: var(--desk-border);
    }

    .status-badge.activo {
        background: rgba(46,204,113,0.1);
        color: #2ecc71;
        border-color: rgba(46,204,113,0.3);
    }

    /* ── Dashboard grid ── */
    .dashboard-grid {
        display: grid;
        grid-template-columns: 320px 1fr;
        gap: 20px;
        align-items: start;
    }

    /* ── Stats ── */
    .stat-card {
        background: var(--desk-card);
        border: 1px solid var(--desk-border);
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    .stat-value { color: var(--desk-text); }
    .stat-label { color: var(--desk-text2); }

    /* ── Inputs ── */
    input, select, textarea {
        background: var(--desk-card);
        border-color: var(--desk-border);
        color: var(--desk-text);
    }

    input::placeholder { color: var(--desk-text2); }

    /* ── Botones ── */
    .btn-secondary {
        background: var(--desk-card);
        color: var(--desk-text);
        border-color: var(--desk-border);
    }

    .btn-ghost { color: var(--desk-text2); }
    .btn-ghost:hover { color: var(--desk-text); }

    /* ── Botón fichar ── */
    .btn-fichar {
        width: 150px;
        height: 150px;
    }

    .btn-fichar-icon { font-size: 2rem; }

    /* ── Admin tabs ── */
    #screen-admin > div:nth-child(2) {
        background: var(--desk-card);
        border-bottom: 1px solid var(--desk-border);
        position: sticky;
        top: var(--desk-header-h);
        z-index: 90;
        padding: 0 24px;
	justify-content: center;
    }

    .admin-tab {
        color: var(--desk-text2);
        border-bottom: 2px solid transparent;
        padding: 14px 16px;
        font-size: 0.85rem;
    }

    .admin-tab:hover { color: var(--desk-text); }

    .admin-tab.active {
        color: var(--desk-accent);
        border-bottom-color: var(--desk-accent);
    }

    /* Botón nuevo — no full width en desktop */
    #screen-admin .btn-primary.mb-16 {
        width: auto;
        padding: 10px 20px;
    }

    /* ── Sheet modal centrado ── */
    .sheet {
        max-width: 460px;
        left: 50%;
        right: auto;
        transform: translateX(calc(-50% + var(--desk-sidebar-w) / 2)) translateY(100%);
        border-radius: 16px;
        background: var(--desk-card);
        padding-bottom: 24px;
    }

    .sheet.show {
        transform: translateX(calc(-50% + var(--desk-sidebar-w) / 2)) translateY(0);
        bottom: 24px;
    }

    .sheet-fecha  { color: var(--desk-text); }

    /* ── Calendario ── */
    .leyenda-item  { color: var(--desk-text2); }
    .cal-mes-label { color: var(--desk-text); }
    .cal-num       { color: var(--desk-text); }
    .cal-weekday   { color: var(--desk-text2); }
    .cal-cell:hover { background: rgba(255,255,255,0.04); }

    /* Ocultar selector de mes en header — desktop usa el del calendario */
    #screen-historial .header input[type="month"] {
        display: none;
    }

    /* ── Offline banner ── */
    .offline-banner { margin-left: var(--desk-sidebar-w); }

    /* ── Scrollbar ── */
    ::-webkit-scrollbar       { width: 6px; }
    ::-webkit-scrollbar-track { background: var(--desk-bg); }
    ::-webkit-scrollbar-thumb { background: var(--desk-border); border-radius: 3px; }


    /* ── Calendario desktop — más compacto ── */
    #screen-historial .content {
        max-width: 700px;
    }

    #screen-historial .card {
        padding: 16px;
    }

    .cal-grid {
        gap: 2px;
    }

    .cal-cell {
        aspect-ratio: auto;
        height: 52px;
        border-radius: 6px;
    }

    .cal-weekday {
        font-size: 0.6rem;
        padding: 4px 0;
    }

    .cal-num {
        font-size: 0.8rem;
    }

    /* Leyenda en horizontal debajo, más compacta */
    .leyenda-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 8px;
        margin-top: 12px;
    }

    .leyenda-item {
        font-size: 0.65rem;
        gap: 4px;
    }

    /* ── Contenido centrado — todas las secciones ── */
    .content {
        max-width: 720px;
        width: 100%;
        padding: 32px 40px;
        margin: 0 auto;
        padding-bottom: 32px !important;
    }

    #screen-historial .content { max-width: 580px; }
    #screen-ausencias .content { max-width: 540px; }
    #screen-perfil    .content { max-width: 480px; }
    #screen-admin     .content { max-width: 860px; }

    /* ── Sheet — panel lateral derecho en desktop ── */
    .sheet {
        top: var(--desk-header-h);
        bottom: 0;
        left: auto;
        right: 0;
        width: 320px;
        max-width: 320px;
        max-height: none;
        border-radius: 0;
        transform: translateX(100%);
        padding-bottom: 0;
    }

    .sheet.show {
        transform: translateX(0);
        bottom: 0;
    }

    .sheet-handle { display: none; }

    /* Fichajes en sheet desktop — más compactos */
    .sheet-content .fichaje-item {
        padding: 6px 0;
        gap: 8px;
    }

    .sheet-content .fichaje-icon {
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }

    .sheet-content .fichaje-tipo { font-size: 0.8rem; }
    .sheet-content .fichaje-hora { font-size: 0.7rem; }

    /* Ocultar badge PWA en sheet desktop */
    .sheet-content .fichaje-origen { display: none; }

    /* ── Header — usuario a la derecha ── */
    .header { justify-content: flex-end; }

    .header > span:not(.header-logo) {
        margin-left: auto;
        font-size: 0.85rem;
        color: var(--desk-text2);
    }

}


/* ===== DESKTOP WIDE ≥ 1200px ===== */
@media (min-width: 1200px) {

    :root { --desk-sidebar-w: 220px; }

    .content {
        max-width: 1040px;
        padding: 28px 40px;
    }

    .dashboard-grid {
        grid-template-columns: 340px 1fr;
    }
}
