/* ══════════════════════════════════════════════════════════════════════
   PopularData - Estilos principales
   ══════════════════════════════════════════════════════════════════════ */

:root {
    --primary: #21599E;
    --primary-light: #3670b5;
    --primary-dark: #184278;
    --primary-subtle: rgba(33, 89, 158, 0.08);
    --bg-main: #f5f7fa;
    --bg-white: #ffffff;
    --text-dark: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e2e6ec;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --sidebar-width: 260px;
    --navbar-height: 60px;
    --transition: 150ms ease;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-dark);
    background: var(--bg-main);
    line-height: 1.6;
}

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

/* ── Layout ───────────────────────────────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-header p {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.sidebar-section {
    padding: 10px 20px 5px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.8);
    transition: all var(--transition);
    font-size: 0.9rem;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    border-left: 3px solid #fff;
    padding-left: 17px;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.navbar {
    background: var(--bg-white);
    height: var(--navbar-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-dark);
}

.notification-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--text-dark);
    transition: background var(--transition);
}

.notification-bell:hover {
    background: var(--bg-main);
    text-decoration: none;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-dark);
    transition: all var(--transition);
}

.user-menu-btn:hover { background: var(--bg-main); }

.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 200px;
    z-index: 60;
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-dropdown a,
.user-menu-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    border: none;
    background: none;
    font-size: 0.875rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: background var(--transition);
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
    background: var(--bg-main);
    text-decoration: none;
}

.user-menu-dropdown .divider {
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.user-role-badge {
    font-size: 0.7rem;
    background: var(--primary-light);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
}

.content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ── Page Header ──────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb a { color: var(--primary); }
.breadcrumb span { margin: 0 6px; }

/* ── Cards ────────────────────────────────────────────────────────── */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

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

.card-stat .card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    background: var(--bg-main);
    color: var(--primary);
}

.card-stat .card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.card-stat .card-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Tables ───────────────────────────────────────────────────────── */

.table-container {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.table-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--bg-main);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) { background: rgba(244,246,248,0.5); }

.table-actions {
    display: flex;
    gap: 8px;
}

/* ── Forms ────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.form-group .required::after {
    content: ' *';
    color: var(--danger);
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-dark);
    transition: border-color var(--transition);
    background: var(--bg-white);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(33,89,158,0.15);
}

select.form-input { cursor: pointer; }

textarea.form-input {
    min-height: 80px;
    resize: vertical;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

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

.btn-secondary {
    background: #e5e7eb;
    color: var(--text-dark);
}
.btn-secondary:hover { background: #d1d5db; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #c82333; color: #fff; }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #218838; color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dark);
}
.btn-outline:hover { background: var(--bg-main); }

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 6px;
    border-radius: 6px;
}

/* ── Badges / Status ──────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

.status-completed { color: var(--success); }
.status-draft { color: var(--warning); }
.status-pending { color: var(--text-muted); }
.status-revision { color: var(--danger); }

/* ── Alerts / Messages ────────────────────────────────────────────── */

.messages {
    position: fixed;
    top: 70px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    animation: slideIn 300ms ease;
}

.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-error { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.alert-info { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--info); }

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.5;
    color: inherit;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Pagination ───────────────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-dark);
    transition: all var(--transition);
}

.pagination a:hover {
    background: var(--bg-main);
    text-decoration: none;
}

.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── Form Builder ─────────────────────────────────────────────────── */

.field-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-item {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    transition: box-shadow var(--transition);
}

.field-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.field-item.sortable-ghost {
    opacity: 0.4;
    background: var(--bg-main);
}

.field-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.field-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 4px;
}

.field-drag-handle:active { cursor: grabbing; }

.field-item-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field-item-body .full-width {
    grid-column: 1 / -1;
}

