/* ═══════════════════════════════════════════════
   URBANIZACIÓN — Sistema de Gestión
   CSS Principal — Mobile First & Fully Responsive
═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w:     240px;
    --topbar-h:      56px;
    --bottomnav-h:   64px;

    --color-bg:      #f4f6f9;
    --color-surface: #ffffff;
    --color-border:  #e2e6ea;
    --color-text:    #1a1d23;
    --color-muted:   #6b7280;

    --color-blue:    #2563eb;
    --color-blue-l:  #eff6ff;
    --color-green:   #16a34a;
    --color-green-l: #f0fdf4;
    --color-amber:   #d97706;
    --color-amber-l: #fffbeb;
    --color-red:     #dc2626;
    --color-red-l:   #fef2f2;
    --color-purple:  #7c3aed;
    --color-purple-l:#faf5ff;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  20px;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,.12);
    --shadow-lg:  0 8px 32px rgba(0,0,0,.16);
}

html { -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    overscroll-behavior: none;
}

/* ══════════════════════════════════════════════
   AUTH PAGE
══════════════════════════════════════════════ */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    padding: 16px;
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 52px; display: block; margin-bottom: 8px; }
.auth-logo h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-logo p  { color: var(--color-muted); font-size: 13px; }

/* ══════════════════════════════════════════════
   TOPBAR (solo móvil)
══════════════════════════════════════════════ */

.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: #1e293b;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f1f5f9;
    font-weight: 700;
    font-size: 15px;
}

.topbar-logo span:first-child { font-size: 22px; }

.btn-menu {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-menu:hover { color: #fff; background: rgba(255,255,255,.08); }

.topbar-section-title {
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
}

/* ══════════════════════════════════════════════
   SIDEBAR OVERLAY (móvil)
══════════════════════════════════════════════ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 299;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .25s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ══════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    background: #1e293b;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 300;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-logo  { font-size: 24px; }
.sidebar-title { font-size: 15px; font-weight: 700; color: #f1f5f9; }

.sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
    cursor: pointer;
}
.nav-item:hover  { background: rgba(255,255,255,.07); color: #e2e8f0; }
.nav-item.active { background: var(--color-blue); color: #fff; }
.nav-icon { font-size: 16px; width: 30px; text-align: center; flex-shrink: 0; fill:white;}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.user-info { font-size: 12px; color: #94a3b8; margin-bottom: 10px; line-height: 1.4; }
.user-info strong { color: #e2e8f0; display: block; font-size: 13px; font-weight: 600; }

/* ══════════════════════════════════════════════
   BOTTOM NAV (solo móvil)
══════════════════════════════════════════════ */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: #1e293b;
    border-top: 1px solid rgba(255,255,255,.08);
    z-index: 200;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0,0,0,.2);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    color: #64748b;
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s, background .15s;
    min-width: 48px;
    text-align: center;
}
.bottom-nav-item .bnav-icon { font-size: 20px; line-height: 1; }
.bottom-nav-item.active { color: white; font-weight: 700; background: var(--color-blue); }
.bottom-nav-item:active  { background: rgba(255,255,255,.06); }

/* Botón "más" para el menú completo en móvil */
.bottom-nav-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    color: #64748b;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    min-width: 48px;
}
.bottom-nav-more .bnav-icon { font-size: 20px; line-height: 1; }

/* ══════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════ */

.main-content {
    margin-left: var(--sidebar-w);
    padding: 24px;
    min-height: 100vh;
}

/* ══════════════════════════════════════════════
   SECTIONS
══════════════════════════════════════════════ */

.section { display: none; }
.section.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.section-header h2 { font-size: 20px; font-weight: 800; }

.header-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════════
   STATS GRID
══════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 18px 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-border);
}
.stat-card.accent-blue  { border-left-color: var(--color-blue); }
.stat-card.accent-green { border-left-color: var(--color-green); }
.stat-card.accent-amber { border-left-color: var(--color-amber); }

.stat-number { font-size: 30px; font-weight: 800; line-height: 1; margin-bottom: 5px; }
.stat-label  { font-size: 11px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ══════════════════════════════════════════════
   PROGRESS
══════════════════════════════════════════════ */

.progress-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.progress-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}
.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 10px;
    font-weight: 600;
    gap: 8px;
}
.progress-bar {
    height: 8px;
    background: var(--color-bg);
    border-radius: 99px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .6s cubic-bezier(.4,0,.2,1);
    width: 0%;
}
.progress-fill.blue  { background: var(--color-blue); }
.progress-fill.green { background: var(--color-green); }

