/* ============================================================
   Variables y reset
   ============================================================ */
:root {
    --blue-900: #1e3a8a;
    --blue-800: #1e40af;
    --blue-600: #2563eb;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;
    --accent:   #0ea5e9;
    --accent-light: #e0f2fe;

    --gray-900: #111827;
    --gray-700: #374151;
    --gray-500: #6b7280;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50:  #f9fafb;

    --red-600:  #dc2626;
    --red-100:  #fee2e2;
    --green-600:#16a34a;
    --green-100:#dcfce7;
    --yellow-600:#ca8a04;

    --radius-sm:  4px;
    --radius:     8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow:    0 1px 4px rgba(0,0,0,.1), 0 4px 16px rgba(0,0,0,.06);

    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 150ms ease;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.55;
    min-height: 100vh;
}

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

/* ============================================================
   Top bar
   ============================================================ */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--blue-900);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1.5rem;
    height: 56px;
    box-shadow: 0 1px 6px rgba(0,0,0,.25);
}

.top-bar__brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    white-space: nowrap;
}

.top-bar__nav {
    display: flex;
    gap: .25rem;
    flex: 1;
}

.top-bar__nav a {
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    font-weight: 500;
    padding: .35rem .75rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}
.top-bar__nav a:hover,
.top-bar__nav a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.top-bar__user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .8rem;
}

.top-bar__username {
    color: rgba(255,255,255,.7);
    font-size: .8rem;
}

.btn-logout {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.85);
    font-size: .8rem;
    font-family: var(--font);
    cursor: pointer;
    padding: .3rem .75rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ============================================================
   Main content
   ============================================================ */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ============================================================
   Login
   ============================================================ */
.login-wrap {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card__logo { margin-bottom: .75rem; }
.login-card__title { font-size: 1.6rem; font-weight: 700; color: var(--blue-900); }
.login-card__subtitle { color: var(--gray-500); font-size: .9rem; margin-bottom: 1.75rem; }

.login-form { text-align: left; }
.login-form .field + .field { margin-top: 1rem; }
.login-form .btn--primary { margin-top: 1.5rem; }

/* ============================================================
   Página genérica
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-title    { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.page-subtitle { font-size: .85rem; color: var(--gray-500); margin-top: .15rem; }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.form-card { padding: 2rem; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn--primary {
    background: var(--blue-800);
    color: #fff;
    border-color: var(--blue-800);
}
.btn--primary:hover { background: var(--blue-900); border-color: var(--blue-900); text-decoration: none; color: #fff; }

.btn--secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn--secondary:hover { background: var(--gray-200); text-decoration: none; color: var(--gray-900); }

.btn--ghost {
    background: transparent;
    color: var(--blue-600);
    border-color: transparent;
}
.btn--ghost:hover { background: var(--blue-50); text-decoration: none; }

.btn--danger {
    background: transparent;
    color: var(--red-600);
    border-color: var(--red-600);
}
.btn--danger:hover { background: var(--red-100); text-decoration: none; }

.btn--sm { padding: .3rem .65rem; font-size: .8rem; }
.btn--full { width: 100%; justify-content: center; }

/* ============================================================
   Formularios
   ============================================================ */
.field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.field + .field { margin-top: 1.25rem; }
.field label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-700);
}
.field input,
.field select,
.field textarea {
    padding: .5rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .9rem;
    color: var(--gray-900);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field input[readonly] { background: var(--gray-100); color: var(--gray-500); cursor: default; }
.field--error input,
.field--error select { border-color: var(--red-600); }
.field__error { font-size: .8rem; color: var(--red-600); }
.field__hint  { font-size: .8rem; color: var(--gray-500); }
.required { color: var(--red-600); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-row + .field,
.form-row + .form-row { margin-top: 1.25rem; }

.form-actions {
    display: flex;
    gap: .75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Toggle checkbox */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    cursor: pointer;
    user-select: none;
}
.toggle input[type="checkbox"] { display: none; }
.toggle__track {
    width: 40px;
    height: 22px;
    background: var(--gray-300);
    border-radius: 99px;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}
.toggle__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}
.toggle input:checked ~ .toggle__track { background: var(--blue-600); }
.toggle input:checked ~ .toggle__track::after { transform: translateX(18px); }
.toggle__label { font-size: .875rem; color: var(--gray-700); }

/* ============================================================
   Alertas
   ============================================================ */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.alert--error { background: var(--red-100); color: var(--red-600); border: 1px solid var(--red-600); }

/* ============================================================
   Search bar
   ============================================================ */
.search-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}
.search-bar__input-wrap {
    position: relative;
    flex: 1;
    max-width: 360px;
}
.search-bar__icon {
    position: absolute;
    left: .65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    pointer-events: none;
}
.search-bar__input {
    width: 100%;
    padding: .45rem .75rem .45rem 2.1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .875rem;
}
.search-bar__input:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ============================================================
   View tabs (agrupación)
   ============================================================ */
