/* ==========================================================================
   Finanzas Personales Albrizzi - Master High-End Mobile & Responsive Engine
   Fluid Viewports, Touch-Optimized (44px Targets), Safe Area Insets, iOS Bottom Sheets
   ========================================================================== */

/* Prevent Horizontal Overflow Globally */
html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  -webkit-text-size-adjust: 100%;
}

.app-layout, .app-main, .content-body {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Sidebar Backdrop Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Category Filter Pills Horizontal Touch Scroll */
.category-pills-scroll {
  display: flex !important;
  gap: 0.45rem !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0.35rem;
  width: 100%;
}

.category-pills-scroll::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  flex-shrink: 0;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 34px;
}

.cat-pill:hover, .cat-pill.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--color-cyan);
  color: var(--color-cyan);
}

/* Table Responsive Horizontal Container */
.table-responsive {
  width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  position: relative;
  display: block;
  scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar {
  height: 5px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

.table-responsive table {
  min-width: 600px;
}

.table-responsive table.min-w-wide {
  min-width: 800px;
}

/* Amount & Numbers formatting (Never wrap across lines) */
.amount-nowrap {
  white-space: nowrap !important;
}

/* Mobile Bottom App Navigation Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(62px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(11, 16, 29, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-color);
  z-index: 90;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.6);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.68rem;
  font-weight: 700;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.35rem 0.2rem;
  transition: all 0.18s ease;
  flex: 1;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  position: relative;
}

.bottom-nav-icon {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
  transition: stroke 0.18s ease, transform 0.18s ease;
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

.bottom-nav-item.active {
  color: var(--color-cyan);
}

.bottom-nav-item.active .bottom-nav-icon {
  stroke: var(--color-cyan);
  transform: translateY(-2px);
}

.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 14px;
  height: 3px;
  background-color: var(--color-cyan);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px var(--color-cyan);
}

.bottom-nav-fab {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-cyan));
  color: white;
  border: 3px solid var(--bg-main);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: -24px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-fab svg {
  stroke: #ffffff;
}

.bottom-nav-fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.4);
}

/* ==========================================================================
   BREAKPOINTS: TABLET & LAPTOP (max-width: 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    width: 220px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }

  .score-hero-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem;
  }

  .score-breakdown-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
  }

  .dashboard-mid-grid,
  .fixed-layout-grid,
  .debts-savings-grid,
  .debts-workspace-split,
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem;
  }

  .chart-card-wide {
    grid-column: span 1 !important;
  }

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

/* ==========================================================================
   BREAKPOINTS: SMARTPHONES & TOUCH DEVICES (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    gap: 0.45rem;
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 38px;
    transition: all 0.15s ease;
  }

  .mobile-menu-btn:active {
    transform: scale(0.94);
    border-color: var(--color-cyan);
    color: var(--color-cyan);
  }

  .mobile-menu-btn svg {
    stroke: var(--color-cyan);
    flex-shrink: 0;
  }

  .sidebar-close-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .sidebar-close-btn:active {
    transform: scale(0.92);
    color: var(--color-danger);
    border-color: var(--color-danger);
  }

  .header-collapse-btn {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }

  /* Slide-in Mobile Drawer */
  .app-sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    bottom: 0;
    width: 290px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
    z-index: 100;
  }

  .app-sidebar.open {
    left: 0 !important;
  }

  /* Header compact adjustments */
  .app-header {
    padding: 0 0.85rem;
    height: 56px;
  }

  .header-left {
    gap: 0.5rem;
  }

  .period-selector-wrapper {
    padding: 0.25rem 0.5rem;
    gap: 0.35rem;
  }

  .period-label {
    display: none;
  }

  .select-period {
    font-size: 0.76rem;
    max-width: 125px;
    padding: 0.25rem 0.4rem;
  }

  .btn-period-action {
    display: none !important;
  }

  .header-right {
    gap: 0.4rem;
  }

  .live-clock-display,
  .live-datetime-chip,
  .header-center {
    display: none !important;
  }

  .period-status-badge {
    padding: 0.15rem 0.35rem !important;
  }

  .period-status-badge span:not(.status-dot) {
    display: none;
  }

  .theme-toggle-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    font-size: 0.9rem !important;
  }

  .btn-quick-income,
  .btn-quick-saving,
  .btn-quick-expense {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.76rem !important;
    border-radius: var(--radius-full) !important;
    min-height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .btn-quick-income .quick-label,
  .btn-quick-saving .quick-label,
  .btn-quick-expense .quick-label {
    display: none;
  }

  .btn-quick-income .quick-icon,
  .btn-quick-saving .quick-icon,
  .btn-quick-expense .quick-icon {
    font-size: 0.95rem;
  }

  .btn-quick-add {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
  }

  /* Content area scroll & bottom nav padding */
  .content-body {
    padding: 0.85rem 0.85rem calc(75px + env(safe-area-inset-bottom, 0px)) 0.85rem !important;
  }

  /* Cards Mobile Padding */
  .card {
    padding: 1.1rem !important;
    border-radius: var(--radius-md) !important;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  /* Executive Dashboard Hero Grid Mobile */
  .dash-hero-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Score Hero Mobile Card */
  .score-hero-card {
    padding: 1.15rem !important;
    gap: 1rem;
    border-radius: var(--radius-lg);
    height: auto !important;
  }

  .period-days-card {
    padding: 1.15rem !important;
    border-radius: var(--radius-lg) !important;
    height: auto !important;
    gap: 0.85rem !important;
  }

  .score-hero-left {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  .score-info h3 {
    font-size: 1.05rem;
  }

  .score-info p {
    font-size: 0.78rem;
  }

  .score-breakdown-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
  }

  .score-pill {
    padding: 0.5rem 0.65rem;
    min-width: 0;
  }

  /* 4 Core KPIs Mobile (2-column compact grid) */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .surplus-pills-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .insights-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .kpi-card {
    padding: 1rem 0.95rem !important;
    border-radius: 16px !important;
    background: rgba(13, 21, 39, 0.75) !important;
  }

  .kpi-value {
    font-size: 1.15rem !important;
  }

  .kpi-label {
    font-size: 0.68rem !important;
  }

  .kpi-subtext {
    font-size: 0.66rem !important;
    line-height: 1.35;
  }

  .insight-card {
    padding: 0.9rem 1rem !important;
  }

  /* Timeseries Metric Bar on Mobile */
  .timeseries-metric-bar {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
    padding: 0.75rem !important;
  }

  /* Form & Filters Mobile */
  .filter-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }

  .filter-group,
  .filter-group.flex-2 {
    width: 100% !important;
    min-width: 0 !important;
  }

  .form-grid-2,
  .form-grid-3,
  .fuel-inputs-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }

  /* Touch Input Heights (Prevents iOS zoom) */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="password"],
  input[type="email"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
    padding: 0.65rem 0.85rem;
    box-sizing: border-box;
  }

  .btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
  }

  /* Chart Containers Mobile Height */
  .chart-container {
    height: 250px !important;
  }

  /* Responsive Bottom-Sheet Modals on Mobile */
  .modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
    background-color: rgba(0, 0, 0, 0.82) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    max-height: 92vh !important;
    animation: slideUpMobile 0.28s cubic-bezier(0.32, 1, 0.23, 1) forwards;
    margin: 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85) !important;
    border-bottom: none !important;
    position: relative;
  }

  .modal-dialog::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    margin: 10px auto 2px auto;
  }

  @keyframes slideUpMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-header {
    padding: 1.1rem 1.25rem;
    position: sticky;
    top: 0;
    background-color: var(--bg-card);
    z-index: 10;
  }

  .modal-body {
    padding: 1.15rem 1.25rem;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom, 0px)) 1.25rem;
    position: sticky;
    bottom: 0;
    background-color: var(--bg-card);
    z-index: 10;
  }

  /* Printable Report Mobile */
  .printable-document {
    padding: 1rem !important;
  }

  .report-dossier-header > div {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .report-meta-box {
    width: 100% !important;
    text-align: left !important;
    box-sizing: border-box !important;
  }

  .report-kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }

  .report-diag-card {
    flex-direction: column !important;
    gap: 0.4rem !important;
  }
}

