* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #f4f6f8; color: #222; }

.navbar {
    display: flex; align-items: center; gap: 16px;
    background: #1f2937; color: #fff; padding: 12px 24px;
}
.navbar a { color: #93c5fd; text-decoration: none; }
.navbar a:hover { text-decoration: underline; }
.navbar span { margin-left: auto; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef9c3; color: #854d0e; }

.login-box {
    max-width: 360px; margin: 80px auto; background: #fff;
    padding: 24px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.form-card { max-width: 480px; background: #fff; padding: 20px; border-radius: 10px; }
label { display: block; margin-top: 12px; font-weight: 600; font-size: 14px; }
input, select, button {
    width: 100%; padding: 9px 10px; margin-top: 4px;
    border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}
button {
    margin-top: 18px; background: #2563eb; color: #fff;
    border: none; cursor: pointer; font-weight: 600;
}
button:hover { background: #1d4ed8; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.card {
    display: block; background: #fff; padding: 20px; border-radius: 10px;
    text-decoration: none; color: #1f2937; font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,.06); transition: transform .15s;
}
.card:hover { transform: translateY(-2px); }

table { width: 100%; border-collapse: collapse; background: #fff; margin-top: 16px; border-radius: 8px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 14px; }
th { background: #f3f4f6; font-weight: 700; }


/* ========== Layout general ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { margin: 0; }

/* ========== Botones ========== */
.btn {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #1f2937;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    width: auto;
    margin: 0;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-link {
    background: transparent;
    border: none;
    color: #2563eb;
    text-decoration: underline;
    padding: 8px 4px;
}
.btn-link:hover { color: #1d4ed8; background: transparent; }

/* ========== Filtros / b煤squeda ========== */
.filters-bar, .search-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
    background: #fff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.filters-bar input[type="text"] { flex: 1; min-width: 200px; }
.filters-bar select { width: auto; min-width: 130px; }
.filters-bar button, .search-bar button { width: auto; padding: 8px 16px; }
.search-bar input[type="text"] { flex: 1; }

.results-info {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
}

/* ========== Tablas ========== */
.table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
table { margin-top: 0; }
th, td { white-space: nowrap; }
.text-center { text-align: center; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-admin { background: #fee2e2; color: #991b1b; }
.badge-residente { background: #dbeafe; color: #1e40af; }
.badge-guardia { background: #fef9c3; color: #854d0e; }

.actions-cell form { display: inline; }
.actions-cell button { margin-left: 4px; }

/* ========== Paginaci贸n ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-decoration: none;
    color: #1f2937;
    background: #fff;
    font-size: 14px;
}
.pagination a:hover { background: #f3f4f6; }
.pagination a.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    font-weight: 600;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-lg { max-width: 720px; }
.modal h3 { margin-bottom: 12px; }
.modal label { margin-top: 12px; }
.modal .hint { font-size: 12px; color: #6b7280; margin-top: 6px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ========== Selector de grupos ========== */
.grupo-picker { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.grupos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.grupo-item {
    padding: 12px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    transition: all .15s;
    width: 100%;
    margin: 0;
}
.grupo-item:hover { background: #eff6ff; border-color: #2563eb; }
.grupo-item.selected { background: #2563eb; color: #fff; border-color: #2563eb; }

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 20px;
}
.form-actions button { width: auto; padding: 10px 20px; margin: 0; }
.form-actions .btn-link { padding: 10px 4px; }


/* ========== Badges de notificación ========== */
.nav-notif {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.badge-notif {
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
    line-height: 1;
}
.nav-user {
    margin-left: auto;
    color: #d1d5db;
    font-size: 14px;
}

/* ========== Badges por prioridad ========== */
.badge-normal  { background: #dbeafe; color: #1e40af; }
.badge-alta    { background: #fef3c7; color: #92400e; }
.badge-urgente { background: #fee2e2; color: #991b1b; }

/* ========== Badges por estado ========== */
.badge-pendiente   { background: #fef3c7; color: #92400e; }
.badge-en_revision { background: #dbeafe; color: #1e40af; }
.badge-aprobada    { background: #dcfce7; color: #166534; }
.badge-rechazada   { background: #fee2e2; color: #991b1b; }
.badge-resuelta    { background: #e0e7ff; color: #3730a3; }

/* ========== Badges por tipo de solicitud ========== */
.badge-permiso       { background: #dbeafe; color: #1e40af; }
.badge-queja         { background: #fee2e2; color: #991b1b; }
.badge-sugerencia    { background: #dcfce7; color: #166534; }
.badge-mantenimiento { background: #fef3c7; color: #92400e; }
.badge-otro          { background: #e5e7eb; color: #374151; }

/* ========== Lista de avisos ========== */
.avisos-list { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.aviso-card {
    background: #fff;
    padding: 18px 20px;
    border-radius: 10px;
    border-left: 5px solid #2563eb;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.aviso-card.prioridad-alta    { border-left-color: #f59e0b; }
.aviso-card.prioridad-urgente { border-left-color: #dc2626; background: #fef2f2; }
.aviso-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.aviso-header h3 { margin: 0; font-size: 17px; }
.aviso-meta { font-size: 12px; color: #6b7280; margin-bottom: 10px; }
.aviso-body { line-height: 1.6; color: #374151; }

/* ========== Solicitud detalle ========== */
.solicitud-info {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.solicitud-info p { margin: 6px 0; }
.descripcion-box {
    background: #f9fafb;
    padding: 14px;
    border-radius: 6px;
    margin-top: 8px;
    line-height: 1.6;
}

/* ========== Chat ========== */
.chat { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.chat-msg {
    background: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border-left: 4px solid #d1d5db;
    max-width: 85%;
}
.chat-user { align-self: flex-start; border-left-color: #2563eb; }
.chat-admin { align-self: flex-end; border-left-color: #16a34a; background: #f0fdf4; }
.chat-interno { background: #fef9c3; border-left-color: #ca8a04; }
.chat-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.chat-time { margin-left: auto; }
.chat-body { line-height: 1.6; color: #374151; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    margin-top: 8px;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    margin-top: 4px;
    resize: vertical;
}

/* ========== Horas tabs ========== */
.horas-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.horas-tabs a {
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    background: #fff;
    border: 1px solid #e5e7eb;
    position: relative;
}
.horas-tabs a:hover { background: #f3f4f6; }
.horas-tabs a.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.horas-tabs a.vacio { opacity: .45; }
.horas-tabs .count {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
}

/* ========== Notificaciones ========== */
.notifs-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.notif-card {
    background: #fff;
    padding: 14px 18px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border-left: 4px solid #2563eb;
}
.notif-card.notif-nueva { background: #eff6ff; border-left-color: #2563eb; }
.notif-card.notif-leida { opacity: .7; border-left-color: #d1d5db; }
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 10px;
}
.notif-time { font-size: 12px; color: #6b7280; }

/* ========== Badges de estado de visita ========== */
.badge-programada { background: #dbeafe; color: #1e40af; }
.badge-llego      { background: #dcfce7; color: #166534; }
.badge-salio      { background: #e0e7ff; color: #3730a3; }
.badge-no_asistio { background: #f3f4f6; color: #6b7280; }
.badge-cancelada  { background: #fee2e2; color: #991b1b; }

input[type="file"] {
    padding: 8px;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
}


/* ========== Badges de pago ========== */
.badge-pendiente  { background: #fef3c7; color: #92400e; }
.badge-parcial    { background: #dbeafe; color: #1e40af; }
.badge-pagado     { background: #dcfce7; color: #166534; }
.badge-cancelado  { background: #f3f4f6; color: #6b7280; }
.badge-vencido    { background: #fee2e2; color: #991b1b; }
.badge-aprobado   { background: #dcfce7; color: #166534; }
.badge-rechazado  { background: #fee2e2; color: #991b1b; }
.badge-reembolsado { background: #e0e7ff; color: #3730a3; }

/* ========== Métodos de pago destacados ========== */
.mp-button {
    background: #009ee3;
    color: white;
    border: none;
    padding: 12px 24px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
}
.mp-button:hover { background: #0073b7; 


/* ========== Dashboard stats ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.stat-card {
    display: block;
    background: #fff;
    padding: 18px 20px;
    border-radius: 12px;
    text-decoration: none;
    color: #1f2937;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    transition: transform .15s, box-shadow .15s;
    border-left: 4px solid #2563eb;
    position: relative;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,.1);
}
.stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    margin: 4px 0;
}
.stat-card .stat-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.stat-card .stat-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.stat-blue   { border-left-color: #2563eb; }
.stat-purple { border-left-color: #7c3aed; }
.stat-gray   { border-left-color: #6b7280; }
.stat-orange { border-left-color: #f59e0b; }
.stat-green  { border-left-color: #16a34a; }
.stat-red    { border-left-color: #dc2626; }
.stat-cyan   { border-left-color: #0891b2; }
.stat-yellow { border-left-color: #ca8a04; }

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .grid-2col { grid-template-columns: 1fr; }
}

.card-panel {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-panel h2 {
    font-size: 17px;
    margin-bottom: 14px;
    color: #374151;
}

.ingreso-grande {
    font-size: 40px;
    font-weight: 800;
    color: #16a34a;
    margin: 8px 0;
    line-height: 1;
}

.text-green { color: #16a34a; font-weight: 600; }
.text-red   { color: #dc2626; font-weight: 600; }

/* ========== Botones de exportación ========== */
.export-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.export-bar .btn {
    font-size: 13px;
}

/* ============================================
   MEJORAS MÓVILES PARA GUARDIAS
   ============================================ */

/* Ocultar la barra superior típica en móvil para guardias */
@media (max-width: 640px) {
    .mobile-bottom-nav ~ .container,
    body:has(.mobile-bottom-nav) .container {
        padding-bottom: 90px;
    }
}

/* Barra inferior de navegación móvil */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    color: #6b7280;
    text-decoration: none;
    font-size: 11px;
    gap: 2px;
    transition: all .15s;
    min-width: 0;
}

.mobile-bottom-nav a span {
    font-size: 22px;
    line-height: 1;
}

.mobile-bottom-nav a small {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mobile-bottom-nav a.active {
    color: #2563eb;
    background: #eff6ff;
}

/* Tarjetas de visitas para móvil */
.cards-mobile {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.card-visita-mobile {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border-left: 4px solid #2563eb;
}

.card-visita-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.visita-hora {
    font-size: 24px;
    font-weight: 800;
    color: #2563eb;
}

.visita-nombre {
    font-size: 17px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.visita-detalle {
    font-size: 14px;
    color: #4b5563;
    margin: 4px 0;
}

.card-visita-actions {
    margin-top: 14px;
}

.btn-large {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px;
}

.visita-completada {
    text-align: center;
    padding: 12px;
    background: #dcfce7;
    color: #166534;
    border-radius: 8px;
    font-weight: 600;
}

/* Formulario móvil */
.mobile-form label {
    font-size: 15px;
    margin-top: 16px;
}

.mobile-form input,
.mobile-form select,
.mobile-form textarea {
    font-size: 16px; /* evita zoom en iOS */
    padding: 12px 14px;
}

.file-input-mobile {
    padding: 12px;
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    width: 100%;
}

.sticky-bottom {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 16px 0;
    margin-top: 20px;
    border-top: 1px solid #e5e7eb;
}

/* ============================================
   RESPONSIVE GENERAL
   ============================================ */

@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    .cards-mobile { display: flex; }
    .mobile-bottom-nav { display: flex; }
}

@media (min-width: 901px) {
    .cards-mobile { display: none !important; }
}

/* Ajustes generales en móvil */
@media (max-width: 640px) {
    .container {
        padding: 0 12px;
        margin: 12px auto;
    }

    .navbar {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
        font-size: 13px;
    }

    .navbar strong {
        font-size: 15px;
    }

    .navbar a {
        font-size: 13px;
    }

    .nav-user {
        font-size: 12px;
        width: 100%;
        margin-left: 0;
        margin-top: 6px;
    }

    h1 { font-size: 22px; }
    h2 { font-size: 18px; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .mobile-header .btn-mobile-full,
    .page-header .btn {
        width: 100%;
        text-align: center;
    }

    .mobile-filters {
        flex-direction: column;
    }

    .mobile-filters input,
    .mobile-filters button,
    .mobile-filters select {
        width: 100%;
    }

    .mobile-tabs {
        gap: 4px;
        padding: 8px 0;
    }

    .mobile-tabs a {
        padding: 8px 10px;
        font-size: 13px;
        min-width: 46px;
        text-align: center;
    }

    .stat-card .stat-value { font-size: 26px; }
    .stat-card .stat-icon { font-size: 22px; }

    .ingreso-grande { font-size: 32px; }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn { width: 100%; }

    .modal { padding: 18px; max-width: 95%; }

    table {
        font-size: 13px;
    }

    th, td { padding: 8px; }

    .chat-msg { max-width: 95%; }
}