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

:root {
  /* LIGHT THEME (Default) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --color-accent: #0f172a; 
  --color-accent-hover: #1e293b;
  
  --color-success: #10b981;
  --color-success-bg: #d1fae5;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-bg: #fee2e2;
  --color-danger-glow: rgba(239, 68, 68, 0.3);
  
  --border-color: #e2e8f0;
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.2);
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

[data-theme="dark"] {
  /* DARK THEME (Premium) */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: #151f32;
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #4b5563;
  
  --color-accent: #10b981;
  --color-accent-hover: #059669;
  
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-danger-glow: rgba(239, 68, 68, 0.3);
  
  --border-color: #374151;
  --card-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --glass-bg: rgba(17, 24, 39, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);
}

/* Personalización de SweetAlert2 */
.swal2-popup {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: 24px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5) !important;
    padding: 2.5rem !important;
    font-family: inherit !important;
}

/* Glow verde por defecto (Success/Info) */
.swal2-popup:has(.swal2-success), .swal2-popup:has(.swal2-info) {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.15) !important;
}

/* Glow ROJO para Precaución Total (Warning/Error) */
.swal2-popup:has(.swal2-warning), .swal2-popup:has(.swal2-error) {
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.25) !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
}

.swal2-title {
    color: var(--text-primary) !important;
    font-size: 1.8rem !important;
    font-weight: 700 !important;
    margin-bottom: 0.5rem !important;
}

.swal2-html-container {
    color: var(--text-secondary) !important;
    font-size: 1.05rem !important;
}

.swal2-confirm {
    border-radius: 14px !important;
    padding: 0.8rem 2.5rem !important;
    font-weight: 600 !important;
    transition: all 0.2s !important;
}

/* CUSTOM SCROLLBARS */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-primary);
}

/* Botón de confirmación para peligros */
.swal2-popup:has(.swal2-warning) .swal2-confirm {
    background: var(--color-danger) !important;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4) !important;
}

/* Botón de confirmación para éxitoso/general */
.swal2-popup:not(:has(.swal2-warning)) .swal2-confirm {
    background: var(--color-accent) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
}

.swal2-cancel {
    background: rgba(255,255,255,0.05) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 14px !important;
}

/* Icono de advertencia en EMERALD RED (Precaución Total) */
.swal2-icon.swal2-warning {
    border-color: var(--color-danger) !important;
    color: var(--color-danger) !important;
    animation: pulse-red 2s infinite !important;
}

@keyframes pulse-red {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.swal2-icon.swal2-success {
    border-color: var(--color-success) !important;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: var(--color-success) !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border: .25em solid rgba(16, 185, 129, .3) !important;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  display: block;
  min-height: 100vh;
}

/* LOGIN LAYOUT OVERRIDE */
.login-page {
  display: flex !important;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 2rem;
}

.login-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 3rem;
  width: 100%;
  max-width: 450px;
  box-shadow: var(--card-shadow);
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--color-success-bg);
  color: var(--color-success);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.5rem;
}

/* LAYOUT */
.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  transition: all var(--transition-normal);
  z-index: 10;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: relative;
}

.top-header {
  height: 70px;
  min-height: 70px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  align-items: center;
  padding: 0 1rem;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
}

.header-left { justify-content: flex-start; gap: 0.5rem; }
.header-center { 
  display: flex; 
  justify-content: center; 
  align-items: center;
  text-align: center;
}
.header-right { justify-content: flex-end; gap: 0.75rem; }

.header-center h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  line-height: normal;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 480px) {
  .top-header {
    grid-template-columns: 80px 1fr 100px;
    height: 60px;
  }
}

.btn-back {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-back:active { transform: scale(0.9); }

.user-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.content-area {
  padding: 2.5rem;
  flex: 1;
}

/* TYPOGRAPHY */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.font-semibold { font-weight: 600; }

/* BRANDING */
.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
}
.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--color-accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
}
.brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* NAV */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.nav-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}
.nav-link.active {
  background-color: var(--color-success-bg);
  color: var(--color-accent);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
}
.btn-primary {
  background-color: var(--color-accent);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background-color: var(--bg-tertiary);
}
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* CARDS */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 2rem; }

