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

:root {
    --primary: #4F86C6;
    --primary-dark: #3a6fa8;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --gray: #6c757d;
    --light: #f8f9fa;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 10px;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f0f4f8;
    color: #333;
    font-size: 15px;
}

/* NAV MOBILE */
nav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 200;
}
nav .brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 6px;
    border: none;
    background: none;
}
.nav-toggle span {
    width: 24px; height: 2px;
    background: #555;
    border-radius: 2px;
    transition: all 0.3s;
    display: block;
}
.nav-links {
    display: none;
    position: fixed;
    top: 54px; left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex-direction: column;
    padding: 8px 0;
    z-index: 199;
}
.nav-links.open { display: flex; }
.nav-links a {
    color: #555;
    text-decoration: none;
    padding: 13px 20px;
    font-size: 15px;
    border-bottom: 1px solid var(--light);
    transition: background 0.2s;
    display: block;
}
.nav-links a:hover { background: var(--light); color: var(--primary); }
.nav-links a.active { color: var(--primary); font-weight: 600; background: #eef4fc; }
.nav-links a:last-child { border-bottom: none; }

/* CONTENEDOR */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 12px 32px;
}

/* CARDS */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #444;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light);
}

/* STAT CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 12px;
    text-align: center;
    border-top: 4px solid var(--primary);
}
.stat-card.verde   { border-top-color: var(--success); }
.stat-card.rojo    { border-top-color: var(--danger); }
.stat-card.naranja { border-top-color: var(--warning); }
.stat-card .valor  { font-size: 20px; font-weight: 700; color: #222; margin: 4px 0 3px; }
.stat-card .label  { font-size: 11px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.4px; }

/* BOTONES */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover, .btn-success:active { background: #27ae60; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover,  .btn-danger:active  { background: #c0392b; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover, .btn-warning:active { background: #d68910; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover, .btn-outline:active { background: var(--primary); color: #fff; }
.btn-sm  { padding: 7px 14px; font-size: 13px; }
.btn-xs  { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* TABLAS — scroll horizontal en mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 400px; }
thead th {
    background: var(--light);
    padding: 9px 10px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: #d4f1e3; color: #1a7a47; }
.badge-danger  { background: #fde8e8; color: #c0392b; }
.badge-warning { background: #fef3cd; color: #856404; }
.badge-info    { background: #d0e8ff; color: #1a5fa8; }

/* FORMULARIOS */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 5px; }
.form-control {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border 0.2s;
    background: #fff;
    -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,134,198,0.15); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0; }

/* ALERTS */
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 500;
}
.alert-success { background: #d4f1e3; color: #1a7a47; border-left: 4px solid var(--success); }
.alert-danger  { background: #fde8e8; color: #c0392b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef3cd; color: #856404; border-left: 4px solid var(--warning); }

/* LOGIN */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f0fe 0%, #f0f4f8 100%);
    padding: 16px;
}
.login-box {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}
.login-box h1 { text-align: center; color: var(--primary); font-size: 22px; margin-bottom: 4px; }
.login-box p  { text-align: center; color: var(--gray); font-size: 13px; margin-bottom: 24px; }

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    padding: 24px 20px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
}
.modal-handle {
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray); line-height: 1; padding: 4px; }

/* PAGE HEADER */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h2 { font-size: 18px; font-weight: 700; color: #333; }

/* CUOTAS GRID */
.cuotas-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.mes-btn {
    padding: 8px 4px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: #555;
}
.mes-btn.pagado    { background: #d4f1e3; border-color: var(--success); color: #1a7a47; }
.mes-btn.pendiente { border-color: var(--warning); }

/* CUOTA ROW (portal apoderado) */
.cuota-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}
.cuota-row:last-child { border-bottom: none; }

/* MISC */
.text-muted  { color: var(--gray); font-size: 13px; }
.text-right  { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }

/* BOLETA GRID */
.boleta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.boleta-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.boleta-preview { width: 100%; height: 140px; object-fit: cover; display: block; background: var(--light); }
.boleta-preview-pdf { width:100%; height:140px; display:flex; align-items:center; justify-content:center; background:var(--light); font-size:40px; }
.boleta-footer { padding: 8px 10px; display:flex; justify-content:space-between; align-items:center; border-top:1px solid var(--border); gap:6px; }

/* DOT */
.dot { width:16px; height:16px; border-radius:50%; display:inline-block; vertical-align:middle; }
.dot.pagado    { background: var(--success); }
.dot.pendiente { background: #e0e0e0; }
.dot.futuro    { background: #f0f0f0; border: 1px solid #ddd; }

/* CHECK BTN (cuotas admin) */
.check-btn {
    width: 38px; height: 32px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.check-btn.pagado { background: #d4f1e3; border-color: var(--success); }

/* DESKTOP (768px+) */
@media (min-width: 768px) {
    .container { padding: 24px 20px 40px; }
    .card { padding: 22px 24px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .stat-card .valor { font-size: 24px; }
    .form-row { grid-template-columns: 1fr 1fr; gap: 16px; }
    .cuotas-grid { grid-template-columns: repeat(10, 1fr); }
    .boleta-grid { grid-template-columns: repeat(3, 1fr); }

    /* Nav desktop */
    .nav-toggle { display: none; }
    nav { padding: 0 24px; }
    nav .brand { max-width: none; }
    .nav-links {
        display: flex !important;
        position: static;
        flex-direction: row;
        border: none;
        box-shadow: none;
        padding: 0;
        background: transparent;
    }
    .nav-links a {
        padding: 4px 10px;
        border-bottom: none;
        font-size: 14px;
        border-radius: 6px;
        display: inline-block;
    }

    /* Modal centrado en desktop */
    .modal-overlay { align-items: center; padding: 20px; }
    .modal {
        border-radius: 12px;
        max-width: 500px;
        max-height: 88vh;
    }
    .modal-handle { display: none; }
    .page-header h2 { font-size: 20px; }
}

@media (min-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(6, 1fr); }
    .boleta-grid { grid-template-columns: repeat(4, 1fr); }
}
