/* ── Admin layout ─────────────────────────────────────────── */
.admin-body { background: var(--surface-alt); min-height: 100vh; transition: background 0.2s; }

.admin-nav {
    background: var(--olive-dark);
    color: #fff;
}

.admin-nav-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 52px;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 40px;
}

.admin-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    margin-right: auto;
    text-decoration: none;
    color: inherit;
}

.admin-nav-portal {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    color: rgba(255,255,255,0.65);
    font-size: 12px;
    padding: 3px 9px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.admin-nav-portal:hover { background: rgba(255,255,255,0.1); color: #fff; }

.admin-nav-logo {
    height: 26px;
    filter: brightness(0) invert(1);
    opacity: 0.85;
}

.admin-nav-links {
    display: flex;
    list-style: none;
    gap: 4px;
}

.admin-nav-links a {
    display: block;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 13px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: background 0.12s;
}

.admin-nav-links a:hover,
.admin-nav-links a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.admin-nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255,255,255,0.65);
}

.admin-nav-logout {
    display: inline-flex;
    align-items: center;
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    color: rgba(255,255,255,0.65);
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    box-sizing: border-box;
}

.admin-nav-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

.admin-wrapper { max-width: var(--page-max); margin: 0 auto; padding: 32px 40px; }

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.pagination-bar .portal-pagination { margin: 0; }
.per-page-form { display: inline-flex; align-items: center; }

.admin-main { }

/* ── Page header ──────────────────────────────────────────── */
.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--olive-dark);
    margin: 4px 0 0;
}

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

.back-link {
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
}

.back-link:hover { color: var(--text); }

/* ── Alertas ──────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
}

.alert-success { background: #d2fad2; border: 1px solid #a6f6a6; color: #1c7d29; }
.alert-error   { background: #ffeaea; border: 1px solid #ffadaf; color: #c22124; }

.alert ul { margin: 0; padding-left: 18px; }

/* ── Stats dashboard ──────────────────────────────────────── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-num { font-size: 32px; font-weight: 700; color: var(--olive-dark); line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ── Secciones ────────────────────────────────────────────── */
.admin-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 24px; }

/* Frame for tables outside .admin-section */
.admin-results-count + .admin-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 24px;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.admin-section-header h2 { font-size: 15px; font-weight: 600; margin: 0; }

.admin-section > h2 { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; margin: 0; }

/* ── Tabla ────────────────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
    box-sizing: border-box;
}

.admin-table *,
.admin-table *::before,
.admin-table *::after {
    box-sizing: border-box;
}

/* Anchos de columnas */
.col-numero { width: 12%; }
.col-tipo { width: 8%; }
.col-year { width: 5%; }
.col-descripcion { width: 26%; }
.col-dependencia { width: 12%; }
.col-docs { width: 5%; }
.col-publicado-en { width: 11%; }
.col-creado { width: 8%; }
.col-publicado { width: 8%; }
.col-acciones { width: 150px; }

.admin-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-table th a {
    display: inline-block;
    cursor: pointer;
    padding: 2px 0;
}

/* Estilos para botones de ordenar */
.sort-link {
    text-decoration: none;
    color: inherit;
    font-weight: inherit;
    padding: 4px 6px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sort-link:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--olive);
}

.sort-link-active {
    color: var(--olive);
    font-weight: 600;
    background: rgba(111, 107, 70, 0.08);
}

.sort-link-active:hover {
    background: rgba(111, 107, 70, 0.12);
}

.sort-icon {
    font-size: 11px;
    margin-left: 2px;
}
    transition: color 0.12s;
}