/* TABLES */
.table-container {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  padding: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}
td {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
tr:last-child td {
  border-bottom: none;
}

/* BADGES */
.badge {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}
.badge-danger {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
}

/* UTILS */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.w-full { width: 100%; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }

/* ADDITIONAL UTILS */
.p-4 { padding: 1rem !important; }
.p-6 { padding: 1.5rem !important; }
.py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
.rounded-lg { border-radius: 1rem !important; }

/* FORMS */
.form-group { margin-bottom: 1.5rem; }
.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  transition: all var(--transition-fast);
}
.form-control:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* THEME TOGGLE */
.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}
.theme-toggle:hover {
  background: var(--border-color);
}

/* RESPONSIVE */
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: -280px;
    height: 100%;
  }
  .sidebar.open {
    left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* PROJECT GRID SYSTEM */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    align-items: stretch;
    margin-top: 2.5rem;
}

.project-card {
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: var(--color-accent);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.project-card .project-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: 1.25rem;
}

/* CLIENTS & PAYMENTS GRID */
.clients-grid-container, 
.receipts-grid-container,
.amortization-grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.payments-vertical-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0.5rem 0;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

@media (min-width: 768px) {
    .clients-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .clients-grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* RECENT PAYMENTS CARDS (Dashboard) */
.payment-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    transition: transform 0.2s, var(--transition-normal);
}

.payment-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.payment-card-badge {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.payment-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.5rem;
}

.payment-card-item label {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.payment-card-item span {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: normal;
}

.payment-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.payment-card-amount {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-success);
}

