/* =========================================================
   Central GrupoJS — Estilos
   ========================================================= */
:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --primary-soft: #e8effd;
    --bg: #f3f5f9;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .06);
    --shadow-lg: 0 10px 30px rgba(17, 24, 39, .18);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; margin-bottom: .25rem; }

/* ---------- Barra superior ---------- */
.topbar {
    background: #0f1c33;
    color: #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 56px;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; }
.brand-name { font-size: 1.02rem; letter-spacing: .2px; }

.main-nav { display: flex; gap: .25rem; flex: 1; }
.nav-link {
    color: #cbd5e1;
    padding: .5rem .8rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: .95rem;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }

.user-menu { position: relative; }
.user-drop summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    padding: .3rem .5rem;
    border-radius: 8px;
}
.user-drop summary::-webkit-details-marker { display: none; }
.user-drop summary:hover { background: rgba(255,255,255,.08); }
.avatar {
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
}
.user-name { color: #fff; font-size: .9rem; }

.drop-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 240px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: .4rem;
    display: flex;
    flex-direction: column;
}
.drop-panel a { padding: .55rem .7rem; border-radius: 7px; color: var(--text); font-size: .9rem; }
.drop-panel a:hover { background: var(--bg); text-decoration: none; }
.drop-user { padding: .55rem .7rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .4rem; display: flex; flex-direction: column; gap: 2px; }
.drop-user span { color: var(--muted); font-size: .8rem; }
.drop-logout { margin-top: .3rem; border-top: 1px solid var(--border); padding-top: .4rem; }
.link-btn {
    background: none; border: 0; cursor: pointer;
    display: flex; align-items: center; gap: .4rem;
    color: var(--danger); font-size: .9rem; font-family: inherit;
    padding: .55rem .7rem; width: 100%; text-align: left; border-radius: 7px;
}
.link-btn:hover { background: var(--danger-soft); }

/* ---------- Contenedor y flashes ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }

.flash {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); color: #14532d; border-color: #86efac; }
.flash-error { background: var(--danger-soft); color: #7f1d1d; border-color: #fca5a5; }
.flash-warning { background: var(--warning-soft); color: #78350f; border-color: #fcd34d; }
.flash-info { background: #e0f2fe; color: #0c4a6e; border-color: #bae6fd; }
.container-flash { max-width: 1180px; margin: .8rem auto 0; }
.flash + .height-passthrough { margin-top: .8rem; }

/* ---------- Títulos y toolbars ---------- */
.page-title { margin-bottom: 1.2rem; }
.page-title h1 { font-size: 1.5rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .15rem; }
.page-title p { color: var(--muted); margin: 0; }

.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #f3f4f6;
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none !important;
    line-height: 1.3;
    transition: filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; filter: none; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-small { padding: .3rem .6rem; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.btn-google { background: #fff; color: #333; border-color: #dadce0; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
}
.form-card > h3 { margin-top: 0; }
.card-narrow { max-width: 560px; }
.hidden { display: none !important; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Formularios ---------- */
form label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; color: #374151; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="month"], input[type="number"], input[type="search"],
input[type="url"], select, textarea {
    font-family: inherit;
    font-size: .95rem;
    padding: .55rem .7rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, .15);
}
textarea { resize: vertical; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .9rem 1rem;
}
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .9rem 1rem 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .9rem 1rem;
}
.form-grid fieldset legend { font-weight: 600; font-size: .85rem; padding: 0 .4rem; color: var(--primary); }
@media (max-width: 620px) { .form-grid fieldset { grid-template-columns: 1fr; } }

