/* ============================================
   Finanzas Familiares - Design System
   Basado en el diseño Stitch: Entrada_gastos
   Font: Inter | Primary: #1152d4 | Rounded: 8px
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
    --primary: #1152d4;
    --primary-light: #e8effc;
    --primary-dark: #0d3fa3;
    --primary-gradient: linear-gradient(135deg, #1152d4 0%, #2b6de8 100%);

    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3CD;

    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a1628 0%, #1a2744 50%, #0f1d36 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(17, 82, 212, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 30%, rgba(43, 109, 232, 0.1) 0%, transparent 40%);
    animation: floatGradient 15s ease-in-out infinite;
}

@keyframes floatGradient {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(1deg); }
    66% { transform: translate(-20px, 20px) rotate(-1deg); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-xl), 0 0 80px rgba(17, 82, 212, 0.08);
    backdrop-filter: blur(20px);
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-image {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(17, 82, 212, 0.2);
    object-fit: cover;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.login-logo p {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.login-tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 28px;
    gap: 4px;
}

.login-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: var(--transition);
}

.login-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.login-tab:hover:not(.active) {
    color: var(--gray-700);
}

/* ---- Form Elements ---- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: white;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 82, 212, 0.12);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: white;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: var(--transition);
    outline: none;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 82, 212, 0.12);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(17, 82, 212, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 14px rgba(17, 82, 212, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Navbar */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--gray-900);
}

.nav-brand .nav-logo-image {
    height: 32px;
    width: auto;
    border-radius: 4px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    font-family: 'Inter', sans-serif;
}

.nav-link:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

.nav-link.active {
    color: var(--primary);
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray-500);
    font-size: 16px;
}

.nav-icon-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
}

.nav-user-menu {
    position: absolute;
    top: 44px;
    right: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    min-width: 200px;
    padding: 8px;
    display: none;
    z-index: 999;
}

.nav-user-menu.show {
    display: block;
    animation: fadeInUp 0.15s ease;
}

.nav-user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    font-family: 'Inter', sans-serif;
}

.nav-user-menu-item:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

.nav-user-menu-item.danger {
    color: var(--danger);
}