/* ══════════════════════════════════════════════
   FILTERS BAR
══════════════════════════════════════════════ */

.filters-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

/* ══════════════════════════════════════════════
   TABLE + CARD MODE (mobile)
══════════════════════════════════════════════ */

.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

/* En móvil las tablas se convierten en tarjetas */
.table-card-mode thead { display: none; }
.table-card-mode tbody tr {
    display: block;
    margin: 0;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}
.table-card-mode tbody tr:last-child { border-bottom: none; }
.table-card-mode tbody tr:hover { background: #f8fafc; }

.table-card-mode td {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 3px 0;
    border: none;
    font-size: 13px;
}
.table-card-mode td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    min-width: 90px;
    flex-shrink: 0;
    padding-top: 2px;
}
/* Celdas sin label (acciones) */
.table-card-mode td[data-label=""]::before { display: none; }
.table-card-mode td[data-label=""] {
    margin-top: 10px;
    gap: 6px;
    flex-wrap: wrap;
}
/* Primera celda: destacada como título */
.table-card-mode td:first-child {
    font-weight: 700;
    font-size: 15px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
}
.table-card-mode td:first-child::before { display: none; }

/* ══════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════ */

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-green  { background: var(--color-green-l);  color: #166534; }
.badge-red    { background: var(--color-red-l);    color: #991b1b; }
.badge-blue   { background: var(--color-blue-l);   color: #1e40af; }
.badge-amber  { background: var(--color-amber-l);  color: #92400e; }
.badge-purple { background: var(--color-purple-l); color: #5b21b6; }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    transition: opacity .15s, transform .1s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
.btn:hover   { opacity: .88; }
.btn:active  { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--color-blue);  color: #fff; }
.btn-success { background: var(--color-green); color: #fff; }
.btn-danger  { background: var(--color-red);   color: #fff; }
.btn-ghost   { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-sm  { padding: 6px 12px;  font-size: 12.5px; }
.btn-xs  { padding: 4px 8px;   font-size: 11.5px; min-height: 28px; }
.btn-full { width: 100%; }

/* ══════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════ */

.form-group { margin-bottom: 14px; flex: 1; }
.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #374151;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 16px;   /* 16px evita zoom en iOS */
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group textarea { resize: vertical; min-height: 72px; }

.form-row { display: flex; gap: 12px; }

.form-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    max-width: 640px;
}
.form-hint {
    color: var(--color-muted);
    font-size: 13px;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: #f0f9ff;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-blue);
    line-height: 1.6;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.select-sm {
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--color-surface);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* ══════════════════════════════════════════════
   INPUT SEARCH
══════════════════════════════════════════════ */

.input-search {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}
.input-search:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ══════════════════════════════════════════════
   FILE UPLOAD
══════════════════════════════════════════════ */

.file-upload {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color .15s;
}
.file-upload:hover,
.file-upload:focus-within { border-color: var(--color-blue); }
.file-upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 24px 16px;
    cursor: pointer;
    text-align: center;
}
.file-icon { font-size: 28px; }
.file-upload-inner small { color: var(--color-muted); font-size: 12px; }

/* ══════════════════════════════════════════════
   ALERTS
══════════════════════════════════════════════ */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
    line-height: 1.5;
}
.alert-danger  { background: var(--color-red-l);   color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--color-green-l); color: #166534; border: 1px solid #bbf7d0; }

/* ══════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════ */

.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1000;
    align-items: flex-end;       /* mobile: sube desde abajo */
    justify-content: center;
}
.modal.open { display: flex; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;  /* bottom sheet en móvil */
    padding: 0;
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    animation: slideUp .28s cubic-bezier(.4,0,.2,1);
}

/* Handle del bottom sheet */
.modal-content::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 12px auto 0;
}

.modal-inner {
    padding: 16px 24px 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-top: 4px;
}
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-close {
    background: var(--color-bg);
    border: none;
    cursor: pointer;
    font-size: 15px;
    color: var(--color-muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}
.modal-close:hover { background: var(--color-border); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: .6; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ══════════════════════════════════════════════
   FINANCE CARDS
══════════════════════════════════════════════ */

.finance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.finance-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}
.finance-card.income   { border-top: 3px solid var(--color-green); }
.finance-card.expenses { border-top: 3px solid var(--color-red); }
.finance-card h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 14px; }

.finance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    gap: 8px;
}
.finance-row:last-child { border-bottom: none; }
.finance-row.total {
    font-weight: 700;
    font-size: 13.5px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    border-bottom: none;
    margin-top: 4px;
}
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.balance-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    border: 2px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}
.balance-card.positive { border-color: var(--color-green); background: var(--color-green-l); }
.balance-card.negative { border-color: var(--color-red);   background: var(--color-red-l); }

.balance-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    margin-bottom: 8px;
}
.balance-amount { font-size: 34px; font-weight: 900; }
.balance-amount.positive { color: var(--color-green); }
.balance-amount.negative { color: var(--color-red); }

/* ══════════════════════════════════════════════
   CASA INFO
══════════════════════════════════════════════ */

.casa-info { margin-bottom: 16px; }
.info-box {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--color-blue-l);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 14px 18px;
}
.info-icon    { font-size: 28px; flex-shrink: 0; }
.info-box strong { font-size: 16px; }
.info-box p   { color: var(--color-muted); font-size: 13px; }

