:root {
    --primary: #1A3EDC;
    --primary-dark: #1230b0;
    --primary-soft: rgba(26, 62, 220, 0.1);
    --primary-card: #1A3EDC;
    --danger: #e53e3e;
    --danger-soft: rgba(229, 62, 62, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --bg: #EEF1F8;
    --surface: #ffffff;
    --surface-2: #f5f7fc;
    --text: #0D1B4E;
    --text-muted: #6B7EBB;
    --text-light: #A0B0D8;
    --border: #DDE3F5;
    --nav-h: 72px;
    --topbar-h: 58px;
    --shadow-sm: 0 1px 4px rgb(26 62 220 / 0.07);
    --shadow-md: 0 4px 16px rgb(26 62 220 / 0.12);
    --shadow-lg: 0 10px 40px rgb(26 62 220 / 0.16);
    --r-sm: 0.75rem;
    --r-md: 1rem;
    --r-lg: 1.25rem;
    --r-xl: 1.5rem;
    --r-full: 9999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: var(--nav-h);
    padding-top: var(--topbar-h);
}

/* ========== TOP BAR ========== */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.top-bar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--primary);
    letter-spacing: -0.02em;
}
.top-bar-logo svg { color: var(--primary); }

.top-bar-right { display: flex; align-items: center; gap: 0.625rem; }

.top-bar-avatar {
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5b7ff5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    border: 2px solid var(--border);
}

.logout-btn {
    width: 1.875rem; height: 1.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.logout-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* ========== APP CONTAINER ========== */
.app-container { max-width: 600px; margin: 0 auto; }

/* ========== VIEWS ========== */
.view { display: none; padding: 1.25rem 1.25rem 1rem; }
.view.active { display: block; animation: fadeSlideIn 0.28s ease; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== HOME / DASHBOARD ========== */
.dash-greeting-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.dash-greeting {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.15;
    margin-bottom: 0.25rem;
    letter-spacing: -0.03em;
}
.dash-subtext {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Stats card grande */
.stats-card-main {
    background: var(--primary-card);
    border-radius: var(--r-xl);
    padding: 1.5rem;
    color: white;
    margin-bottom: 0.875rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(26, 62, 220, 0.35);
}
.stats-card-main::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
}
.stats-card-main::after {
    content: '';
    position: absolute;
    bottom: -60px; right: 40px;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}
.stats-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.75;
    margin-bottom: 0.5rem;
}
.stats-card-value {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 0.625rem;
}
.stats-card-trend {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.85;
}

/* Mini stats */
.stats-mini-row { display: flex; gap: 0.875rem; margin-bottom: 1.25rem; }
.stats-mini-card {
    flex: 1;
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.stats-mini-icon {
    width: 2rem; height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.625rem;
}
.stats-mini-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stats-mini-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stats-mini-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.2rem; }
.stats-mini-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* CTA Button */
.cta-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--r-lg);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 18px rgba(26, 62, 220, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: -0.01em;
}
.cta-btn:active { transform: scale(0.98); }

