/* ==============================================================================
   DEBTTRACKER - ULTRA CLEAN FINTECH STYLING (TELEGRAM & WEB READY)
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-subtle: #f1f5f9;
    
    --border-light: #e2e8f0;
    --border-strong: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --brand-blue: #2563eb;
    --brand-blue-soft: #eff6ff;
    --brand-blue-border: #bfdbfe;
    
    --emerald-green: #059669;
    --emerald-soft: #ecfdf5;
    --emerald-border: #a7f3d0;
    
    --purple-accent: #7c3aed;
    --purple-soft: #f5f3ff;
    --purple-border: #ddd6fe;

    --amber-warning: #d97706;
    --amber-soft: #fffbeb;
    --amber-border: #fde68a;
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.02);
    --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.08);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    padding: 1.5rem 1rem;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1380px;
    margin: 0 auto;
}

/* 1. HEADER */
/* 1. HEADER (EXECUTIVE FINTECH LEDGER) */
.app-header {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.6rem;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.header-logo {
    width: 44px;
    height: 44px;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.15);
}

.header-titles h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.version-tag {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.header-titles p {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tg-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.15s ease;
}

.tg-badge:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.tg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.btn-secondary-sm {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 0.42rem 0.85rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.15s ease;
}

.btn-secondary-sm:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

/* 2. KPI GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.kpi-box.primary {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border-color: var(--emerald-border);
}

.kpi-box.highlight {
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    border-color: var(--brand-blue-border);
}

.kpi-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.kpi-box-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.kpi-box-icon {
    font-size: 1.1rem;
}

.kpi-box-val {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0.2rem 0;
}

.kpi-box-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 3. SECTIONS */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* 4. DEBT CARDS */
.debts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.2rem;
}

.debt-card {
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.3rem;
    background: var(--bg-card);
    transition: all 0.2s ease;
}

.debt-card.active-card {
    border-color: var(--brand-blue-border);
    background: #fbfcfe;
}

.debt-card.active-card:hover {
    border-color: var(--brand-blue);
    box-shadow: var(--shadow-md);
}

.debt-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.debt-brand {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.debt-icon {
    font-size: 2rem;
    background: var(--brand-blue-soft);
    padding: 0.4rem;
    border-radius: var(--radius-md);
    line-height: 1;
}

.debt-tag {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--brand-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debt-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0.1rem 0;
}

.debt-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.debt-metrics-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    margin-bottom: 1rem;
}

.debt-metric {
    display: flex;
    flex-direction: column;
}

.dm-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.dm-val {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.1rem;
}

.debt-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.debt-progress-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.btn-sm {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-sm:hover {
    background: #e2e8f0;
}

/* PLACEHOLDER CARD */
.debt-card.placeholder-card {
    border: 2px dashed var(--border-strong);
    background: #fafbfd;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1.5rem;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    max-width: 320px;
}

.placeholder-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--text-muted);
}

.placeholder-content h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.placeholder-content p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* 5. CRONOGRAMA DESPLEGABLE */
.crono-drawer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    max-height: 300px;
    overflow-y: auto;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.mini-table th {
    background: var(--bg-card-subtle);
    padding: 0.5rem 0.7rem;
    text-align: left;
    font-weight: 700;
    color: var(--text-muted);
    position: sticky;
    top: 0;
}

.mini-table td {
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border-light);
}

/* 6. MONTHLY MATRIX */
.filter-controls {
    display: flex;
    gap: 0.4rem;
}

.filter-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.filter-btn:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

.filter-btn.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

.monthly-matrix {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.month-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.3rem;
    transition: all 0.15s ease;
}

.month-card:hover {
    border-color: var(--brand-blue-border);
    box-shadow: var(--shadow-sm);
}

.month-card.is-paid {
    background: #f8fafc;
    opacity: 0.85;
}

.month-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.8rem;
}

.month-titles {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.month-badge {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-strong);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--text-muted);
}

.month-titles h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.month-total-box {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.mt-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
}

.mt-val {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--emerald-green);
}

.mt-sub-desembolso {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--brand-blue);
    background: var(--brand-blue-soft);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
}

.month-debts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.month-debt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card-subtle);
    font-size: 0.86rem;
}

.mdr-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.mdr-icon {
    font-size: 1.2rem;
}

.mdr-name {
    color: var(--text-primary);
    font-weight: 700;
    margin-right: 0.5rem;
}