.view-tabs {
    display: flex;
    gap: .25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.view-tab {
    padding: .3rem .8rem;
    border-radius: 99px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}
.view-tab:hover { background: var(--gray-200); text-decoration: none; color: var(--gray-900); }
.view-tab.active { background: var(--blue-800); color: #fff; border-color: var(--blue-800); }

/* ============================================================
   Data table
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th {
    padding: .75rem 1rem;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.data-table td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table--compact th { padding: .5rem .75rem; }
.data-table--compact td { padding: .5rem .75rem; }

.th-sort {
    color: var(--gray-500);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.th-sort:hover { color: var(--gray-900); text-decoration: none; }
.th-sort.active { color: var(--blue-600); }
.th-sort.sort-asc::after  { content: ' ↑'; }
.th-sort.sort-desc::after { content: ' ↓'; }

.text-center { text-align: center; }

.actions {
    display: flex;
    gap: .4rem;
    justify-content: flex-end;
    white-space: nowrap;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge--success { background: var(--green-100); color: var(--green-600); }
.badge--info    { background: var(--blue-100);  color: var(--blue-800);  }
.badge--muted   { background: var(--gray-100);  color: var(--gray-500);  }
.badge--danger  { background: var(--red-100);   color: var(--red-600);   }
.badge--subject { background: var(--accent-light); color: #0369a1; font-family: monospace; font-size: .8rem; }
.badge--stage   { background: var(--gray-100);  color: var(--gray-600);  font-weight: 500; }

/* ============================================================
   Accordion
   ============================================================ */
.accordion-group {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: .5rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    background: #fff;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition);
    font-family: var(--font);
}
.accordion-header:hover { background: var(--gray-50); }
.accordion-header.open  { background: var(--blue-50); }

.accordion-label {
    flex: 1;
    font-weight: 600;
    font-size: .9rem;
    color: var(--gray-900);
}
.accordion-count {
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: .75rem;
    font-weight: 600;
    padding: .1rem .5rem;
    border-radius: 99px;
}
.accordion-header.open .accordion-count {
    background: var(--blue-100);
    color: var(--blue-800);
}
.accordion-chevron {
    color: var(--gray-400);
    transition: transform var(--transition);
    flex-shrink: 0;
}
.accordion-header.open .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
    display: none;
    border-top: 1px solid var(--gray-100);
}
.accordion-body.open { display: block; }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}
.empty-state__icon {
    font-size: 3rem;
    font-weight: 700;
    color: var(--gray-300);
    margin-bottom: .5rem;
}
.empty-state h2 { color: var(--gray-700); margin-bottom: .5rem; }

/* ============================================================
   Miscelánea
   ============================================================ */
.inline { display: inline; }
.muted  { color: var(--gray-500); font-size: .8rem; }
small.muted { font-size: .78rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .top-bar__nav { display: none; }
    .main-content { padding: 1rem; }
    .data-table th:nth-child(n+4),
    .data-table td:nth-child(n+4) { display: none; }
}

/* ============================================================
   Toolbar (search bar sobre tabla)
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}
.search-form {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.search-input {
    padding: .4rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    width: 240px;
}
.search-input:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px var(--blue-100);
}

/* ============================================================
   Edición inline
   ============================================================ */
