/* Large, high-contrast, touch-friendly styles on top of Bootstrap 5.3 */
:root {
  --bs-body-font-size: 1.125rem;   /* 18px base */
  --bs-body-color: #1a1d20;
  --bs-secondary-color: #495057;
  --bs-border-radius: .6rem;
  --bs-border-radius-lg: .8rem;
  --bottom-nav-h: 72px;
}
html { font-size: 100%; }
body { background: #f3f5f8; -webkit-text-size-adjust: 100%; }
body.has-nav { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px); }
@media (min-width: 992px) { body.has-nav { padding-bottom: 2rem; } }

.text-muted, .text-body-secondary { color: #495057 !important; }
h1, .h1 { font-size: 1.9rem; font-weight: 700; }
@media (min-width: 768px) { h1, .h1 { font-size: 2.2rem; } }

/* Buttons & inputs: at least 48px tall */
.btn { min-height: 48px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.btn-lg { min-height: 56px; font-size: 1.2rem; }
.btn-sm { min-height: 40px; }
.form-control, .form-select { min-height: 52px; font-size: 1.15rem; border-width: 2px; }
.form-control-lg { min-height: 60px; font-size: 1.35rem; }
.form-label { font-weight: 600; font-size: 1.1rem; margin-bottom: .35rem; }
.form-check-input { width: 1.6em; height: 1.6em; margin-top: .1em; }
.form-check-label { padding-left: .4rem; }
.form-control:focus, .form-select:focus, .btn:focus-visible { box-shadow: 0 0 0 .3rem rgba(13, 110, 253, .35); }
.form-control.is-invalid { border-color: #b02a37; }
.field-error { color: #b02a37; font-weight: 600; margin-top: .4rem; font-size: 1.05rem; }

.amount-input { font-size: 2rem !important; font-weight: 700; text-align: left; min-height: 72px; }
.amount-wrap .input-group-text { font-size: 1.8rem; font-weight: 700; min-width: 3rem; justify-content: center; }

/* Navigation */
.top-nav .nav-link { font-size: 1.1rem; border-radius: .5rem; }
.top-nav .nav-link.active { background: rgba(255,255,255,.18); }
.mobile-header { padding: .75rem 0; position: sticky; top: 0; z-index: 1020; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; background: #fff; border-top: 1px solid #dee2e6;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.bottom-nav > a, .bottom-nav > .dropup { flex: 1; }
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: var(--bottom-nav-h); color: #495057; text-decoration: none; font-size: .9rem; font-weight: 600;
}
.bottom-nav .dropup > a { height: var(--bottom-nav-h); }
.bottom-nav a .bi { font-size: 1.6rem; line-height: 1.1; }
.bottom-nav a.active { color: #0b5ed7; }
.bottom-nav .tab-badge { position: absolute; top: -4px; right: -14px; font-size: .75rem; }
.more-menu { font-size: 1.15rem; min-width: 14rem; }
.more-menu .dropdown-item { padding: .85rem 1.2rem; }

/* Alerts: fixed near the top so they are always visible */
.alert-area {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  width: min(640px, calc(100% - 20px)); z-index: 1090; pointer-events: none;
}
.app-alert {
  pointer-events: auto; opacity: 0; transform: translateY(-12px); transition: all .2s ease;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  font-size: 1.2rem; font-weight: 600; border-width: 2px; margin: 0; padding: 1rem 1.1rem;
}
.app-alert.show { opacity: 1; transform: none; }
.app-alert .alert-msg { display: flex; gap: .6rem; align-items: flex-start; flex: 1 1 260px; }
.app-alert .alert-icon { font-size: 1.6rem; line-height: 1; }
.app-alert .alert-actions { display: flex; gap: .5rem; margin-left: auto; }
.app-alert .btn { min-width: 84px; }

/* Cards */
.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); border-radius: var(--bs-border-radius-lg); }
.card-title { font-weight: 700; }
.page-title { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* Dashboard */
.hero-card { background: linear-gradient(135deg, #0b5ed7, #0a58ca); color: #fff; }
.hero-card.level-warn { background: linear-gradient(135deg, #b35c00, #cc6a00); }
.hero-card.level-over { background: linear-gradient(135deg, #a51d2d, #c0392b); }
.hero-amount { font-size: 3rem; font-weight: 800; line-height: 1.1; }
@media (min-width: 992px) { .hero-amount { font-size: 3.6rem; } }
.hero-card .progress { background: rgba(255,255,255,.3); height: 22px; }
.hero-card .progress-bar.bg-success { background: #fff !important; }
.budget-progress { height: 16px; border-radius: 99px; }
.budget-progress .progress-bar { border-radius: 99px; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.month-nav .month-label { font-size: 1.35rem; font-weight: 700; text-align: center; flex: 1; }
.month-nav .btn { min-width: 56px; }

.cat-card .cat-icon, .txn-icon {
  width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; flex-shrink: 0;
}
.cat-card .cat-name { font-weight: 700; font-size: 1.15rem; }
.status-text-ok { color: #146c43; }
.status-text-warn { color: #995200; }
.status-text-over { color: #b02a37; }

/* Category picker */
.category-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 576px) { .category-grid { grid-template-columns: repeat(3, 1fr); } }
.category-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  min-height: 88px; padding: .6rem .4rem; border: 2px solid #ced4da; background: #fff; color: #212529;
  font-size: 1rem; line-height: 1.2; text-align: center; white-space: normal;
}
.category-btn .bi { font-size: 1.7rem; color: var(--cat-color); }
.btn-check:checked + .category-btn { background: var(--cat-color); border-color: var(--cat-color); color: #fff; box-shadow: 0 0 0 .2rem rgba(0,0,0,.15); }
.btn-check:checked + .category-btn .bi { color: #fff; }
.btn-check:checked + .category-btn::after { content: "\2713  Selected"; font-size: .85rem; }
.btn-check:focus-visible + .category-btn { outline: 3px solid #0b5ed7; outline-offset: 2px; }
.is-invalid ~ .category-btn, .category-grid:has(.is-invalid) .category-btn { border-color: #b02a37; }

/* Compact category grid for bank cards */
.category-grid.compact { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 576px) { .category-grid.compact { grid-template-columns: repeat(3, 1fr); } }
.category-grid.compact .category-btn { min-width: 0; min-height: 64px; font-size: .95rem; flex-direction: row; gap: .4rem; }
.category-grid.compact .category-btn .bi { font-size: 1.3rem; }
.category-grid.compact .btn-check:checked + .category-btn::after { content: ""; }

/* Date quick buttons */
.date-quick .btn { flex: 1; }

/* Transaction list */
.day-heading { font-size: 1rem; font-weight: 700; color: #495057; text-transform: uppercase; letter-spacing: .03em; margin: 1.2rem 0 .5rem; }
.txn-row {
  display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; background: #fff;
  border-radius: var(--bs-border-radius-lg); box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: .6rem;
  width: 100%; text-align: left; border: 0; color: inherit;
}
.txn-row:hover { background: #f8f9fa; }
.txn-row .txn-main { flex: 1; min-width: 0; }
.txn-row .txn-desc { font-weight: 700; font-size: 1.15rem; overflow-wrap: anywhere; }
.txn-row .txn-meta { font-size: .98rem; color: #495057; }
.txn-row .txn-amount { font-weight: 800; font-size: 1.25rem; white-space: nowrap; }
.txn-row .txn-amount.refund { color: #146c43; }
.badge-source { font-size: .8rem; font-weight: 600; }

/* Bank feed cards */
.bank-card .bank-amount { font-size: 1.6rem; font-weight: 800; }
.bank-card .bank-amount.credit { color: #146c43; }
.bank-card .bank-label { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }

/* Animations for visual feedback */
@keyframes flashNew { 0% { box-shadow: 0 0 0 4px #20c997; background: #d1f5e8; } 100% { box-shadow: 0 1px 3px rgba(0,0,0,.08); } }
.flash-new { animation: flashNew 2.2s ease-out; }
.fade-remove { transition: opacity .3s, transform .3s; opacity: 0; transform: translateX(40px); }

/* Login */
body.bare { background: linear-gradient(160deg, #0b5ed7 0%, #084298 100%); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.login-card { width: 100%; max-width: 460px; }

/* Forms centered on larger screens */
.form-narrow { max-width: 640px; margin-left: auto; margin-right: auto; }

/* Password checklist */
.pw-rules { list-style: none; padding: 0; margin: .5rem 0 0; }
.pw-rules li { font-size: 1.05rem; padding: .15rem 0; color: #6c757d; }
.pw-rules li.met { color: #146c43; font-weight: 600; }
.pw-rules li .bi { margin-right: .4rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: #495057; }
.empty-state .bi { font-size: 3rem; color: #adb5bd; }

.sticky-actions { position: sticky; bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; }
@media (min-width: 992px) { .sticky-actions { position: static; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Touch devices keep :hover after a tap; keep unselected category buttons plain */
.category-btn:hover, .category-btn:active, .category-btn:focus { background: #fff; color: #212529; border-color: #adb5bd; }
.btn-check:checked + .category-btn:hover, .btn-check:checked + .category-btn:active { background: var(--cat-color); color: #fff; }