/* ==========================================================================
   BREAKPOINTS: EXTRA SMALL MOBILE (max-width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
  /* Keep KPIs and Metric tiles compact 2-columns on small screens */
  .report-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .report-kpi-tile {
    padding: 0.75rem 0.65rem !important;
  }

  .report-kpi-tile .amount-nowrap {
    font-size: 1.05rem !important;
  }

  .timeseries-metric-bar {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .score-breakdown-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.4rem !important;
  }

  .card {
    padding: 0.9rem !important;
  }

  /* Full-width block buttons only where appropriate */
  .btn-block,
  .form-actions .btn,
  .auth-form .btn {
    width: 100% !important;
  }

  /* Crucial: Never force table action buttons, chips, or small buttons to 100% width */
  .data-table .btn,
  .btn-table-action,
  .btn-sm,
  .btn-xs,
  .debt-sim-presets .btn,
  .category-pills-scroll .cat-pill {
    width: auto !important;
    max-width: fit-content;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100% !important;
  }

  /* Header compact fitting for 360px - 440px phones */
  .mobile-menu-btn span {
    display: none;
  }

  .mobile-menu-btn {
    padding: 0.4rem 0.55rem;
  }

  .period-selector-wrapper {
    padding: 0.2rem 0.4rem;
    gap: 0.25rem;
    max-width: 165px;
  }

  .select-period {
    max-width: 135px;
    font-size: 0.74rem;
  }

  #period-status-badge {
    display: none !important;
  }

  .theme-toggle-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
  }
}