.payment-card-footer-item label {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.payment-card-footer-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.project-card .client-count {
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.project-card .btn-edit,
.project-card .btn-delete {
    position: absolute;
    top: 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all var(--transition-fast);
    opacity: 0;
    transform: scale(0.8);
    z-index: 10;
}

.project-card .btn-edit {
    right: 3.25rem; /* Espacio para el botón de borrar al lado */
    color: var(--text-secondary);
}

.project-card .btn-delete {
    right: 1.25rem;
    color: var(--color-danger);
}

.project-card:hover .btn-edit,
.project-card:hover .btn-delete {
    opacity: 0.6;
    transform: scale(1);
}

.project-card .btn-edit:hover {
    opacity: 1 !important;
    color: var(--color-accent);
}

.project-card .btn-delete:hover {
    opacity: 1 !important;
    color: var(--color-danger);
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.3));
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS (UX SENIOR)
   ========================================================================== */

/* Navbar Bottom - Hidden by default */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    /* Layout Adjustments */
    .app-container {
        display: block;
        height: auto;
        overflow: visible;
    }

    .main-content {
        height: auto;
        overflow: visible;
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    .sidebar {
        display: none !important; /* Use bottom nav instead */
    }

    .top-header {
        padding: 1rem 1.25rem;
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    /* Hide hamburger if using bottom nav for primary links */
    .menu-toggle {
        display: none !important;
    }

    .content-area {
        padding: 1.25rem 1rem;
    }

    /* Overriding Inline Styles commonly used in the HTML */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* Typography adjustments */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.35rem; }
    .card h3 { font-size: 1.1rem !important; }

    /* Touch Targets & Spacing */
    .btn {
        padding: 0.85rem 1.5rem; /* Larger touch area */
        width: 100%; /* Stack buttons by default on mobile */
    }

    .flex-wrap {
        flex-direction: column;
        align-items: stretch !important;
    }

    .flex-wrap > * {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
        padding: 0.6rem;
    }

    /* Form Improvements */
    .form-control {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.9rem 1rem;
    }

    /* Login Specifics */
    .login-container {
        padding: 1rem;
    }

    .login-card {
        padding: 2.5rem 1.5rem;
        border-radius: 20px;
    }

    /* Bottom Navigation Bar (Mobile Native Look) */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .bottom-nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 0.65rem;
        font-weight: 500;
        gap: 4px;
        width: 25%;
        transition: all var(--transition-fast);
    }

    .bottom-nav-link i {
        font-size: 1.5rem;
        transition: transform 0.2s ease;
    }

    .bottom-nav-link.active {
        color: var(--color-accent);
    }

    .bottom-nav-link.active i {
        transform: translateY(-2px);
    }

    /* Specific Component Fixes */
    .project-grid {
        grid-template-columns: 1fr;
    }

    /* Metrics Adjustments */
    #totalCartera, #recaudoMes, #totalMora {
        font-size: 1.5rem !important;
    }

    /* Detail View Adjustments */
    /* Table to Card Transformation */
    .table-container {
        overflow-x: hidden; /* Prevent ANY horizontal scroll */
        padding: 0;
        margin: 0;
        background: transparent;
        border: none;
    }

    table, thead, tbody, th, td, tr {
        display: block;
        width: 100%;
    }

    /* Hide table headers but keep accessibility */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 16px;
        margin-bottom: 1.25rem;
        padding: 1.25rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        position: relative;
    }

    td {
        border: none;
        padding: 0.6rem 0;
        padding-left: 45%;
        text-align: left;
        font-size: 0.95rem;
        min-height: 2.5rem;
        display: flex;
        align-items: center;
        border-bottom: 1px solid rgba(255,255,255,0.03);
    }

    td:before {
        position: absolute;
        left: 0;
        width: 40%;
        padding-right: 15px;
        white-space: nowrap;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        content: attr(data-label);
    }

    /* Action button at the bottom of the card */
    td:last-child {
        border-bottom: none;
        margin-top: 1rem;
        padding: 0;
        justify-content: stretch;
    }

    td:last-child:before {
        display: none; /* No label for actions */
    }

    td:last-child .btn {
        width: 100%;
        margin: 0;
        justify-content: center;
    }

    /* Global 100% Width Fix & Edge-to-Edge Header */
    .app-container, .main-content {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    .content-area {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .top-header {
        display: grid !important;
        grid-template-columns: 80px 1fr 100px !important;
        width: 100% !important;
        height: 60px !important;
        padding: 0 0.5rem !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-card);
    }

    .header-center h2 {
        font-size: 0.95rem !important;
        margin-right: 0 !important;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Toolbar Redorder for Clients Management */
    .toolbar-container {
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: stretch !important;
    }

    .toolbar-container > div {
        max-width: 100% !important;
        width: 100% !important;
    }

    .toolbar-container .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Client Card Footer 50-50 */
    .payment-card-footer {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.75rem !important;
        padding-bottom: 0.5rem;
    }

    .payment-card-footer .badge,
    .payment-card-footer .btn {
        flex: 1 !important;
        width: 50% !important;
        height: 48px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.75rem !important;
        padding: 0 !important;
    }

    /* Global Flex Col Utility (if missing) */
    .flex-col {
        flex-direction: column !important;
    }

    /* Profile Page Action Reorder for Mobile (Stacked) */
    .profile-actions-wrapper > div {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        display: flex !important;
    }

    .status-badge {
        width: 100% !important;
        height: 48px !important;
        margin-bottom: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.95rem !important;
        border-radius: 12px !important;
        padding: 0 !important;
    }

    .action-buttons {
        width: 100% !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 0.75rem !important;
        margin-top: 0.25rem !important; /* Extra space from badge */
    }

    .action-buttons .btn {
        flex: 1 !important;
        width: 50% !important;
        height: 48px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 12px !important;
    }
}

/* RESPONSIVE GRID UTILITIES */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-responsive-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.grid-responsive-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  .grid-responsive-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-responsive-3, .grid-responsive-2 {
    grid-template-columns: 1fr !important;
  }
}

/* Tablas Responsivas para Plan de Pagos */
@media (min-width: 769px) {
    .mobile-amortization-cards {
        display: none !important;
    }
    .desktop-amortization-table {
        display: block !important;
    }
}

@media (max-width: 768px) {
    .desktop-amortization-table {
        display: none !important;
    }
    .mobile-amortization-cards {
        display: block !important;
    }
}
