:root {
    /* Paleta oficial extraída del CSS real de congresogro.gob.mx (tema "egovt") */
    --brand: #39515e;
    --brand-light: #4d6a7a;
    --brand-dark: #202b5d;
    --brand-gray: #808080;
    --accent-gold: #ffc689;
    --bg: #f4f2f0;
    --card: #ffffff;
    --text: #435363;
    --muted: #62718d;
    --border: #e4e0dc;
}

body.app-body, body { font-family: 'Nunito Sans', Arial, sans-serif; }
h1, h2, h3, .gaceta-doc-title strong { font-family: 'Cabin', 'Nunito Sans', Arial, sans-serif; color: var(--brand-dark); }

* { box-sizing: border-box; }

body.app-body {
    background: var(--bg);
    font-family: 'Poppins', Arial, sans-serif;
    color: var(--text);
    margin: 0;
}

/* ==== Header: barra fija con logo, enlaces por rol y acciones de usuario ==== */

.navbar-wrapper {
    position: sticky;
    top: 0;
    z-index: 900;
    padding: 14px 20px 0;
}

.navbar {
    position: relative;
    max-width: 1320px;
    margin: 0 auto;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 20px;
    background: var(--brand);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 18px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 10px 30px rgba(32,43,93,.18);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-family: 'Cabin', 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.brand-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255,255,255,.14);
    flex-shrink: 0;
    overflow: hidden;
}

.brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.navbar-menu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    margin-left: 18px;
    margin-right: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .2px;
    white-space: nowrap;
    transition: background .2s ease;
}

.nav-link i { font-size: 12px; opacity: .9; }

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.16);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
}

.avatar {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-gold);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
}

.user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.1);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s ease;
}

.icon-button:hover { background: rgba(255,255,255,.2); }

/* Submenú "Registros › Gacetas" (solo escritorio, roles editor/su) */
.nav-item {
    position: relative;
}

.nav-caret {
    font-size: 9px;
    margin-left: 3px;
    opacity: .85;
}

.dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 200px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(32,43,93,.2);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
    z-index: 20;
}

.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.dropdown-item:hover {
    background: var(--bg);
    color: var(--brand);
}

.dropdown-item i { width: 14px; text-align: center; color: var(--brand); }

.mobile-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

.mobile-menu {
    display: none;
}

/* Espacio para que el contenido inicie justo debajo de la barra */
#page-wrap {
    padding-top: 24px;
}

@media (max-width: 860px) {
    .navbar-menu { display: none; }

    .navbar-wrapper { padding: 0; }

    .navbar {
        border-radius: 0 0 22px 22px;
        max-width: none;
    }

    .brand-text { display: none; }

    .user-name { display: none; }

    .user-pill { padding: 0; background: transparent; }

    .mobile-toggle { display: flex; }

    .navbar-actions { margin-left: auto; }

    .mobile-menu {
        position: absolute;
        top: calc(100% + 8px);
        left: 12px;
        right: 12px;
        padding: 8px;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 15px 40px rgba(32,43,93,.2);
    }

    .navbar.menu-open .mobile-menu { display: block; }

    .mobile-link {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 12px;
        border-radius: 10px;
        color: var(--text);
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
    }

    .mobile-link:hover { background: var(--bg); }

    .mobile-link i { width: 18px; text-align: center; color: var(--brand); }

    .mobile-sublink {
        padding-left: 32px;
        font-size: 13px;
        font-weight: 500;
        color: var(--muted);
    }

    .mobile-sublink i { color: var(--brand-light); }

    .mobile-section {
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid var(--border);
    }

    #page-wrap { padding-top: 16px; }
}

.app-main {
    max-width: 1320px;
    margin: 30px auto;
    padding: 0 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 18px;
}

.alert-ok {
    background: #e4f6e9;
    color: #1f7a3d;
    border: 1px solid #b7e4c4;
}

/* Filtros */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--card);
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.filter-bar select,
.filter-bar input {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    flex: 1 1 180px;
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 640px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select,
    .filter-bar input,
    .filter-bar button {
        flex: none;
        width: 100%;
    }
}

.filter-bar button {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
}

/* Tabla */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    table-layout: auto;
}

.data-table th, .data-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}

.data-table th {
    background: #f8f6f4;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

.link-danger {
    background: none;
    border: none;
    color: #c0392b;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    margin-left: 10px;
    font-size: 13px;
}

/* Íconos de acción (Editar/Eliminar) — solo en la tabla de Registros de la Gaceta */
.row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: var(--bg);
    color: var(--brand);
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s ease, color .15s ease;
}

.icon-action:hover {
    background: var(--brand);
    color: #fff;
}