.editable-table td[data-field]:not([data-readonly="true"]) {
    cursor: pointer;
    transition: background .12s;
}
.editable-table td[data-field]:not([data-readonly="true"]):hover {
    background: var(--blue-50);
}
.editable-table td.editing {
    padding: 0;
    background: var(--blue-50);
}
.cell-input {
    width: 100%;
    min-width: 80px;
    padding: .35rem .5rem;
    border: 2px solid var(--blue-600);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: inherit;
    background: #fff;
    outline: none;
    box-sizing: border-box;
}
.cell-input:focus {
    box-shadow: 0 0 0 3px var(--blue-100);
}
.cell--error .cell-input {
    border-color: var(--red-600);
}
.cell--error .cell-input:focus {
    box-shadow: 0 0 0 3px var(--red-100);
}
.row-new td {
    background: var(--blue-50);
}
.row-actions-col { width: 40px; }
.row-actions {
    text-align: center;
    white-space: nowrap;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    color: #fff;
    max-width: 360px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
}
.toast--visible {
    opacity: 1;
    transform: translateY(0);
}
.toast--error   { background: var(--red-600); }
.toast--success { background: var(--green-600); }

/* ============================================================
   Filtros por columna en cabecera
   ============================================================ */
.thead-filters th {
    padding: .3rem .5rem;
    background: #fff;
    border-bottom: 2px solid var(--gray-200);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}
.col-filter {
    width: 100%;
    padding: .25rem .45rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: .78rem;
    font-family: var(--font);
    color: var(--gray-700);
    background: #fff;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    min-width: 0;
}
.col-filter:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 2px var(--blue-100);
}

/* ── Nav groups (dropdown) ───────────────────────────────────────────────── */
.nav-group {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-group__trigger {
    display: flex;
    align-items: center;
    gap: .3rem;
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    font-weight: 500;
    padding: .35rem .75rem;
    border-radius: var(--radius-sm);
    cursor: default;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    user-select: none;
}
.nav-group__trigger.active,
.nav-group:hover .nav-group__trigger {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.nav-chevron {
    width: 10px;
    height: 10px;
    opacity: .7;
    transition: transform .15s;
    flex-shrink: 0;
}
.nav-group:hover .nav-chevron {
    transform: rotate(180deg);
}

.nav-group__menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--blue-900);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    padding: .6rem 0 .35rem;
    min-width: 168px;
    z-index: 200;
    flex-direction: column;
}
.nav-group:hover .nav-group__menu {
    display: flex;
}

.nav-group__menu a {
    color: rgba(255,255,255,.78);
    font-size: .855rem;
    font-weight: 400;
    padding: .45rem 1.1rem;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    border-radius: 0;
}
.nav-group__menu a:hover,
.nav-group__menu a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.nav-group__sep {
    height: 1px;
    background: rgba(255,255,255,.1);
    margin: .3rem .6rem;
    border: none;
}

/* ── Section placeholders ────────────────────────────────────────────────── */
.section-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}
.section-placeholder__icon {
    width: 56px;
    height: 56px;
    margin-bottom: 1.25rem;
    opacity: .35;
}
.section-placeholder__icon svg {
    width: 100%;
    height: 100%;
}
.section-placeholder__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-600);
    margin: 0 0 .5rem;
}
.section-placeholder__desc {
    font-size: .9rem;
    margin: 0 0 1.25rem;
    max-width: 360px;
}
.section-placeholder__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.section-placeholder__list li {
    font-size: .855rem;
    color: var(--gray-400);
    padding: .3rem .8rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

/* ── Export button ───────────────────────────────────────────────────────── */
.export-btn-group {
    display: inline-flex;
    gap: .4rem;
    align-self: center;
}
.btn--export {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .38rem .85rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
    line-height: 1;
    border: 1px solid;
}
.btn--export svg { flex-shrink: 0; }
.btn--export-xls {
    background: #f3fbf5;
    border-color: #2d9048;
    color: #1e7a38;
}
.btn--export-xls:hover { background: #e1f2e6; }
.btn--export-doc {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}
.btn--export-doc:hover { background: #dbeafe; }

/* ============================================================
   Modal de confirmación de borrado
   ============================================================ */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: overlay-in .15s ease;
}
@keyframes overlay-in { from { opacity:0 } to { opacity:1 } }

.confirm-dialog {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 2rem 2rem 1.5rem;
    width: min(420px, 92vw);
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
    animation: dialog-in .15s ease;
    text-align: center;
}
@keyframes dialog-in { from { transform: scale(.95); opacity:0 } to { transform: scale(1); opacity:1 } }

.confirm-dialog__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--red-100);
    color: var(--red-600);
    margin-bottom: 1rem;
}
.confirm-dialog__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 .35rem;
}
.confirm-dialog__record {
    font-size: .9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 .85rem;
    word-break: break-word;
}
.confirm-dialog__warning {
    font-size: .82rem;
    color: var(--gray-500);
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: .6rem .85rem;
    margin: 0 0 1.5rem;
    text-align: left;
    line-height: 1.5;
}
.confirm-dialog__actions {
    display: flex;
    gap: .65rem;
    justify-content: flex-end;
}