/* ==========================================================================
   AUTH / LOGIN SCREEN MOBILE RESPONSIVE ENGINE
   ========================================================================== */
@media (max-width: 640px) {
  .auth-body {
    padding: 1rem !important;
    align-items: flex-start;
    padding-top: 2rem !important;
  }

  .auth-card {
    padding: 2rem 1.35rem !important;
    border-radius: 20px !important;
  }

  .auth-header {
    margin-bottom: 1.25rem;
  }

  .auth-logo {
    margin-bottom: 0.85rem;
  }

  .auth-logo-badge {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
    border-radius: 12px;
  }

  .auth-title {
    font-size: 1.35rem;
  }

  .auth-subtitle {
    font-size: 0.8rem;
    margin-bottom: 1.25rem;
  }

  .auth-tabs {
    margin-bottom: 1.25rem;
  }

  .auth-tab {
    padding: 0.55rem 0.4rem;
    font-size: 0.8rem;
    min-height: 40px;
  }

  .auth-info-banner {
    padding: 0.65rem 0.75rem;
    font-size: 0.76rem;
  }

  .auth-security-notice {
    font-size: 0.72rem;
  }

  /* Profile Mobile Layout */
  .profile-hero-card {
    padding: 1.35rem 1.25rem !important;
  }

  .profile-hero-content {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1.25rem !important;
  }

  .profile-hero-main {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    width: 100% !important;
  }

  .profile-avatar-lg {
    width: 64px !important;
    height: 64px !important;
    font-size: 1.55rem !important;
  }

  .profile-hero-name {
    font-size: 1.35rem !important;
  }

  .profile-hero-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }

  .profile-stat-box {
    min-width: 0 !important;
    padding: 0.6rem 0.75rem !important;
  }

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

  .profile-card-body {
    padding: 1.25rem !important;
  }

  /* Debts & Metrics Mobile Experience */
  .metric-tiles-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .metric-tile {
    padding: 0.65rem 0.75rem !important;
  }

  .metric-number {
    font-size: 1.05rem !important;
  }

  .metric-caption {
    font-size: 0.68rem !important;
    line-height: 1.2 !important;
  }

  .debts-desktop-table,
  .debts-cards-grid,
  .debts-compact-table,
  .view-mode-toggle,
  .desktop-table-wrapper {
    display: none !important;
  }


  .debts-mobile-cards-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.85rem !important;
  }

  .debt-mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
  }

  body.theme-light .debt-mobile-card {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }

  .debt-mobile-card.is-paid {
    opacity: 0.8;
    border-color: rgba(16, 185, 129, 0.35);
  }

  .debt-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .debt-card-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .debt-card-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
  }

  .debt-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  .debt-card-badge-group {
    flex-shrink: 0;
  }

  .debt-card-progress-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  body.theme-light .debt-card-progress-section {
    background: #f8fafc;
  }

  .debt-card-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
  }

  .debt-card-progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
  }

  body.theme-light .debt-card-progress-bar {
    background: #e2e8f0;
  }

  .debt-card-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
  }

  .debt-card-cuotas-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
  }

  .debt-card-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .debt-metric-box {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  body.theme-light .debt-metric-box {
    background: #f8fafc;
  }

  .debt-metric-box.highlight-danger {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.25);
  }

  .debt-metric-box.highlight-success {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.25);
  }

  .debt-metric-label {
    font-size: 0.67rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .debt-metric-value {
    font-size: 0.92rem;
    font-weight: 700;
  }

  .debt-card-month-status {
    font-size: 0.74rem;
    padding: 0.4rem 0.65rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
  }

  .debt-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-color);
  }

  .debt-card-actions .btn {
    font-size: 0.75rem !important;
    padding: 0.35rem 0.65rem !important;
    min-height: 36px !important;
  }

  .btn-debt-action-primary {
    flex: 1;
    min-width: 120px;
    font-weight: 700 !important;
  }

  /* Simulator Mobile Refinements */
  .debt-sim-box {
    padding: 0.85rem !important;
  }

  .sim-controls-row {
    display: flex;
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .sim-controls-row .form-group {
    width: 100% !important;
  }

  .sim-controls-row .form-group button {
    width: 100% !important;
  }
}