.icon-action-danger {
    color: #c0392b;
}

.icon-action-danger:hover {
    background: #c0392b;
    color: #fff;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 18px;
}

.pagination a {
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--card);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
}

.pagination a.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.pagination a.pagination-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    padding: 6px 0;
}

.pagination-ellipsis {
    padding: 6px 4px;
    color: var(--muted);
    font-size: 13px;
}

/* Formulario de edición */
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--card);
    padding: 24px;
    border-radius: 10px;
    border: 1px solid var(--border);
    max-width: 720px;
}

.edit-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-top: 10px;
}

.edit-form select,
.edit-form input,
.edit-form textarea {
    padding: 9px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 14px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
}

.form-actions button {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-secondary {
    padding: 10px 22px;
    border-radius: 6px;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

/* Calendario */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
}

.calendar-header h1 { margin: 0; font-size: 22px; }

.cal-nav {
    text-decoration: none;
    font-size: 20px;
    color: var(--brand);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.cal-weekday {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 600;
    padding-bottom: 4px;
}

.cal-cell {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    min-height: 96px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cal-empty { background: transparent; border: none; }

.cal-day-number {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

.cal-cell.is-today {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(138,106,31,.18);
}

.cal-cell.has-gazette {
    background: #eef2f4;
}

.cal-gazette-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    max-height: 70px;
}

.cal-gazette-chip {
    background: var(--brand-light);
    color: #fff;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 5px;
    text-decoration: none;
    line-height: 1.3;
}

.cal-gazette-chip:hover { background: var(--brand); }

@media (max-width: 720px) {
    .calendar-grid { grid-template-columns: repeat(7, minmax(36px, 1fr)); }
    .cal-cell { min-height: 70px; padding: 4px; }
    .cal-gazette-chip { font-size: 9px; }
}

/* Editor de texto ligero (contenteditable) */
.lite-editor-toolbar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: #f8f6f4;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 6px;
}

.lite-editor-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 9px;
    cursor: pointer;
    font-size: 13px;
}

.lite-editor-btn:hover { background: var(--brand-light); color: #fff; }

.lite-editor-area {
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    padding: 12px;
    min-height: 180px;
    background: #fff;
    font-size: 14px;
    line-height: 1.5;
}

/* Búsqueda pública de leyes */
.law-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.law-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.law-card h3 { margin: 0 0 6px; font-size: 16px; }

/* ===== Agenda de diputados (rol burgess) — diseño MOBILE-FIRST =====
   Se define primero para pantallas pequeñas; @media (min-width) va ampliando. */
.agenda-mobile {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 0 40px;
}

.agenda-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.agenda-date {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.agenda-card h3 {
    margin: 0 0 6px;
    font-size: 17px;
    line-height: 1.3;
}

.agenda-meta {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 12px;
}

.agenda-link {
    display: inline-block;
    background: var(--brand-light);
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
    text-align: center;
}

/* A partir de tablet/escritorio, la agenda pasa a grid de columnas */
@media (min-width: 640px) {
    .agenda-mobile {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .agenda-link { width: auto; }
}

@media (min-width: 1024px) {
    .agenda-mobile {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Directorio de diputados (mobile-first) */
.directory-group {
    margin-bottom: 24px;
}

.directory-group h2 {
    font-size: 15px;
    color: var(--brand);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.directory-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.directory-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.directory-card img,
.directory-avatar-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 8px;
}

.directory-avatar-placeholder {
    background: var(--brand-light);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
}

.directory-name {
    font-size: 12px;
    display: block;
}

@media (min-width: 640px) {
    .directory-cards { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .directory-cards { grid-template-columns: repeat(6, 1fr); }
}

/* Búsqueda pública mobile (diputados) */
.search-mobile-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-mobile-form input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
}

.search-mobile-form button {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 0 18px;
    border-radius: 8px;
}

/* Sección informativa de Leyes (links permanentes, sin CRUD) */
.laws-intro {
    color: var(--muted);
    margin: -6px 0 20px;
    font-size: 14px;
}

.laws-groups {
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
}

@media (min-width: 900px) {
    .laws-groups { grid-template-columns: 2fr 1fr; align-items: start; }
}

.laws-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--brand-dark);
    margin: 0 0 12px;
}

.laws-group-title i { color: var(--brand); }

.laws-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.laws-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.laws-item:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(32,43,93,.08);
}

.laws-item-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg);
    color: var(--brand);
    font-size: 15px;
}

.laws-item:hover .laws-item-icon {
    background: var(--brand);
    color: #fff;
}

.laws-item-label { flex: 1; }

.laws-item-arrow {
    color: var(--border);
    font-size: 12px;
}

.laws-item:hover .laws-item-arrow { color: var(--brand); }

.laws-item-featured {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.laws-item-featured .laws-item-icon {
    background: rgba(255,255,255,.15);
    color: var(--accent-gold);
}

.laws-item-featured .laws-item-arrow { color: rgba(255,255,255,.7); }

.laws-item-featured:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

/* Hub de catálogos */
.hub-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.hub-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.hub-card:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(32,43,93,.08);
}

.hub-card-icon {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--bg);
    color: var(--brand);
    font-size: 19px;
    transition: background .15s ease, color .15s ease;
}