.nav-user-menu-item.danger:hover {
    background: var(--danger-light);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    padding: 32px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.page-header p {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.page-header .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.badge-blue {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-green {
    background: var(--success-light);
    color: var(--success);
}

.badge-red {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-orange {
    background: var(--warning-light);
    color: var(--warning);
}

/* ---- Alert Banner ---- */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    animation: fadeInUp 0.4s ease;
}

.alert-banner-danger {
    background: var(--danger-light);
    border: 1px solid #FECACA;
}

.alert-banner-danger .alert-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.alert-banner .alert-text {
    flex: 1;
}

.alert-banner .alert-text strong {
    display: block;
    font-weight: 700;
    color: var(--gray-900);
    font-size: 14px;
}

.alert-banner .alert-text span {
    font-size: 13px;
    color: var(--gray-600);
}

.alert-btn {
    padding: 8px 20px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    white-space: nowrap;
}

.alert-btn:hover {
    background: #DC2626;
}

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.stat-card .stat-header .stat-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -1px;
}

.stat-card .stat-footer {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
}

.text-blue { color: var(--primary); }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }
.text-orange { color: var(--warning); }
.text-gray { color: var(--gray-500); }

.dot-blue { background: var(--primary); }
.dot-green { background: var(--success); }
.dot-red { background: var(--danger); }

/* ---- Cards ---- */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.card-header .card-action {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    border: none;
    background: none;
    font-family: 'Inter', sans-serif;
}

/* ---- Content Grid ---- */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

/* ---- Transaction Items ---- */
.transaction-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item:hover {
    background: var(--gray-50);
    margin: 0 -12px;
    padding: 14px 12px;
    border-radius: var(--radius);
}

.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.transaction-info {
    flex: 1;
    min-width: 0;
}

.transaction-info .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.transaction-info .meta {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.transaction-amount {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

/* ---- Bar Chart ---- */
.bar-chart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.bar-chart-label {
    width: 80px;
    font-size: 13px;
    color: var(--gray-600);
    font-weight: 500;
}

.bar-chart-bar-container {
    flex: 1;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    height: 10px;
    overflow: hidden;
}

.bar-chart-bar {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-chart-value {
    width: 60px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

/* ---- Donut Chart ---- */
.donut-container {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* ---- Member Cards ---- */
.members-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.member-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: left;
    transition: var(--transition);
}

.member-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.member-card .member-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.member-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.member-card .member-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
}

.member-card .member-role {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
}

.role-padre { background: var(--primary-light); color: var(--primary); }
.role-madre { background: #FDE68A; color: #92400E; }
.role-hijo { background: var(--success-light); color: var(--success); }
.role-hija { background: #FCE7F3; color: #BE185D; }
.role-otro { background: var(--gray-100); color: var(--gray-600); }

.member-stats {
    margin-bottom: 16px;
}

.member-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
}

.member-stat-row .label {
    color: var(--gray-500);
}

.member-stat-row .value {
    font-weight: 700;
}

.member-progress {
    height: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 8px 0 16px;
}

.member-progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.8s ease;
}

.member-card .btn-outline {
    width: 100%;
    font-size: 13px;
}

/* ---- CTA Banner ---- */
.cta-banner {
    background: var(--primary-light);
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.cta-banner h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.cta-banner p {
    font-size: 13px;
    color: var(--gray-600);
}

/* ---- Savings Banner ---- */
.savings-banner {
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    padding: 24px 32px;
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
    margin-bottom: 28px;
}

.savings-banner .savings-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.savings-banner .savings-text {
    flex: 1;
}

.savings-banner .savings-text strong {
    font-size: 15px;
    display: block;
    margin-bottom: 2px;
}

.savings-banner .savings-text span {
    font-size: 13px;
    opacity: 0.9;
}

.savings-banner .btn {
    background: white;
    color: var(--primary);
    font-weight: 600;
}

/* ---- Cabeza Info ---- */
.cabeza-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gray-50);
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.cabeza-info .label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
}

.cabeza-info .name {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
}

/* ---- Transaction Form ---- */
.form-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 640px;
    margin: 0 auto;
}

.form-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.form-card > p {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 28px;
}

/* Toggle Gasto/Ingreso */
.type-toggle {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.type-toggle-btn {
    flex: 1;
    padding: 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.type-toggle-btn .icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.type-toggle-btn .label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
}

.type-toggle-btn.active-gasto {
    border-color: var(--danger);
    background: var(--danger-light);
}

.type-toggle-btn.active-gasto .label {
    color: var(--danger);
}

.type-toggle-btn.active-ingreso {
    border-color: var(--primary);
    background: var(--primary-light);
}

.type-toggle-btn.active-ingreso .label {
    color: var(--primary);
}

/* ---- Analysis Cards ---- */
.analysis-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    margin-bottom: 28px;
}

.comparativa-card {
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: white;
}

.comparativa-card .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-bottom: 8px;
}

.comparativa-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.comparativa-card .savings-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
}

.deuda-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.deuda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.deuda-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary);
}

/* ---- Members Breakdown ---- */
.breakdown-grid {
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 20px 0;
}

.breakdown-item {
    text-align: center;
}

.breakdown-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    margin: 0 auto 8px;
    position: relative;
}

.breakdown-avatar .crown {
    position: absolute;
    top: -6px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--success);
    border-radius: var(--radius-full);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.breakdown-item .name {
    font-size: 13px;
    color: var(--gray-600);
    font-weight: 500;
}

.breakdown-item .amount {
    font-size: 20px;
    font-weight: 800;
    color: var(--gray-900);
    margin: 4px 0;
}

.breakdown-item .pct {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
}

.breakdown-item .mini-bar {
    height: 4px;
    background: var(--gray-100);
    border-radius: 2px;
    margin-top: 8px;
    width: 60px;
    display: inline-block;
    overflow: hidden;
}

.breakdown-item .mini-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--primary);
}

/* ---- Summary Footer ---- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.summary-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.summary-card .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.summary-card .value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* ---- Root Dashboard ---- */
.root-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.family-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.family-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.family-table td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.family-table tr:hover td {
    background: var(--gray-50);
}

.family-table .family-name {
    font-weight: 700;
    color: var(--gray-900);
}

.family-table .family-cabeza {
    color: var(--gray-600);
}

.family-table .action-btns {
    display: flex;
    gap: 8px;
}

/* ---- Canvas Chart ---- */
.chart-canvas-container {
    position: relative;
    width: 100%;
    height: 250px;
}