/* ==========================================================================
   CALENDAR RESPONSIVE RULES (Mobile & Tablet)
   ========================================================================== */
@media (max-width: 768px) {
  .calendar-summary-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    padding: 0.75rem !important;
  }

  .calendar-summary-strip .cal-summary-item:last-child {
    grid-column: span 2;
  }

  .cal-day-cell {
    min-height: 72px !important;
    padding: 0.3rem 0.25rem !important;
  }

  .cal-cell-amount {
    font-size: 0.75rem !important;
  }

  .cal-pill {
    font-size: 0.58rem !important;
    padding: 1px 3px !important;
  }

  .calendar-footer-hint {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
}

@media (max-width: 480px) {
  .calendar-filter-bar {
    width: 100% !important;
    justify-content: space-between !important;
  }

  .calendar-month-nav {
    width: 100% !important;
    justify-content: space-between !important;
  }

  .cal-weekday {
    font-size: 0.68rem !important;
    padding: 0.3rem 0 !important;
  }

  .cal-day-cell {
    min-height: 58px !important;
    padding: 0.2rem 0.15rem !important;
  }

  .cal-cell-day-num {
    font-size: 0.7rem !important;
  }

  .cal-cell-day-num.badge-today {
    width: 18px !important;
    height: 18px !important;
    font-size: 0.65rem !important;
  }

  .cal-badge-today-text {
    display: none !important;
  }

  .cal-cell-amount {
    font-size: 0.68rem !important;
    letter-spacing: -0.02em !important;
  }

  .cal-pill {
    font-size: 0.52rem !important;
    padding: 0 2px !important;
  }

  .cal-cell-pills {
    gap: 1px !important;
  }

  .debt-card-actions .btn {
    flex: 1 1 45% !important;
    text-align: center;
    justify-content: center;
  }

  .debt-card-actions .btn-debt-action-primary {
    flex: 1 1 100% !important;
  }
}

/* Expenses Responsive Overrides */
@media (max-width: 768px) {
  .expenses-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }

  .expense-mobile-card {
    padding: 0.85rem !important;
  }

  .mobile-only {
    display: block !important;
  }
}