.field-saved-indicator {
    font-size: 0.75rem;
    color: var(--success);
    animation: fadeIn 300ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Form Preview ─────────────────────────────────────────────────── */

.form-preview {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 800px;
    box-shadow: var(--shadow-sm);
}

/* ── Responsive table scroll ─────────────────────────────────────── */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.form-preview .field-preview {
    margin-bottom: 20px;
}

.form-preview .field-heading {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 6px;
    margin-top: 8px;
}

/* ── IFrame Container ─────────────────────────────────────────────── */

.iframe-container {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.iframe-container iframe {
    width: 100%;
    border: none;
}

/* ── Login Page ───────────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background-image: linear-gradient(135deg, rgba(33,89,158,0.85), rgba(24,66,120,0.95)), url("../img/login-bg.92f1bffe0744.jpg");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    padding-bottom: 60px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}

.login-card h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 1.6rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.login-card .form-group { margin-bottom: 16px; }

.login-card .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    justify-content: center;
}

.login-links {
    text-align: center;
    margin-top: 16px;
}

.login-links a {
    font-size: 0.85rem;
    color: var(--primary);
}

.login-links a:hover {
    text-decoration: underline;
}

/* ── Microsoft SSO ───────────────────────────────────────────────── */

.login-divider {
    display: flex;
    align-items: center;
    margin: 20px 0 16px;
    color: #999;
    font-size: 0.85rem;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}
.login-divider span {
    padding: 0 12px;
}

.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s;
}
.btn-microsoft:hover {
    background: #f8f8f8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
    color: #333;
}

/* Badge Microsoft status */
.badge-microsoft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}
.badge-microsoft.linked {
    background: #e6f4ea;
    color: #1a7f37;
}
.badge-microsoft.unlinked {
    background: #f0f0f0;
    color: #666;
}

/* ── Login Footer ─────────────────────────────────────────────────── */

.login-footer {
    position: absolute;
    bottom: 24px;
    left: 0;
    right: 0;
    text-align: center;
}

.login-footer a {
    color: rgba(255,255,255,0.8);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s;
}

.login-footer a:hover {
    color: #fff;
    text-decoration: underline;
}

.login-footer-sep {
    color: rgba(255,255,255,0.4);
    margin: 0 8px;
    font-size: 0.8rem;
}

/* ── Cookie Banner ───────────────────────────────────────────────── */

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: #fff;
    padding: 16px 24px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

