:root {
    --mhm-navy: #1D2D5A;
    --mhm-navy-dark: #131F40;
    --mhm-cyan: #139CD9;
    --mhm-cyan-hover: #0E84BA;
    --bg-app: #F1F5F9;
    --surface: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --green: #059669;
    --green-soft: #ECFDF5;
    --amber: #D97706;
    --amber-soft: #FFFBEB;
    --red: #DC2626;
    --red-soft: #FEF2F2;
    --radius-lg: 16px;
    --radius-md: 11px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 12px 32px rgba(29, 45, 90, 0.10);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    line-height: 1.45;
    min-height: 100vh;
}

/* ==========================================================================
   PANTALLA DE LOGIN Y REGISTRO DE USUARIOS
   ========================================================================== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top right, rgba(19, 156, 217, 0.22), transparent 45%),
                linear-gradient(145deg, #0F1A36 0%, #1D2D5A 55%, #152347 100%);
    position: relative;
    overflow-x: hidden;
}

.auth-wrapper {
    width: 100%;
    max-width: 500px;
    z-index: 2;
}

.auth-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 28px 30px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

.auth-logo-box {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    flex-shrink: 0;
}

.auth-logo-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.auth-brand-text {
    flex: 1;
}

.auth-kicker {
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--mhm-cyan);
}

.auth-brand-text h1 {
    font-size: 19px;
    font-weight: 800;
    color: var(--mhm-navy);
    line-height: 1.2;
}

.auth-brand-text p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.pg-pill {
    font-size: 10.5px;
    font-weight: 700;
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
    padding: 4px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 11px;
    margin-bottom: 18px;
}

.auth-tab {
    border: none;
    background: transparent;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.18s ease;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--mhm-navy);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.auth-switch-hint {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
}

.link-btn {
    border: none;
    background: none;
    color: var(--mhm-cyan);
    font-weight: 700;
    cursor: pointer;
    font-size: 12.5px;
    margin-left: 4px;
}

.link-btn:hover {
    text-decoration: underline;
}

.auth-footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    margin-top: 16px;
}

/* ==========================================================================
   ELEMENTOS DE FORMULARIO Y BOTONES COMUNES
   ========================================================================== */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field label {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9.5px 12px;
    border: 1.5px solid var(--border-strong);
    border-radius: 9px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-main);
    background: #FFFFFF;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--mhm-cyan);
    box-shadow: 0 0 0 3px rgba(19, 156, 217, 0.16);
}

.pwd-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.pwd-wrap input {
    padding-right: 64px;
}

.pwd-toggle {
    position: absolute;
    right: 8px;
    border: none;
    background: #F1F5F9;
    color: var(--mhm-navy);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}

.cedula-group {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.16s ease;
    white-space: nowrap;
}

.btn-block {
    width: 100%;
    padding: 11.5px 16px;
    font-size: 14px;
}

.btn-primary {
    background: var(--mhm-navy);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: var(--mhm-navy-dark);
}

.btn-cyan {
    background: var(--mhm-cyan);
    color: #FFFFFF;
}

.btn-cyan:hover {
    background: var(--mhm-cyan-hover);
}

.btn-outline {
    background: #FFFFFF;
    color: var(--mhm-navy);
    border-color: var(--border-strong);
}

.btn-outline:hover {
    background: #F8FAFC;
    border-color: var(--mhm-cyan);
}

.btn-ghost-light {
    background: rgba(255, 255, 255, 0.10);
    color: #FFFFFF;
    border-color: rgba(255, 255, 255, 0.22);
}

.btn-ghost-light:hover {
    background: rgba(255, 255, 255, 0.20);
}

.btn-success-sm {
    background: var(--green);
    color: #FFFFFF;
    padding: 6px 11px;
    font-size: 12px;
    border-radius: 7px;
}

.btn-success-sm:hover {
    background: #047857;
}

.btn-amber-sm {
    background: #FFFBEB;
    color: #B45309;
    border: 1px solid #FCD34D;
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: 7px;
}

.btn-amber-sm:hover {
    background: #FEF3C7;
}

.alert {
    padding: 10px 13px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 14px;
}

.alert-error {
    background: var(--red-soft);
    color: #B91C1C;
    border: 1px solid #FECACA;
}

.alert-success {
    background: var(--green-soft);
    color: #047857;
    border: 1px solid #A7F3D0;
}

/* ==========================================================================
   CABECERA SUPERIOR DEL DASHBOARD
   ========================================================================== */
.topbar {
    background: linear-gradient(90deg, var(--mhm-navy-dark) 0%, var(--mhm-navy) 65%, #1B3B6F 100%);
    color: #FFFFFF;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-bottom: 3px solid var(--mhm-cyan);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.16);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-logo {
    width: 44px;
    height: 44px;
    background: #FFFFFF;
    border-radius: 10px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.topbar-title h1 {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.topbar-subtitle {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.78);
    display: flex;
    align-items: center;
    gap: 8px;
}

.db-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #34D399;
    border-radius: 50%;
    box-shadow: 0 0 8px #34D399;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.user-chip {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.role-tag {
    background: var(--mhm-cyan);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 999px;
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL, KPIs Y TABLERO DE CARNETS 01-10
   ========================================================================== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px 36px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 15px 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--mhm-navy);
    margin-top: 3px;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
}