/* ══════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════ */

.toast {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    max-width: 360px;
    margin: 0 auto;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    transform: translateY(20px);
    opacity: 0;
    transition: all .3s cubic-bezier(.4,0,.2,1);
    z-index: 9999;
    box-shadow: var(--shadow-md);
    text-align: center;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--color-green); }
.toast-error   { background: var(--color-red); }
.toast-warning { background: var(--color-amber); }

/* ══════════════════════════════════════════════
   CALENDARIO DE PAGOS (detalle de casa)
══════════════════════════════════════════════ */

.cal-loading {
    text-align: center;
    color: var(--color-muted);
    font-size: 13px;
    padding: 20px;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.cal-mes {
    border-radius: var(--radius-md);
    padding: 10px 6px;
    text-align: center;
    border: 2px solid transparent;
    cursor: default;
    transition: transform .15s;
    position: relative;
}
.cal-mes:hover { transform: translateY(-2px); }

/* Colores por estado */
.cal-ambos {
    background: #dcfce7;
    border-color: #86efac;
}
.cal-agua {
    background: #dbeafe;
    border-color: #93c5fd;
}
.cal-vig {
    background: #f3e8ff;
    border-color: #d8b4fe;
}
.cal-nada {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Mes actual: borde más grueso */
.cal-hoy {
    border-width: 2.5px;
    box-shadow: 0 0 0 2px rgba(37,99,235,.2);
}
.cal-hoy .cal-mes-nombre::after {
    content: ' ●';
    font-size: 7px;
    color: var(--color-blue);
    vertical-align: super;
}

.cal-mes-nombre {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #374151;
    margin-bottom: 4px;
}
.cal-emojis {
    font-size: 18px;
    line-height: 1.2;
    margin-bottom: 3px;
}
.cal-nada .cal-emojis {
    font-size: 14px;
    color: #ef4444;
    font-weight: 800;
}
.cal-label {
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6b7280;
}

/* Responsive: 4 columnas en tablet, 3 en móvil */
@media (max-width: 768px) {
    .cal-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .cal-mes  { padding: 8px 4px; }
    .cal-emojis { font-size: 16px; }
}
@media (max-width: 480px) {
    .cal-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .cal-mes-nombre { font-size: 10px; }
    .cal-label { display: none; }
}

/* ══════════════════════════════════════════════
   ACCIONES
══════════════════════════════════════════════ */

.acciones-col {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════════
   UTILS
══════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-muted  { color: var(--color-muted); }
.text-danger { color: var(--color-red); }
code {
    font-family: "SF Mono", "Fira Code", monospace;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* ══════════════════════════════════════════════
   DESKTOP — sidebar visible, sin topbar/bottomnav
══════════════════════════════════════════════ */

@media (min-width: 769px) {
    .topbar      { display: none !important; }
    .bottom-nav  { display: none !important; }
    .sidebar-overlay { display: none !important; }
    .sidebar { transform: translateX(0) !important; }
    .main-content { margin-left: var(--sidebar-w); padding: 24px; }

    /* Modals centrados en desktop */
    .modal { align-items: center; }
    .modal-content {
        border-radius: var(--radius-lg);
        max-width: 540px;
        max-height: 88vh;
        animation: fadeScaleIn .22s ease;
    }
    .modal-content::before { display: none; }
    .modal-inner { padding: 24px 28px 28px; }

    @keyframes fadeScaleIn {
        from { transform: scale(.95); opacity: 0; }
        to   { transform: scale(1);   opacity: 1; }
    }
}

/* ══════════════════════════════════════════════
   TABLET — sidebar colapsable, sin bottom nav
══════════════════════════════════════════════ */

@media (min-width: 600px) and (max-width: 768px) {
    .topbar { display: flex; }
    .bottom-nav { display: none; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 80px 16px 24px; }
    .toast { bottom: 16px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Tablas con scroll horizontal en tablet */
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ══════════════════════════════════════════════
   MÓVIL — todo adaptado
══════════════════════════════════════════════ */

@media (max-width: 599px) {
    .topbar     { display: flex; }
    .bottom-nav { display: flex; }

    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        padding: calc(var(--topbar-h) + 12px) 12px calc(var(--bottomnav-h) + 12px);
        min-height: 100dvh;
    }

    /* Header de sección en móvil */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 14px;
    }
    .section-header h2 { font-size: 18px; }
    .section-header > div { width: 100%; }
    .header-filters { width: 100%; }
    .header-filters select,
    .header-filters button { flex: 1; min-width: 0; }

    /* Stats: 2 columnas en móvil */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-number { font-size: 26px; }

    /* Progress: 1 columna */
    .progress-section { grid-template-columns: 1fr; }

    /* Filters bar en móvil */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px;
    }
    .filters-bar select,
    .filters-bar .select-sm,
    .filters-bar .input-search,
    .filters-bar button { width: 100%; font-size: 15px; }

    /* Tablas → cards en móvil */
    .table-wrapper { border-radius: var(--radius-md); overflow: hidden; }
    .table { display: block; }
    .table thead { display: none; }
    .table tbody { display: block; }
    .table tbody tr {
        display: block;
        padding: 14px 16px;
        border-bottom: 1px solid var(--color-border);
        position: relative;
    }
    .table tbody tr:last-child { border-bottom: none; }
    .table tbody tr:hover { background: #f8fafc; }
    .table td {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding: 4px 0;
        border: none;
        font-size: 13.5px;
        line-height: 1.4;
    }
    .table td::before {
        content: attr(data-label);
        font-size: 10.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--color-muted);
        min-width: 84px;
        flex-shrink: 0;
        padding-top: 3px;
    }
    .table td[data-label=""]::before { display: none; }
    .table td[data-label=""] {
        margin-top: 10px;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    /* Primera celda: título de la card */
    .table td:first-child {
        font-weight: 800;
        font-size: 15px;
        padding-bottom: 8px;
        margin-bottom: 4px;
        border-bottom: 1px solid #f1f5f9;
    }
    .table td:first-child::before { display: none; }

    /* Botones en tablas-card: tamaño cómodo para dedo */
    .table .btn-xs { padding: 6px 12px; font-size: 12px; min-height: 34px; }

    /* Finanzas en móvil: 1 columna */
    .finance-grid { grid-template-columns: 1fr; }
    .balance-amount { font-size: 28px; }

    /* Modal en móvil: bottom sheet */
    .modal { align-items: flex-end; }
    .modal-content { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
    .modal-inner { padding: 12px 16px 28px; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
    .modal-header h3 { font-size: 16px; }

    /* Form rows → columnas en móvil */
    .form-row { flex-direction: column; gap: 0; }

    /* Modal actions: botones full en móvil */
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

    /* Toast encima de bottom nav */
    .toast {
        bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom));
        right: 12px;
        left: 12px;
    }

    /* Form card full width */
    .form-card { padding: 16px; border-radius: var(--radius-md); }

    /* Form acciones */
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; padding: 12px; font-size: 15px; }

    /* Acciones col en card */
    .acciones-col { margin-top: 8px; gap: 6px; }
    .acciones-col .btn-xs { flex: 1; min-width: 60px; }

    /* Info box */
    .info-box { padding: 12px 14px; gap: 10px; }
    .info-icon { font-size: 22px; }

    /* Section header buttons */
    .section-header .btn,
    .section-header > div { width: 100%; }
    .section-header > div.btn-group {
        display: flex;
        gap: 8px;
    }
    .section-header > div.btn-group .btn { flex: 1; }
}

/* ══════════════════════════════════════════════
   SMALL PHONES (< 380px)
══════════════════════════════════════════════ */

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-number { font-size: 22px; }
    .stat-card { padding: 14px 12px; }
    .bottom-nav-item { padding: 6px 8px; min-width: 40px; }
    .bottom-nav-item .bnav-icon { font-size: 18px; }
    .bottom-nav-item span:last-child { font-size: 9px; }
}