.cookie-banner-content {
    max-width: 900px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-banner-content p {
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
    flex: 1;
    min-width: 280px;
}

.cookie-banner-content a {
    color: #a3c4f3;
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.cookie-banner .btn-primary {
    background: #fff;
    color: var(--primary);
    border: none;
}

.cookie-banner .btn-primary:hover {
    background: #e8e8e8;
}

.cookie-banner .btn-outline {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

.cookie-banner .btn-outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: #fff;
}

@media (max-width: 600px) {
    .cookie-banner-content {
        flex-direction: column;
        text-align: center;
    }
    .cookie-banner-actions {
        justify-content: center;
    }
}

/* ── Legal Pages ─────────────────────────────────────────────────── */

.legal-page {
    min-height: 100vh;
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.legal-container {
    max-width: 800px;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    padding: 40px 48px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    line-height: 1.7;
    color: var(--text-dark);
}

.legal-container h1 {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.legal-updated {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.legal-container h2 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-top: 28px;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.legal-container p {
    font-size: 0.92rem;
    margin-bottom: 12px;
}

.legal-container ul {
    margin: 0 0 14px 20px;
    font-size: 0.92rem;
}

.legal-container li {
    margin-bottom: 6px;
}

.legal-container code {
    background: var(--bg-main);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.legal-container a {
    color: var(--primary);
}

.legal-back {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.legal-back:hover {
    text-decoration: underline;
}

.legal-footer-links {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .legal-container {
        padding: 24px 20px;
    }
}

.login-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
}

.login-success {
    background: #d4edda;
    color: #155724;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
}

/* ── Empty States ─────────────────────────────────────────────────── */

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

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 16px;
}

/* ── Section Title ────────────────────────────────────────────────── */

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

/* ── Audit Log ────────────────────────────────────────────────────── */

.log-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.log-item:last-child { border-bottom: none; }

.log-time {
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 130px;
}

.log-action {
    font-weight: 600;
    min-width: 160px;
}

/* ── Notifications ────────────────────────────────────────────────── */

.notification-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.notification-item:last-child { border-bottom: none; }

.notification-unread {
    background: var(--primary-subtle);
    margin: 0 -20px;
    padding: 14px 20px;
    border-radius: 6px;
}

.notification-content p {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

/* ── Calendar ─────────────────────────────────────────────────────── */

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.cal-nav-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
}

.cal-container {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-header-cell {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
}

.cal-header-cell.cal-weekend {
    color: var(--primary);
    opacity: 0.7;
}

.cal-day {
    min-height: 100px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 4px;
    position: relative;
    background: var(--bg-white);
}

.cal-day:nth-child(7n) {
    border-right: none;
}

.cal-day-empty {
    background: var(--bg-main);
    min-height: 60px;
}

.cal-day-today {
    background: var(--primary-subtle);
}

.cal-day-today .cal-day-number {
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cal-day-number {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    padding: 2px 4px;
    margin-bottom: 2px;
}

.cal-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-event {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    border: none;
    text-align: left;
    width: 100%;
    transition: opacity var(--transition);
    line-height: 1.3;
}

.cal-event:hover {
    opacity: 0.8;
}

.cal-event-lock {
    font-size: 0.6rem;
}

.cal-event-time {
    font-weight: 600;
    white-space: nowrap;
}

.cal-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Calendar legend */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cal-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Side panel */
.cal-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    backdrop-filter: blur(2px);
}

.cal-panel-overlay.show {
    display: block;
}

.cal-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-white);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 201;
    transform: translateX(100%);
    transition: transform 250ms ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cal-panel.open {
    transform: translateX(0);
}

.cal-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
}

.cal-panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.cal-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition);
}

.cal-panel-close:hover {
    background: var(--border);
}

.cal-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Event detail */
.cal-detail-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.cal-detail-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.cal-detail-row strong {
    color: var(--text-dark);
}

/* Dashboard calendar summary */
.cal-summary-list {
    list-style: none;
}

.cal-summary-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.cal-summary-item:last-child {
    border-bottom: none;
}

.cal-summary-date {
    flex-shrink: 0;
    text-align: center;
    background: var(--primary-subtle);
    border-radius: 6px;
    padding: 6px 10px;
    min-width: 52px;
}

.cal-summary-date .cal-summary-day {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.cal-summary-date .cal-summary-month {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cal-summary-info h4 {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.cal-summary-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cal-summary-cat {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .cards-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .field-item-body {
        grid-template-columns: 1fr;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .navbar {
        padding: 0 16px;
    }

    .user-menu-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .user-role-badge {
        display: none;
    }

    .messages {
        left: 16px;
        right: 16px;
        max-width: none;
    }

    .login-card {
        margin: 0 16px;
        padding: 28px 24px;
    }

    .table-container {
        border-radius: 0;
        margin: 0 -16px;
        border-left: none;
        border-right: none;
    }

    td, th {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .table-actions {
        flex-direction: column;
        gap: 4px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .log-item {
        flex-direction: column;
        gap: 4px;
    }

    .log-time {
        min-width: auto;
        font-size: 0.75rem;
    }

    .log-action {
        min-width: auto;
    }

    .notification-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .legal-container {
        padding: 24px 16px;
    }

    .legal-footer-links {
        flex-direction: column;
        gap: 10px;
    }

    .help-role-header {
        padding: 14px 16px;
    }

    .help-role-body {
        padding: 16px;
    }

    /* Calendar mobile */
    .cal-day {
        min-height: 60px;
        padding: 2px;
    }

    .cal-day-number {
        font-size: 0.75rem;
    }

    .cal-event-time {
        display: none;
    }

    .cal-event {
        font-size: 0.65rem;
        padding: 2px 4px;
    }

    .cal-header-cell {
        font-size: 0.65rem;
        padding: 6px 2px;
    }

    .cal-nav-title {
        font-size: 1rem;
    }

    .cal-panel {
        width: 100vw;
    }

    .cal-legend {
        gap: 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 12px;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

    .card {
        padding: 16px;
    }

    .card-stat .card-value {
        font-size: 1.5rem;
    }

    .form-preview {
        padding: 16px;
    }
}

/* ── Overlay for mobile sidebar ───────────────────────────────────── */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ── Touch-friendly & accessibility ──────────────────────────────── */

@media (pointer: coarse) {
    .sidebar-link {
        padding: 14px 20px;
        min-height: 48px;
    }

    .btn {
        min-height: 44px;
        padding: 10px 18px;
    }

    .btn-sm {
        min-height: 36px;
        padding: 8px 14px;
    }

    .form-input {
        padding: 10px 12px;
        font-size: 16px;
    }

    .pagination a,
    .pagination span {
        padding: 8px 14px;
        min-width: 40px;
        text-align: center;
    }

    .notification-bell {
        width: 44px;
        height: 44px;
    }
}

/* ── Utility ──────────────────────────────────────────────────────── */

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Help page ───────────────────────────────────────────────────── */

.help-card {
    margin-bottom: 20px;
    padding: 0;
    overflow: hidden;
}

.help-role-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
}

.help-role-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.help-role-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.help-role-admin { background: var(--primary); }
.help-role-vicesecretaria { background: #6366f1; }
.help-role-coordinacion { background: #0891b2; }
.help-role-consejeria { background: var(--success); }
.help-role-analista { background: #f59e0b; }
.help-role-general { background: var(--text-muted); }

.help-role-body {
    padding: 20px 24px;
}

.help-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.6;
}

.help-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.help-list li:first-child {
    padding-top: 0;
}

.help-list li strong {
    color: var(--primary);
}