.form-inline { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { min-width: 180px; }

.search-form { display: flex; gap: .4rem; }
.search-form input { width: 280px; }
@media (max-width: 620px) { .search-form input { width: 100%; } }

.muted { color: var(--muted); font-size: .83rem; }
.empty-state { color: var(--muted); text-align: center; padding: 2rem 0; margin: 0; }
.text-danger { color: var(--danger); font-weight: 500; }
.text-note { white-space: pre-line; background: var(--bg); padding: .75rem .9rem; border-radius: 8px; }
.hint-horas { margin-top: .6rem; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .65rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table td a { font-weight: 500; }

.row-actions { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* ---------- Dashboard ---------- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.module-card { display: flex; gap: .9rem; color: var(--text); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.module-icon { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.module-card h3 { margin: 0 0 .2rem; }
.module-card p { margin: 0; color: var(--muted); font-size: .85rem; }

.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.4rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; flex-direction: column; }
.stat strong { font-size: 1.5rem; color: var(--primary); }
.stat span { color: var(--muted); font-size: .82rem; }
.small-stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: .14rem .5rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    background: var(--bg);
    color: #374151;
}
.badge-admin { background: var(--danger-soft); color: #b91c1c; }
.badge-editor { background: var(--primary-soft); color: var(--primary-dark); }
.badge-lector { background: #e5e7eb; color: #374151; }
.badge-apto, .badge-justificada, .badge-certificado { background: var(--success-soft); color: #15803d; }
.badge-no_apto, .badge-injustificada { background: var(--danger-soft); color: #b91c1c; }
.badge-pendiente, .badge-documento, .badge-otro { background: #e5e7eb; color: #374151; }
.badge-enfermedad, .badge-medico { background: #ede9fe; color: #6d28d9; }
.badge-enfermedad { background: var(--warning-soft); color: #b45309; }

/* ---------- Listas de definición ---------- */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: .45rem 1rem; margin: .4rem 0; }
.dl dt { color: var(--muted); font-size: .83rem; }
.dl dd { margin: 0; }

/* ---------- Pestañas ---------- */
.tab-nav { display: flex; gap: .3rem; border-bottom: 2px solid var(--border); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tab-btn {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: .6rem .9rem;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { background: var(--bg); border-radius: 999px; padding: .05rem .45rem; font-size: .75rem; margin-left: .25rem; }
.tab-btn.active .tab-count { background: var(--primary-soft); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Archivos ---------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.file-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.file-preview { height: 130px; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.file-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-icon { font-size: 1.1rem; color: var(--danger); background: var(--danger-soft); padding: .4rem .7rem; border-radius: 8px; font-weight: 700; letter-spacing: .5px; }
.file-meta { padding: .7rem .8rem .5rem; flex: 1; }
.file-meta h4 { margin: 0 0 .25rem; font-size: .86rem; }
.file-meta .muted { display: inline-block; }
.file-actions { display: flex; gap: .35rem; flex-wrap: wrap; padding: .4rem .8rem .8rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal { background: #fff; border-radius: 12px; max-width: 92vw; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body img { display: block; max-width: 100%; }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #0f1c33 0%, #1e3a8a 100%);
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}
.login-brand { text-align: center; margin-bottom: 1.4rem; }
.login-logo {
    width: 54px; height: 54px;
    margin: 0 auto .6rem;
    display: grid; place-items: center;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
}
.login-brand h1 { font-size: 1.3rem; margin: 0; }
.login-brand p { color: var(--muted); margin: .15rem 0 0; font-size: .85rem; }
.login-form { display: flex; flex-direction: column; gap: .9rem; }
.login-form label { font-size: .85rem; font-weight: 500; color: #374151; }
.login-divider { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .8rem; margin: 1rem 0; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-back { display: block; text-align: center; font-size: .85rem; color: var(--muted); margin-top: .4rem; }
.login-check { flex-direction: row !important; align-items: center; gap: .5rem; font-weight: 400; }
.login-check input { width: auto; }

/* ---------- 2FA ---------- */
.qrcode-box { display: flex; justify-content: center; padding: 1rem 0; }
.secret-box {
    display: block;
    text-align: center;
    background: var(--bg);
    border-radius: 8px;
    padding: .6rem;
    margin: .4rem 0 .9rem;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .85rem;
    letter-spacing: 2px;
    word-break: break-all;
}
.status-on { color: var(--success); font-weight: 600; margin-right: .5rem; }
.status-off { color: var(--muted); margin-right: .5rem; }
.ok-text { color: var(--success); }
.icon-inline { display: flex; align-items: center; gap: .4rem; }

/* ---------- Footer ---------- */
.footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: .6rem 1rem 2rem;
    display: flex;
    gap: .5rem;
    color: var(--muted);
    font-size: .8rem;
}

@media (max-width: 760px) {
    .brand-name { display: none; }
    .user-name { display: none; }
    .container { padding: 1rem .7rem 2.5rem; }
    .topbar-inner { padding: 0 .6rem; }
}