/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #0D67B3;
    --primary-dark: #0a5291;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #e65100;
    --warning-bg: #fff8e1;
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-600: #6c757d;
    --gray-800: #343a40;
    --gray-900: #212529;
    --sidebar-width: 220px;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.5;
}

/* Auth layout */
.auth-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.auth-container { width: 100%; max-width: 400px; padding: 1rem; }

.auth-card {
    background: #fff;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.auth-card h1 { text-align: center; color: var(--primary); margin-bottom: 0.25rem; font-size: 1.8rem; }
.auth-subtitle { text-align: center; color: var(--gray-600); margin-bottom: 1.5rem; }

/* App layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-800); display: flex; align-items: center; gap: 0.65rem; }
.sidebar-header h2 { font-size: 1.3rem; }
.sidebar-logo { width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0; }
.sidebar-beta { display: inline-block; font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #fff; background: #e67e22; padding: 1px 6px; border-radius: 3px; vertical-align: middle; margin-left: 0.35rem; line-height: 1.6; }

.nav-links { list-style: none; padding: 1rem 0; flex: 1; }
.nav-links li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 1.5rem;
    color: var(--gray-200);
    text-decoration: none;
    transition: background 0.2s;
}
.nav-links li a svg { flex-shrink: 0; opacity: 0.7; }
.nav-links li a:hover svg, .nav-links li a.active svg { opacity: 1; }
.nav-links li a:hover { background: var(--gray-800); color: #fff; }
.nav-links li a.active { background: var(--gray-800); color: #fff; }

/* Nav group (collapsible parent like Taker) */
.nav-group-header {
    display: flex; align-items: center; justify-content: space-between;
}
.nav-group-header a { flex: 1; }
.nav-chevron {
    background: none; border: none; cursor: pointer; padding: 0.5rem 1rem;
    color: var(--gray-400); transition: transform 0.25s ease;
    display: flex; align-items: center;
}
.nav-chevron:hover { color: #fff; }
.nav-chevron svg { transition: transform 0.25s ease; }
.nav-chevron-open svg { transform: rotate(90deg); }

/* Sub-navigation (children, collapsed by default) */
.nav-sub {
    list-style: none; padding: 0; margin: 0;
    max-height: 0; overflow: hidden;
    transition: max-height 0.25s ease;
}
.nav-sub-open { max-height: 200px; }
.nav-sub li a {
    padding: 0.4rem 1.5rem 0.4rem 2.8rem;
    font-size: 0.85rem;
    color: var(--gray-400);
    opacity: 0.85;
}
.nav-sub li a:hover { background: var(--gray-800); color: #fff; opacity: 1; }
.nav-sub li a.active { background: var(--gray-800); color: #fff; opacity: 1; }

/* Sidebar "Mis Apps" collapsible section */
.sidebar-apps-section {
    border-top: 1px solid var(--gray-800);
    margin-top: auto;
}
.sidebar-apps-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    gap: 8px;
}
.sidebar-apps-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.sidebar-apps-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    flex-shrink: 0;
}
.sidebar-apps-dot-ok {
    background: #4caf50;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.4);
}
.sidebar-apps-dot-off {
    background: #f44336;
    box-shadow: 0 0 4px rgba(244, 67, 54, 0.4);
}
.sidebar-apps-title {
    flex: 1;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #777;
    font-weight: 700;
}
.sidebar-apps-chevron {
    background: none; border: none; cursor: pointer; padding: 0.25rem;
    color: var(--gray-400); display: flex; align-items: center;
    transition: color 0.2s;
}
.sidebar-apps-chevron:hover { color: #fff; }
.sidebar-apps-chevron svg { transition: transform 0.25s ease; }
.sidebar-apps-chevron-open svg { transform: rotate(0deg); }
.sidebar-apps-chevron:not(.sidebar-apps-chevron-open) svg { transform: rotate(-90deg); }

.sidebar-apps-list {
    max-height: 0; overflow: hidden;
    transition: max-height 0.25s ease;
}
.sidebar-apps-list-open { max-height: 200px; }

.sidebar-apps-add {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1.5rem;
    text-decoration: none;
    font-size: 0.78rem;
    color: var(--gray-400);
    transition: background 0.2s, color 0.2s;
    border-top: 1px solid var(--gray-800);
}
.sidebar-apps-add:hover { background: var(--gray-800); color: #fff; }
.sidebar-apps-add svg { flex-shrink: 0; opacity: 0.6; }
.sidebar-apps-add:hover svg { opacity: 1; }

/* Taker connection status bar */
.taker-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1.5rem;
    text-decoration: none;
    font-size: 0.75rem;
    transition: background 0.2s;
    cursor: pointer;
}
.taker-status-bar:hover { background: var(--gray-800); }
.taker-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.taker-ok .taker-status-dot { background: #4caf50; box-shadow: 0 0 4px #4caf50; }
.taker-off .taker-status-dot { background: #f44336; box-shadow: 0 0 4px #f44336; }
.taker-status-label { color: #999; font-weight: 600; }
.taker-status-user { color: var(--gray-200); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.taker-status-alert { color: #ff9800; font-size: 0.85rem; cursor: help; margin-left: auto; flex-shrink: 0; animation: alertPulse 2s ease-in-out infinite; }
@keyframes alertPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Sidebar credits widget */
.sidebar-credits {
    padding: 0.65rem 1.5rem;
    border-top: 1px solid var(--gray-800);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sidebar-credits-label {
    color: #999;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.sidebar-credits-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.credits-ok .sidebar-credits-value { color: #4caf50; }
.credits-low .sidebar-credits-value { color: #ff9800; }
.credits-negative .sidebar-credits-value { color: #f44336; }
.sidebar-credits-warning {
    font-size: 0.65rem;
    margin-top: 1px;
}
.credits-low .sidebar-credits-warning { color: #ff9800; }
.credits-negative .sidebar-credits-warning { color: #f44336; }
a.sidebar-credits { text-decoration: none; cursor: pointer; transition: background 0.2s; }
a.sidebar-credits:hover { background: var(--gray-800); }

/* Credits admin — pill toggle switch (iOS-style) */
.toggle-pill {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--gray-300);
    flex-shrink: 0;
    vertical-align: middle;
    transition: background 0.2s;
    pointer-events: none;
}
.toggle-pill::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.18s cubic-bezier(.4,0,.2,1);
}
.toggle-pill.is-on { background: var(--success); }
.toggle-pill.is-on::after { transform: translateX(18px); }

/* Button wrapper */
.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    transition: opacity 0.15s;
    line-height: 1;
}
.toggle-btn:hover { opacity: 0.75; }
.toggle-status { color: var(--gray-500); font-weight: 400; }
.toggle-btn.is-on .toggle-status { color: var(--success); font-weight: 500; }

/* Credits admin — configuraciones generales (collapsible) */
.credits-config-panel {
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
}
.credits-config-summary {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--gray-700);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.credits-config-summary::-webkit-details-marker { display: none; }
.credits-config-summary::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--gray-400);
    transition: transform 0.15s;
    display: inline-block;
}
details.credits-config-panel[open] .credits-config-summary::before { transform: rotate(90deg); }
.credits-config-summary:hover { background: var(--gray-50); border-radius: var(--radius); }
.credits-config-body {
    border-top: 1px solid var(--gray-100);
    padding: 0.25rem 0;
}
.credits-config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}
.credits-config-row:last-child { border-bottom: none; }
.credits-config-col { flex: 1; min-width: 0; }
.credits-config-label { font-weight: 500; font-size: 0.875rem; margin-bottom: 0.15rem; }
.credits-config-desc { font-size: 0.8rem; color: var(--gray-500); }
.credits-config-control { flex-shrink: 0; }
.credits-decimals-select {
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: #fff;
    cursor: pointer;
    font-family: monospace;
}
.credits-decimals-select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Credits admin — tables: no browser hyphenation */
.data-table { border-collapse: collapse; width: 100%; }
.data-table th, .data-table td { hyphens: none; overflow-wrap: break-word; padding: 0.55rem 0.75rem; text-align: left; border-bottom: 1px solid var(--gray-100); vertical-align: middle; font-size: 0.875rem; }
.data-table th { background: var(--gray-50); font-weight: 600; font-size: 0.75rem; color: var(--gray-600); text-transform: uppercase; }

/* Credits admin — event badge */
.event-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    background: #e3f2fd;
    color: #1565c0;
}
.event-badge code {
    font-size: 0.7rem;
    background: rgba(0,0,0,0.06);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: var(--gray-600);
}

/* Credits admin — sub-navigation */
.credits-subnav {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-100);
}
.credits-subnav a {
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.15s;
}
.credits-subnav a:hover { background: #fff; color: var(--gray-900); }
.credits-subnav a.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.08); font-weight: 600; }

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gray-800);
    font-size: 0.85rem;
}
.sidebar-footer a { color: var(--gray-200); text-decoration: none; }
/* Dark user widget adjustments for sidebar */
.sidebar-footer .um-widget { padding: 0; border-top: none; align-items: flex-start; gap: 2px; }
.sidebar-footer .um-avatar-btn { margin-bottom: 4px; }
.sidebar-footer .um-name { font-size: 0.82rem; max-width: 160px; }
.sidebar-footer .um-role { font-size: 0.7rem; opacity: 0.7; }

/* Insufficient credits modal */
.credits-modal-overlay { position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:9999;display:flex;align-items:center;justify-content:center;padding:1rem; }
.credits-modal { background:#fff;border-radius:10px;padding:2rem;max-width:380px;width:100%;text-align:center;box-shadow:0 8px 32px rgba(0,0,0,0.2); }
.sidebar-logout-btn {
    background: none;
    border: none;
    color: var(--gray-200);
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}
.sidebar-logout-btn:hover { color: #fff; text-decoration: underline; }

.content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    flex: 1;
}

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; }
.form-group input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.95rem;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,103,179,0.15);
}
.form-group textarea, .form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}