.mdr-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.mdr-amount-zone {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.mdr-amount {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.98rem;
    color: var(--text-primary);
}

/* 7. BADGES & PILLS */
.badge {
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: inline-block;
    white-space: nowrap;
}

.badge.green { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge.blue { background: #f8fafc; color: #1e293b; border: 1px solid #cbd5e1; }
.badge.purple { background: #faf5ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.badge.yellow { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.status-pill {
    padding: 0.18rem 0.55rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-block;
    white-space: nowrap;
}

.status-pill.pagado { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.status-pill.proximo { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.status-pill.pendiente { background: #f8fafc; color: #475569; border: 1px solid #cbd5e1; }
.status-pill.desembolso { background: #f8fafc; color: #0f172a; border: 1px solid #cbd5e1; }

/* 8. MODAL TELEGRAM */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 1.2rem 1.5rem;
    overflow-y: auto;
}

.code-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
}

.btn-copy {
    background: #0088cc;
    color: #ffffff;
    border: none;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-copy:hover {
    background: #0077b5;
}

.json-code {
    display: block;
    background: #0f172a;
    color: #38bdf8;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    white-space: pre-wrap;
    max-height: 380px;
    overflow-y: auto;
}

/* UTILITY */
.hidden { display: none !important; }
.text-green { color: #059669 !important; }
.text-blue { color: #0f172a !important; }
.text-purple { color: #0f172a !important; }
.text-amber { color: #b45309 !important; }

/* ==============================================================================
   9. FINANCIAL EXECUTIVE SUMMARY BAR (CFO SPREADSHEET TERMINAL STYLE)
   ============================================================================== */
.fin-summary-bar {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.fsb-metrics {
    display: grid;
    grid-template-columns: repeat(8, minmax(130px, 1fr));
    background: #ffffff;
    overflow-x: auto;
    border-bottom: 1px solid #e2e8f0;
}

.fsb-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.85rem 1rem;
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    min-width: 130px;
    transition: background 0.15s ease;
}

.fsb-item:last-child {
    border-right: none;
}

.fsb-item:hover {
    background: #f8fafc;
}

/* Subtle Cell Accents matching Spreadsheet Table */
.fsb-item.bank-cell {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
}

.fsb-item.surplus-cell {
    background: #fafdfb;
}

.fsb-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.fsb-val {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.fsb-tag {
    font-size: 0.68rem;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 0.25rem;
    white-space: nowrap;
}

/* Clean Professional Colors */
.text-emerald { color: #059669 !important; }
.text-rose { color: #e11d48 !important; }
.text-blue { color: #0f172a !important; }

/* Status Pill inside Cell */
.health-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-sans);
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
    width: fit-content;
    white-space: nowrap;
    line-height: 1.2;
}

/* ==============================================================================
   TOOLBAR (EXECUTIVE FINTECH ACTIONS)
   ============================================================================== */
.fsb-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
}

.qa-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.qa-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.qa-btn.primary {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

.qa-btn.primary:hover {
    background: #1e293b;
    border-color: #1e293b;
}

.qa-btn.ghost {
    background: transparent;
    border-color: transparent;
    color: #64748b;
    box-shadow: none;
}

.qa-btn.ghost:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* ==============================================================================
   10. FINANCIAL TABLES (LEDGER & MATRICES)
   ============================================================================== */
.section-table-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 1.6rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.table-card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.table-card-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    text-align: left;
}

.fin-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65rem 1rem;
    border-bottom: 1.5px solid #e2e8f0;
    white-space: nowrap;
}

.fin-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: var(--text-primary);
}

.fin-table tr:hover td {
    background: #fbfcfe;
}

.fin-table tr.row-paid td {
    background: #fafaf9;
    color: #94a3b8;
}

.fin-table tfoot td {
    background: #f8fafc;
    border-top: 2px solid #cbd5e1;
    font-weight: 700;
    padding: 0.75rem 1rem;
}

.num-col {
    text-align: right !important;
    font-family: var(--font-mono);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* BOTONES DE PAGO Y COBRO DENTRO DE TABLAS */
.btn-pay-trigger {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    padding: 0.28rem 0.65rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-pay-trigger:hover {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

.btn-paid-done {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 0.28rem 0.65rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-paid-done:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.btn-paid-done:hover::after {
    content: " (Revertir)";
}

.btn-info-toggle {
    background: none;
    border: 1px solid #cbd5e1;
    color: #64748b;
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
    cursor: pointer;
    font-weight: 700;
}

.btn-info-toggle:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.sub-detail-row td {
    background: #f8fafc !important;
    padding: 0.75rem 1.4rem !important;
    border-bottom: 1.5px solid #e2e8f0;
}

.detail-chips-box {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.76rem;
    color: #334155;
}

.detail-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ==============================================================================
   11. SPREADSHEET 18-MONTH MATRIX
   ============================================================================== */
.matrix-scroll-container {
    max-height: 600px;
    overflow-y: auto;
}

.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
}

.matrix-table th, .matrix-table td {
    border-right: 1px solid #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

.matrix-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
}

/* Sticky first two columns for comfortable spreadsheet scrolling */
.matrix-table .sticky-name {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #ffffff;
    min-width: 200px;
    font-weight: 700;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.03);
}

.matrix-table th.sticky-name {
    z-index: 4;
    background: #f8fafc;
}

.matrix-table .sticky-titular {
    position: sticky;
    left: 200px;
    z-index: 3;
    background: #ffffff;
    min-width: 85px;
    text-align: center;
    border-right: 2px solid #cbd5e1;
    box-shadow: 3px 0 5px rgba(15, 23, 42, 0.04);
}

.matrix-table th.sticky-titular {
    z-index: 4;
    background: #f8fafc;
}

.matrix-table tr:hover td.sticky-name,
.matrix-table tr:hover td.sticky-titular {
    background: #f1f5f9;
}

.matrix-table tfoot td.sticky-name,
.matrix-table tfoot td.sticky-titular {
    background: #f8fafc;
    z-index: 3;
    font-weight: 800;
}

.zero-dash {
    color: #cbd5e1;
    font-weight: 400;
}

/* 12. MODAL FORM STYLES */
.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.form-input, .form-select {
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    background: #ffffff;
    color: var(--text-primary);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    margin-top: 1.4rem;
}

.btn-form-cancel {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-strong);
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
}

.btn-form-submit {
    background: var(--brand-blue);
    border: 1px solid var(--brand-blue);
    color: #ffffff;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 800;
    cursor: pointer;
}

@media (max-width: 768px) {
    .fsb-metrics {
        grid-template-columns: 1fr 1fr;
    }
    .table-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==============================================================================
   13. CUSTOM DIALOG MODALS & TOAST NOTIFICATIONS (PREMIUM UI/UX)
   ============================================================================== */
.modal-dialog-card {
    max-width: 440px !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.2), 0 10px 10px -5px rgba(15, 23, 42, 0.08) !important;
    animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dialog-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.btn-dialog-danger {
    background: #e11d48 !important;
    border-color: #e11d48 !important;
    color: #ffffff !important;
}

.btn-dialog-danger:hover {
    background: #be123c !important;
    border-color: #be123c !important;
}

.btn-dialog-emerald {
    background: #059669 !important;
    border-color: #059669 !important;
    color: #ffffff !important;
}

.btn-dialog-emerald:hover {
    background: #047857 !important;
    border-color: #047857 !important;
}

.btn-dialog-amber {
    background: #d97706 !important;
    border-color: #d97706 !important;
    color: #ffffff !important;
}

.btn-dialog-amber:hover {
    background: #b45309 !important;
    border-color: #b45309 !important;
}

/* TOAST FLOATING CONTAINER */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
    max-width: 380px;
    width: 100%;
}

.fin-toast {
    pointer-events: auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.fin-toast.toast-hide {
    opacity: 0;
    transform: translateX(40px);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 0.1rem;
}

.fin-toast.toast-success .toast-icon { color: #059669; }
.fin-toast.toast-danger .toast-icon { color: #e11d48; }
.fin-toast.toast-warning .toast-icon { color: #d97706; }
.fin-toast.toast-info .toast-icon { color: #2563eb; }

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    margin-bottom: 0.2rem;
}

.toast-message {
    font-size: 0.78rem;
    color: #475569;
    line-height: 1.35;
}

.toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s ease;
}

.toast-close:hover {
    color: #0f172a;
    background: #f1f5f9;
}

@media (max-width: 640px) {
    .toast-container {
        top: auto;
        bottom: 1.5rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
        width: auto;
    }
}
