/* Extranet de exámenes · La Purísima */
:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #dde3ea;
    --text: #1c2733;
    --muted: #5d6b7a;
    --primary: #1f4e79;
    --primary-hover: #173c5e;
    --primary-soft: #e6eef6;
    --ok: #1e7a46;
    --ok-soft: #e4f4ea;
    --warn: #8a5a00;
    --warn-soft: #fff4dc;
    --error: #b42318;
    --error-soft: #fdecea;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
code { font-size: .9em; background: var(--primary-soft); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* Barra superior */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .6rem 1.25rem; background: var(--primary); color: #fff;
    position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; }
.brand-mark {
    display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px;
    background: #fff; color: var(--primary); font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}
.topbar-user { display: flex; align-items: center; gap: .75rem; }
.topbar-user a { color: #fff; text-decoration: none; }
.topbar-user small { opacity: .75; margin-left: .25rem; }
.topbar-user form { margin: 0; }

/* Estructura */
.shell { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
    width: 220px; flex-shrink: 0; padding: 1rem .75rem; background: var(--surface);
    border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: .15rem;
}
.sidebar a { padding: .5rem .75rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-soon { margin-top: auto; padding: .75rem; font-size: .8rem; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 1.5rem; max-width: 1200px; }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); padding: .5rem; }
    .sidebar-soon { display: none; }
    .main { padding: 1rem; }
    .topbar-user small { display: none; }
}

/* Tarjetas y estadísticas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.stat:hover { border-color: var(--primary); }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; color: var(--primary); }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-warn .stat-value { color: var(--warn); }
.stat-ok .stat-value { color: var(--ok); }
.stat-error .stat-value { color: var(--error); }

/* Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem 1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
    color: var(--text); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; line-height: 1.3;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: var(--error); color: var(--error); background: var(--error-soft); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; border-color: #fff; }
.btn-sm { padding: .25rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label, .field { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.form small, .field small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, input[type=file] {
    font: inherit; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.check { flex-direction: row !important; align-items: center; gap: .5rem !important; font-weight: 400 !important; }
.check input { width: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { min-width: 180px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .35rem; }

/* Avisos */
.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #b8e2c8; }
.alert-info { background: var(--primary-soft); color: var(--primary); border-color: #c6d8ea; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f1d79a; }
.alert-error { background: var(--error-soft); color: var(--error); border-color: #f5c2bd; }
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-off td { color: var(--muted); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.change { font-size: .85rem; }
.change del { color: var(--error); }
.change ins { color: var(--ok); text-decoration: none; }
.emails { margin: 0; padding: 0; list-style: none; font-size: .9rem; }

details.card summary { cursor: pointer; font-weight: 600; }
details.card[open] summary { margin-bottom: .75rem; }

/* Acceso */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card-wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--primary); margin-bottom: 1.5rem; }
.auth-brand .brand-mark { background: var(--primary); color: #fff; }
.error-box { text-align: center; padding: 1rem 0; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); margin: 0; line-height: 1; }

/* Etiquetas */
.sheet-preview { background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); margin: 0 auto; position: relative; }
.sheet-preview .lbl { position: absolute; border: 1px dashed #c5ced8; display: flex; align-items: center; gap: 4%; padding: 2%; overflow: hidden; font-size: 9px; line-height: 1.2; }
.sheet-preview .lbl.empty { background: repeating-linear-gradient(45deg, #f6f7f9, #f6f7f9 4px, #fff 4px, #fff 8px); }
.sheet-preview .lbl .qr { background: #1c2733; aspect-ratio: 1; height: 80%; flex-shrink: 0; }
.sheet-preview .lbl strong { display: block; }
.labels-layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 980px) { .labels-layout { grid-template-columns: 1fr; } }
.student-pick { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: .5rem; }
.student-pick label { display: flex; align-items: center; gap: .5rem; padding: .2rem .25rem; border-radius: 4px; cursor: pointer; }
.student-pick label:hover { background: var(--bg); }
.student-pick input { width: auto; }

/* Subida de escaneos */
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin: -0.5rem 0 1rem; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.pages-table td { vertical-align: middle; }
.pages-table select { max-width: 360px; }
.pages-table .thumb { width: 60px; border: 1px solid var(--border); border-radius: 3px; cursor: zoom-in; display: block; background: #fff; }
.pages-table tr.row-start td { border-top: 2px solid var(--primary); }
.pages-table tr:first-child.row-start td { border-top: 0; }
.pages-table tr.row-unassigned td { background: var(--warn-soft); }
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .6); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 1rem; max-width: min(900px, 100%); max-height: 100%; display: flex; flex-direction: column; }
.modal-body { overflow: auto; }
.modal-body canvas { max-width: 100%; height: auto; display: block; }
