/* ============================================================================
   MisCuentas — estilos custom encima de Tailwind CDN.
   Mobile first. Tipografía sistema. Números tabulares en columnas de monto.
============================================================================ */

:root {
    --color-ingreso: #16a34a;
    --color-egreso: #dc2626;
    --color-pendiente: #eab308;
    --color-vencido: #b91c1c;
    --color-conciliado: #2563eb;
    --color-fondo: #f6f8fb;
    --color-borde: #e6eaf0;
    --color-texto: #0f172a;
    --color-texto-suave: #64748b;
    --color-acento: #2563eb;
    --color-acento-hover: #1d4ed8;

    /* Sombras "premium" en capas — inspiradas en Linear / Stripe / Vercel */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 8px -2px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 20px -4px rgba(15, 23, 42, 0.07), 0 4px 8px -2px rgba(15, 23, 42, 0.05);
    --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.14);

    --transition: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    -webkit-tap-highlight-color: transparent;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
                 "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
    letter-spacing: -0.005em;
}

/* ============================================================================
   Header / Brand
============================================================================ */
.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--color-borde);
}
.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--color-texto);
    border-radius: 0.625rem;
    padding: 0.25rem 0.375rem;
    margin: -0.25rem -0.375rem;
    transition: background var(--transition);
}
.app-brand:hover { background: rgba(37, 99, 235, 0.06); }
.app-brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 0.625rem;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.app-brand-text {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.1;
}
.app-brand-nombre {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-texto);
    letter-spacing: -0.01em;
}
.app-brand-titulo {
    font-size: 0.75rem;
    color: var(--color-texto-suave);
    margin-top: 2px;
}
.app-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    color: var(--color-texto-suave);
    transition: background var(--transition), color var(--transition);
}
.app-icon-btn:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--color-texto);
}

/* Números de monto: tabulares + alineados a la derecha */
.monto {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    text-align: right;
    font-weight: 500;
}
.monto-ingreso { color: var(--color-ingreso); }
.monto-egreso  { color: var(--color-egreso); }