.admin-table th a:hover {
    color: var(--text);
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-table td[data-label="Descripción"] {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.admin-table td[data-label="Dependencia"] {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.admin-table td[data-label="Dependencia"][title],
.admin-table td[data-label="Número"][title],
#docs-tbody tr td:nth-child(2)[title] {
    cursor: help;
}

.admin-table td[data-label="Estado"] {
    text-align: center;
}

.admin-table tbody tr {
    background: white;
}

.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: white; }

.td-actions {
    padding: 12px 16px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.td-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 5px;
}
.td-actions a { color: var(--olive); font-size: 12px; text-decoration: underline; }
.link-action { color: var(--olive); font-size: 12px; text-decoration: underline; }

/* Procedimientos table: ensure consistent row height */
.admin-table-procedimientos .td-actions {
    white-space: nowrap;
}

.empty { padding: 24px 16px; color: var(--muted); text-align: center; }

/* ── Badges de estado ─────────────────────────────────────── */
.estado-badge, .group-estado {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.estado-convocada     { background: #ecf2ff; color: #254c97; }  /* info */
.estado-en_proceso    { background: #ffefb6; color: #936901; }  /* warning */
.estado-fallo_emitido { background: #d2fad2; color: #1c7d29; }  /* success */
.estado-desierta      { background: #ebeade; color: #5f5f55; }  /* neutral */
.estado-cancelada     { background: #ffeaea; color: #c22124; }  /* error */

/* Indicador de publicación con tooltip nativo */
.pub-indicator {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    cursor: default;
    border-bottom: 1px dashed currentColor;
}
.pub-indicator--si     { color: #1c7d29; background: #d2fad2; }
.pub-indicator--no     { color: #c22124; background: #ffeaea; }
.pub-indicator--nunca  { color: #5f5f55; background: #ebeade; }

.tipo-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: var(--radius-min);
    font-size: 11px;
    background: var(--vt-95);
    color: var(--olive-dark);
}

/* ── Meta grid ────────────────────────────────────────────── */
.admin-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 13px;
}

.admin-meta-grid > div { display: flex; flex-direction: column; gap: 4px; }
.meta-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Formularios ──────────────────────────────────────────── */
.admin-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    max-width: 760px;
}

@media (max-width: 700px) {
    .admin-form {
        max-width: 100%;
        padding: 16px;
    }
}

.form-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 160px; }
.form-group-wide { flex: 2; }
.form-group-check { justify-content: flex-end; }

.admin-form label { font-size: 12px; font-weight: 600; color: var(--text); }

.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="number"],
.admin-form input[type="date"],
.admin-form input[type="password"],
.admin-form input[type="file"],
.admin-form select,
.admin-form textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.12s;
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(119,51,87,0.15);
}

.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

.tipos-permitidos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
}
.tipos-permitidos-grid .checkbox-label { font-weight: 400; font-size: 13px; }
.form-hint { font-size: 11px; color: var(--muted); margin: 2px 0 0; }

.form-actions { display: flex; gap: 10px; padding-top: 20px; border-top: 1px solid var(--border); margin-top: 8px; }

/* ── Icon action buttons ─────────────────────────────────── */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--olive);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    padding: 0;
    flex-shrink: 0;
}

.btn-icon:hover { background: var(--btn-bg); color: var(--olive-dark); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon:disabled:hover { background: transparent; color: var(--olive); }

/* Reordenar documentos (arrastrar y soltar) */
.doc-orden-cell { white-space: nowrap; }
.doc-drag-handle {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    cursor: grab;
    padding: 2px;
    vertical-align: middle;
}
.doc-drag-handle:active { cursor: grabbing; }
.doc-pos { margin-left: 4px; font-size: 12px; vertical-align: middle; }
.doc-row-ghost { opacity: 0.45; background: var(--surface-alt); }
.sortable-chosen { background: var(--surface-2); }

.btn-icon-danger {
    color: #c22124;
    border-color: #ffadaf;
    background: #ffeaea;
}

.btn-icon-danger:hover { background: #ffd6d7; border-color: #ff6e70; }

[data-theme="dark"] .btn-icon {
    border-color: #3a3a3a;
    color: #9aaa6a;
}
[data-theme="dark"] .btn-icon:hover { background: #2a2a2a; color: #b8c880; }
[data-theme="dark"] .btn-icon-danger { background: #1a1010; border-color: #4a2020; color: #e06060; }
[data-theme="dark"] .btn-icon-danger:hover { background: #2a1414; }

/* ── Botones ──────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: filter 0.12s;
}

.btn-primary:hover { filter: brightness(0.92); }
.btn-full { width: 100%; justify-content: center; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s;
}

.btn-secondary:hover { background: var(--btn-bg); }

.btn-danger {
    padding: 8px 16px;
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
}

.btn-danger:hover { background: #c22124; }

.btn-danger-sm {
    padding: 4px 10px;
    background: #ffeaea;
    color: #c22124;
    border: 1px solid #ffadaf;
    border-radius: var(--radius-min);
    font-size: 11px;
    cursor: pointer;
}

.btn-danger-sm:hover { background: #ffd6d7; }

/* ── Danger zone ──────────────────────────────────────────── */
.danger-zone {
    margin-top: 32px;
    border: 1px solid #ffadaf;
    border-radius: var(--radius-sm);
    padding: 16px;
    background: #ffeaea;
}

.danger-zone summary {
    font-size: 13px;
    color: #c22124;
    cursor: pointer;
    font-weight: 600;
}

.danger-zone[open] summary { margin-bottom: 12px; }

/* ── Login ────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--surface-alt);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 36px 40px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-md);
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { height: 44px; margin-bottom: 10px; }
.login-header h1 { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.login-header p  { font-size: 13px; color: var(--muted); margin: 0; }

.login-form .form-group { margin-bottom: 14px; }
.login-form label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.login-form input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; box-sizing: border-box; background: var(--surface); color: var(--text); }
.login-note { font-size: 11px; color: var(--muted); text-align: center; margin: 12px 0 0; }

/* ── Botón oficial Llave Morelos (Digital Morelos) ──────────── */
.btn-digital-morelos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn-digital-morelos svg {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}
.btn-digital-morelos.dark {
    background-color: #2d3b2a;
    color: #fff;
    border-color: #f4f5f0;
}
.btn-digital-morelos.dark:hover {
    background-color: #f4f5f0;
    color: #2d3b2a;
}
.btn-digital-morelos.light {
    background-color: #f4f5f0;
    color: #6f7857;
    border-color: #f4f5f0;
}
.btn-digital-morelos.light:hover {
    background-color: #2d3b2a;
    color: #fff;
}
[data-theme="dark"] .btn-digital-morelos.dark {
    background-color: #f4f5f0;
    color: #2d3b2a;
    border-color: #2d3b2a;
}
[data-theme="dark"] .btn-digital-morelos.dark:hover {
    background-color: #2d3b2a;
    color: #fff;
}

.login-local-toggle {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.login-local-toggle summary {
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.login-local-toggle summary::before {
    content: '▸';
    font-size: 10px;
    transition: transform 0.15s;
}

.login-local-toggle[open] summary::before { transform: rotate(90deg); }

.login-local-toggle summary:hover { color: var(--olive-dark); }

/* ── Portal: doc-tipo badge ───────────────────────────────── */
.doc-tipo-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--olive);
    background: #eef0e8;
    padding: 2px 7px;
    border-radius: 3px;
    margin-bottom: 5px;
}

/* ── Portal: group heading right ──────────────────────────── */
.group-heading-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Admin filters ────────────────────────────────────────── */
.admin-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.admin-filter-input,
.admin-filter-select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.admin-filter-input:focus,
.admin-filter-select:focus { border-color: var(--accent); }

.admin-results-count {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 12px;
}

.tipo-chip {
    display: inline-block;
    padding: 2px 7px;
    border-radius: var(--radius-min);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
/* Chips por tipo — tintes derivados de los ramps del DS */
.tipo-lpn   { background: #ecf2ff; color: #254c97; }  /* Blue Informative */
.tipo-itp   { background: #d2fad2; color: #1c7d29; }  /* Green Success */
.tipo-ad    { background: #ffeedd; color: #755937; }  /* Arena */
.tipo-adb   { background: #ffddb6; color: #5b4221; }  /* Arena */
.tipo-ads   { background: #ffd8e7; color: #773357; }  /* Mora */
.tipo-sub   { background: #edf4d1; color: #434a30; }  /* Verde Tierra */
.tipo-com   { background: #b2ccff; color: #254c97; }  /* Blue Informative */
.tipo-paaas { background: #e6f5de; color: #546250; }  /* Bosque */
.tipo-con   { background: #e5dbd7; color: #4a2c20; }  /* Tierra */

/* ── Responsive admin ─────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-stats { grid-template-columns: 1fr 1fr; }
    .admin-form { padding: 16px; }
    .admin-filters { flex-direction: column; align-items: stretch; }
    .admin-filter-select { width: 100%; }
    .admin-section { overflow: visible; }
    .admin-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
        scrollbar-gutter: stable;
    }
}

/* ── Elementos solo visibles en móvil / desktop ───────────── */
.admin-nav-mobile-only { display: none !important; }

/* ── Hamburger button (oculto por defecto, visible en móvil) ─ */
.admin-nav-hamburger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    line-height: 1;
    box-sizing: border-box;
}
.admin-nav-hamburger span {
    display: block;
    width: 16px;
    height: 2px;
    background: rgba(255,255,255,0.75);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}
.admin-nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.admin-nav-hamburger.open span:nth-child(2) { opacity: 0; }
.admin-nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Nav hamburger media query (≤900px) ──────────────────────── */
@media (max-width: 900px) {
    .admin-nav { position: relative; }
    .admin-nav-inner { padding: 0 14px; }
    .admin-nav-hamburger { display: inline-flex; }
    .admin-nav-desktop-only { display: none !important; }
    .admin-nav-mobile-only { display: block !important; }

    /* Ocultar links por defecto, mostrar como dropdown */
    .admin-nav-links {
        display: none;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        background: var(--olive-dark);
        border-top: 1px solid rgba(255,255,255,0.12);
        flex-direction: column;
        gap: 0;
        padding: 4px 0;
        z-index: 100;
        box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    }
    .admin-nav-links.open { display: flex; }
    .admin-nav-links li { width: 100%; }
    .admin-nav-links a {
        display: block;
        padding: 12px 20px;
        border-radius: 0;
        font-size: 14px;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    /* Salir dentro del dropdown */
    .admin-nav-mobile-logout { border-top: 1px solid rgba(255,255,255,0.12); margin-top: 2px; }
    .admin-nav-mobile-logout form { margin: 0; }
    .admin-nav-mobile-logout button {
        width: 100%;
        text-align: left;
        background: none;
        border: none;
        color: rgba(255,255,255,0.75);
        font-size: 14px;
        padding: 12px 20px;
        cursor: pointer;
        font-family: inherit;
    }
    .admin-nav-mobile-logout button:hover { background: rgba(255,255,255,0.08); color: #fff; }

    /* Ocultar columnas en tabla de procedimientos */
    .admin-table-procedimientos .col-year,
    .admin-table-procedimientos .col-dependencia,
    .admin-table-procedimientos .col-docs,
    .admin-table-procedimientos .col-creado {
        display: none;
    }

    .admin-table-procedimientos thead th:nth-child(3),
    .admin-table-procedimientos tbody td:nth-child(3),
    .admin-table-procedimientos thead th:nth-child(5),
    .admin-table-procedimientos tbody td:nth-child(5),
    .admin-table-procedimientos thead th:nth-child(6),
    .admin-table-procedimientos tbody td:nth-child(6),
    .admin-table-procedimientos thead th:nth-child(8),
    .admin-table-procedimientos tbody td:nth-child(8) {
        display: none;
    }

    /* Ajustar anchos para pantallas pequeñas (solo procedimientos) */
    .admin-table-procedimientos .col-numero { width: 15%; }
    .admin-table-procedimientos .col-tipo { width: 12%; }
    .admin-table-procedimientos .col-descripcion { width: 40%; }
    .admin-table-procedimientos .col-publicado-en { width: 15%; }
    .admin-table-procedimientos .col-publicado { width: 6%; }
    .admin-table-procedimientos .col-acciones { width: 150px; }
}

/* Hide user name only on mobile (≤640px) */
@media (max-width: 640px) {
    .admin-nav-user-name { display: none; }
}

@media (min-width: 701px) and (max-width: 900px) {
    /* Tablet 700-900px: Show Descripción, hide Año, Publicado En, and Estado */
    .admin-table-procedimientos td[data-label="Año"],
    .admin-table-procedimientos td[data-label="Dependencia"],
    .admin-table-procedimientos td[data-label="Publicado En"],
    .admin-table-procedimientos td[data-label="Estado"] { display: none; }

    /* Hide corresponding header columns */
    .admin-table-procedimientos th:nth-child(3),
    .admin-table-procedimientos th:nth-child(5),
    .admin-table-procedimientos th:nth-child(7),
    .admin-table-procedimientos th:nth-child(9) { display: none; }

    /* Remove width from hidden columns so they don't take up space */
    .col-year,
    .col-dependencia,
    .col-publicado-en,
    .col-publicado { width: 0 !important; display: none !important; }

    /* Adjust column widths for tablet (total = 90% for larger action buttons) */
    .admin-table-procedimientos .col-numero { width: 14%; }
    .admin-table-procedimientos .col-tipo { width: 10%; }
    .admin-table-procedimientos .col-descripcion { width: 38%; }
    .admin-table-procedimientos .col-docs { width: 8%; }
    .admin-table-procedimientos .col-acciones { width: 20%; }
}

@media (max-width: 700px) {
    /* Mobile: Simplify procedures table, hide less important columns */
    .admin-table-procedimientos td[data-label="Año"],
    .admin-table-procedimientos td[data-label="Descripción"],
    .admin-table-procedimientos td[data-label="Dependencia"],
    .admin-table-procedimientos td[data-label="Estado"] { display: none; }

    /* Hide corresponding header columns - only in procedures table */
    .admin-table-procedimientos th:nth-child(3),
    .admin-table-procedimientos th:nth-child(4),
    .admin-table-procedimientos th:nth-child(5),
    .admin-table-procedimientos th:nth-child(9) { display: none; }

    /* White background for procedures table rows between 700-900px */
    .admin-section-header + .admin-table-wrap .admin-table tbody tr {
        background: white;
    }

    /* Simplify documents table - hide Tipo, Tamaño and Adjuntado columns */
    #docs-tbody tr td:nth-child(2),
    #docs-tbody tr td:nth-child(4),
    #docs-tbody tr td:nth-child(6) { display: none; }

    /* Hide corresponding headers - only in documents table (after .form-hint) */
    .form-hint + .admin-table th:nth-child(2),
    .form-hint + .admin-table th:nth-child(4),
    .form-hint + .admin-table th:nth-child(6) { display: none; }

    /* White background for rows between 700-900px */
    #docs-tbody tr {
        background: white;
    }

    /* Ensure all visible cells align to middle of row */
    #docs-tbody tr td:nth-child(1),
    #docs-tbody tr td:nth-child(3),
    #docs-tbody tr td:nth-child(5),
    #docs-tbody tr td.td-actions {
        vertical-align: middle;
    }

    /* Show Título in documents table */
    #docs-tbody tr td:nth-child(3) {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        padding: 12px 16px;
    }

    /* Make actions column fill the space in mobile */
    #docs-tbody tr td.td-actions {
        padding: 12px;
        width: 100%;
        background: var(--surface);
    }

    /* Allow horizontal scroll if table gets too narrow */
    .admin-table-wrap {
        overflow-x: visible;
        width: 100%;
    }

    .admin-table {
        width: 100%;
        table-layout: auto;
    }
}

@media (max-width: 700px) {
    /* Reducir padding en móvil para más espacio */
    .admin-wrapper {
        padding: 20px 12px;
    }

    /* Switch to card layout at 700px to avoid table decomposition */
    .admin-table-wrap {
        overflow-x: visible;
        margin: 0 -12px;
        padding: 0 12px;
        box-sizing: content-box;
    }

    .admin-table {
        min-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    /* Make section background transparent for card layout visibility */
    .admin-section,
    .admin-results-count + .admin-table-wrap {
        background: transparent;
        border: none;
        padding: 0;
        margin-bottom: 0;
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .admin-section-header {
        padding: 0 0 16px 0;
        border: none;
        background: transparent;
    }

    .admin-table {
        width: 100% !important;
        table-layout: auto;
    }

    .admin-table colgroup {
        display: none;
    }

    .admin-table thead { display: none; }

    .admin-table tbody {
        display: block;
        width: 100%;
    }

    /* Expandir contenido de celdas en móvil */
    .admin-table td {
        display: block;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-break: break-word;
        padding: 12px 16px;
        width: 100% !important;
        box-sizing: border-box;
    }

    .admin-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin: 0 0 12px 0;
        background: var(--surface);
        overflow: visible;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        box-sizing: border-box;
        width: 100%;
    }

    /* Remove hover effect on cards in mobile */
    .admin-table tbody tr:hover {
        background: var(--surface) !important;
    }

    /* Header: Type + Published */
    .admin-table tbody tr td:nth-child(2),
    .admin-table tbody tr td:nth-child(7) {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-low);
        background: white;
        font-size: 11px;
        font-weight: 600;
        order: 1;
    }

    /* Main title: Número */
    .admin-table tbody tr td:nth-child(1) {
        display: flex;
        align-items: center;
        padding: 16px;
        border-bottom: 1px solid var(--border-low);
        background: var(--surface-alt);
        font-size: 15px;
        font-weight: 700;
        color: var(--olive-dark);
        order: 2;
        border-top-left-radius: var(--radius-md);
        border-top-right-radius: var(--radius-md);
        overflow: hidden;
    }

    /* Info: Publicado En (7) */
    .admin-table tbody tr td:nth-child(7) {
        display: flex !important;
        align-items: center;
        padding: 10px 16px;
        border-bottom: none;
        font-size: 12px;
        order: 3;
    }

    /* Hide unwanted columns: Año(3), Dependencia(5), Docs(6), Creado(8) */
    .admin-table tbody tr td:nth-child(3),
    .admin-table tbody tr td:nth-child(5),
    .admin-table tbody tr td:nth-child(6),
    .admin-table tbody tr td:nth-child(8) {
        display: none;
    }

    /* Show Descripción (4) prominently in card layout */
    .admin-table tbody tr td[data-label="Descripción"] {
        display: block !important;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-low);
        background: white;
        font-size: 13px;
        line-height: 1.6;
        word-break: break-word;
        white-space: normal;
        overflow: visible;
        -webkit-line-clamp: unset;
        max-height: unset;
        text-overflow: clip;
        order: 3;
    }

    /* Actions footer */
    .admin-table tbody tr td:nth-child(10) {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding: 12px 16px;
        border-top: 1px solid var(--border-low);
        background: var(--surface-alt);
        order: 4;
        border-bottom-left-radius: var(--radius-md);
        border-bottom-right-radius: var(--radius-md);
        overflow: hidden;
    }

    .admin-table tbody tr td:nth-child(10).td-actions {
        width: 100% !important;
        padding: 12px 16px !important;
    }

    .admin-table td.td-actions .btn-icon {
        width: 36px;
        height: 36px;
    }

    .admin-section { overflow: visible; }

    /* Show Título in documents table cards */
    #docs-tbody tr td:nth-child(3) {
        display: block !important;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-low);
        background: var(--surface);
        font-size: 13px;
        line-height: 1.5;
        word-break: break-word;
        order: 2;
    }

    /* Actions column with header background color in mobile cards */
    #docs-tbody tr td.td-actions {
        display: flex !important;
        align-items: center;
        justify-content: flex-end !important;
        gap: 8px;
        padding: 12px 16px;
        border-bottom: none;
        background: var(--surface-alt);
        border-bottom-left-radius: var(--radius-md);
        border-bottom-right-radius: var(--radius-md);
        overflow: hidden;
    }
}

@media (max-width: 640px) {
    /* Card layout also applies at smaller sizes */
    .admin-table tbody tr td:nth-child(9) {
        width: 100%;
    }

    .admin-table td.empty {
        display: block;
        text-align: center;
        padding: 40px 16px;
        border: none;
    }

    /* Bitácora table - show description in card layout */
    .admin-table tbody tr td[data-label="Descripción"] {
        display: block !important;
        padding: 12px 16px;
        border-top: 1px solid var(--border-low);
        background: white;
        font-size: 12px;
        line-height: 1.5;
        word-break: break-word;
    }
}

@media (max-width: 540px) {
    .admin-stats { grid-template-columns: 1fr; }
    .admin-wrapper { padding: 16px 14px; }
    .admin-nav-user { gap: 6px; }

    .admin-page-header { flex-direction: column; gap: 8px; }
    .admin-page-header h1 { font-size: 18px; }
    .header-actions { width: 100%; }
    .header-actions .btn-primary { flex: 1; justify-content: center; }

    .form-row { flex-direction: column; gap: 12px; }
    .form-group { min-width: unset; }
    .form-group-wide { flex: unset; }

    .admin-form { border-radius: var(--radius-sm); }

    .pag-numbers { display: none; }
}

@media (max-width: 400px) {
    .admin-nav-links a { font-size: 12px; padding: 9px 4px; }
    .admin-nav-brand span { font-size: 12px; }
}

/* ── Admin theme toggle button ────────────────────────────── */
.admin-theme-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 4px;
    padding: 6px 7px;
    cursor: pointer;
    color: rgba(255,255,255,0.65);
    display: inline-flex;
    align-items: center;
    line-height: 1;
    box-sizing: border-box;
    transition: background 0.15s;
}
.admin-theme-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }


/* ── Admin dark mode ──────────────────────────────────────── */
[data-theme="dark"] .admin-section {
    background: #1a1a1a;
    border-color: #2e2e2e;
}
[data-theme="dark"] .admin-section-header,
[data-theme="dark"] .admin-section > h2 {
    border-color: #2e2e2e;
}
[data-theme="dark"] .admin-table th {
    background: #242424;
    color: #b0b0b0;
    border-color: #3a3a3a;
}
[data-theme="dark"] .admin-table td {
    border-color: #3a3a3a;
    color: #e0e0e0;
}
[data-theme="dark"] .admin-table tbody tr {
    background: #1a1a1a;
}
[data-theme="dark"] .admin-table tbody tr:hover { background: #252525; }
[data-theme="dark"] .admin-results-count + .admin-table-wrap {
    background: #1a1a1a;
    border-color: #3a3a3a;
}
[data-theme="dark"] .sort-link {
    color: inherit;
}
[data-theme="dark"] .sort-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #b8c880;
}
[data-theme="dark"] .sort-link-active {
    color: #b8c880;
    background: rgba(184, 200, 128, 0.12);
}
[data-theme="dark"] .sort-link-active:hover {
    background: rgba(184, 200, 128, 0.18);
}
[data-theme="dark"] .admin-meta-grid {
    background: #1a1a1a;
    border-color: #2e2e2e;
}
[data-theme="dark"] .admin-form {
    background: #1a1a1a;
    border-color: #2e2e2e;
}
[data-theme="dark"] .admin-form input,
[data-theme="dark"] .admin-form select,
[data-theme="dark"] .admin-form textarea {
    background: #111;
    border-color: #3a3a3a;
    color: #e2e2e2;
    color-scheme: dark;
}
[data-theme="dark"] .admin-form input:focus,
[data-theme="dark"] .admin-form select:focus,
[data-theme="dark"] .admin-form textarea:focus {
    border-color: var(--olive);
    box-shadow: 0 0 0 3px rgba(102,107,68,0.2);
}
[data-theme="dark"] .form-actions { border-color: #2e2e2e; }
[data-theme="dark"] .stat-card {
    background: #1a1a1a;
    border-color: #2e2e2e;
}
[data-theme="dark"] .admin-filter-input,
[data-theme="dark"] .admin-filter-select {
    background: #1a1a1a;
    border-color: #3a3a3a;
    color: #e2e2e2;
    color-scheme: dark;
}
[data-theme="dark"] .text-muted {
    color: #999 !important;
}
[data-theme="dark"] .admin-table td.text-center {
    color: #e0e0e0;
}
[data-theme="dark"] .empty {
    background: #141414;
    color: #888;
    border-color: #2e2e2e;
}
[data-theme="dark"] .btn-secondary {
    background: #1a1a1a;
    border-color: #2e2e2e;
    color: #e2e2e2;
}
[data-theme="dark"] .btn-secondary:hover { background: #2a2a2a; }
[data-theme="dark"] .danger-zone {
    background: #1a1010;
    border-color: #4a2020;
}

/* Card layout dark mode */
@media (max-width: 700px) {
    [data-theme="dark"] .admin-table tbody tr {
        background: var(--surface);
        border-color: #2e2e2e;
    }
    [data-theme="dark"] .admin-table td { border-color: #2e2e2e; }
}

/* Login dark ───────────────────────────────────────────────── */
[data-theme="dark"] .login-body { background: #0f0f0f; }
[data-theme="dark"] .login-card {
    background: #1a1a1a;
    border-color: #2e2e2e;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
[data-theme="dark"] .login-form input {
    background: #111;
    border-color: #3a3a3a;
    color: #e2e2e2;
    color-scheme: dark;
}
[data-theme="dark"] .btn-hub { background: #2a3d1a; }
[data-theme="dark"] .btn-hub:hover { background: #1e2e10; }

/* ── Bitácora badges ──────────────────────────────────────── */
.bitacora-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.bitacora-verde  { background: #d2fad2; color: #1c7d29; }
.bitacora-rojo   { background: #ffeaea; color: #c22124; }
.bitacora-azul   { background: #ecf2ff; color: #254c97; }

[data-theme="dark"] .bitacora-verde { background: #1a3020; color: #5dbd7a; }
[data-theme="dark"] .bitacora-rojo  { background: #2a1010; color: #e07070; }
[data-theme="dark"] .bitacora-azul  { background: #0d2030; color: #5aabde; }

/* ── Document publish toggle ──────────────────────────────── */
.doc-pub-toggle {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.12s;
}
.doc-pub-toggle:hover { opacity: 0.8; }

.doc-pub-toggle.is-published {
    background: #d2fad2;
    color: #1c7d29;
    border-color: #a6f6a6;
}

.doc-pub-toggle.is-hidden {
    background: var(--surface-2);
    color: var(--muted);
    border-color: var(--border);
}

[data-theme="dark"] .doc-pub-toggle.is-published {
    background: #1a3020;
    color: #5dbd7a;
    border-color: #2a5038;
}
[data-theme="dark"] .doc-pub-toggle.is-hidden {
    background: #2a2a2a;
    color: #888;
    border-color: #3a3a3a;
}

.doc-pub-toggle.is-hidden-danger {
    background: #ffeaea;
    color: #c22124;
    border-color: #ffadaf;
}
[data-theme="dark"] .doc-pub-toggle.is-hidden-danger {
    background: #2a1a1a;
    color: #e07070;
    border-color: #5a2a2a;
}

/* ═══ MÓVIL — objetivos táctiles más grandes en el panel ═══ */
@media (max-width: 768px) {
    .btn-icon { width: 38px; height: 38px; }
    .doc-drag-handle { padding: 6px; }
    .doc-pub-toggle { padding: 7px 14px; font-size: 12px; }
    .admin-nav-links a { padding: 10px 14px; }
    .admin-nav-logout { padding: 9px 13px; }
    .admin-nav-portal { padding: 7px 12px; }
    .admin-nav-hamburger { padding: 8px; }
    .btn-primary, .btn-secondary, .btn-danger { padding: 11px 18px; font-size: 14px; }
    .admin-filter-input, .admin-filter-select { padding: 10px 12px; font-size: 15px; }
    .btn-digital-morelos { padding: 14px 20px; }
}

/* Tooltip nativo en descripción del listado */
.desc-cell[title] { cursor: help; }

/* ── Upload Modal ──────────────────────────────────────── */
.upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.upload-modal.active {
    display: flex;
}

.upload-modal-content {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 32px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.upload-modal-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    border: 4px solid var(--surface-alt);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.upload-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.upload-modal-message {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 0;
}

.upload-modal-progress {
    width: 100%;
    height: 6px;
    background: var(--surface-alt);
    border-radius: 3px;
    margin: 16px 0 12px;
    overflow: hidden;
}

.upload-modal-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.upload-modal-percent {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin: 0;
}

.upload-modal-success {
    color: #1c7d29;
}

.upload-modal-success .upload-modal-spinner {
    border-top-color: #1c7d29;
    animation: none;
    position: relative;
}
