* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar: #1f4037;
  --sidebar-2: #2a5549;
  --sidebar-text: #d8efe4;
  --bg: #e9eeeb;
  --mint: #f0f8f5;
  --card: #e8f5f0;
  --white: #ffffff;
  --green: #4caf50;
  --green-dark: #3b8a3f;
  --red: #d74e54;
  --red-orange: #e0553f;
  --grey: #8a9a92;
  --text: #22302a;
  --muted: #7a8a82;
  --border: #d6e4dd;
  --shadow: 0 8px 24px rgba(31, 64, 55, 0.08);
  --radius: 18px;
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

button { font-family: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------- Loading ---------- */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--mint);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-card { text-align: center; color: var(--sidebar); }
.spinner {
  width: 46px; height: 46px;
  margin: 0 auto 18px;
  border: 4px solid rgba(31, 64, 55, 0.15);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-error { margin-top: 10px; color: var(--red); font-size: 13px; max-width: 320px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--sidebar-text);
  border-radius: 0 24px 24px 0;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; -webkit-overflow-scrolling: touch; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: var(--green); color: #fff; }
.sidebar-profile {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
}
.sidebar-profile:hover { background: rgba(255,255,255,.12); }

.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1180px;
  margin: 0 auto;
}
.page { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Page header ---------- */
.page-header {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h2 { font-size: 24px; color: var(--sidebar); }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.header-balance { font-size: 34px; font-weight: 800; color: var(--green-dark); margin: 4px 0 2px; line-height: 1.1; overflow-wrap: anywhere; }
.header-balance.dash-income { color: var(--green-dark); }
.header-balance.dash-expense { color: var(--red); }
.header-balance-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.balance-caption { font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: transform .1s, box-shadow .15s, filter .15s;
}
.btn::after, .nav-item::after, .icon-btn::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.45) 10%, transparent 10.5%);
  background-position: center; background-repeat: no-repeat;
  transform: scale(10); opacity: 0; transition: transform .45s, opacity .6s;
}
.btn:active::after, .nav-item:active::after, .icon-btn:active::after {
  transform: scale(0); opacity: 1; transition: 0s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-small { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn-green { background: var(--green); }
.btn-expense { background: linear-gradient(135deg, #e0553f, #d74e54); }
.btn-income { background: linear-gradient(135deg, #57b65c, var(--green)); }
.btn-transfer { background: var(--grey); }
.btn-ghost { background: #eef3f0; color: var(--text); }
.btn-danger { background: var(--red); }

.action-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.action-buttons .btn { flex: 1; min-width: 170px; padding: 15px; font-size: 15px; }
.action-buttons.secondary-actions { margin-top: 4px; margin-bottom: 20px; }
.action-buttons.secondary-actions .btn { min-width: 0; padding: 11px 14px; font-size: 13.5px; }

/* ---------- Quick Expense entry ---------- */
.quick-entry { margin-bottom: 16px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.nature-toggle { display: flex; gap: 8px; }
.nature-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.nature-btn.active[data-nature="must"] { border-color: var(--green); background: rgba(76,175,80,.14); color: var(--green-dark); }
.nature-btn.active[data-nature="want"] { border-color: var(--red); background: rgba(215,78,84,.12); color: var(--red); }
.quick-grid input, .quick-grid select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--text);
}
.quick-grid input:focus, .quick-grid select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(76,175,80,.15); outline: none; }
.quick-entry #btnQuickSave { width: 100%; margin: 0; grid-column: 1 / -1; }
.quick-entry #qDateTime { grid-column: 1 / -1; }
.quick-error { color: var(--red); font-size: 13px; min-height: 16px; margin: 8px 0 0; }
.quick-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
@media (max-width: 560px) {
  .quick-grid { grid-template-columns: 1fr; }
}

/* ---------- Dashboard cards ---------- */
.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.dash-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-balance {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--sidebar), var(--sidebar-2));
  color: var(--sidebar-text);
}
.dash-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.dash-balance .dash-label { color: rgba(255,255,255,.7); }
.dash-value { font-size: 26px; font-weight: 700; }
.dash-balance .dash-value { font-size: 32px; color: #fff; }
.dash-sub { font-size: 12px; color: rgba(255,255,255,.6); }
.dash-income { color: var(--green-dark); }
.dash-expense { color: var(--red); }

/* ---------- Activity ---------- */
.activity-panel, .card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.panel-header, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-header h3, .section-head h3 { font-size: 17px; color: var(--sidebar); }
.panel-count { font-size: 13px; color: var(--muted); }

.transaction-list { display: flex; flex-direction: column; gap: 10px; }
.tx-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 12px;
  background: var(--mint);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.tx-badge {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-top: 2px;
}
.badge-income { background: rgba(76,175,80,.16); color: var(--green-dark); }
.badge-expense { background: rgba(215,78,84,.14); color: var(--red); }
.badge-transfer { background: rgba(138,154,146,.18); color: #55665e; }
.tx-info { flex: 1; min-width: 0; order: 2; }
.tx-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.tx-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.tx-desc { font-size: 12.5px; color: #2f6fd0; font-weight: 700; margin-top: 1px; overflow-wrap: anywhere; }
.tx-time { font-size: 12px; color: var(--muted); white-space: nowrap; margin-top: 1px; }
.tx-amount { font-weight: 700; font-size: 16px; white-space: nowrap; order: 3; margin-left: auto; }
.tx-amount.plus { color: var(--green-dark); }
.tx-amount.minus { color: var(--red); }
.tx-amount.transfer { color: #55665e; }
.tx-actions { display: flex; gap: 6px; order: 4; }
.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--green); color: var(--green-dark); background: var(--card); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.empty-state { text-align: center; color: var(--muted); font-size: 14px; padding: 30px 10px; }

/* ---------- Accounts ---------- */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.acct-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.acct-summary-card { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.acct-summary-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.acct-summary-value { font-size: 18px; font-weight: 800; color: var(--green-dark); }
.acct-summary-value.acct-summary-green { color: var(--green-dark); }
.acct-summary-value.acct-summary-red { color: var(--red); }
@media (max-width: 560px) {
  .acct-summary { grid-template-columns: 1fr; }
}
.account-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acct-head { display: flex; align-items: center; gap: 8px; }
.acct-name { font-weight: 700; font-size: 16px; }
.default-tag { background: rgba(76,175,80,.16); color: var(--green-dark); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.acct-type { font-size: 12.5px; color: var(--muted); }
.acct-balance { font-size: 22px; font-weight: 800; margin: 4px 0; color: var(--green-dark); }
.acct-balance.acct-neg { color: var(--red); }
.acct-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.acct-foot .btn { padding: 8px 12px; font-size: 12.5px; border-radius: 9px; }
.acct-stats { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.cc-info {
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px;
}
.cc-stat { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; font-weight: 600; }
.cc-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.cc-avail { font-weight: 800; }
.cc-avail.neg { color: var(--red); }
.cc-overdue { color: var(--red); font-weight: 700; }

/* ---------- Credit Cards tab ---------- */
.cc-reminder-list { display: grid; gap: 16px; }
.cc-reminder-card { background: var(--white); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: 0 2px 10px rgba(31,64,55,.05); }
.cc-reminder-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cc-reminder-name { font-size: 17px; font-weight: 800; }
.cc-reminder-bal { font-size: 20px; font-weight: 800; color: var(--red); }
.cc-reminder-sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.cc-bills { margin-top: 12px; display: grid; gap: 8px; }
.cc-bill-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border-radius: 12px; padding: 10px 14px; }
.cc-bill-label { font-size: 12.5px; font-weight: 700; }
.cc-bill-due { font-size: 12px; color: var(--muted); }
.cc-bill-amt { font-size: 17px; font-weight: 800; white-space: nowrap; }
.cc-urgent { color: var(--red-orange); font-weight: 700; }
.cc-reminder { font-size: 13px; font-weight: 700; border-radius: 10px; padding: 9px 12px; }
.cc-reminder.ok { background: rgba(76,175,80,.14); color: var(--green-dark); }
.cc-reminder.warn { background: rgba(224,85,63,.15); color: var(--red-orange); }
.cc-reminder.over { background: rgba(215,78,84,.16); color: var(--red); }

/* ---------- Categories ---------- */
.category-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.chip .icon-btn { width: 26px; height: 26px; font-size: 12px; border-radius: 8px; }

/* ---------- Spending ---------- */
.period-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.period-tab {
  padding: 10px 22px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 12px;
  font-weight: 600;
  color: var(--muted);
  font-size: 14px;
}
.period-tab.active { background: var(--green); color: #fff; border-color: var(--green); }
.custom-dates {
  display: flex; align-items: center; gap: 10px;
  background: var(--white);
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}
.analytics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.category-breakdown { margin-bottom: 20px; }
.bar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.bar-label { width: 130px; font-size: 13.5px; font-weight: 600; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 18px; background: var(--card); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), #79c27d); border-radius: 999px; transition: width .4s ease; min-width: 0; }
.bar-amount { width: 90px; text-align: right; font-size: 13.5px; font-weight: 700; flex-shrink: 0; }

/* ---------- Forms ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(31, 64, 55, 0.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 200;
}
.modal {
  background: var(--white);
  border-radius: 20px;
  width: 100%; max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(31,64,55,.25);
  animation: popin .18s ease;
}
@keyframes popin { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-head h3 { font-size: 18px; color: var(--sidebar); }
.modal-close { border: none; background: var(--card); color: var(--muted); width: 32px; height: 32px; border-radius: 9px; font-size: 16px; }
.modal-close:hover { color: var(--red); }
.modal-top { position: sticky; top: 0; z-index: 2; background: var(--white); border-bottom: 1px solid var(--border); }
.modal-foot-top { padding: 10px 24px 14px; display: flex; justify-content: flex-end; }
.modal-body { padding: 18px 24px 6px; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: 14px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-body label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
.modal-body input, .modal-body select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 16px;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  outline: none;
}
.modal-body input:focus, .modal-body select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(76,175,80,.15); }
.time-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.time-row select { width: auto; text-align: center; }
.time-row select:nth-child(1) { flex: 1.2; }
.time-row select:nth-child(3) { flex: 1.2; }
.time-row select:nth-child(4) { flex: 1; }
.time-sep { color: var(--muted); font-weight: 700; }
.modal-error { color: var(--red); font-size: 13px; margin: 12px 0 0; }
.confirm-text { font-size: 15px; padding: 6px 0 2px; }

.sync-code-row { display: flex; gap: 8px; align-items: center; }
.sync-code-row code {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  font-family: Consolas, monospace;
}
.sync-join-row { display: flex; gap: 8px; }
.sync-join-row input { flex: 1; width: auto; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c4d5cc; border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-radius: 0 0 22px 22px;
    padding: 16px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }
  .sidebar-nav { flex-direction: row; overflow-x: auto; flex: 1; order: 3; width: 100%; padding-bottom: env(safe-area-inset-bottom); }
  .nav-item { white-space: nowrap; padding: 10px 14px; }
  .sidebar-profile { order: 2; }
  .main { padding: 18px 14px; padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
  .category-sections { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .action-buttons .btn { min-width: 100%; }
  .bar-label { width: 90px; }
  .bar-amount { width: 78px; }
  .tx-item { padding: 10px 12px; }
  .tx-badge { font-size: 10px; padding: 4px 9px; }
  .tx-title { font-size: 14px; }
  .tx-amount { font-size: 15px; }
  .tx-actions { width: 100%; justify-content: flex-end; }
  .tx-actions .icon-btn { width: 38px; height: 38px; font-size: 16px; }
  .modal-content { width: 96%; }
  .modal-body input, .modal-body select { font-size: 16px; }
}

/* ---------- History ---------- */
.history-day { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.history-day-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.history-date { font-weight: 700; color: var(--green-dark); font-size: 15px; }
.history-total { font-weight: 800; color: var(--red); font-size: 16px; white-space: nowrap; }
.history-entry { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13.5px; white-space: nowrap; }
.history-cat { font-weight: 600; flex: 0 0 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.history-desc { color: #2f6fd0; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.history-amt { font-weight: 600; color: var(--red); white-space: nowrap; flex: 0 0 auto; }

/* ---------- Shared new helpers ---------- */
.muted { color: var(--muted); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.row-2 { display: flex; gap: 8px; }
.row-2 input { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.checkbox-row input { width: auto; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 2px; }
.toggle-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--grey); border-radius: 24px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.shadow-tag { background: rgba(138,154,146,.18); color: #55665e; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 7px; border-radius: 8px; }

/* ---------- Status badges ---------- */
.st-active { background: rgba(76,175,80,.16); color: var(--green-dark); }
.st-paused { background: rgba(138,154,146,.18); color: #55665e; }
.st-track { background: rgba(76,175,80,.16); color: var(--green-dark); }
.st-risk { background: rgba(240,165,0,.2); color: #8a6200; }
.st-over { background: rgba(215,78,84,.16); color: var(--red); }
.bar-fill.st-over { background: linear-gradient(90deg, var(--red), #f08a8e); }
.bar-fill.st-risk { background: linear-gradient(90deg, #f0a500, #f2c063); }
.bar-fill.st-paused { background: var(--grey); }

/* ---------- Spending nature (Must / Need / Want) ---------- */
.nature-must { color: var(--green-dark); }
.nature-need { color: #b58900; }
.nature-want { color: var(--red); }
.nature-select option.nature-must { color: var(--green-dark); font-weight: 700; }
.nature-select option.nature-need { color: #b58900; font-weight: 700; }
.nature-select option.nature-want { color: var(--red); font-weight: 700; }
.nature-tag {
  display: inline-block; font-size: 11px; font-weight: 800;
  padding: 2px 9px; border-radius: 999px;
  letter-spacing: .04em; text-transform: uppercase;
}
.nature-tag.nature-must { color: var(--green-dark); background: rgba(76,175,80,.14); }
.nature-tag.nature-need { color: #8a6200; background: rgba(240,165,0,.2); }
.nature-tag.nature-want { color: var(--red); background: rgba(215,78,84,.14); }
.tx-nature { margin-top: 2px; }
.nature-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.nature-row:last-child { border-bottom: none; }
.nature-row .bar-row { grid-column: 1 / -1; margin: 2px 0 0; }
.nature-row .muted { justify-self: end; }
.chart-solo { height: 340px; display: flex; flex-direction: column; margin-bottom: 20px; }
.chart-solo canvas { flex: 1; min-height: 0; width: 100% !important; }
.chart-solo h3 { font-size: 15px; color: var(--sidebar); margin-bottom: 10px; }

/* ---------- Recurring ---------- */
.recurring-due {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; background: #fff7e6; border: 1px solid #f0c36d;
  color: #7a5c00; font-weight: 600; flex-wrap: wrap;
}
.recurring-list { display: flex; flex-direction: column; gap: 12px; }
.recurring-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 8px;
}
.recurring-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.recurring-name { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.recurring-status {
  font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  letter-spacing: .03em; text-transform: uppercase;
}
.recurring-amount { font-size: 22px; font-weight: 800; }
.recurring-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.recurring-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Budgets ---------- */
.budget-overview { margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.budget-overview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.budget-overview-nums { display: flex; align-items: baseline; gap: 10px; }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 20px; }
.budget-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 10px;
}
.budget-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.budget-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.budget-sub { font-size: 12.5px; color: var(--muted); }
.budget-nums { display: flex; align-items: baseline; gap: 8px; font-weight: 700; }
.budget-nums .muted { font-weight: 600; }
.budget-foot { display: flex; gap: 8px; }
.budget-analytics { margin-bottom: 0; }
.budget-note { margin-top: 8px; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 10px; }
.budget-note.warn { background: rgba(240,165,0,.14); color: #8a6200; }
.budget-note.over { background: rgba(215,78,84,.12); color: var(--red); }
.template-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
.template-btn {
  padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); font-weight: 700; color: var(--text); text-align: left;
}
.template-btn:hover { border-color: var(--green); }

/* ---------- Advanced: tabs & analytics ---------- */
.sub-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.sub-tab {
  padding: 10px 20px; border: 1px solid var(--border); background: var(--white);
  border-radius: 12px; font-weight: 600; color: var(--muted); font-size: 14px;
}
.sub-tab.active { background: var(--green); color: #fff; border-color: var(--green); }
.analytics-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-card { height: 320px; display: flex; flex-direction: column; }
.chart-card h3 { font-size: 15px; color: var(--sidebar); margin-bottom: 10px; }
.chart-card canvas { flex: 1; min-height: 0; width: 100% !important; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
.data-table th {
  text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border);
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.weekday-bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.weekday-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar-track.v { width: 100%; max-width: 46px; height: 100%; display: flex; align-items: flex-end; }
.bar-track.v .bar-fill { width: 100%; min-height: 2px; }
.weekday-val { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.weekday-lbl { font-size: 12px; font-weight: 600; white-space: nowrap; }
.insight-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; flex-wrap: wrap; }
.anomaly-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; flex-wrap: wrap; }
.rec-list { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.forecast-body { display: flex; flex-direction: column; gap: 6px; }
.forecast-num { font-size: 30px; font-weight: 800; color: var(--green-dark); }
.forecast-conf { font-weight: 700; }

/* ---------- Goals ---------- */
.sub-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sub-section-head h3 { font-size: 20px; color: var(--sidebar); }
.goal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.goal-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 10px;
  border-top: 4px solid var(--goal, var(--green));
}
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.goal-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.goal-deadline { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.goal-nums { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.goal-pace { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; }
.goal-foot { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Reports ---------- */
.report-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.report-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-row label { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 80px; }
.report-row input, .report-row select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: var(--white); color: var(--text);
}
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-preview h3 { font-size: 20px; color: var(--sidebar); }
.report-section { margin-top: 18px; }
.report-section h4 { font-size: 15px; color: var(--sidebar); margin-bottom: 6px; }

/* ---------- Toast ---------- */
.toast-box {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--sidebar); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(31,64,55,.3);
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- Responsive additions ---------- */
@media (max-width: 900px) {
  .analytics-kpis { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .analytics-kpis { grid-template-columns: 1fr; }
  .report-row label { min-width: 100%; }
}