/* ============================================================
   Informes — report pivot
   ============================================================ */
.report-tabs {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
}
.report-tab {
    padding: .3rem .9rem;
    border-radius: 99px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.report-tab:hover { background: var(--gray-200); text-decoration: none; color: var(--gray-900); }
.report-tab--active { background: var(--blue-800); color: #fff; border-color: var(--blue-800); }

.report-card { padding: 0; overflow: hidden; }

.report-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Pivot table — fiel al estilo Word: plata + negro + compacto */
.report-table {
    white-space: nowrap;
    border-collapse: collapse;
    font-size: .78rem;
    min-width: 100%;
    font-family: inherit;
}
.report-table th,
.report-table td {
    padding: .3rem .5rem;
    border: 1px solid #000;
    vertical-align: middle;
    line-height: 1.3;
}

/* Cabecera de materias: gris plata + negrita + centrado */
.report-table thead tr:first-child th {
    background: #c0c0c0;
    color: #000;
    font-weight: 700;
    font-size: .78rem;
    text-transform: none;
    letter-spacing: 0;
    text-align: center;
    white-space: normal;
    word-break: break-word;
}
.report-th--group {
    min-width: 80px;
    text-align: center;
    background: #c0c0c0;
}
.report-th--subject {
    min-width: 90px;
}

/* Primera columna: código de grupo — gris plata + negrita + centrado */
.report-td--group {
    background: #c0c0c0;
    font-weight: 700;
    color: #000;
    text-align: center;
    position: sticky;
    left: 0;
    z-index: 1;
}

/* Celdas de datos: fondo blanco, nombre(s) del docente */
.report-td--cell {
    text-align: center;
    background: #fff;
    color: #000;
    min-width: 90px;
    white-space: normal;
    word-break: break-word;
}
.report-td--cell:empty { background: #fff; }
.report-td--exception { background: #fef3c7 !important; }

/* Variante de programa (azul, como en el Word original): oculta por defecto */
.cell-variant {
    display: none;
    font-weight: 700;
    color: #0000ff;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.show-variants .cell-variant { display: inline; margin-right: .25em; }

/* Aulas / zonas: ocultas por defecto, rojas cuando se activan */
.cell-room {
    display: none;
    color: #ff0000;
    font-weight: 600;
}
.show-rooms .cell-room { display: inline; }
/* En la columna de grupo (tabla e informe por grupo) el aula va en línea propia */
.show-rooms .report-td--group .cell-room,
.show-rooms .report-group-header .cell-room { display: block; }

/* Anotaciones sin docente: siempre visibles independientemente de los checkboxes */
.cell-annotation--always { display: inline !important; }

/* Título de sub-tabla (curso) */
.report-year {
    padding: .5rem .85rem .2rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .06em;
    background: #e8e8e8;
    border-bottom: 1px solid #c0c0c0;
}

/* Separación entre sub-tablas */
.report-card + .report-card { margin-top: 1.25rem; }

/* Fila tabs + controles */
.report-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Controles: switcher + checkboxes */
.report-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-shrink: 0;
}

/* Switcher de vista */
.report-view-switch {
    display: flex;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    overflow: hidden;
}
.view-btn {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    font-size: .78rem;
    font-weight: 500;
    color: var(--gray-600);
    background: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.view-btn + .view-btn { border-left: 1px solid var(--gray-300); }
.view-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.view-btn--active {
    background: var(--primary, #2563eb);
    color: #fff;
}
.view-btn--active:hover { background: var(--primary, #2563eb); color: #fff; }

/* Grupo de checkboxes alineado a la derecha */
.report-toggles {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}
.report-rooms-label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .82rem;
    color: var(--gray-600);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

/* Vista 1 visible por defecto; Vista 2 oculta */
.report-view--2 { display: none; }
#report-container.view-2 .report-view--1 { display: none; }
#report-container.view-2 .report-view--2 { display: block; }

/* Zona del grupo en la columna de grupos */
.cell-group-zone {
    display: block;
    font-size: .7em;
    font-weight: 400;
    color: #444;
}

/* Grid de tarjetas por grupo — 2 columnas en pantallas anchas, 1 en móvil */
.report-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Tarjeta de grupo: no desborda hacia la derecha */
.report-group-card {
    min-width: 0;
    overflow: hidden;
}

/* Cabecera de cada tarjeta de grupo */
.report-group-header {
    padding: .45rem .75rem;
    background: #c0c0c0;
    border-bottom: 1px solid #aaa;
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
}
.report-group-code {
    font-size: 1rem;
    font-weight: 700;
}
.report-group-header .cell-group-zone {
    display: inline;
    font-size: .75em;
    color: #444;
}

/* Tabla compacta por grupo: columnas fijas para que el contenido haga wrap */
.report-group-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: .82rem;
}
.report-group-table tr:nth-child(even) td { background: #f7f7f7; }
.report-gtd--subject {
    padding: .3rem .6rem;
    font-weight: 600;
    color: #333;
    width: 42%;
    border-right: 1px solid #e0e0e0;
    vertical-align: top;
    overflow-wrap: break-word;
    word-break: break-word;
}
.report-gtd--cell {
    padding: .3rem .6rem;
    color: #000;
    width: 58%;
    vertical-align: top;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Vista 1 FPGM/FPGS: tarjeta por grupo */
.report-card--group-row { margin-bottom: .75rem; }

/* Título de curso sobre el grid (sección B1, B2, etc.) */
.report-year--section {
    margin-bottom: .5rem;
    border-radius: var(--radius) var(--radius) 0 0;
}
.report-groups-grid + .report-groups-grid { margin-top: 0; }

/* ── Glosario de materias ───────────────────────────────────────────────── */
.report-glossary {
    margin-top: 2rem;
    padding: .875rem 1.25rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.report-glossary__title {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-500);
    margin: 0 0 .6rem;
}
.report-glossary__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: .2rem .75rem;
    margin: 0;
}
.report-glossary__item {
    display: flex;
    gap: .35rem;
    align-items: baseline;
    font-size: .72rem;
    line-height: 1.45;
}
.report-glossary__code {
    font-weight: 700;
    color: var(--gray-800);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 4rem;
}
.report-glossary__code::after { content: '·'; margin-left: .25rem; color: var(--gray-400); }
.report-glossary__desc {
    color: var(--gray-600);
    margin: 0;
}

/* ── Calendario de Evaluaciones ─────────────────────────────────────────── */
.cal-course-section { margin-bottom: 2rem; }

.cal-course-heading {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    padding: .5rem .85rem .2rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .06em;
    background: #e8e8e8;
    border-bottom: 1px solid #c0c0c0;
    border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: .5rem;
}
.cal-slot-count {
    font-size: .72rem;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: none;
    letter-spacing: 0;
}

.cal-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 1rem;
}

.cal-group-card {
    min-width: 0;
    overflow: hidden;
    padding: 0;
}

.cal-group-header {
    padding: .45rem .75rem;
    background: #c0c0c0;
    border-bottom: 1px solid #aaa;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .1rem;
}

.cal-group-code {
    font-size: .95rem;
    font-weight: 700;
}

/* Cita de evaluación: fecha+hora en verde oscuro, encima del código de grupo */
.eval-slot {
    display: block;
    font-size: .68rem;
    font-weight: 600;
    color: #14532d;
    letter-spacing: .02em;
    line-height: 1.4;
    white-space: nowrap;
}

.cal-scroll { overflow-x: auto; }

.cal-table {
    width: 100%;
    table-layout: fixed;
}

.cal-th--subject,
.cal-td--subject { width: 38%; }

.cal-th--teacher,
.cal-td--teacher { width: 62%; }

.cal-td--subject {
    font-weight: 600;
    color: #333;
}

/* Dos vistas: tabla (filas=grupos, cols=materias) y grupos (tarjetas) */
.cal-view--2 { display: none; }
#cal-container.cal-view-2 .cal-view--1 { display: none; }
#cal-container.cal-view-2 .cal-view--2 { display: block; }

/* ── Leyenda de criterios de distribución ─────────────────────────────────── */
.cal-legend {
    margin-top: 2rem;
    padding: .875rem 1.25rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.cal-legend__title {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-500);
    margin: 0 0 .6rem;
}
.cal-legend__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.cal-legend__item {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .75rem;
    line-height: 1.4;
}
.cal-legend__dot {
    flex-shrink: 0;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
}
.cal-legend__dot--applied   { background: #16a34a; }
.cal-legend__dot--exception { background: #d97706; }
.cal-legend__dot--unused    { background: var(--gray-300); }
.cal-legend__rule {
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}
.cal-legend__desc {
    color: var(--gray-400);
    flex: 1;
}
.cal-legend__status {
    font-size: .68rem;
    font-weight: 600;
    white-space: nowrap;
    padding: .1rem .45rem;
    border-radius: 99px;
}
.cal-legend__status--applied   { color: #14532d; background: #dcfce7; }
.cal-legend__status--exception { color: #92400e; background: #fef3c7; }
.cal-legend__status--unused    { color: var(--gray-400); background: var(--gray-100); }

/* ── Botón de info (?) ────────────────────────────────────────────────────── */
.cal-info-btn {
    flex-shrink: 0;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    border: 1px solid var(--gray-300);
    background: transparent;
    color: var(--gray-400);
    font-size: .65rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, color .15s, background .15s;
}
.cal-info-btn:hover {
    border-color: var(--gray-500);
    color: var(--gray-700);
    background: var(--gray-100);
}

/* ── Popup flotante de info ──────────────────────────────────────────────── */
.cal-info-popup {
    position: fixed;
    z-index: 900;
    width: 17rem;
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    padding: .75rem 1rem .875rem;
}
.cal-info-popup__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}
.cal-info-popup__title {
    font-size: .75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.3;
}
.cal-info-popup__close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-top: -.1rem;
}
.cal-info-popup__close:hover { color: var(--gray-700); }
.cal-info-popup__body {
    font-size: .73rem;
    color: var(--gray-600);
    line-height: 1.55;
    margin: 0;
}
.cal-info-popup__badge {
    display: inline-block;
    font-size: .65rem;
    font-weight: 600;
    padding: .1rem .4rem;
    border-radius: 99px;
    vertical-align: middle;
    margin-left: .25rem;
}
.cal-info-popup__badge--applied   { color: #14532d; background: #dcfce7; }
.cal-info-popup__badge--exception { color: #92400e; background: #fef3c7; }
.cal-info-popup__badge--unused    { color: var(--gray-500); background: var(--gray-100); }
.cal-info-popup__violations {
    margin: .55rem 0 0;
    padding-left: 1.1rem;
    font-size: .7rem;
    color: #92400e;
    line-height: 1.55;
}
.cal-info-popup__violations li + li { margin-top: .1rem; }

/* ── Tooltip de materia (activado por click) ──────────────────────────────── */
[data-tooltip] { cursor: pointer; }
.subject-tooltip {
    position: fixed;
    z-index: 1100;
    background: #1e293b;
    color: #f1f5f9;
    font-size: .75rem;
    line-height: 1.4;
    padding: .35rem .6rem;
    border-radius: .35rem;
    max-width: 18rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    pointer-events: none;
}