/* Sección actividad reciente */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.875rem;
}
.section-title-lg {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.section-link {
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

/* Activity list */
.activity-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.activity-item {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: background 0.12s;
}
.activity-item:hover { background: var(--surface-2); }
.activity-icon {
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1.5px solid var(--border);
}
.activity-info { flex: 1; min-width: 0; }
.activity-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.activity-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}
.activity-chevron { color: var(--text-light); flex-shrink: 0; }

/* Shortcut cards */
.shortcuts-row { display: flex; gap: 0.875rem; }
.shortcut-card {
    flex: 1;
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.15s;
}
.shortcut-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.shortcut-icon {
    width: 2.5rem; height: 2.5rem;
    border-radius: 0.75rem;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}
.shortcut-label { font-size: 0.875rem; font-weight: 700; color: var(--text); }

/* ========== FORM (CAPTURA) ========== */
.view-header { margin-bottom: 1.25rem; }
.view-header h1 { font-size: 1.4rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.view-header p { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

.registro-form {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.form-section {
    margin-bottom: 1.4rem;
    padding-bottom: 1.4rem;
    border-bottom: 1px dashed var(--border);
}
.form-section:last-of-type { border-bottom: none; margin-bottom: 1.5rem; }

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.875rem;
}
.section-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

/* Floating Label Inputs */
.input-row { display: flex; gap: 0.75rem; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.input-group {
    position: relative;
    margin-bottom: 1rem;
    width: 100%;
}
.input-group input {
    width: 100%;
    padding: 1rem 0.875rem 0.4rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--r-sm);
    outline: none;
    transition: all 0.2s;
}
.input-group input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.input-group label {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
    transition: all 0.2s;
    pointer-events: none;
}
.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
    top: 0.38rem;
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
}
.input-group input:not(:placeholder-shown):not(:focus) + label { color: var(--text-muted); }

/* Submit */
.submit-btn {
    width: 100%;
    padding: 0.9rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--r-full);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(26, 62, 220, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.submit-btn:active { transform: scale(0.98); }
.submit-btn.loading span { opacity: 0; }
.loader-spinner {
    position: absolute;
    width: 1.25rem; height: 1.25rem;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0; visibility: hidden;
}
.submit-btn.loading .loader-spinner { opacity: 1; visibility: visible; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== HISTORIAL (TABLA) ========== */
.consulta-header { display: flex; flex-direction: column; gap: 0.875rem; }

.search-box-wrapper { position: relative; }
.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-light);
    pointer-events: none;
}
.search-box {
    width: 100%;
    padding: 0.7rem 0.875rem 0.7rem 2.5rem;
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: var(--r-full);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    border: 1px solid var(--border);
}
.search-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.search-box::placeholder { color: var(--text-light); }

/* ========== DATA TABLE ========== */
.registro-grid { width: 100%; }
.table-wrapper {
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    animation: fadeSlideIn 0.3s ease;
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 520px;
}
.data-table thead tr {
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}
.data-table th {
    padding: 0.75rem 0.875rem;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}
.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f5f7ff; }
.data-table td {
    padding: 0.75rem 0.875rem;
    vertical-align: middle;
    color: var(--text);
}
.col-id { font-size: 0.75rem; color: var(--text-light); font-weight: 600; width: 32px; text-align: center; }
.col-name { display: flex; align-items: center; gap: 0.625rem; min-width: 160px; }
.row-avatar {
    width: 2rem; height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5b7ff5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.72rem;
    flex-shrink: 0;
}
.row-name-block { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.row-fullname { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.row-email { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.col-address { display: flex; flex-direction: column; gap: 1px; min-width: 130px; font-size: 0.82rem; }
.row-colonia { font-size: 0.72rem; color: var(--text-muted); }
.col-phone { font-size: 0.82rem; white-space: nowrap; min-width: 105px; }
.col-badge { text-align: center; }
.badge { font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.55rem; border-radius: var(--r-full); white-space: nowrap; display: inline-block; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-gray { background: #eef1f8; color: var(--text-muted); }
.col-actions { display: flex; gap: 0.375rem; width: 72px; }
.btn-icon {
    width: 2rem; height: 2rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-icon-edit { background: var(--primary-soft); color: var(--primary); }
.btn-icon-edit:hover { background: rgba(26,62,220,0.2); }
.btn-icon-edit:active { transform: scale(0.9); }
.btn-icon-delete { background: var(--danger-soft); color: var(--danger); }
.btn-icon-delete:hover { background: rgba(229,62,62,0.2); }
.btn-icon-delete:active { transform: scale(0.9); }

/* ========== MOBILE CARD LAYOUT ========== */
.mobile-cards { display: none; flex-direction: column; gap: 0.75rem; }

@media (max-width: 600px) {
    .table-wrapper { display: none; }
    .mobile-cards { display: flex; }

    .mobile-card {
        background: var(--surface);
        border-radius: var(--r-lg);
        padding: 1rem;
        border: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
        animation: fadeSlideIn 0.3s ease;
    }
    .mobile-card-top {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }
    .mobile-card-avatar {
        width: 2.5rem; height: 2.5rem;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), #5b7ff5);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 0.82rem;
        flex-shrink: 0;
    }
    .mobile-card-name {
        flex: 1;
        min-width: 0;
    }
    .mobile-card-name .fullname {
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mobile-card-name .email {
        font-size: 0.78rem;
        color: var(--text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mobile-card-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem 1rem;
        padding: 0.75rem 0;
        border-top: 1px dashed var(--border);
        border-bottom: 1px dashed var(--border);
        margin-bottom: 0.75rem;
    }
    .mobile-card-detail {
        display: flex;
        flex-direction: column;
        gap: 1px;
    }
    .mobile-card-detail .detail-label {
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 700;
        color: var(--text-light);
    }
    .mobile-card-detail .detail-value {
        font-size: 0.85rem;
        font-weight: 500;
        color: var(--text);
    }
    .mobile-card-badges {
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    .mobile-card-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .mobile-card-actions {
        display: flex;
        gap: 0.5rem;
    }
    .mobile-card-actions .btn-icon {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 0.625rem;
    }
}

/* ========== EMPTY STATE ========== */
.hidden { display: none !important; }
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-icon { width: 4rem; height: 4rem; margin: 0 auto 1rem; color: var(--text-light); }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.empty-state p { font-size: 0.875rem; }

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--surface);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -4px 20px rgb(26 62 220 / 0.06);
    padding: 0 1.5rem;
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.2s;
    padding: 0.5rem;
    border-radius: var(--r-lg);
}
.nav-btn svg { width: 22px; height: 22px; transition: transform 0.2s; }
.nav-btn.active {
    color: var(--primary);
    font-weight: 700;
}
.nav-btn.active svg { transform: scale(1.1); }
.nav-btn span { letter-spacing: 0.01em; }

/* ========== MODALS ========== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(13, 27, 78, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    opacity: 0; visibility: hidden;
    transition: all 0.25s;
    padding: 1rem;
}
.modal.active { opacity: 1; visibility: visible; }
.modal-content {
    background: var(--surface);
    padding: 1.75rem;
    border-radius: var(--r-xl) var(--r-xl) var(--r-lg) var(--r-lg);
    text-align: center;
    width: 100%;
    max-width: 380px;
    transform: translateY(40px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-lg);
}
.modal.active .modal-content { transform: translateY(0); }
.success-icon, .delete-icon {
    width: 3.5rem; height: 3.5rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
}
.success-icon { background: var(--success); box-shadow: 0 0 0 10px rgba(34,197,94,0.1); }
.delete-icon { background: var(--danger); box-shadow: 0 0 0 10px rgba(229,62,62,0.1); }
.success-icon svg, .delete-icon svg { width: 24px; height: 24px; }
.modal-content h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.375rem; color: var(--text); }
.modal-content p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.25rem; }
.modal-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: var(--r-full);
    font-weight: 700;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    background: var(--success);
    color: white;
}
.modal-actions { display: flex; gap: 0.75rem; }
.modal-btn-cancel {
    flex: 1;
    padding: 0.75rem;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    border-radius: var(--r-full);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
}
.modal-btn-danger { flex: 1; background: var(--danger); }