.hub-card:hover .hub-card-icon {
    background: var(--brand);
    color: #fff;
}

.hub-card-label {
    font-size: 14.5px;
    line-height: 1.3;
}

@media (min-width: 640px) {
    .hub-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .hub-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Toolbar de catálogos CRUD */
.crud-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.crud-toolbar h1 { margin: 0; font-size: 20px; }

.btn-primary {
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 14px;
}

.btn-primary:hover { background: var(--brand-light); }

/* Previsualización inline del PDF al editar */
.pdf-preview {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 8px 0;
}

.pdf-preview iframe {
    width: 100%;
    height: 420px;
    border: none;
}

/* Toolbar del calendario (filtro legislatura + toggle vista semanal/mensual) */
.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.calendar-filter {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
}

.calendar-filter select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* Vista semanal (timeline) */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline-day {
    display: flex;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}

.timeline-day.is-today {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(138,106,31,.18);
}

.timeline-day-label {
    min-width: 70px;
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: var(--muted);
}

.timeline-day-label strong {
    color: var(--text);
    font-size: 13px;
}

.timeline-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.timeline-chip {
    background: var(--brand-light);
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
}

.timeline-chip:hover { background: var(--brand); }

.timeline-empty {
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

@media (max-width: 640px) {
    .timeline-day { flex-direction: column; gap: 6px; }
    .timeline-day-label { flex-direction: row; gap: 6px; }
}

/* ==== Visor de la Gaceta (documento por fecha) ==== */
.gaceta-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    position: relative;
}

.gaceta-sumario-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.sidebar-toggle {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-toggle:hover { background: #eef2f4; }

/* Botón para volver a abrir la barra: pequeño, pegado a la orilla, no reserva espacio en el layout */
.sidebar-open {
    display: none;
    position: sticky;
    top: 84px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
    align-self: flex-start;
}

.sidebar-open:hover { background: #eef2f4; }

.gaceta-layout.sidebar-collapsed .gaceta-sidebar {
    display: none;
}

.gaceta-layout.sidebar-collapsed .sidebar-open {
    display: block;
}

.gaceta-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.gaceta-main {
    flex: 1;
    min-width: 0;
}

/* Mini calendario */
.mini-cal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 18px;
}

.mini-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
}

.mini-cal-nav {
    text-decoration: none;
    color: var(--brand);
    font-weight: 700;
    padding: 2px 6px;
}

.mini-cal-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.mini-cal-grid th {
    color: var(--muted);
    font-weight: 600;
    padding-bottom: 4px;
}

.mini-cal-grid td {
    text-align: center;
    padding: 2px 0;
}

.mini-cal-day {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 50%;
    color: var(--text);
    text-decoration: none;
}

.mini-cal-day.has-gazette {
    background: var(--brand-light);
    color: #fff;
    font-weight: 600;
}

.mini-cal-day.has-gazette:hover { background: var(--brand); }

.mini-cal-day.is-selected {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.mini-cal-full-link {
    display: block;
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--brand);
    text-decoration: none;
}

/* Gacetas anteriores */
.recent-dates {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
}

.recent-dates h3 {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    margin: 0 0 10px;
}

.recent-dates ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
}

.recent-dates li a {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 4px;
    font-size: 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: 5px;
}

.recent-dates li a strong { font-size: 12px; }
.recent-dates li a span { font-size: 11px; color: var(--muted); }

.recent-dates li a:hover { background: #eef2f4; }

.recent-dates li a.is-active {
    background: var(--brand);
    color: #fff;
}
.recent-dates li a.is-active span { color: #dbe4ea; }

.muted-note { color: var(--muted); font-size: 12px; }

/* Encabezado del documento */
.gaceta-doc-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: var(--brand);
    color: #fff;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 16px;
    text-align: center;
}

.gaceta-doc-header .cal-nav {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: none;
}

.gaceta-doc-header .cal-nav.is-disabled {
    opacity: .35;
    pointer-events: none;
}

.gaceta-doc-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gaceta-doc-title strong { font-size: 16px; color: #fff; }
.gaceta-doc-title span { font-size: 13px; opacity: .9; color: #fff; }

.gaceta-doc-meta {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
}

.gaceta-search {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    font-size: 14px;
}

.empty-doc {
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    color: var(--muted);
}

/* Sumario */
.gaceta-sumario {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 22px;
}

.gaceta-sumario h2 {
    font-size: 14px;
    letter-spacing: .5px;
    color: var(--brand);
    margin: 0 0 10px;
}

.gaceta-sumario ol {
    margin: 0;
    padding-left: 20px;
    columns: 2;
    column-gap: 30px;
}

.gaceta-sumario li {
    font-size: 13px;
    margin-bottom: 6px;
    break-inside: avoid;
}

.gaceta-sumario a {
    color: var(--text);
    text-decoration: none;
}

.gaceta-sumario a:hover { color: var(--brand); text-decoration: underline; }

.gaceta-sumario h3 {
    font-size: 13px;
    color: var(--brand);
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gaceta-sumario h3:first-of-type { margin-top: 0; }

.gaceta-sumario ul {
    margin: 0 0 4px;
    padding-left: 18px;
}

.sumario-presenter {
    font-size: 11px;
    color: var(--muted);
}

.orden-dia-title {
    text-align: center;
    font-size: 20px;
    letter-spacing: 1px;
    color: var(--brand);
    margin: 0 0 20px;
}

.gaceta-item-action {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 6px;
}

/* Contenido por sección */
.gaceta-section {
    margin-bottom: 26px;
    scroll-margin-top: 20px;
}

.gaceta-section h2 {
    background: #e8edf0;
    color: var(--brand);
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 6px;
    margin: 0 0 12px;
}

.gaceta-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand-light);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 10px;
}

.gaceta-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.gaceta-item-file {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
}

.gaceta-item-body {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

@media (max-width: 900px) {
    .gaceta-layout { flex-direction: column; }
    .gaceta-sidebar { width: 100%; position: static; }
    .gaceta-sumario ol { columns: 1; }
}

/* Contador de documentos por sección en el ÍNDICE */
.section-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    background: #2c3e50;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.section-counter.modern {
    background: transparent;
    color: #2c3e50;
    border: 2px solid #2c3e50;
    border-radius: 6px;
    font-weight: 700;
}

.section-counter.gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    min-width: 35px;
    padding: 0;
}

.section-counter.badge {
    background: #e74c3c;
    border-radius: 20px;
    padding: 0 12px;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Cambio masivo de nivel de acceso */
.bulk-auth-panel {
    background: linear-gradient(135deg, #fff 0%, #eef2f4 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

.bulk-auth-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    background: none;
    border: none;
    padding: 14px 18px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.bulk-auth-icon { font-size: 20px; }

.bulk-auth-toggle span:nth-child(2) {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bulk-auth-toggle strong {
    font-size: 14px;
    color: var(--text);
}

.bulk-auth-toggle small {
    font-size: 12px;
    color: var(--muted);
}

.bulk-auth-chevron {
    color: var(--brand);
    transition: transform .2s;
}

.bulk-auth-toggle.is-open .bulk-auth-chevron {
    transform: rotate(180deg);
}

.bulk-auth-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
}

.bulk-auth-body.is-open {
    max-height: 200px;
}

.bulk-auth-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    padding: 4px 18px 18px;
}

.bulk-auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bulk-auth-field label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--muted);
}

.bulk-auth-field select {
    padding: 9px 12px;
    border-radius: 7px;
    border: 1px solid var(--border);
    min-width: 220px;
    font-size: 13px;
    background: #fff;
}

.bulk-auth-arrow {
    font-size: 20px;
    color: var(--brand-light);
    padding-bottom: 9px;
}

.bulk-auth-submit {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 26px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

.bulk-auth-submit:hover { background: var(--brand-light); }

@media (max-width: 720px) {
    .bulk-auth-form { flex-direction: column; align-items: stretch; }
    .bulk-auth-field select { min-width: 0; width: 100%; }
    .bulk-auth-arrow { display: none; }
    .bulk-auth-body.is-open { max-height: 420px; }
}

/* Tabla de registros (13 columnas):
   - ≥1200px (escritorio): se expande al ancho completo del viewport y el texto
     de cada celda se ajusta en varias líneas dentro de su columna, para que
     TODO sea visible sin scroll horizontal.
   - <1200px (tablet/móvil): el texto NO se parte (nowrap) y el contenedor
     scrollea horizontalmente, para que las columnas sigan siendo legibles. */
.table-scroll {
    border-radius: 10px;
}

@media (min-width: 1200px) {
    .table-scroll {
        width: 100vw;
        max-width: 100vw;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        padding: 0 24px;
        overflow-x: visible;
    }

    .data-table th, .data-table td {
        white-space: normal;
        word-break: break-word;
    }

    .data-table td:nth-child(7) {
        max-width: 260px;
    }
}

@media (max-width: 1199px) {
    .table-scroll {
        overflow-x: auto;
    }

    .data-table th, .data-table td {
        white-space: nowrap;
    }
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-actions .icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: none;
    background: none;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s ease, color .15s ease;
}

.row-actions .icon-action:hover { background: var(--bg); }

.row-actions .icon-edit:hover { color: var(--brand); }

.row-actions .icon-delete:hover { color: #c0392b; }

.link-file {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

/* ==== Accesibilidad ==== */
:root {
    --a11y-font-scale: 1;
}

/* El sitio usa tamaños de fuente en px fijos, así que escalamos con "zoom" en vez de
   font-size en :root (que no cascadearía a los px fijos). Zoom soportado en todos los
   navegadores modernos relevantes (Chrome/Edge/Safari/Firefox 126+). */
.app-main, .gaceta-doc-header {
    zoom: var(--a11y-font-scale);
}

.container-login100 {
    zoom: var(--a11y-font-scale);
}

/* Alto contraste: fondo oscuro, texto blanco, bordes marcados */
html.a11y-high-contrast body.app-body {
    background: #000;
    color: #fff;
}

html.a11y-high-contrast .navbar,
html.a11y-high-contrast .mobile-toggle,
html.a11y-high-contrast .icon-button,
html.a11y-high-contrast .mobile-menu {
    background: #000 !important;
    border: 2px solid #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html.a11y-high-contrast .nav-link,
html.a11y-high-contrast .mobile-link,
html.a11y-high-contrast .user-name { color: #ffe37a !important; }
html.a11y-high-contrast .navbar-brand { color: #ffe37a; }

html.a11y-high-contrast .gaceta-sidebar,
html.a11y-high-contrast .gaceta-sumario,
html.a11y-high-contrast .recent-dates,
html.a11y-high-contrast .mini-cal,
html.a11y-high-contrast .gaceta-item,
html.a11y-high-contrast .data-table,
html.a11y-high-contrast .card,
html.a11y-high-contrast .empty-doc {
    background: #111 !important;
    color: #fff !important;
    border: 1px solid #fff !important;
}

html.a11y-high-contrast .gaceta-section h2,
html.a11y-high-contrast .section-counter {
    background: #fff !important;
    color: #000 !important;
}

html.a11y-high-contrast a { color: #7ec8ff; }
html.a11y-high-contrast .btn-primary,
html.a11y-high-contrast .bulk-auth-submit,
html.a11y-high-contrast .gaceta-doc-header {
    background: #ffe37a !important;
    color: #000 !important;
    border: 1px solid #000 !important;
}

/* Subrayar todos los enlaces (ayuda a usuarios con dificultad para distinguir color) */
html.a11y-underline-links a {
    text-decoration: underline !important;
}

/* Fuente de lectura fácil: sans-serif ancha, buen espaciado entre letras/líneas */
html.a11y-readable-font body {
    font-family: Verdana, Tahoma, 'Trebuchet MS', sans-serif !important;
    letter-spacing: .015em;
    line-height: 1.6 !important;
}

/* Botón flotante */
#a11y-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--brand, #39515e);
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
    z-index: 9999;
}

#a11y-fab:hover { background: var(--brand-light, #4d6a7a); }

#a11y-panel {
    position: fixed;
    bottom: 82px;
    right: 20px;
    width: 260px;
    background: #fff;
    color: #2b2b2b;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,.2);
    padding: 16px;
    z-index: 9999;
}

#a11y-panel h2 {
    font-size: 15px;
    margin: 0 0 12px;
    color: #39515e;
}

.a11y-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}

.a11y-row:last-of-type { border-bottom: none; }

.a11y-btn-group { display: flex; gap: 4px; }

.a11y-btn-group button {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    border: 1px solid #ddd;
    background: #f8f6f4;
    cursor: pointer;
    font-size: 11px;
}

.a11y-btn-group button:hover { background: #eee; }

.a11y-switch-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.a11y-reset-btn {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #f8f6f4;
    cursor: pointer;
    font-size: 12px;
}

.a11y-reset-btn:hover { background: #eee; }

@media (max-width: 480px) {
    #a11y-panel { width: calc(100vw - 40px); right: 20px; }
}