.chart-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.modal > p {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* Modal Container (usado por módulos nuevos) */
#modalContainer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

#modalContainer.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}


/* ---- Footer ---- */
.app-footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-400);
    background: white;
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: white;
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    min-width: 300px;
    animation: toastSlideIn 0.3s ease;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---- Skeleton Loading ---- */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content-grid, .analysis-grid {
        grid-template-columns: 1fr;
    }

    .members-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid, .root-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .breakdown-grid {
        flex-wrap: wrap;
        gap: 24px;
    }

    .main-content {
        padding: 20px 16px;
    }

    .top-navbar {
        padding: 0 16px;
    }

    .nav-links {
        position: fixed;
        top: 60px;
        left: -250px;
        width: 250px;
        height: calc(100vh - 60px);
        background: white;
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
        gap: 12px;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        z-index: 900;
        display: flex;
    }

    .nav-links.show {
        left: 0;
    }

    .nav-link {
        width: 100%;
        text-align: left;
    }

    .cta-banner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .page-header {
        flex-direction: column;
        gap: 12px;
    }

    .login-card {
        padding: 32px 24px;
    }
}

/* ---- Hidden utility ---- */
.hidden {
    display: none !important;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-400);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    max-width: 300px;
    margin: 0 auto;
}

/* ---- Spinner ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Mobile Header / Hamburguesa ---- */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-800);
    padding: 4px;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
}

/* ---- Notifications ---- */
.nav-icon-btn {
    position: relative;
}
.notification-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: none;
}
.notification-dot.active {
    display: block;
    animation: pulseRed 2s infinite;
}
@keyframes pulseRed {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ---- Dark Mode ---- */
body.dark-mode {
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;

    /* Azul más suave para dark mode */
    --primary: #5b8def;
    --primary-light: #1e3a5e;
    --primary-dark: #4a7ae0;
    --primary-gradient: linear-gradient(135deg, #4a7ae0 0%, #6b9cf5 100%);

    --success: #34d399;
    --success-light: #064e3b;
    --danger: #f87171;
    --danger-light: #7f1d1d;
    --warning: #fbbf24;
    --warning-light: #78350f;

    background-color: var(--gray-50);
    color: var(--gray-800);
}

body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .summary-card,
body.dark-mode .form-card,
body.dark-mode .member-card,
body.dark-mode .deuda-card,
body.dark-mode .nav-icon-btn,
body.dark-mode .app-footer,
body.dark-mode .type-toggle-btn,
body.dark-mode .cabeza-info,
body.dark-mode .top-navbar,
body.dark-mode .form-input,
body.dark-mode .form-select,
body.dark-mode .btn-outline,
body.dark-mode .nav-user-menu,
body.dark-mode .modal,
body.dark-mode .modal-content {
    background-color: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-800);
}

body.dark-mode .nav-links {
    background: var(--gray-100);
}

body.dark-mode .transaction-item:hover,
body.dark-mode .nav-link:hover,
body.dark-mode .nav-user-menu-item:hover {
    background-color: var(--gray-200);
}

body.dark-mode .mobile-menu-btn {
    color: var(--gray-800);
}

/* Dark mode - botones */
body.dark-mode .btn-primary {
    background: var(--primary-gradient);
    color: #fff;
}

body.dark-mode .btn-outline {
    color: var(--gray-700);
    border-color: var(--gray-300);
}

/* Dark mode - alertas y banners */
body.dark-mode .alert-banner {
    background: var(--gray-100) !important;
    border-color: var(--gray-300) !important;
}

/* Dark mode - badges */
body.dark-mode .badge-blue {
    background: var(--primary-light);
    color: var(--primary);
}

body.dark-mode .badge-green {
    background: var(--success-light);
    color: var(--success);
}

body.dark-mode .badge-red {
    background: var(--danger-light);
    color: var(--danger);
}

body.dark-mode .badge-orange {
    background: var(--warning-light);
    color: var(--warning);
}

/* Dark mode - progress bars */
body.dark-mode .member-progress {
    background: var(--gray-200) !important;
}

/* Dark mode - text overrides */
body.dark-mode .text-blue { color: var(--primary) !important; }
body.dark-mode .text-primary { color: var(--primary) !important; }
body.dark-mode .text-green { color: var(--success) !important; }
body.dark-mode .text-red { color: var(--danger) !important; }
body.dark-mode .text-orange { color: var(--warning) !important; }
body.dark-mode .text-gray { color: var(--gray-500) !important; }

/* Dark mode - separadores y bordes inline */
body.dark-mode [style*="border-top:1px solid var(--gray-100)"],
body.dark-mode [style*="border-bottom:1px solid var(--gray-100)"] {
    border-color: var(--gray-200) !important;
}

/* Dark mode - comparativa y resumen cards */
body.dark-mode .comparativa-card,
body.dark-mode .savings-pill {
    background: var(--gray-100);
    color: var(--gray-800);
}

body.dark-mode .donut-container,
body.dark-mode .chart-canvas-container {
    background: var(--gray-100);
}

/* Dark mode - login */
body.dark-mode .login-container {
    background: var(--gray-100);
}