.kpi-cyan .kpi-icon { background: #E0F2FE; color: var(--mhm-cyan); }
.kpi-green .kpi-icon { background: var(--green-soft); color: var(--green); }
.kpi-amber .kpi-icon { background: var(--amber-soft); color: var(--amber); }
.kpi-navy .kpi-icon { background: #EEF2FF; color: var(--mhm-navy); }

/* TABLERO DE LOS 10 CARNETS DE VISITANTE (01 AL 10) */
.badges-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
    flex-wrap: wrap;
}

.section-head h2 {
    font-size: 15px;
    font-weight: 800;
    color: var(--mhm-navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-group {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.dot-free { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.dot-busy { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }

.badges-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 10px;
}

.badge-tile {
    border-radius: 12px;
    padding: 10px 9px;
    border: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 106px;
    transition: all 0.16s ease;
    position: relative;
}

.badge-tile.free {
    background: linear-gradient(180deg, #FFFFFF 0%, #F0FDF4 100%);
    border-color: #A7F3D0;
    cursor: pointer;
}

.badge-tile.free:hover {
    transform: translateY(-2px);
    border-color: var(--green);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.12);
}

.badge-tile.free.selected {
    border: 2px solid var(--mhm-cyan);
    background: linear-gradient(180deg, #F0F9FF 0%, #E0F2FE 100%);
    box-shadow: 0 0 0 3px rgba(19, 156, 217, 0.20);
}

.badge-tile.busy {
    background: linear-gradient(180deg, #FFFBEB 0%, #FEF3C7 100%);
    border-color: #FCD34D;
}

.badge-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.badge-num {
    font-size: 20px;
    font-weight: 800;
    color: var(--mhm-navy);
    letter-spacing: -0.02em;
}

.badge-pdf-link {
    font-size: 10px;
    font-weight: 700;
    color: var(--mhm-cyan);
    text-decoration: none;
    padding: 2px 5px;
    border-radius: 5px;
    background: rgba(19, 156, 217, 0.10);
}

.badge-pdf-link:hover {
    background: var(--mhm-cyan);
    color: #FFFFFF;
}

.badge-status-lbl {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.badge-tile.free .badge-status-lbl { color: var(--green); }
.badge-tile.busy .badge-status-lbl { color: #B45309; }

.badge-holder {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.badge-out-btn {
    margin-top: 6px;
    width: 100%;
    border: none;
    background: var(--mhm-navy);
    color: #FFFFFF;
    font-size: 10.5px;
    font-weight: 700;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
}

.badge-out-btn:hover {
    background: var(--red);
}

/* ==========================================================================
   LAYOUT PRINCIPAL DE 2 COLUMNAS: FORMULARIO + BITÁCORA EN VIVO
   ========================================================================== */
.workspace-grid {
    display: grid;
    grid-template-columns: 410px 1fr;
    gap: 20px;
    align-items: start;
}

.panel-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    padding: 15px 20px;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.panel-header h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--mhm-navy);
}

.panel-body {
    padding: 18px 20px;
}

.autofill-hint {
    font-size: 11.5px;
    font-weight: 600;
    padding: 7px 10px;
    border-radius: 8px;
    display: none;
    margin-top: 4px;
}

.autofill-hint.ok {
    display: block;
    background: var(--green-soft);
    color: var(--green);
    border: 1px solid #A7F3D0;
}

.autofill-hint.warn {
    display: block;
    background: var(--amber-soft);
    color: #B45309;
    border: 1px solid #FCD34D;
}

/* FILTROS Y TABLA DE BITÁCORA */
.toolbar {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-pills {
    display: flex;
    gap: 6px;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 9px;
}

.filter-pill {
    border: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
}

.filter-pill.active {
    background: #FFFFFF;
    color: var(--mhm-navy);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}

.search-box input[type="search"] {
    max-width: 280px;
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border-strong);
    border-radius: 9px;
    font-size: 13px;
}

.hoy-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--mhm-navy);
    cursor: pointer;
    user-select: none;
}

.table-wrap {
    overflow-x: auto;
}

.visits-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.visits-table th {
    background: #F8FAFC;
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
}

.visits-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}

.visits-table tr:hover td {
    background: #F8FAFC;
}

.carnet-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 13px;
    background: var(--mhm-navy);
    color: #FFFFFF;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.status-pill.en_planta {
    background: #FEF3C7;
    color: #B45309;
}

.status-pill.finalizada {
    background: var(--green-soft);
    color: var(--green);
}

.sub-line {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.empty-state {
    text-align: center;
    padding: 42px 20px;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* ==========================================================================
   MODAL DE GESTIÓN DE USUARIOS Y TOASTS
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
}

.modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 880px;
    border-radius: 18px;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.32);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 22px;
    background: var(--mhm-navy);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 800;
}

.modal-close {
    border: none;
    background: rgba(255, 255, 255, 0.16);
    color: #FFFFFF;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
}

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 310px 1fr;
    gap: 20px;
}

.toast-box {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--mhm-navy);
    color: #FFFFFF;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--mhm-cyan);
    max-width: 380px;
}

.toast.error {
    background: #991B1B;
    border-left-color: #FCA5A5;
}

@media (max-width: 1180px) {
    .badges-grid { grid-template-columns: repeat(5, 1fr); }
    .workspace-grid { grid-template-columns: 1fr; }
    .modal-body { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .badges-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
