:root { --app-border: #e5eaf1; --app-muted: #64748b; }
html, body, .app-root { min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { background: #f6f8fb; }
.app-root { width: 100%; }
.bslib-card, .card-body, .tab-content, .tab-pane { min-width: 0; }
.table-responsive { -webkit-overflow-scrolling: touch; }
.brand, .login-brand { font-weight: 750; letter-spacing: -.03em; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 420px); padding: .75rem; border: 1px solid var(--app-border); box-shadow: 0 18px 45px rgba(15, 23, 42, .08); }
.login-card h2 { margin-top: .5rem; }
.user-summary { display: flex; flex-direction: column; padding: .25rem 0 .75rem; }
.user-summary small { color: var(--app-muted); text-transform: capitalize; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; }
.sidebar-footer .btn { margin-top: .45rem; }
.family-context { display: block; color: var(--app-muted); text-align: center; }
.settings-card { width: min(100%, 620px); }
.module-heading { margin: .25rem 0 1rem; }
.module-heading h2 { margin-bottom: .2rem; font-size: clamp(1.5rem, 3vw, 2rem); }
.module-heading p { color: var(--app-muted); margin: 0; }
.scope-badge, .demo-label { font-size: .78rem; }
.scope-badge { display: inline-block; margin-bottom: 1rem; padding: .3rem .65rem; border-radius: 999px; background: #e8eefc; color: #1d4ed8; }
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.dashboard-grid > * { grid-column: span 4; min-width: 0; }
.home-summary-list { display: grid; gap: .85rem; }
.home-summary-list > div, .home-alert-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.home-summary-list small, .home-alert-row small { color: var(--app-muted); }
.home-alert-list { display: grid; gap: .65rem; }
.home-alert-row { padding-bottom: .65rem; border-bottom: 1px solid #e2e8f0; }
.home-alert-row:last-child { border-bottom: 0; padding-bottom: 0; }
.home-alert-row.overdue strong { color: #b91c1c; }
.home-issue-list { margin-bottom: 0; }
.habit-period { min-width: 220px; margin-bottom: 0; }
.habit-today-section { margin: 1rem 0; }
.habit-today-heading, .habit-history-header { display: flex; justify-content: space-between; align-items: end; gap: 1rem; }
.habit-today-heading h3, .habit-history-header h3 { margin: 0; }
.habit-today-heading p, .habit-history-header p { margin: .2rem 0 0; color: var(--app-muted); }
.habit-today-heading > strong { color: #166534; }
.habit-today-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .7rem; margin-top: .8rem; }
.habit-today-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; width: 100%; padding: .45rem .55rem .45rem .8rem; border: 1px solid #dbe4f0; border-radius: .85rem; background: white; transition: border-color .15s,background .15s; }
.habit-today-card:hover { border-color: #7c3aed; }
.habit-today-card.done { background: #f0fdf4; border-color: #86efac; }
.habit-today-toggle { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .8rem; padding: .45rem 0; border: 0; background: transparent; text-align: left; }
.habit-today-edit { min-height: 38px; }
.habit-today-check { display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid #cbd5e1; border-radius: 50%; color: white; }
.habit-today-card.done .habit-today-check { background: #16a34a; border-color: #16a34a; }
.habit-today-copy { display: flex; flex-direction: column; }
.habit-today-copy small { color: var(--app-muted); }
.habit-today-action { color: #6d28d9; font-size: .82rem; font-weight: 700; }
.habit-today-card.done .habit-today-action { color: #166534; }
.habit-today-empty { margin: 1rem 0; padding: 1.5rem; border: 1px dashed #cbd5e1; border-radius: 1rem; background: #f8fafc; text-align: center; }
.habit-history-header { margin: 1.5rem 0 .7rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; }
.habit-week-header { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin: 1.5rem 0 .7rem; }
.habit-week-header h3 { margin: 0; }
.habit-week-range { display: block; margin-top: .2rem; color: var(--app-muted); }
.habit-week-navigation .btn { min-width: 44px; }
.habit-week-wrap { overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 1rem; background: white; }
.habit-week-table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; }
.habit-week-table th, .habit-week-table td { padding: .65rem; text-align: center; border-bottom: 1px solid #eef2f7; }
.habit-week-table th { background: #f8fafc; color: var(--app-muted); font-size: .78rem; }
.habit-week-table th span, .habit-week-table th strong, .habit-week-name strong, .habit-week-name small { display: block; }
.habit-week-table .habit-week-name { min-width: 175px; text-align: left; }
.habit-week-name small { color: var(--app-muted); }
.habit-week-table .today { background: #f5f3ff; }
.habit-week-progress { font-weight: 700; white-space: nowrap; }
.habit-future { color: #cbd5e1; }
.habit-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
.habit-calendar-wrap { overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 1rem; background: white; }
.habit-calendar { border-collapse: separate; border-spacing: 0; min-width: 1100px; width: 100%; }
.habit-calendar th, .habit-calendar td { padding: .42rem; text-align: center; border-bottom: 1px solid #eef2f7; }
.habit-calendar th { position: sticky; top: 0; background: #f8fafc; z-index: 2; font-size: .72rem; color: var(--app-muted); }
.habit-calendar th span, .habit-calendar th strong { display: block; }
.habit-calendar .habit-name-column { position: sticky; left: 0; z-index: 3; min-width: 210px; text-align: left; background: white; }
.habit-calendar thead .habit-name-column { background: #f8fafc; }
.habit-calendar .today { background: #f5f3ff; }
.habit-area-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .45rem; }
.habit-name-column > div { display: inline-flex; flex-direction: column; vertical-align: middle; }
.habit-name-column small { color: var(--app-muted); }
.habit-check, .habit-goal-check { width: 30px; height: 30px; border: 1px solid #cbd5e1; border-radius: .5rem; background: white; color: white; font-weight: 700; }
.habit-check.done, .habit-goal-row.complete .habit-goal-check { background: #16a34a; border-color: #16a34a; }
.habit-unavailable { color: #cbd5e1; }
.habit-stat { white-space: nowrap; font-variant-numeric: tabular-nums; }
.habit-row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.habit-goal-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.habit-goal-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .7rem; padding: .65rem 0; border-bottom: 1px solid #e2e8f0; }
.habit-goal-row:last-child { border-bottom: 0; }
.habit-goal-row.complete > span { text-decoration: line-through; color: var(--app-muted); }
.empty-state { min-height: 220px; display: grid; place-content: center; text-align: center; color: var(--app-muted); padding: 2rem; }
.empty-state h3 { color: #334155; }
#main_navigation .form-check { margin: .2rem 0; padding: 0; }
#main_navigation .form-check-input { position: absolute; opacity: 0; }
#main_navigation .form-check-label { display: block; padding: .65rem .8rem; border-radius: .65rem; cursor: pointer; }
#main_navigation .form-check-input:checked + .form-check-label { color: #1d4ed8; background: #e8eefc; font-weight: 650; }
@media (max-width: 991.98px) { .dashboard-grid > * { grid-column: span 6; } }
@media (max-width: 575.98px) {
  html { scroll-padding-top: .75rem; }
  body { overflow-x: hidden; }
  .app-root { padding-bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
  .module-heading { margin-bottom: .75rem; }
  .module-heading h2 { font-size: 1.45rem; line-height: 1.15; }
  .module-heading p { font-size: .9rem; line-height: 1.35; }
  .habit-today-list { grid-template-columns: 1fr; }
  .habit-today-heading, .habit-history-header { align-items: stretch; flex-direction: column; }
  .habit-week-header { align-items: stretch; flex-direction: column; }
  .habit-week-navigation { width: 100%; }
  .habit-week-navigation .btn { flex: 1; }
  .habit-week-table { min-width: 620px; }
  .habit-week-table .habit-week-name { position: sticky; left: 0; z-index: 2; min-width: 145px; background: white; box-shadow: 1px 0 0 #e2e8f0; }
  .habit-week-table thead .habit-week-name { z-index: 3; background: #f8fafc; }
  .habit-week-table th, .habit-week-table td { padding: .55rem .45rem; }
  .habit-period { width: 100%; }
  .dashboard-grid { display: block; }
  .dashboard-grid > * { margin-bottom: .8rem; }
  .bslib-page-sidebar > .main { padding: .85rem max(.85rem, env(safe-area-inset-right)) max(.85rem, env(safe-area-inset-bottom)) max(.85rem, env(safe-area-inset-left)) !important; }
  .bslib-card .card-header { padding: .75rem .85rem; }
  .bslib-card .card-body { padding: .85rem; }
  .home-summary-list > div, .home-alert-row { align-items: flex-start; }
  .home-summary-list strong, .home-alert-row > strong { max-width: 58%; text-align: right; overflow-wrap: anywhere; }
  #main_navigation .form-check-label { display: flex; align-items: center; min-height: 48px; padding: .7rem .85rem; }
  .login-page { align-items: start; padding-top: 8vh; }
  input.form-control, select.form-select, textarea.form-control { font-size: 16px; }
  .btn, .form-check-label { min-height: 44px; }
  .modal-dialog { margin: .5rem; }
  .modal-content { max-height: calc(100dvh - 1rem); }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-footer { flex-wrap: nowrap; padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1 1 0; }
}

.finance-header, .finance-toolbar, .finance-filters, .record-actions { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.finance-header { justify-content: space-between; align-items: start; }
.finance-add { min-height: 46px; }
.finance-fab { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1040; width: 58px; height: 58px; border-radius: 50%; font-size: 1.7rem; line-height: 1; box-shadow: 0 10px 28px rgba(37,99,235,.32); }
.finance-toolbar { justify-content: flex-end; margin-bottom: 1rem; }
.finance-filters { margin-bottom: 1rem; }
.finance-filters > * { flex: 1 1 160px; }
.finance-kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.finance-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.account-balance-note { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid #bfdbfe; border-radius: .8rem; background: #eff6ff; color: #1e3a5f; }
.account-card-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.account-card-head h3, .account-card-head h4 { margin: 0; }
.account-card-head h3 { white-space: nowrap; font-variant-numeric: tabular-nums; }
.account-card small { color: var(--app-muted); }
.account-adjust-button { margin-top: .85rem; width: 100%; }
.reconciliation-current { padding: .75rem 1rem; margin-bottom: 1rem; border-radius: .7rem; background: #f8fafc; }
.reconciliation-current h3 { margin: .15rem 0 0; }
.credit-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .65rem; padding: .75rem; border-radius: .8rem; background: var(--bs-tertiary-bg); }
.credit-summary > div { display: flex; flex-direction: column; }
.account-card-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.finance-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.finance-form-note { padding: .65rem .8rem; margin-bottom: .75rem; border-radius: .7rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
.msi-fields { padding: .75rem; border-left: 3px solid var(--bs-primary); background: var(--bs-tertiary-bg); border-radius: .5rem; }
.credit-card-overview h3 { font-size: 1.35rem; }
.msi-plan-list { display: grid; gap: .65rem; }
.msi-plan-card { padding: .8rem; border: 1px solid var(--app-border); border-radius: .75rem; background: #fff; }
.budget-row { display: grid; grid-template-columns: minmax(160px, 1fr) auto minmax(140px, 1fr); gap: 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--app-border); }
.budget-row small { display: block; color: var(--app-muted); }
.budget-values { text-align: right; font-variant-numeric: tabular-nums; }
.record-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--app-border); }
.finance-mobile-list { display: none; }
.movement-card { padding: .9rem 0; border-bottom: 1px solid var(--app-border); }
.movement-card-head { display: flex; justify-content: space-between; gap: 1rem; }
.movement-card-meta { color: var(--app-muted); font-size: .86rem; margin-top: .2rem; }
.movement-card-footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .65rem; }
.budget-section-title { margin: 1.35rem 0 .25rem; font-size: 1.05rem; color: #334155; }
.budget-card-header, .budget-section-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.budget-card-header small { display: block; color: var(--app-muted); font-weight: 400; }
.budget-section-header { margin: 1.4rem 0 .4rem; padding-bottom: .45rem; border-bottom: 2px solid #dbe4f0; }
.budget-section-header h4 { margin: 0; font-size: 1.05rem; }
.budget-section-header span { color: var(--app-muted); font-size: .9rem; }
.budget-grid { display: grid; grid-template-columns: minmax(180px, 1.4fr) 78px 135px 145px minmax(120px, .8fr) minmax(145px, auto); gap: .65rem; align-items: center; }
.budget-grid-labels { color: var(--app-muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .035em; padding: .35rem .6rem; }
.budget-edit-row { position: relative; padding: .65rem .6rem 1rem; border-bottom: 1px solid var(--app-border); }
.budget-edit-row .form-group { margin: 0; }
.budget-edit-row input { font-variant-numeric: tabular-nums; }
.budget-concept small, .budget-number small { display: block; color: var(--app-muted); }
.budget-number { font-variant-numeric: tabular-nums; }
.budget-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.budget-status { display: inline-block; width: fit-content; padding: .22rem .45rem; border-radius: 999px; font-size: .7rem; font-weight: 750; }
.budget-status.ok { background: #dcfce7; color: #166534; }
.budget-status.warning { background: #fef3c7; color: #92400e; }
.budget-status.danger { background: #fee2e2; color: #991b1b; }
.budget-progress { position: absolute; left: .6rem; right: .6rem; bottom: .28rem; height: 3px; grid-column: 1 / -1; }
.budget-accordion { display: grid; gap: .7rem; }
.budget-accordion .accordion-item { border: 1px solid var(--app-border); border-radius: .8rem !important; overflow: hidden; }
.budget-accordion .accordion-button { padding: .9rem 1rem; background: #fff; box-shadow: none; }
.budget-accordion .accordion-button:not(.collapsed) { background: #f8fafc; }
.budget-accordion-title { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-right: .75rem; }
.budget-accordion-title > div:first-child { display: flex; flex-direction: column; }
.budget-accordion-title small { color: var(--app-muted); font-weight: 400; }
.budget-accordion-total { text-align: right; font-variant-numeric: tabular-nums; }
.budget-accordion-total small { display: block; font-size: .7rem; text-transform: uppercase; }
.budget-section-content { padding: .15rem .15rem .4rem; }
.household-budget-note { margin: 0 0 1rem; padding: .8rem 1rem; border: 1px solid #bfdbfe; border-radius: .8rem; background: #eff6ff; color: #1e3a5f; }
.contribution-summary { margin-bottom: 1rem; }
.commitments-card { margin-bottom: 1rem; }
.commitment-overview { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .75rem; margin-bottom: .8rem; }
.commitment-overview > div { display: flex; flex-direction: column; padding: .75rem; border-radius: .7rem; background: #f8fafc; }
.commitment-overview strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.commitment-negative { background: #fef2f2 !important; color: #991b1b; }
.commitment-list { border-top: 1px solid var(--app-border); }
.commitment-row { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--app-border); }
.next-income-note { margin-top: .75rem; padding: .65rem .8rem; border-radius: .65rem; background: #eff6ff; color: #1e3a5f; }
.month-close-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .35rem 1rem; margin-bottom: 1rem; padding: .75rem 1rem; border-radius: .75rem; }
.month-close-status.closed { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.month-close-status.reopened { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.close-ok, .close-warning { padding: .7rem .8rem; margin-bottom: .7rem; border-radius: .65rem; }
.close-ok { background: #ecfdf5; color: #065f46; }
.close-warning { background: #fff7ed; color: #9a3412; }
.close-check-list { margin-bottom: .75rem; border-top: 1px solid var(--app-border); }
.close-check-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--app-border); }
.close-summary-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .65rem; }
.close-summary-grid > div { display: flex; flex-direction: column; padding: .75rem; border-radius: .65rem; background: #f8fafc; }
.contribution-summary .card-header { display: flex; flex-direction: column; }
.contribution-summary .card-header small, .contribution-card small { color: var(--app-muted); }
.contribution-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .75rem; }
.contribution-card { box-shadow: none; border: 1px solid var(--app-border); }
.contribution-card-head { display: flex; justify-content: space-between; gap: .75rem; font-variant-numeric: tabular-nums; }
.savings-goal-card .progress { margin: .4rem 0 .9rem; }
.investment-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
.investment-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .6rem; margin-top: .8rem; }
.investment-metrics > div { display: flex; flex-direction: column; padding: .6rem; border-radius: .65rem; background: #f8fafc; }
.investment-metrics small { color: var(--app-muted); }
.investment-metrics strong { font-variant-numeric: tabular-nums; }
.investment-price-age { display: block; margin-top: .65rem; color: var(--app-muted); }
.investment-operation-summary { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .65rem; color: var(--app-muted); }
.investment-history-list { display: grid; gap: .65rem; }
.investment-history-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem; border: 1px solid var(--app-border); border-radius: .7rem; }
.investment-history-main { display: flex; flex-direction: column; min-width: 0; }
.investment-history-main small { color: var(--app-muted); }
.price-refresh-status { display: flex; justify-content: space-between; gap: .75rem; margin: 0 0 1rem; padding: .65rem .8rem; border-radius: .7rem; font-size: .88rem; }
.price-refresh-status.ok { background: #ecfdf5; color: #065f46; }
.price-refresh-status.warning { background: #fff7ed; color: #9a3412; }
.price-refresh-status details { max-width: 70%; }
.price-refresh-status ul { margin: .45rem 0 0; }
.quick-entry-title { display: flex; flex-direction: column; }
.quick-entry-title small { color: var(--app-muted); font-size: .78rem; font-weight: 400; }
.quick-entry-primary { display: grid; grid-template-columns: 1.25fr 1fr; gap: .75rem; }
.quick-entry-primary > :only-child { grid-column: 1 / -1; }
.quick-entry-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.quick-entry-secondary > :last-child { grid-column: 1 / -1; }
.transaction-type-picker .shiny-options-group { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: .35rem; }
.transaction-type-picker .form-check { margin: 0; padding: 0; }
.transaction-type-picker .form-check-input { position: absolute; opacity: 0; }
.transaction-type-picker .form-check-label { width: 100%; padding: .6rem .25rem; border: 1px solid var(--app-border); border-radius: .6rem; text-align: center; font-size: .78rem; cursor: pointer; }
.transaction-type-picker .form-check-input:checked + .form-check-label { background: #e8eefc; border-color: #2563eb; color: #1d4ed8; font-weight: 700; }
.quick-entry-modal .modal-footer .btn-primary { min-width: 180px; }
.analytics-period-filter { max-width: 360px; margin-bottom: .25rem; }
.analytics-period-caption { margin: 0 0 1rem; color: var(--app-muted); font-size: .88rem; }
.analytics-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
.analytics-card { min-height: 360px; }
.analytics-card .card-body { min-height: 0; }
.analytics-insight-grid { display: grid; gap: .7rem; }
.analytics-insight { display: flex; flex-direction: column; gap: .2rem; padding: .75rem; border: 1px solid var(--app-border); border-radius: .75rem; background: #f8fafc; }
.analytics-insight small { color: var(--app-muted); }
.analytics-insight strong { overflow-wrap: anywhere; }
.analytics-insight.ok { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.analytics-insight.danger { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.analytics-method-note { margin: .9rem 0 0; color: var(--app-muted); font-size: .82rem; line-height: 1.4; }
@media (max-width: 991.98px) { .finance-kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .finance-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 575.98px) {
  .habit-goal-grid { grid-template-columns: 1fr; }
  .commitment-overview { grid-template-columns: 1fr; }
  .close-summary-grid { grid-template-columns: 1fr 1fr; }
  .credit-summary { grid-template-columns: 1fr; }
  .finance-form-row { grid-template-columns: 1fr; gap: 0; }
  .account-card-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .finance-kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
  .finance-kpi-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .finance-kpi-grid .bslib-value-box { min-height: 0; }
  .finance-kpi-grid .value-box-area { padding: .75rem; }
  .finance-kpi-grid .value-box-title { font-size: .76rem; line-height: 1.2; }
  .finance-kpi-grid .value-box-value { font-size: clamp(1.05rem,5.3vw,1.35rem); overflow-wrap: anywhere; }
  .finance-card-grid { grid-template-columns: 1fr; }
  .analytics-period-filter { max-width: none; }
  .analytics-card { min-height: 330px; }
  .analytics-card .card-body { padding: .5rem; }
  .investment-kpis, .investment-metrics { grid-template-columns: 1fr; }
  .investment-history-row { align-items: stretch; flex-direction: column; }
  .contribution-grid { grid-template-columns: 1fr; }
  .finance-header { display: block; }
  .finance-header > .btn, .finance-add, .finance-toolbar .btn { width: 100%; min-height: 48px; }
  .finance-toolbar, .finance-filters { align-items: stretch; }
  .finance-filters > * { flex-basis: 100%; }
  .budget-row { grid-template-columns: 1fr; gap: .35rem; }
  .budget-values { text-align: left; }
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: x proximity; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-item { flex: 0 0 auto; scroll-snap-align: start; }
  .nav-tabs .nav-link { min-height: 44px; white-space: nowrap; }
  .table-responsive { font-size: .85rem; }
  .finance-table-view { display: none; }
  .finance-mobile-list { display: block; }
  .record-actions .form-group { flex: 1 1 100%; }
  .budget-period .btn { width: 100%; min-height: 44px; }
  .budget-card-header { align-items: flex-start; }
  .budget-card-header .badge { display: none; }
  .budget-accordion-title { align-items: flex-start; }
  .budget-accordion-total { white-space: nowrap; }
  .budget-accordion .accordion-body { padding: .45rem .7rem .7rem; }
  .budget-grid-labels { display: none; }
  .budget-edit-row { grid-template-columns: 1fr 1fr; gap: .55rem .75rem; padding: .85rem .2rem 1.1rem; }
  .budget-concept { grid-column: 1 / -1; }
  .budget-edit-row > :nth-child(2)::before { content: "Día"; display: block; color: var(--app-muted); font-size: .7rem; text-transform: uppercase; }
  .budget-edit-row > :nth-child(3)::before { content: "Proyectado"; display: block; color: var(--app-muted); font-size: .7rem; text-transform: uppercase; }
  .budget-edit-row > :nth-child(4)::before { content: "Real"; display: block; color: var(--app-muted); font-size: .7rem; text-transform: uppercase; }
  .budget-actions { grid-column: 1 / -1; justify-content: stretch; }
  .budget-actions .btn { flex: 1; min-height: 42px; }
  .budget-progress { left: .2rem; right: .2rem; }
  .finance-add { display: none; }
  .finance-fab { right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); width: 54px; height: 54px; }
  .quick-entry-primary { grid-template-columns: 1fr 1fr; }
  .transaction-type-picker .shiny-options-group { display: flex; grid-template-columns: none; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; scroll-snap-type: x proximity; scrollbar-width: none; }
  .transaction-type-picker .shiny-options-group::-webkit-scrollbar { display: none; }
  .transaction-type-picker .form-check { flex: 0 0 auto; scroll-snap-align: start; }
  .transaction-type-picker .form-check-label { width: auto; min-width: 82px; padding-inline: .65rem; }
  .quick-entry-modal .modal-dialog { width: 100%; max-width: none; height: 100dvh; margin: 0; }
  .quick-entry-modal .modal-content { height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .quick-entry-modal .modal-header { padding: max(.7rem, env(safe-area-inset-top)) 1rem .65rem; }
  .quick-entry-modal .modal-body { padding: .7rem 1rem; }
  .quick-entry-modal .form-group { margin-bottom: .55rem; }
  .quick-entry-modal .transaction-type-picker .form-group { margin-bottom: .65rem; }
  .quick-entry-modal .accordion { margin-top: .1rem; }
  .quick-entry-modal .accordion-button { min-height: 44px; padding: .65rem .8rem; }
  .quick-entry-dynamic > .shiny-html-output { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 .65rem; }
  .quick-entry-dynamic > .shiny-html-output > .finance-form-note,
  .quick-entry-dynamic > .shiny-html-output > .form-group:first-child:nth-last-child(n+3) { grid-column: 1 / -1; }
  .quick-entry-modal .modal-footer { position: sticky; bottom: 0; gap: .5rem; padding: .65rem 1rem max(.65rem, env(safe-area-inset-bottom)); background: #fff; }
  .quick-entry-modal .modal-footer .btn-primary { flex: 1; min-height: 48px; }
}

@media (max-width: 399.98px) {
  .finance-kpi-grid, .close-summary-grid { grid-template-columns: 1fr; }
  .finance-kpi-grid > :last-child:nth-child(odd) { grid-column: auto; }
  .quick-entry-dynamic > .shiny-html-output { grid-template-columns: 1fr; }
  .quick-entry-dynamic > .shiny-html-output > * { grid-column: auto !important; }
  .quick-entry-secondary { grid-template-columns: 1fr; }
  .quick-entry-secondary > * { grid-column: auto; }
  .budget-edit-row { grid-template-columns: 1fr; }
  .budget-concept, .budget-actions { grid-column: auto; }
}
