:root {
  --brand: #2b6cb0;
  --brand-dark: #1e4e8c;
  --wife: #d63384;
  --husband: #0d6efd;
  --family: #198754;
  --bg: #f4f6fb;
  --income: #198754;
  --expense: #dc3545;
}

* { font-family: 'Sarabun', -apple-system, 'Segoe UI', sans-serif; }

body {
  background: var(--bg);
  color: #2d3748;
}

.app-navbar {
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.app-navbar .nav-link { color: rgba(255,255,255,.82); font-weight: 500; border-radius: .5rem; padding: .4rem .8rem; }
.app-navbar .nav-link:hover { color: #fff; background: rgba(255,255,255,.12); }
.app-navbar .nav-link.active { color: #fff; background: rgba(255,255,255,.22); }

/* ---------- cards ---------- */
.card {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 2px 10px rgba(20,40,80,.06);
}
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-label { font-size: .82rem; color: #718096; }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-icon {
  position: absolute; right: .9rem; top: .8rem;
  font-size: 1.8rem; opacity: .18;
}
.stat-sub { font-size: .78rem; color: #a0aec0; }

.text-income { color: var(--income) !important; }
.text-expense { color: var(--expense) !important; }

/* ---------- owner badges ---------- */
.bg-owner-wife { background: var(--wife) !important; color: #fff; }
.bg-owner-husband { background: var(--husband) !important; color: #fff; }
.bg-owner-family { background: var(--family) !important; color: #fff; }

/* ---------- section title ---------- */
.section-title { font-weight: 700; color: #2d3748; margin: 1.2rem 0 .6rem; }
.section-title i { color: var(--brand); }

/* ---------- tables ---------- */
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { color: #718096; font-weight: 600; font-size: .85rem; border-bottom: 2px solid #e2e8f0; }
.money { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- progress ---------- */
.progress { height: .6rem; border-radius: 1rem; background: #e2e8f0; }

/* ---------- chart wrapper ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box-sm { position: relative; height: 240px; }

/* ---------- responsive tweaks ---------- */
@media (max-width: 576px) {
  .stat-card .stat-value { font-size: 1.3rem; }
  .chart-box { height: 260px; }
}

/* badge สถานะรายจ่ายคงที่ */
.status-badge { font-size: .72rem; }

/* สีส้มสำหรับสถานะงบ 91–100% */
.bg-orange { background-color: #fd7e14 !important; color: #fff !important; }
.text-orange { color: #fd7e14 !important; }
.progress-bar.bg-orange { background-color: #fd7e14 !important; }

/* ---------- แถบเมนูล่างสำหรับมือถือ ---------- */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -2px 10px rgba(20,40,80,.06);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1030;
}
.mbn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #94a3b8;
  text-decoration: none;
  font-size: .68rem;
  font-weight: 500;
  padding: .3rem 0;
  min-height: 44px;
}
.mbn-item i { font-size: 1.25rem; }
.mbn-item.active { color: var(--brand); }
.mbn-fab {
  flex: 0 0 auto;
  width: 54px; height: 54px;
  margin-top: -20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(43,108,176,.4);
}
.mbn-fab i { font-size: 1.5rem; }

/* ให้เนื้อหาไม่ถูกแถบล่างบัง + แตะง่ายบนมือถือ */
@media (max-width: 991.98px) {
  body { padding-bottom: 62px; }
  .btn { min-height: 40px; }
  .form-control, .form-select { min-height: 44px; font-size: 16px; } /* 16px กัน iOS zoom */
  .table > :not(caption) > * > * { padding: .55rem .5rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
  h4 { font-size: 1.15rem; }
}
