/* Identidad institucional compartida por planificación, administración y portal docente. */
:root {
    --primary-color: #2b5f9e;
    --ink: #183149;
    --muted: #5e7389;
    --line: #d8e3ef;
    --surface: #ffffff;
    --canvas: #f2f6fb;
    --text-color: var(--ink);
    --text-light: var(--ink);
    --glass-bg: #ffffff;
    --glass-border: var(--line);
    --card-bg: #f6f9fd;
    --glass-shadow: 0 12px 36px rgba(27, 55, 87, .08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: Inter, system-ui, sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 85% 8%, #dce9f9 0, transparent 30%),
        linear-gradient(145deg, #f7faff 0%, #edf3f9 100%);
}
#global-loader[hidden] { display: none; }
#global-loader { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(24, 49, 73, .34); z-index: 5000; }
.global-loader-card { display: flex; align-items: center; gap: 14px; max-width: 100%; padding: 20px 24px; border-radius: 16px; background: white; color: var(--ink); box-shadow: 0 20px 60px rgba(24, 49, 73, .22); font-weight: 700; }
.global-loader-spinner { width: 26px; height: 26px; flex: 0 0 26px; border: 3px solid #d7e6f4; border-top-color: var(--primary-color); border-radius: 50%; animation: loader-spin .75s linear infinite; }
@keyframes loader-spin { to { transform: rotate(360deg); } }
.shape { display: none; }
.shape-1 { background: #9cc8f0; }
.shape-2 { background: #d9e8f9; }
.container { max-width: 1280px; padding: 24px clamp(16px, 3vw, 36px) 64px; }
a { color: var(--primary-color); }
a:hover { color: #174778; }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.025em; }
h1 { text-shadow: none; }
p { line-height: 1.6; }
.eyebrow { display: block; color: var(--primary-color); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }

.site-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 14px clamp(16px, 2vw, 26px); margin-bottom: 28px;
    border: 1px solid rgba(255, 255, 255, .95); border-radius: 20px;
    background: rgba(255, 255, 255, .94); box-shadow: 0 14px 36px rgba(24, 49, 73, .08);
}
.site-brand { display: inline-flex; align-items: center; gap: 16px; color: var(--ink); font-weight: 800; text-decoration: none; white-space: nowrap; }
.site-brand img { width: clamp(145px, 20vw, 225px); height: auto; max-height: 52px; object-fit: contain; }
.site-brand span { padding-left: 16px; border-left: 1px solid var(--line); }
.site-nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.site-nav a { font-size: .86rem; font-weight: 700; text-decoration: none; }
.page-heading { color: var(--ink); text-align: left; margin: 28px 0 26px; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.1; margin: 8px 0; }
.page-heading p { color: var(--muted); max-width: 68ch; margin: 0; }

label, .filters label, .flow-step label, .billing-controls label { color: var(--ink); font-weight: 650; }
input, select, button, .billing-page input, .billing-page select, .billing-dialog input {
    font: inherit; color: var(--ink); background: white;
    border: 1px solid #c8d8e9; border-radius: 10px;
}
input, select, .billing-page input, .billing-page select { min-height: 44px; }
input::placeholder { color: #77899c; }
input:focus, select:focus, button:focus-visible, a:focus-visible,
.billing-page input:focus, .billing-page select:focus {
    outline: 3px solid rgba(43, 95, 158, .25); outline-offset: 2px;
    border-color: var(--primary-color); box-shadow: none; background: white;
}
select option { color: var(--ink); background: white; }
::-webkit-calendar-picker-indicator { filter: none; }
button { min-height: 44px; background: #eaf1f9; color: var(--primary-color); border-color: #c8d8e9; transition: background .15s, box-shadow .15s; }
button:hover { transform: none; background: #dce9f7; }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary, .btn-apply, #btn-filter, #btn-gen-control, #btn-export, #btn-account {
    background: var(--primary-color) !important; border: 1px solid var(--primary-color) !important;
    color: white !important; box-shadow: 0 5px 13px rgba(43, 95, 158, .16);
}
.btn-primary:hover, .btn-apply:hover, #btn-filter:hover, #btn-gen-control:hover, #btn-export:hover, #btn-account:hover { background: #214f85 !important; }
.btn-secondary, .btn-back { background: #edf3fa !important; color: var(--primary-color) !important; border: 1px solid #cbdbea !important; }
.btn-danger, .billing-page button.billing-danger { background: #ae3747 !important; color: white !important; }

.filters, .grouping-options, .resource-group, .summary-card, .flow-step, .info-bar,
.comp-sede-block, .sede-title, .verif-table, .comp-prog-block, .comp-details {
    background: var(--surface); border: 1px solid var(--line);
    color: var(--ink); box-shadow: var(--glass-shadow); backdrop-filter: none;
}
.filters { justify-content: flex-start; }
.summary-card h3, .summary-card p, .resource-header, .flow-step h4, .info-bar,
.info-label, .info-item span:last-child, .flow-step p, .sede-title, .comp-sede-title,
.verif-table th, .verif-table td, .comp-docente, .comp-materia { color: var(--ink); text-shadow: none; }
.flow-step, .comp-sede-block { border-radius: 18px; }
.flow-step { animation: none; }
.flow-step h4 { border-color: var(--line); font-size: 1.1rem; }
.flow-step p { color: var(--muted); }
.info-bar { justify-content: flex-start; }
.info-label { color: var(--muted); }
.empty-state { color: var(--muted); }
.verif-table th { background: #eaf2fb; }
.verif-table td { background: white; }
.verif-table th, .verif-table td { border-color: var(--line); }
.verif-input, .flow-step input[type="text"], .flow-step input[type="number"], .flow-step input[type="file"] { color: var(--ink); background: white; border: 1px solid #c8d8e9; }
.sede-block, .comparison-container { overflow-x: auto; }
.comp-prog-header { background: #f5f8fc; color: var(--ink); }
.comp-details { box-shadow: none; }
.comp-item-row, .resource-header { border-color: var(--line); }
.badg-sys, .badg-ctrl { background: #e8f1fa; color: var(--ink); }
.match-green { background: #ecf8f1; border-color: #258055; }
.match-red { background: #fff0f1; border-color: #c84753; }
.btn-text, .mode-label, .grouping-header, .grouping-options, .grouping-controls { color: var(--ink); }
.group-header, .header-program, .header-day, .header-sede, .header-salon { background: #f1f6fc; color: var(--ink); border-color: var(--line); }
.group-header:hover, .resource-header:hover, .slot-card:hover { background: #e9f2fb; }
.group-select, .group-select option { background: white; color: var(--ink); border-color: #c8d8e9; }
.hierarchy-item label, .summary-card p, .resource-count { color: var(--ink); text-shadow: none; }
.resource-count { background: #e8f1fa; }
.slot-card { background: #f7fafd; border-color: var(--line); color: var(--ink); }
.slot-card:hover { transform: none; }
.btn-verificacion { background: #e9f1fa; color: var(--primary-color); border: 1px solid #c7daed; }
.btn-confirmacion { background: var(--primary-color); color: white; border: 1px solid var(--primary-color); }
.btn-action { box-shadow: 0 5px 15px rgba(27, 55, 87, .1); }

dialog, .billing-dialog { color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 18px; }
dialog::backdrop, .billing-dialog::backdrop { background: rgba(18, 43, 66, .55); }
dialog h2, dialog h3, dialog label { color: var(--ink); }
dialog p { color: var(--muted); }
.billing-page a { color: var(--primary-color); }
.billing-section h2, .billing-section h3, .billing-card h3 { color: var(--ink); }
.billing-card { background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 5px 18px rgba(27, 55, 87, .05); }
.billing-table { color: var(--ink); }
.billing-table th { background: #f1f6fc; color: #315777; white-space: nowrap; }
.billing-table th, .billing-table td { border-bottom: 1px solid var(--line); vertical-align: middle; }
.billing-table tbody tr:hover { background: #f8fbff; }
.billing-status { color: #334b64; background: #eaf0f7; }
.billing-status.firmado, .billing-status.signed { color: #15593c; background: #dff5e8; }
.billing-status.annulled { color: #5c6570; background: #e8edf3; }
.billing-status.requiere_correccion, .billing-status.error_documento { color: #9e2a36; background: #ffe9eb; }
.billing-status.pendiente_firma { color: #765300; background: #fff2cb; }
.billing-warning { color: #694d00; background: #fff5d6; border: 1px solid #ebd18a; }
#admin-message, #teacher-message, #login-message { color: var(--primary-color); }

.teacher-page .page-heading { max-width: 850px; }
.teacher-page #teacher-login { display: grid; gap: 14px; width: min(100%, 560px); margin: 40px auto 0; padding: clamp(26px, 5vw, 56px); }
.teacher-page #teacher-login h2 { font-size: clamp(1.7rem, 4vw, 2.2rem); margin: 0; }
.teacher-page #teacher-login label { display: grid; gap: 10px; }
.teacher-page #teacher-login input { width: 100%; }
.teacher-page #teacher-login button { width: 100%; }
.teacher-page #teacher-login p { margin: 0; font-size: .85rem; }
.teacher-page .teacher-history-cards { display: none; }
.teacher-page .teacher-history-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.teacher-page .teacher-history-card h3 { margin: 0 0 10px; }
.teacher-page .teacher-history-card p { margin: 4px 0; }
.teacher-page .teacher-history-card a { display: inline-block; margin-top: 10px; }
.billing-dialog { width: min(760px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); overflow: auto; padding: clamp(18px, 3vw, 32px); }
.billing-dialog .sign-summary-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f3f7fc; }
.billing-dialog .sign-summary-card strong { display: block; font-size: 1.1rem; color: var(--ink); }
.billing-dialog .sign-summary-card span { display: block; margin-top: 5px; font-weight: 700; color: var(--primary-color); }
.billing-dialog #signature-canvas { display: block; width: 100%; height: clamp(210px, 34vh, 290px); margin-top: 10px; background: white; border: 2px solid #a9c2de; border-radius: 12px; touch-action: none; }
.billing-dialog .sign-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.billing-dialog .sign-actions button { flex: 1 1 160px; }
.billing-dialog #sign-error { min-height: 1.3em; margin: 8px 0 12px; color: #a12f3e; font-weight: 600; }
.teacher-page #teacher-login small { color: var(--muted); }
.teacher-page #teacher-login #login-message { color: #a12f3e; }
.teacher-page .billing-consent input { min-height: auto; width: 20px; height: 20px; flex: 0 0 20px; }
.billing-consent { color: var(--ink); }

.admin-page { background: var(--canvas); }
.admin-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100dvh; }
.admin-sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px; background: #fff; border-right: 1px solid var(--line); padding: 28px 16px; z-index: 30; }
.sidebar-brand { display: grid; gap: 14px; padding: 10px; color: var(--ink); text-decoration: none; font-weight: 800; }
.sidebar-brand img { display: block; width: 205px; max-width: 100%; height: auto; }
.sidebar-caption { margin: 25px 12px 0; color: #7790a8; letter-spacing: .14em; font-size: .67rem; font-weight: 800; }
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-nav a, .sidebar-nav button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 48px; padding: 11px 14px; border: 0; border-radius: 11px; color: #465f77; background: transparent; text-align: left; text-decoration: none; font-size: .9rem; font-weight: 700; }
.sidebar-nav a span, .sidebar-nav button span { width: 23px; text-align: center; font-size: 1.1rem; }
.sidebar-nav a:hover, .sidebar-nav button:hover, .sidebar-nav [aria-current="page"] { color: var(--primary-color); background: #eaf2fb; }
.sidebar-note { margin: auto 12px 0; padding-top: 20px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.sidebar-backdrop { display: none; }
.admin-main { min-width: 0; max-width: 1550px; width: 100%; padding: 26px clamp(18px, 3vw, 46px) 70px; }
.admin-topbar { display: flex; align-items: center; gap: 18px; min-height: 74px; padding: 14px 22px; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--glass-shadow); }
.admin-topbar h1 { margin: 2px 0 0; font-size: 1.35rem; }
.topbar-link { margin-left: auto; font-size: .85rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.menu-toggle { display: none; }
.section-heading { margin: 34px 0 20px; }
.section-heading h2 { font-size: clamp(1.9rem, 3vw, 2.5rem); margin: 7px 0 4px; }
.section-heading p { margin: 0; color: var(--muted); }
.admin-view > .flow-step, .history-panel > .flow-step { display: block; margin: 16px 0; }
.admin-view .billing-grid { margin-top: 16px; }
.admin-view .billing-card { padding: 22px; }
.admin-view .billing-card h4 { margin: 22px 0 8px; }
.admin-view .billing-controls { align-items: flex-end; }
.admin-view .billing-controls label { min-width: 150px; }
.section-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-row h3 { margin: 0; }
.section-row p { margin: 5px 0; }
.history-filters { padding: 18px 22px; }
.history-filters .billing-controls { margin: 0; }
.history-filters .search-label { flex: 1 1 220px; }
.history-tabs { display: flex; gap: 6px; padding: 5px; width: fit-content; margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; background: white; }
.history-tabs button { min-width: 130px; border: 0; background: transparent; color: var(--muted); }
.history-tabs button[aria-selected="true"] { background: var(--primary-color); color: white; }
.summary-line { color: var(--muted); }
.danger-section { border-color: #efd0d3; background: #fffafa; }
.danger-section h3 { color: #8f2b38; }
.danger-section p { max-width: 100ch; }
.admin-view .billing-table-wrap { max-width: 100%; overflow-x: auto; }
.admin-view .billing-table { min-width: 740px; }
.admin-view .billing-table button { margin: 3px 5px 3px 0; white-space: nowrap; }
#loading { color: var(--muted) !important; }
#btn-detallada { color: var(--primary-color) !important; background: #e9f1fa !important; border: 1px solid #c7daed !important; }
#login-modal { width: min(450px, calc(100vw - 28px)); max-width: none; padding: clamp(24px, 4vw, 40px); box-shadow: 0 28px 90px rgba(24, 49, 73, .26); }
#login-modal[open] { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; }
#login-modal input { width: 100%; margin: 12px 0 0; }
#login-modal #login-error { color: #a12f3e; }
#login-modal button { width: 100%; }
#login-modal a { color: var(--primary-color); }

@media (max-width: 900px) {
    .admin-shell { display: block; }
    .admin-sidebar { position: fixed; left: 0; top: 0; width: min(82vw, 290px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 10px 0 32px rgba(24, 49, 73, .15); }
    .admin-sidebar.is-open { transform: translateX(0); }
    .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(20, 42, 64, .45); z-index: 20; }
    .menu-toggle { display: inline-grid; place-items: center; width: 44px; padding: 0; flex: 0 0 44px; }
    .admin-main { padding: 16px 16px 48px; }
}
@media (max-width: 640px) {
    .container { padding: 12px 14px 40px; }
    .site-topbar { padding: 12px 14px; border-radius: 14px; flex-wrap: wrap; }
    .site-brand { gap: 8px; }
    .site-brand img { width: 145px; }
    .site-brand span { font-size: .8rem; padding-left: 8px; }
    .site-nav { width: 100%; justify-content: space-between; gap: 10px; }
    .page-heading { margin: 24px 4px; }
    .filters, .flow-step, .resource-group { padding: 18px; }
    .filters .input-group, .filters button { width: 100%; }
    .action-buttons-section .btn-action { max-width: none; }
    .info-bar { align-items: flex-start; }
    .billing-controls > button, .billing-controls > label { flex: 1 1 100%; }
    .teacher-page .teacher-history-table { display: none; }
    .teacher-page .teacher-history-cards { display: grid; gap: 12px; }
    .billing-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding: 20px 16px 28px; }
    .billing-dialog #signature-canvas { height: clamp(220px, 29dvh, 280px); }
    .billing-dialog .sign-actions { position: sticky; bottom: -28px; background: white; padding: 10px 0 20px; }
    .admin-topbar { padding: 12px 14px; }
    .topbar-link { display: none; }
    .section-row { align-items: flex-start; flex-direction: column; }
    .history-tabs { width: 100%; }
    .history-tabs button { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
