* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Arial, sans-serif; }
body { background: #f0f2f5; color: #1a2a3a; }

.topbar {
    background: #ffffff;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #2e7d32;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    height: 60px;
}
.topbar .izq { display: flex; align-items: center; gap: 15px; }
.topbar .der { display: flex; align-items: center; gap: 15px; }
.topbar .titulo { color: #1b5e20; font-size: 20px; font-weight: bold; letter-spacing: 1px; }
.topbar .bienvenido { color: #3a5a4a; font-size: 14px; display: none; }
.topbar .bienvenido span { color: #1b5e20; font-weight: bold; }
.topbar .perfil-btn {
    background: #e8f5e9;
    border: none;
    color: #1b5e20;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.topbar .perfil-btn:hover { background: #c8e6c9; }
.menu-btn {
    background: none;
    border: none;
    color: #1b5e20;
    font-size: 30px;
    cursor: pointer;
    padding: 0 5px;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 290px;
    height: 100%;
    background: #ffffff;
    border-right: 2px solid #2e7d32;
    transition: left 0.3s ease;
    z-index: 999;
    padding-top: 70px;
    overflow-y: auto;
}
.sidebar.open { left: 0; }
.sidebar a {
    display: flex;
    align-items: center;
    padding: 14px 25px;
    color: #2a4a3a;
    text-decoration: none;
    font-size: 15px;
    border-bottom: 1px solid #e8f5e9;
    transition: background 0.2s, color 0.2s;
    gap: 12px;
}
.sidebar a:hover { background: #e8f5e9; color: #1b5e20; }
.sidebar a .icono { font-size: 18px; width: 28px; text-align: center; }
.sidebar .cerrar-sesion { color: #c0392b; border-top: 2px solid #e74c3c; margin-top: 15px; }
.sidebar .cerrar-sesion:hover { background: #fde8e6; color: #a93226; }
.sidebar .admin-link { color: #e67e22; border-top: 2px solid #f39c12; margin-top: 8px; }

.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.25);
    z-index: 998;
    display: none;
}
.overlay.show { display: block; }

.content {
    margin-top: 60px;
    padding: 16px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    min-height: calc(100vh - 60px);
}

.seccion { display: none; }
.seccion.activa { display: block; }

.bienvenida {
    background: #ffffff;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    border: 1px solid #c8e6c9;
    margin-bottom: 20px;
}
.bienvenida h2 { color: #1b3a2a; font-size: 22px; }
.bienvenida .dias {
    font-size: 18px;
    margin-top: 8px;
    color: #3a5a4a;
}
.bienvenida .dias span { color: #1b5e20; font-weight: bold; font-size: 26px; }
.bienvenida .dias.alerta span { color: #d68910; }
.bienvenida .dias.expirado span { color: #c0392b; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 15px;
}
.card {
    background: #ffffff;
    padding: 18px 12px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #c8e6c9;
}
.card .numero {
    font-size: 30px;
    font-weight: bold;
    color: #1b5e20;
}
.card .label {
    color: #3a5a4a;
    font-size: 13px;
    margin-top: 4px;
}

.panel-seccion {
    background: #ffffff;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #c8e6c9;
    margin-top: 15px;
}
.panel-seccion h3 { color: #1b3a2a; margin-bottom: 15px; font-size: 20px; }
.panel-seccion .vacio { color: #5a7a6a; text-align: center; padding: 30px 0; }

.btn-agregar {
    background: #2e7d32;
    color: white;
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 14px;
}
.btn-agregar:hover { background: #1b5e20; }

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-content {
    background: #ffffff;
    border-radius: 20px;
    padding: 30px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #a5d6a7;
}
.modal-content h2 { color: #1b3a2a; margin-bottom: 20px; text-align: center; font-size: 24px; }
.modal-content label { display: block; color: #2a5a3a; margin-top: 12px; font-size: 13px; }
.modal-content input, .modal-content select {
    width: 100%;
    padding: 12px;
    margin-top: 4px;
    background: #f1f8f2;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    color: #1a2a3a;
    font-size: 15px;
    outline: none;
}
.modal-content input:focus { border-color: #2e7d32; }
.modal-content .btn-guardar {
    background: #2e7d32;
    color: white;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
}
.modal-content .btn-guardar:hover { background: #1b5e20; }
.modal-content .btn-cerrar-modal {
    background: transparent;
    color: #4a7a5a;
    padding: 10px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
}

.tarjeta-audiencia {
    background: #ffffff;
    border: 2px solid #2e7d32;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
    margin-right: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s, transform 0.2s;
    display: inline-block;
    vertical-align: top;
    min-width: 200px;
    max-width: 280px;
    width: 100%;
}
.tarjeta-audiencia:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.10); transform: translateY(-2px); }
.tarjeta-audiencia .tarjeta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8f5e9;
    padding-bottom: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 4px;
}
.tarjeta-audiencia .tarjeta-numero { font-weight: bold; font-size: 14px; color: #1b3a2a; }
.tarjeta-audiencia .tarjeta-tipo { background: #2e7d32; color: white; padding: 2px 10px; border-radius: 20px; font-size: 10px; font-weight: bold; }
.tarjeta-audiencia .tarjeta-body { display: block; margin: 4px 0; }
.tarjeta-audiencia .tarjeta-fila { font-size: 12px; color: #1a2a3a; padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tarjeta-audiencia .tarjeta-label { display: inline-block; width: 18px; color: #4a7a5a; font-size: 12px; }
.tarjeta-audiencia .tarjeta-footer { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #e8f5e9; flex-wrap: wrap; }
.tarjeta-audiencia .btn-ver { background: #2a7de1; color: white; padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px; }
.tarjeta-audiencia .btn-ver:hover { background: #1a5fb0; }
.tarjeta-audiencia .btn-borrar-tarjeta { background: #e74c3c; color: white; padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px; }
.tarjeta-audiencia .btn-borrar-tarjeta:hover { background: #c0392b; }

.tarjeta-cliente {
    background: #ffffff;
    border: 2px solid #2e7d32;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 16px;
    margin-right: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s, transform 0.2s;
    display: inline-block;
    vertical-align: top;
    min-width: 220px;
    max-width: 280px;
    width: 100%;
}
.tarjeta-cliente:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
.tarjeta-cliente .tarjeta-header { border-bottom: 1px solid #e8f5e9; padding-bottom: 10px; margin-bottom: 10px; }
.tarjeta-cliente .tarjeta-numero { font-weight: bold; font-size: 15px; color: #1b3a2a; display: block; }
.tarjeta-cliente .tarjeta-body { margin: 8px 0; }
.tarjeta-cliente .tarjeta-fila { font-size: 13px; color: #1a2a3a; padding: 4px 0; display: flex; align-items: center; gap: 6px; }
.tarjeta-cliente .tarjeta-label { display: inline-block; width: 22px; color: #2e7d32; font-size: 14px; }
.tarjeta-cliente .tarjeta-footer { display: flex; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e8f5e9; flex-wrap: wrap; }
.tarjeta-cliente .btn-ver { background: #2a7de1; color: white; padding: 6px 18px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px; }
.tarjeta-cliente .btn-ver:hover { background: #1a5fb0; }
.tarjeta-cliente .btn-borrar-tarjeta { background: #e74c3c; color: white; padding: 6px 18px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px; }
.tarjeta-cliente .btn-borrar-tarjeta:hover { background: #c0392b; }

.tarjeta-agenda {
    background: #ffffff;
    border: 2px solid #2a7de1;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
    margin-right: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s, transform 0.2s;
    display: inline-block;
    vertical-align: top;
    min-width: 220px;
    max-width: 320px;
    width: 100%;
}
.tarjeta-agenda:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.10); transform: translateY(-2px); }
.tarjeta-agenda .tarjeta-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e8f0fe; padding-bottom: 8px; margin-bottom: 8px; flex-wrap: wrap; gap: 4px; }
.tarjeta-agenda .tarjeta-titulo { font-weight: bold; font-size: 14px; color: #1b3a6a; }
.tarjeta-agenda .tarjeta-body { display: block; margin: 4px 0; }
.tarjeta-agenda .tarjeta-fila { font-size: 12px; color: #1a2a3a; padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tarjeta-agenda .tarjeta-label { display: inline-block; width: 20px; color: #2a7de1; font-size: 12px; }
.tarjeta-agenda .tarjeta-footer { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #e8f0fe; flex-wrap: wrap; }
.tarjeta-agenda .btn-ver { background: #2a7de1; color: white; padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px; }
.tarjeta-agenda .btn-ver:hover { background: #1a5fb0; }
.tarjeta-agenda .btn-borrar-tarjeta { background: #e74c3c; color: white; padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px; }
.tarjeta-agenda .btn-borrar-tarjeta:hover { background: #c0392b; }

.tarjeta-tarea {
    background: #ffffff;
    border: 2px solid #d68910;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
    margin-right: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s, transform 0.2s;
    display: inline-block;
    vertical-align: top;
    min-width: 220px;
    max-width: 320px;
    width: 100%;
}
.tarjeta-tarea:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.10); transform: translateY(-2px); }
.tarjeta-tarea .tarjeta-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #fef5e7; padding-bottom: 8px; margin-bottom: 8px; flex-wrap: wrap; gap: 4px; }
.tarjeta-tarea .tarjeta-titulo { font-weight: bold; font-size: 14px; color: #1b3a2a; }
.tarjeta-tarea .tarjeta-body { display: block; margin: 4px 0; }
.tarjeta-tarea .tarjeta-fila { font-size: 12px; color: #1a2a3a; padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tarjeta-tarea .tarjeta-label { display: inline-block; width: 20px; color: #d68910; font-size: 12px; }
.tarjeta-tarea .tarjeta-footer { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #fef5e7; flex-wrap: wrap; }
.tarjeta-tarea .btn-ver { background: #2a7de1; color: white; padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px; }
.tarjeta-tarea .btn-ver:hover { background: #1a5fb0; }
.tarjeta-tarea .btn-borrar-tarjeta { background: #e74c3c; color: white; padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px; }
.tarjeta-tarea .btn-borrar-tarjeta:hover { background: #c0392b; }

.tabla-facturas {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.tabla-facturas th {
    background: #1b3a2a;
    color: white;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tabla-facturas td { padding: 10px 10px; border-bottom: 1px solid #e8f5e9; vertical-align: middle; }
.tabla-facturas tr:hover td { background: #f8fbf8; }

@media (min-width: 768px) {
    .topbar .bienvenido { display: inline; }
}
@media (max-width: 600px) {
    .topbar .bienvenido { display: none; }
    .topbar .titulo { font-size: 17px; }
    .sidebar { width: 250px; left: -250px; }
    .cards { grid-template-columns: repeat(2, 1fr); }
    .modal-content { padding: 20px; }
    .tarjeta-audiencia, .tarjeta-cliente, .tarjeta-agenda, .tarjeta-tarea {
        min-width: 100%;
        max-width: 100%;
        margin-right: 0;
    }
}

/* =============================================
   VERSIÓN RESPONSIVE (MÓVIL)
   ============================================= */

@media (max-width: 768px) {
    .topbar .bienvenido { display: none; }
    .topbar .titulo { font-size: 17px; }
    .sidebar { width: 250px; left: -250px; }
    .content { padding: 12px; margin-left: 0; }
    .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        padding: 5px 0px !important;
        margin: 0 !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
        background: #ffffff !important;
    }

    .modal {
        padding: 0 !important;
        margin: 0 !important;
    }

    .tarjeta-audiencia, .tarjeta-cliente, .tarjeta-agenda, .tarjeta-tarea {
        min-width: 100%;
        max-width: 100%;
        margin-right: 0;
    }
    
    .tabla-facturas, .panel-seccion table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .btn, .btn-agregar, .btn-filtro, .btn-pdf, .btn-ver, .btn-borrar-tarjeta {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .item-factura input::placeholder {
        color: #888 !important;
        font-size: 13px !important;
        opacity: 1 !important;
    }

    #panelNotificaciones { width: 280px !important; right: -10px !important; }
}

@media (max-width: 480px) {
    .topbar .titulo { font-size: 14px; }
    .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .card .numero { font-size: 22px; }
    .card .label { font-size: 11px; }
    .modal-content { padding: 15px; }
    .modal-content h2 { font-size: 18px; }
}