/* Form layout */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 1.5rem;
    max-width: 700px;
}
.form-section { margin-bottom: 1.5rem; }
.form-section h3 { margin-bottom: 0.5rem; font-size: 1rem; color: var(--gray-800); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--gray-100); }
.form-section-subtitle { margin: 1rem 0 0.5rem; font-size: 0.95rem; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }
.page-subtitle { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 1rem; }

/* Page header actions */
.page-header-actions { display: flex; gap: 0.5rem; }

/* Section header (h2 + button) */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.section-header h2 { margin: 0; }
.section-header-spaced { margin-top: 2rem; }

/* Barrios toolbar */
.barrios-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.search-box {
    position: relative;
    flex: 1;
    max-width: 320px;
}
.search-box .search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-600);
    line-height: 0;
}
.search-box input {
    width: 100%;
    padding: 0.55rem 0.8rem 0.55rem 2.2rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: #fff;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,103,179,0.1); }
.toolbar-count { font-size: 0.8rem; color: var(--gray-600); white-space: nowrap; }

.view-toggle { display: flex; gap: 0; margin-left: auto; border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.view-btn {
    background: #fff;
    border: none;
    padding: 0.45rem 0.6rem;
    cursor: pointer;
    line-height: 0;
    transition: all 0.15s;
    color: var(--gray-600);
}
.view-btn + .view-btn { border-left: 1px solid var(--gray-200); }
.view-btn.active { background: var(--primary); color: #fff; }
.view-btn.active svg { stroke: #fff; }
.view-btn:hover:not(.active) { background: var(--gray-50); }

.btn-with-icon { display: inline-flex; align-items: center; gap: 0.35rem; }

/* Barrio badges */
.badge-synced { background: #e0f2f1; color: #00695c; font-size: 0.7rem; padding: 0.15rem 0.5rem; }
.badge-manual { background: #fff3e0; color: #e65100; font-size: 0.7rem; padding: 0.15rem 0.5rem; }

/* Barrio cards grid */
.barrios-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

.barrio-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.barrio-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.barrio-card-manual { border-left: 3px solid #ff9800; }

.barrio-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.85rem 1rem 0.5rem;
}
.barrio-card-title h3 { font-size: 0.95rem; margin: 0 0 0.3rem; color: var(--gray-900); }
.barrio-badges { display: flex; gap: 0.3rem; }

.barrio-card-actions { display: flex; gap: 0.2rem; flex-shrink: 0; }
.barrio-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    line-height: 0;
    color: var(--gray-600);
    transition: all 0.15s;
}
.barrio-action-sync:hover { color: #00695c; background: #e0f2f1; }
.barrio-action-edit:hover { color: var(--primary); background: #e3f2fd; }
.barrio-action-delete:hover { color: var(--danger); background: #ffebee; }

.barrio-card-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
}
.barrio-amount { text-align: center; }
.barrio-amount-value { display: block; font-size: 0.85rem; font-weight: 700; color: var(--gray-900); }
.barrio-amount-label { font-size: 0.6rem; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.3px; }

.barrio-card-expand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.4rem;
    font-size: 0.75rem;
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.barrio-card-expand:hover { background: var(--gray-50); }
.expand-chevron { line-height: 0; transition: transform 0.2s; }
.expand-chevron.rotated { transform: rotate(180deg); }

.barrio-card-detail { padding: 0.5rem 1rem 0.75rem; }
.barrio-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.8rem;
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-100);
}
.barrio-detail-row:last-child { border-bottom: none; }

.barrio-card-footer {
    padding: 0.4rem 1rem;
    font-size: 0.7rem;
    color: var(--gray-600);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

/* Barrios table */
.barrios-table td { font-size: 0.85rem; }
.barrios-table .actions-cell { display: flex; gap: 0.2rem; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-600); }
.empty-state p:first-child { font-size: 1.1rem; margin-bottom: 0.3rem; }

/* Section title inside cards */
.section-title { font-size: 0.8rem; color: var(--gray-600); text-transform: uppercase; margin-bottom: 0.4rem; letter-spacing: 0.5px; }

/* Header actions in cards */
.header-actions { display: flex; gap: 0.4rem; align-items: center; }

/* Campo custom badges */
.campo-meta { display: inline-flex; gap: 0.25rem; margin-left: 0.4rem; vertical-align: middle; }
.badge-tipo-campo { background: #e8eaf6; color: #3949ab; font-size: 0.65rem; padding: 0.1rem 0.4rem; }
.badge-obligatorio { background: #fff3e0; color: #e65100; font-size: 0.65rem; padding: 0.1rem 0.4rem; }

/* Campo value with inline delete */
.campo-value-group { display: flex; align-items: center; gap: 0.4rem; }
.btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 0.75rem;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    opacity: 0.4;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1;
}
.btn-icon-sm:hover { opacity: 1; background: #f8d7da; }
.campo-row:hover .btn-icon-sm { opacity: 0.7; }

/* New campo form (inline in card footer) */
.campo-form { margin-top: 0.75rem; }
.campo-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.campo-form-grid .form-group { margin-bottom: 0.5rem; }
.campo-form-grid .form-group label { font-size: 0.8rem; margin-bottom: 0.2rem; display: block; color: var(--gray-600); }
.campo-form-grid .form-group input,
.campo-form-grid .form-group select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.campo-check { display: flex; align-items: end; }
.campo-check label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; cursor: pointer; }
.campo-check input[type="checkbox"] { width: auto; margin: 0; }
.campo-form-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-small { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-full { width: 100%; }
.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: #e3f0fa; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #f8d7da; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: var(--success); border: 1px solid #c3e6cb; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-align: center;
}
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--gray-600); }

/* Upload */
.upload-section { margin-bottom: 1.5rem; }
.upload-area {
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
    cursor: pointer;
}
.upload-area.drag-over { border-color: var(--primary); background: rgba(13,103,179,0.05); }
.upload-area p { margin-bottom: 1rem; color: var(--gray-600); }
.upload-hint-mobile { display: none; }
.upload-hint-desktop { display: block; }

#fileList { margin-top: 1rem; text-align: left; font-size: 0.85rem; color: var(--gray-600); }
#fileList div { padding: 0.25rem 0; }

/* File count badge */
.file-count {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success);
}

/* Upload actions row (barrio + button) */
.upload-actions {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

/* Barrio selector */
.barrio-selector {
    position: relative;
    flex: 1;
    max-width: 300px;
}
.barrio-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.95rem;
    height: 100%;
    box-sizing: border-box;
}
.barrio-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,103,179,0.15); }
.barrio-input.selected { border-color: var(--success); background: #f0fdf4; }
.barrio-input.error { border-color: var(--danger); background: #fff5f5; box-shadow: 0 0 0 3px rgba(220,53,69,0.15); }
.barrio-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}
.barrio-dropdown.open { display: block; }
.barrio-option {
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.barrio-option:hover, .barrio-option-active { background: var(--gray-50); }
.barrio-empty {
    padding: 0.8rem;
    font-size: 0.85rem;
    color: var(--gray-600);
    text-align: center;
}
.barrio-empty a { color: var(--primary); }

/* Table */
.table-responsive { overflow-x: auto; margin-top: 1rem; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.table th, .table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--gray-100); vertical-align: middle; white-space: nowrap; }
.table th { background: var(--gray-50); font-weight: 600; font-size: 0.75rem; color: var(--gray-600); text-transform: uppercase; }
.table td { font-size: 0.85rem; }
.table td[rowspan] { border-right: 1px solid var(--gray-100); }

/* Error text for missing data */
.text-error { color: var(--danger); font-size: 0.8rem; font-weight: 500; }

/* Delete button */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}
/* Action buttons (SVG icons) */
.action-btn {
    background: none;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    line-height: 0;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.action-delete { color: var(--danger); }
.action-delete:hover { background: #f8d7da; border-color: var(--danger); }
.action-edit { color: var(--primary); opacity: 0.4; margin-left: 0.25rem; border: none; }
.action-edit:hover { opacity: 1; background: #e3f2fd; }
.action-sync { color: #00695c; }
.action-sync:hover { background: #e0f2f1; border-color: #00695c; }

/* File link */
.file-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.file-link:hover { text-decoration: underline; }

/* Upload area with files selected */
.upload-area.has-files { border-color: var(--success); background: #e8f5e9; }
.upload-area.has-files p { color: var(--success); }
.upload-area.error-border { border-color: var(--danger); background: #fff5f5; }

/* Inline edit input */
.inline-input {
    width: 100%;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--primary);
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
    box-shadow: 0 0 0 2px rgba(13,103,179,0.2);
}

/* Actions cell */
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }

/* PDF Preview Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
}
.modal-close { font-size: 1.5rem; }
.modal-iframe { flex: 1; border: none; width: 100%; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-ok { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff8e1; color: #b56a00; }
.badge-fail { background: #ffebee; color: #c62828; }
.badge-tipo { background: #f3e5f5; color: #7b1fa2; }
.badge-usuario { background: #e1f5fe; color: #0277bd; }

/* Password toggle eye */
.password-field { position: relative; }
.password-field input { padding-right: 40px; width: 100%; }
.password-toggle {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: #999; padding: 4px;
    display: flex; align-items: center;
}
.password-toggle:hover { color: #555; }
.badge-muted { background: var(--gray-100); color: var(--gray-600); }

/* Info box */
.info-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.text-small { font-size: 0.8rem; }
.text-muted { color: var(--gray-600); }

/* Upload block layout */
.upload-block {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.upload-block-recent { border-left: 4px solid var(--success); }

/* Upload list — grid columns for aligned layout */
.upload-list-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.upload-list-wrap .upload-block {
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    overflow: visible;
    border-bottom: 1px solid var(--gray-100);
}
.upload-list-wrap .upload-block:last-child { border-bottom: none; }
.upload-list-wrap .upload-block-recent {
    border-left: none;
    box-shadow: inset 4px 0 0 var(--success);
}
.upload-grid-cols {
    display: grid;
    grid-template-columns:
        36px        /* actions: expand + delete */
        2fr         /* archivo (nombre) */
        1fr         /* aseguradora */
        0.8fr       /* póliza */
        1.5fr       /* vigencia (two dates) */
        42px        /* personas */
        58px        /* fecha */
        48px        /* step 1: archivo ok (header "ARCHIVO") */
        96px        /* step 2: req (pill + approve/undo btn) */
        92px        /* step 3: taker (pill "Enviado") */
        116px;      /* step 4: estado taker (pill "Procesando") */
    align-items: center;
    column-gap: 0.5rem;
    min-width: 940px;
}
/* Journey stepper row — numbered circles connected by dotted line */
.upload-grid-stepper {
    padding: 0.5rem 0.75rem 0.25rem;
    background: var(--gray-50);
}
.journey-stepper-track {
    grid-column: 8 / -1;
    grid-row: 1;
    height: 0;
    border-top: 2px dotted var(--gray-200);
    align-self: center;
    margin: 0 24px;
}
.step-num {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    justify-self: center;
    position: relative;
    z-index: 1;
}
.step-num-1 { grid-column: 8; }
.step-num-2 { grid-column: 9; }
.step-num-3 { grid-column: 10; }
.step-num-4 { grid-column: 11; }

.upload-grid-header {
    padding: 0 0.75rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

/* Summary line (always visible, clickable) */
.upload-summary {
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    font-size: 0.82rem;
    color: var(--gray-800);
}
.upload-summary:hover { background: var(--gray-50); }

.us-actions { display: flex; align-items: center; gap: 0.2rem; }
.us-expand {
    font-size: 0.7rem;
    color: var(--gray-600);
    transition: transform 0.2s;
    display: inline-block;
    cursor: pointer;
}
.us-expand.expanded { transform: rotate(90deg); }

/* Grid cell helpers */
.us-center { text-align: center; justify-content: center; }
.us-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.us-cell-file { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.us-cell-file .file-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; max-width: 100%; }
.us-cell-journey { display: flex; align-items: center; justify-content: center; gap: 3px; white-space: nowrap; overflow: hidden; }

/* Detail panel (collapsible) */
.upload-detail {
    border-top: 1px solid var(--gray-100);
}

/* Editable detail fields row */
.detail-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fafbfc;
    border-bottom: 1px solid var(--gray-100);
}
.detail-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.detail-label {
    font-size: 0.7rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.detail-value {
    font-size: 0.85rem;
    color: var(--gray-900);
}
.detail-field-inline {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Selectable text (allow copy with mouse) */
.selectable { user-select: text; cursor: text; }

/* Edit button hidden until hover */
.detail-field .barrio-action-edit,
.detail-field-inline .barrio-action-edit { opacity: 0; transition: opacity 0.15s; }
.detail-field:hover .barrio-action-edit,
.detail-field-inline:hover .barrio-action-edit { opacity: 1; }

.table-inner { box-shadow: none; margin: 0; border-radius: 0; }
.table-inner th { font-size: 0.7rem; }
.th-validation { max-width: 140px; }
.th-req { display: block; font-weight: 400; font-size: 0.65rem; color: var(--gray-600); font-style: italic; }
.td-validation { text-align: center; vertical-align: middle; }
.validation-detail { display: block; font-size: 0.65rem; color: var(--gray-600); }

/* Journey stepper — pill badges */
.jp {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
    border: 1.5px solid transparent;
    background: var(--gray-100);
    color: var(--gray-600);
    font-family: inherit;
}
.jp svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 3; flex-shrink: 0; }
.jp-success { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.jp-warning { background: #fff8e1; color: #e65100; border-color: #ffe082; }
.jp-danger { background: #ffebee; color: #c62828; border-color: #ef9a9a; }
.jp-muted { background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-200); }
.jp-action { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }
.jp-sending { background: #e3f2fd; color: #1565c0; border-color: #90caf9; cursor: wait; }
.jp-btn {
    cursor: pointer;
    transition: filter 0.15s, transform 0.15s;
}
.jp-btn:hover { filter: brightness(0.92); transform: scale(1.04); }
.jp-btn:disabled { opacity: 0.6; cursor: wait; transform: none; filter: none; }
/* Manual override — lighter green to distinguish from natural pass */
.jp-approved { background: #f1f8e9; color: #558b2f; border-color: #c5e1a5; }
.jp-clickable { cursor: pointer; }
.jp-clickable:hover { filter: brightness(0.93); }
.jp .j-spinner {
    width: 12px; height: 12px;
    border: 2px solid rgba(21,101,192,0.3);
    border-top: 2px solid #1565c0;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Journey — small round action button (approve/undo) */
.jp-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
    font-family: inherit;
}
.jp-round svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 3; }
.jp-round-approve:hover { border-color: #2e7d32; background: #e8f5e9; color: #2e7d32; transform: scale(1.12); }
.jp-round-undo:hover { border-color: #c62828; background: #ffebee; color: #c62828; transform: scale(1.12); }

/* Upload toolbar (search + sort) */
.upload-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0 0.75rem;
    flex-wrap: wrap;
}
.upload-toolbar .search-box {
    flex: 1;
    min-width: 250px;
    max-width: 450px;
}
.upload-toolbar .sort-group {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sort-label { font-size: 0.8rem; color: var(--gray-600); white-space: nowrap; }
.sort-select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.8rem;
    min-width: 180px;
    background: #fff;
}
.sort-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,103,179,0.1); }

/* Taker message (inline notification) */
.taker-msg {
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
}
.taker-msg-error { background: #fff0f0; color: #c33; border: 1px solid #f0c0c0; }
.taker-msg-info { background: #f0f8ff; color: #456; border: 1px solid #c0d8f0; }

/* File list remove button */
.file-remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    font-weight: bold;
    flex-shrink: 0;
}
.file-remove-btn:hover { color: #a00; }
.file-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0; }

/* Barrio dropdown group label */
.barrio-group-label {
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.barrio-group-divider { border-top: 1px solid var(--gray-100); margin: 0.25rem 0; }

/* Section header count */
.section-count {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* Workers header — ID input */
.start-id-label { display: flex; align-items: center; gap: 4px; }
.start-id-input { width: 80px; min-width: 80px; }
.worker-insurance-dates { display: block; margin-top: 2px; font-size: 0.7rem; color: var(--gray-600); }
.worker-detail-panel {
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.worker-row td:nth-child(3) { text-align: center; }
.worker-detail-row td { padding: 0.25rem 0.5rem; }

/* Invitations */
.invitation-form {
    background: #fff;
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}
.invitation-form h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.invitation-list { display: flex; flex-direction: column; gap: 0.5rem; }
.invitation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: box-shadow 0.15s;
}
.invitation-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.invitation-item-highlight { animation: fadeIn 0.5s; border-left: 3px solid var(--primary); }
.invitation-info { flex: 1; min-width: 0; }
.invitation-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.invitation-email { font-weight: 600; font-size: 0.95rem; }
.invitation-meta { display: flex; gap: 1rem; margin-top: 0.35rem; font-size: 0.8rem; color: var(--gray-600); flex-wrap: wrap; }
.invitation-link-box {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border: 1px dashed var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--gray-600);
    cursor: pointer;
    word-break: break-all;
    transition: background 0.2s;
}
.invitation-link-box:hover { background: #e3f2fd; border-color: var(--primary); color: var(--primary); }
.badge-accepted-inv { background: #e8f5e9; color: #2e7d32; }
.badge-expired-inv { background: var(--gray-100); color: var(--gray-600); }
.badge-pending-inv { background: #fff8e1; color: #f57f17; }

/* Disabled input (e.g., locked email) */
.input-disabled { background: var(--gray-50); color: var(--gray-600); }

/* Settings test connection result */
.test-result-box { margin-top: 1rem; max-width: 700px; }

/* Landing CTA margin */
.btn-cta-top { margin-top: 1.25rem; }

/* Table cell helpers */
.td-nowrap { white-space: nowrap; }

/* Inline form (wraps action buttons without breaking layout) */
.form-inline { display: inline; }

/* Font weight utility */
.fw-600 { font-weight: 600; }

/* Badge spacing helper */
.ml-half { margin-left: 0.5rem; }

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.loading-box {
    text-align: center;
    padding: 2rem;
}
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; background: #e8f5e9; } to { opacity: 1; background: transparent; } }
.row-fade-in { animation: fadeIn 0.3s; }

/* Button spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

/* Tabs (Workers, etc.) */
.tabs { display: flex; gap: 0; margin-bottom: 1rem; border-bottom: 2px solid var(--gray-200); }
.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gray-600);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--gray-800); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn .badge { vertical-align: middle; margin-left: 0.3rem; }

/* Sync panel (Workers exploration) */
.sync-panel {
    background: #f0f4ff;
    border: 1px solid #c0d0f0;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
.sync-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.sync-panel-log {
    font-size: 0.8rem;
    max-height: 120px;
    overflow-y: auto;
}
.sync-log-ok { color: #2a7d2a; padding: 1px 0; }
.sync-log-error { color: #c33; padding: 1px 0; }
.sync-log-muted { color: var(--gray-600); padding: 1px 0; }

/* Logs */
.logs-filters { margin-bottom: 1rem; }
.logs-filter-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.log-filter-select,
.log-filter-input {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.log-message { max-width: 400px; white-space: normal; word-break: break-word; }
.log-row-error td { background: #fff8f8; }
.log-row-warning td { background: #fffdf0; }
.badge-warning-log { background: #fff3e0; color: #e65100; }
.badge-info-log { background: #e3f2fd; color: #1565c0; }
.log-context {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 300px;
    margin: 0;
}

/* Actions */
.actions { margin-bottom: 2rem; }

/* Active nav link */
.nav-links li a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border-left: 3px solid #fff;
    padding-left: calc(1.5rem - 3px);
}

/* Mobile header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--gray-900);
    color: #fff;
    z-index: 1001;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
}
.mobile-brand { font-weight: 600; font-size: 1.1rem; }

/* Hamburger button */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
}
.hamburger-line {
    display: block;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.3s, opacity 0.3s;
}
.hamburger.open .hamburger-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open .hamburger-line:nth-child(2) { opacity: 0; }
.hamburger.open .hamburger-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* Dashboard - Welcome card (new users) */
.welcome-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
    border: 1px solid #90caf9;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.welcome-icon { color: var(--primary); flex-shrink: 0; }
.welcome-text h2 { font-size: 1.25rem; color: var(--gray-900); margin-bottom: 0.25rem; }
.welcome-text p { color: var(--gray-600); font-size: 0.95rem; margin: 0; }

/* Dashboard - Onboarding steps */
.onboarding-steps { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }
.onboarding-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-decoration: none;
    color: var(--gray-900);
    transition: box-shadow 0.2s, transform 0.15s;
    border: 1px solid transparent;
}
.onboarding-step:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); border-color: var(--primary); }
.onboarding-step:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.onboarding-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.onboarding-step div { flex: 1; }
.onboarding-step strong { font-size: 0.95rem; display: block; margin-bottom: 0.15rem; }
.onboarding-step p { font-size: 0.85rem; color: var(--gray-600); margin: 0; }
.onboarding-arrow { font-size: 1.2rem; color: var(--gray-200); flex-shrink: 0; transition: color 0.2s; }
.onboarding-step:hover .onboarding-arrow { color: var(--primary); }

/* Dashboard - Stat card variants */
.stat-card-success .stat-number { color: var(--success); }
.stat-card-warning .stat-number { color: #f57f17; }
.stat-card-danger .stat-number { color: #c62828; }
.stat-card-danger { border-color: #ffcdd2; }

/* Dashboard - Quick actions */
.quick-actions { margin-top: 2rem; }
.quick-actions-title { font-size: 1rem; color: var(--gray-800); margin-bottom: 1rem; font-weight: 600; }
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}
.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-decoration: none;
    color: var(--gray-800);
    font-size: 0.9rem;
    font-weight: 500;
    transition: box-shadow 0.2s, transform 0.15s;
    border: 1px solid transparent;
}
.quick-action-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); border-color: var(--primary); }
.quick-action-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.quick-action-icon { color: var(--primary); }

/* Screen-reader only (accessibility) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to content link (accessibility) */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border-radius: 0 0 var(--radius) var(--radius);
    text-decoration: none;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Global - Focus visible for interactive elements */
.btn:focus-visible,
.action-btn:focus-visible,
.barrio-action-btn:focus-visible,
.btn-icon:focus-visible,
.sidebar-logout-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.nav-links li a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
    border-radius: 4px;
}

/* Global - Settings section divider */
.settings-divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 2rem 0;
}

/* ============================================================
   Dashboard — Attention section
   ============================================================ */
.dash-attention {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
    border-left: 4px solid #ff9800;
}
.dash-attention-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fff8e1;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e65100;
}
.dash-attention-items { display: flex; flex-direction: column; }
.dash-attention-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gray-100);
    text-decoration: none;
    color: var(--gray-800);
    transition: background 0.15s;
}
.dash-attention-item:hover { background: var(--gray-50); }
.dash-att-count {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.dash-att-warning .dash-att-count { background: #fff3e0; color: #e65100; }
.dash-att-info .dash-att-count { background: #e3f2fd; color: #1565c0; }
.dash-att-text { flex: 1; font-size: 0.9rem; }
.dash-att-arrow { color: var(--gray-200); font-size: 1.1rem; flex-shrink: 0; }
.dash-attention-item:hover .dash-att-arrow { color: var(--primary); }

.dash-expiring-list {
    padding: 0 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.dash-expiring-worker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
}
.dash-exp-urgent { background: #ffebee; }
.dash-exp-warning { background: #fff8e1; }
.dash-exp-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-exp-dni { color: var(--gray-600); font-family: monospace; font-size: 0.75rem; }
.dash-exp-days {
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.dash-exp-urgent .dash-exp-days { background: #c62828; color: #fff; }
.dash-exp-warning .dash-exp-days { background: #ff9800; color: #fff; }

/* Dashboard — Workers overview card */
.dash-workers-overview {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.dash-wo-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--gray-800);
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s;
}
.dash-wo-header:hover { background: var(--gray-50); }
.dash-wo-total {
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 0.8rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
}
.dash-wo-arrow { margin-left: auto; color: var(--gray-200); font-size: 1.1rem; }
.dash-wo-header:hover .dash-wo-arrow { color: var(--primary); }

.dash-wo-bars { padding: 0 1rem 0.75rem; }
.dash-wo-bar-track {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--gray-100);
    gap: 2px;
}
.dash-wo-bar-segment { border-radius: 4px; transition: flex 0.5s; }
.bar-green { background: #4caf50; }
.bar-orange { background: #ff9800; }
.bar-red { background: #f44336; }
.bar-gray { background: #bdbdbd; }

.dash-wo-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.dash-wo-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--gray-600);
}
.dash-wo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dash-wo-legend-count { font-weight: 700; color: var(--gray-800); }

/* Dashboard — Stat cards with icons */
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
}
.stat-icon-primary { background: #e3f2fd; color: var(--primary); }
.stat-icon-success { background: #e8f5e9; color: var(--success); }
.stat-icon-warning { background: #fff8e1; color: #f57f17; }

/* ============================================================
   Workers — Summary bar
   ============================================================ */
.workers-summary {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.ws-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.ws-count { font-weight: 700; font-size: 1.1rem; }
.ws-label { font-size: 0.8rem; }
.ws-green { background: #e8f5e9; color: #2e7d32; }
.ws-orange { background: #fff8e1; color: #e65100; }
.ws-red { background: #ffebee; color: #c62828; }
.ws-gray { background: var(--gray-100); color: var(--gray-600); }

/* ============================================================
   Workers — Mobile card view
   ============================================================ */
.workers-cards-mobile { display: none; }

.wc-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.wc-card:active { box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.wc-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
}
.wc-main .semaforo { flex-shrink: 0; }
.wc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.wc-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wc-dni {
    font-size: 0.75rem;
    color: var(--gray-600);
    font-family: monospace;
}
.wc-badges {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}
.wc-badges .badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
}
.wc-chevron {
    flex-shrink: 0;
    color: var(--gray-200);
    transition: transform 0.2s;
    line-height: 0;
}
.wc-expanded .wc-chevron { transform: rotate(180deg); }

.wc-detail {
    display: none;
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid var(--gray-100);
    background: #fafbfc;
}
.wc-expanded .wc-detail { display: block; }

.wc-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
    gap: 0.25rem;
}
.wc-detail-row:last-child { border-bottom: none; }
.wc-detail-label {
    font-size: 0.7rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.wc-dates {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-left: 0.4rem;
}
.wc-days-left { font-weight: 700; }
.wc-days-urgent { color: #c62828; }
.wc-days-warn { color: #e65100; }

.wc-detail-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.wc-detail-actions .btn { font-size: 0.75rem; }

/* ============================================================
   Uploads — Mobile card view
   ============================================================ */
.upload-cards-mobile { display: none; }

.uc-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 0.6rem;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.uc-card:active { box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.uc-card-recent { border-left: 4px solid var(--success); }

.uc-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 0.9rem;
}
.uc-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.uc-status-dot.uc-sent { background: #4caf50; }
.uc-status-dot.uc-error { background: #f44336; }
.uc-status-dot.uc-pending { background: #ff9800; }

.uc-top-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.uc-filename {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.uc-meta {
    font-size: 0.85rem;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uc-status-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}
.uc-status-badge.uc-sent { background: #e8f5e9; color: #2e7d32; }
.uc-status-badge.uc-error { background: #ffebee; color: #c62828; }
.uc-status-badge.uc-pending { background: #fff8e1; color: #e65100; }

.uc-bottom {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.9rem 0.65rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}
.uc-vigencia { font-family: monospace; font-size: 0.8rem; }
.uc-personas { font-weight: 600; }
.uc-req {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}
.uc-req-ok { background: #e8f5e9; color: #2e7d32; }
.uc-req-fail { background: #ffebee; color: #c62828; }
.uc-req-warn { background: #fff8e1; color: #e65100; }

.uc-detail {
    display: none;
    padding: 0.75rem 0.9rem 0.9rem;
    border-top: 1px solid var(--gray-100);
    background: #fafbfc;
}
.uc-expanded .uc-detail { display: block; }
.uc-detail .btn { margin-right: 0.4rem; margin-bottom: 0.4rem; font-size: 0.85rem; padding: 0.4rem 0.75rem; }

.uc-personas-list {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.uc-persona {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    background: #fff;
    border-radius: 6px;
    font-size: 0.88rem;
    border: 1px solid var(--gray-100);
}
.uc-persona-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.uc-persona-dni { color: var(--gray-600); font-family: monospace; font-size: 0.8rem; flex-shrink: 0; }
.uc-persona .badge { font-size: 0.65rem; padding: 0.15rem 0.4rem; flex-shrink: 0; }
.uc-delete-form { margin-top: 0.6rem; }
.uc-preview-btn { text-decoration: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .mobile-header { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        top: 52px;
        bottom: 0;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { top: 52px; }

    .content {
        margin-left: 0;
        padding: calc(52px + 1rem) 0.75rem 1rem;
        overflow-x: hidden;
        max-width: 100vw;
    }

    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card { padding: 1rem 0.75rem; }
    .stat-number { font-size: 1.5rem; }
    .stat-label { font-size: 0.75rem; }
    .stat-icon { width: 32px; height: 32px; margin-bottom: 0.3rem; }
    .stat-icon svg { width: 18px; height: 18px; }

    .barrios-cards { grid-template-columns: 1fr; }
    .upload-actions { flex-direction: column; }
    .barrio-selector { max-width: none; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .page-header h1 { font-size: 1.3rem; }
    .page-header-actions { flex-wrap: wrap; gap: 0.4rem; }
    .page-header-actions .btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
    .start-id-label { display: none; }

    /* Workers: hide desktop table, show mobile cards */
    .table[aria-label="Workers guardados"] { display: none; }
    .workers-cards-mobile { display: block; }
    .workers-summary { gap: 0.35rem; }
    .ws-item { padding: 0.4rem 0.6rem; font-size: 0.8rem; flex: 1; min-width: 0; justify-content: center; }
    .ws-count { font-size: 1rem; }
    .ws-label { font-size: 0.7rem; }

    /* Workers toolbar mobile */
    .barrios-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .barrios-toolbar .search-box { max-width: none !important; min-width: 0 !important; }
    .barrios-toolbar .barrio-selector { min-width: 0 !important; }
    .barrios-toolbar .toolbar-count { text-align: center; }

    /* Uploads: hide desktop grid, show mobile cards */
    .upload-list-wrap { display: none !important; }
    .upload-cards-mobile { display: block; }

    .upload-hint-desktop { display: none; }
    .upload-hint-mobile { display: block; }

    .upload-toolbar { gap: 0.5rem; }
    .upload-toolbar .search-box { min-width: 0; max-width: none; flex: 1; }
    .upload-toolbar .sort-group { margin-left: 0; flex: 1; }
    .sort-select { min-width: 0; flex: 1; }
    .sort-label { display: none; }

    /* Prevent iOS auto-zoom on input focus (requires font-size >= 16px) */
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Upload area on mobile */
    .upload-area { padding: 1.25rem; }
    .upload-area p { font-size: 0.9rem; margin-bottom: 0.5rem; }

    .welcome-card { flex-direction: column; text-align: center; }
    .quick-actions-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .quick-action-card { padding: 1rem 0.75rem; font-size: 0.8rem; }

    /* Dashboard attention section mobile */
    .dash-expiring-list { gap: 0.15rem; }
    .dash-expiring-worker { gap: 0.5rem; font-size: 0.75rem; padding: 0.35rem 0.4rem; }
    .dash-exp-name { font-size: 0.8rem; }

    /* Section header mobile */
    .section-header h2 { font-size: 1rem; }
    .section-count { font-size: 0.75rem; }

    /* Credits section mobile */
    .credits-subnav { flex-wrap: wrap; gap: 0.2rem; padding: 0.35rem; }
    .credits-subnav a { padding: 0.35rem 0.6rem; font-size: 0.8rem; }

    /* Credits user detail: stack forms vertically */
    [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }

    /* Credits toggle compact */
    .toggle-pill { width: 34px; height: 19px; border-radius: 10px; }
    .toggle-pill::after { width: 15px; height: 15px; }
    .toggle-pill.is-on::after { transform: translateX(15px); }
    .toggle-btn { font-size: 0.8rem; }

    /* Credits tables: horizontal scroll on small screens */
    .card:has(.data-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 500px; hyphens: none; }

    /* Event badge compact */
    .event-badge { font-size: 0.75rem; padding: 0.1rem 0.4rem; }
    .event-badge code { display: none; }
}

/* ─── Apps marketplace page ─── */
.apps-page { max-width: 720px; }

.apps-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.apps-hero-text h1 {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin-bottom: 0.35rem;
}
.apps-hero-text p {
    color: var(--gray-600);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 480px;
}

.apps-search-wrap {
    position: relative;
    margin-bottom: 1.25rem;
}
.apps-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-200);
    pointer-events: none;
}
.apps-search {
    width: 100%;
    padding: 0.65rem 0.75rem 0.65rem 2.5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.apps-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 103, 179, 0.12);
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
}

.app-card {
    background: #fff;
    border: 1px solid var(--gray-100);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}
.app-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    border-color: var(--gray-200);
    transform: translateY(-2px);
}

.app-card-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.75rem 1rem 0.75rem;
    position: relative;
}
.app-card-logo {
    width: 96px;
    height: 96px;
    border-radius: 16px;
    object-fit: contain;
    background: var(--gray-50);
    padding: 10px;
    border: 1px solid var(--gray-100);
    margin-bottom: 0.65rem;
}

.app-card-body {
    padding: 0.25rem 1rem 0.75rem;
    text-align: center;
    flex: 1;
}
.app-card-body h3 {
    font-size: 1rem;
    color: var(--gray-900);
    margin: 0 0 0.3rem;
}
.app-card-short {
    font-size: 0.8rem;
    color: var(--gray-600);
    line-height: 1.4;
    margin: 0;
}

.app-card-expand {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 1rem;
}
.app-card-expand-open {
    max-height: 250px;
    padding: 0.5rem 1rem 0.25rem;
}
.app-card-expand p {
    font-size: 0.8rem;
    color: var(--gray-600);
    line-height: 1.5;
    border-top: 1px solid var(--gray-100);
    padding-top: 0.6rem;
    margin: 0;
    text-align: left;
}

.app-card-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 0.55rem 1rem;
    background: none;
    border: none;
    border-top: 1px solid var(--gray-100);
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    transition: background 0.15s;
    margin-top: auto;
}
.app-card-toggle:hover { background: var(--gray-50); }
.app-card-toggle svg {
    transition: transform 0.25s ease;
    margin-left: 2px;
}
.app-card-toggle-open svg { transform: rotate(180deg); }
.app-card-toggle .app-card-toggle-less { display: none; }
.app-card-toggle-open .app-card-toggle-more { display: none; }
.app-card-toggle-open .app-card-toggle-less { display: inline; }

.app-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    border-top: 1px solid var(--gray-100);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: default;
}
.app-card-action-ok {
    background: #e8f5e9;
    color: #2e7d32;
}
.app-card-action-add {
    background: var(--gray-50);
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s;
}
.app-card-action-add:hover:not(:disabled) { background: #e3f0fa; }
.app-card-action-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.apps-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
    grid-column: 1 / -1;
}
.apps-empty svg { margin-bottom: 0.75rem; }
.apps-empty p { font-size: 0.9rem; }

@media (max-width: 600px) {
    .apps-hero { flex-direction: column; gap: 0.75rem; }
    .apps-hero-btn { align-self: stretch; justify-content: center; }
    .apps-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .app-card-hero { padding: 1.25rem 0.75rem 0.5rem; }
    .app-card-logo { width: 72px; height: 72px; padding: 8px; border-radius: 14px; }
    .app-card-body { padding: 0.15rem 0.75rem 0.65rem; }
    .app-card-body h3 { font-size: 0.9rem; }
    .app-card-short { font-size: 0.75rem; }
    .app-card-expand { padding-left: 0.75rem; padding-right: 0.75rem; }
    .app-card-expand-open { padding-left: 0.75rem; padding-right: 0.75rem; }
    .app-card-toggle { padding: 0.45rem 0.75rem; font-size: 0.7rem; }
}

/* ─── Nav badge (unread counter) ─── */
.nav-badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: auto;
    line-height: 1;
}

/* ─── Suggest button on apps page ─── */
.apps-suggest-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

/* ─── Suggestion form ─── */
.page-subtitle {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}
.suggest-card { padding: 1.5rem; }
.required { color: var(--danger); }
.form-group-check { margin-top: 0.25rem; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.9rem;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* ─── Messages list (admin) ─── */
.msg-unread-pill {
    display: inline-flex;
    align-items: center;
    background: var(--danger);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.7rem;
    border-radius: 50px;
    margin-left: 0.75rem;
    vertical-align: middle;
}
.msg-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.msg-item {
    background: #fff;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}
.msg-unread { border-left: 3px solid var(--primary); }
.msg-read { opacity: 0.7; }
.msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    gap: 0.75rem;
}
.msg-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.msg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}
.msg-app-name { font-size: 0.9rem; }
.msg-separator { color: var(--gray-200); }
.msg-user {
    font-size: 0.8rem;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.msg-date {
    font-size: 0.75rem;
    color: var(--gray-600);
    white-space: nowrap;
}
.msg-mark-btn { padding: 0.25rem 0.5rem; }
.msg-body {
    padding: 0.75rem 1rem;
}
.msg-body p {
    font-size: 0.88rem;
    color: var(--gray-900);
    line-height: 1.55;
    margin: 0 0 0.5rem;
}
.msg-field {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}
.msg-field a { color: var(--primary); }

@media (max-width: 600px) {
    .apps-suggest-btn { align-self: stretch; justify-content: center; }
    .msg-header { flex-direction: column; align-items: flex-start; }
    .msg-actions { align-self: flex-end; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; text-align: center; }
}

/* Small phones */
@media (max-width: 400px) {
    .content { padding: calc(52px + 0.75rem) 0.5rem 0.75rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.35rem; }
    .stat-card { padding: 0.75rem 0.5rem; }
    .stat-number { font-size: 1.3rem; }
    .workers-summary { gap: 0.25rem; }
    .ws-item { padding: 0.3rem 0.4rem; }
    .ws-count { font-size: 0.9rem; }
    .ws-label { font-size: 0.65rem; }
    .quick-actions-grid { gap: 0.35rem; }
    .quick-action-card { padding: 0.75rem 0.5rem; }

    /* Upload cards on small phones */
    .uc-top { padding: 0.75rem 0.65rem; gap: 0.5rem; }
    .uc-filename { font-size: 0.9rem; }
    .uc-meta { font-size: 0.8rem; }
    .uc-status-badge { font-size: 0.65rem; padding: 0.2rem 0.45rem; }
    .uc-bottom { padding: 0 0.65rem 0.55rem; font-size: 0.8rem; gap: 0.5rem; }
    .uc-vigencia { font-size: 0.75rem; }
    .uc-detail { padding: 0.6rem 0.65rem 0.75rem; }
    .uc-persona { font-size: 0.82rem; padding: 0.4rem 0.5rem; }
    .uc-persona-dni { font-size: 0.75rem; }
}