/* Estados */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
}
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-vencido   { background: #fee2e2; color: var(--color-vencido); }
.badge-conciliado{ background: #dbeafe; color: var(--color-conciliado); }
.badge-confirmado{ background: #dcfce7; color: var(--color-ingreso); }
.badge-auto      { background: #ede9fe; color: #6d28d9; }
.badge-pago      { background: #ffe4e6; color: #9f1239; }

/* Botones de acción inline (Editar / Eliminar / Pagar) en listados */
.btn-accion {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    line-height: 1rem;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    cursor: pointer;
    text-decoration: none;
    background: transparent;
    font-family: inherit;
}
.btn-accion-editar    { color: #1d4ed8; border-color: #dbeafe; }
.btn-accion-editar:hover    { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }

.btn-accion-eliminar  { color: #b91c1c; border-color: #fee2e2; }
.btn-accion-eliminar:hover  { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }

.btn-accion-pagar     { color: #047857; border-color: #d1fae5; font-weight: 500; }
.btn-accion-pagar:hover     { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }

/* Ayudas contextuales (helper tips() en PHP) */
.tips-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
    padding: 0.5rem 0.875rem;
    transition: background 0.2s;
}
.tips-box[open]            { background: #dbeafe; }
.tips-box summary          {
    cursor: pointer;
    color: #1e40af;
    font-weight: 500;
    font-size: 0.875rem;
    list-style: none;
    user-select: none;
}
.tips-box summary::-webkit-details-marker { display: none; }
.tips-box summary::before  { content: '▸ '; font-size: 0.75rem; }
.tips-box[open] summary::before { content: '▾ '; }
.tips-box summary:hover    { color: #1e3a8a; }
.tips-content              {
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px solid #93c5fd;
    color: #1e3a8a;
    font-size: 0.875rem;
    line-height: 1.55;
}
.tips-content > *:last-child { margin-bottom: 0; }
.tips-content p            { margin: 0 0 0.5rem 0; }
.tips-content ul, .tips-content ol { margin: 0.25rem 0 0.5rem 1.25rem; }
.tips-content li           { margin-bottom: 0.25rem; }
.tips-content code         {
    background: #c7d2fe;
    color: #312e81;
    padding: 0.0625rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.8125rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
}
.tips-content strong       { color: #1e3a8a; font-weight: 600; }
.tips-content em           { color: #3730a3; font-style: italic; }
.tips-content table        { font-size: 0.8125rem; border-collapse: collapse; margin: 0.25rem 0; }
.tips-content th, .tips-content td { padding: 0.25rem 0.625rem; border: 1px solid #93c5fd; }
.tips-content th           { background: #bfdbfe; font-weight: 600; }

/* Inputs, selects, botones (encima de Tailwind para no repetir clases) */
.input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--color-borde);
    border-radius: 0.5rem;
    background: white;
    color: var(--color-texto);
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    border-radius: 0.625rem;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.25;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color var(--transition), border-color var(--transition), transform 80ms ease, box-shadow var(--transition);
    user-select: none;
    box-shadow: var(--shadow-xs);
    font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary,
.btn-primario  {
    background: linear-gradient(180deg, #2f6df7 0%, #2256d8 100%);
    color: white;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn-primary:hover,
.btn-primario:hover { background: linear-gradient(180deg, #2256d8 0%, #1a45b8 100%); }
.btn-secundario { background: white; color: var(--color-texto); border-color: var(--color-borde); }
/* Alpine.js: oculta elementos hasta que Alpine los procese (evita FOUC). */
[x-cloak] { display: none !important; }
.btn-secundario:hover { background: var(--color-fondo); }
.btn-peligro  { background: var(--color-egreso); color: white; }
.btn-peligro:hover { background: #b91c1c; }

/* Card estándar */
.card {
    background: white;
    border: 1px solid var(--color-borde);
    border-radius: 0.875rem;
    padding: 1.125rem 1.125rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition), border-color var(--transition);
}
.card-hover:hover, .card.is-link:hover {
    border-color: #d8e0eb;
    box-shadow: var(--shadow-md);
}
.card-titulo {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-texto-suave);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.625rem;
}

/* Hero del módulo asistente — métrica grande arriba */
.tile {
    background: white;
    border: 1px solid var(--color-borde);
    border-radius: 0.875rem;
    padding: 1rem 1rem 0.875rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--color-texto);
    position: relative;
    overflow: hidden;
}
.tile:hover {
    border-color: #d2dceb;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 0.625rem;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.tile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.tile-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-texto-suave);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.tile-metrica {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--color-texto);
    font-variant-numeric: tabular-nums;
}
.tile-sub {
    font-size: 0.8125rem;
    color: var(--color-texto-suave);
    line-height: 1.35;
}
.tile-flecha {
    color: #cbd5e1;
    transition: color var(--transition), transform var(--transition);
}
.tile:hover .tile-flecha {
    color: var(--color-acento);
    transform: translateX(2px);
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.4s ease-in-out infinite;
    border-radius: 0.375rem;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Mobile: tablas a cards. Aplicar en .tabla-responsive */
@media (max-width: 640px) {
    .tabla-responsive thead { display: none; }
    .tabla-responsive tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid var(--color-borde);
        border-radius: 0.5rem;
        padding: 0.5rem;
        background: white;
    }
    .tabla-responsive td {
        display: flex;
        justify-content: space-between;
        padding: 0.375rem 0.25rem;
        border: none;
    }
    .tabla-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-texto-suave);
        font-size: 0.8rem;
    }
}

/* Login form centrado */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: white;
    border: 1px solid var(--color-borde);
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
.login-titulo {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
}
.login-subtitulo {
    font-size: 0.9rem;
    text-align: center;
    color: var(--color-texto-suave);
    margin-bottom: 1.5rem;
}

/* Sidebar mobile bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--color-borde);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom, 0));
    z-index: 50;
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem 0.875rem;
    color: var(--color-texto-suave);
    font-size: 0.7rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0.625rem;
    transition: color var(--transition), background var(--transition);
}
.bottom-nav a:hover { color: var(--color-texto); background: rgba(15, 23, 42, 0.04); }
.bottom-nav a.activo { color: #2563eb; background: #eff6ff; }
.bottom-nav svg { width: 1.25rem; height: 1.25rem; }

/* Reservar espacio inferior para el bottom-nav */
.con-bottom-nav { padding-bottom: 5rem; }

/* Mensajes flash */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-ok      { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
