﻿*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f1f5f9;
  --surface: #fff;
  --border: #e2e8f0;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --accent: #0d6b6b;
  --accent-bg: #e6f5f5;
  --good: #16a34a;
  --warn: #b45309;
  --danger: #dc2626;
  --nav-h: 64px;
  --hdr-h: 54px;
  --r: 12px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  height: 100dvh;
  overflow: hidden;
}

/* ── App shell ─────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg);
}

.app-header {
  height: var(--hdr-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}
.app-header h1 { font-size: 1.05rem; font-weight: 700; }
.header-sub { font-size: 0.8rem; color: var(--ink-soft); font-weight: 500; }

.pages { flex: 1; overflow: hidden; position: relative; }

.page {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 14px;
  padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.page.active { display: block; }

/* ── Bottom nav ────────────────────────────────────────── */
.bottom-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  z-index: 10;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
  transition: color 0.15s;
  padding: 0;
}
.nav-btn svg { width: 22px; height: 22px; fill: currentColor; }
.nav-btn span { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.02em; }
.nav-btn.active { color: var(--accent); }

/* ── KPI strip ─────────────────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  padding: 14px 8px;
  text-align: center;
}
.kpi-lbl { display: block; font-size: 0.68rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.kpi-val { display: block; font-size: 0.98rem; font-weight: 700; }
.kpi-val.good { color: var(--good); }
.kpi-val.danger { color: var(--danger); }
.kpi-val.warn { color: var(--warn); }

/* ── Section header ────────────────────────────────────── */
.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sec-hdr h2 { font-size: 0.74rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.07em; }
.link-btn { background: none; border: none; color: var(--accent); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }

/* ── Transaction list ──────────────────────────────────── */
.txn-list { display: flex; flex-direction: column; gap: 8px; }
.txn-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.txn-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.txn-info { flex: 1; min-width: 0; }
.txn-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-meta { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }
.txn-amt { font-size: 0.9rem; font-weight: 700; color: var(--danger); flex-shrink: 0; }
.empty-state { text-align: center; padding: 28px 14px; color: var(--ink-soft); font-size: 0.86rem; line-height: 1.6; }

/* ── SMS paste ─────────────────────────────────────────── */
.sms-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 11px 16px;
  font: inherit; font-size: 0.88rem; font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.15s;
}
.sms-btn:hover { opacity: 0.85; }
.sms-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 14px;
}
.sms-panel textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 0.84rem;
  resize: none; background: var(--bg); color: var(--ink);
  min-height: 64px;
}

/* ── Forms ─────────────────────────────────────────────── */
.exp-form { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.field input, .field select {
  height: 46px; padding: 0 12px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 0.92rem; color: var(--ink); background: var(--surface);
  width: 100%; transition: border-color 0.15s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; font: inherit; font-weight: 700;
  cursor: pointer; text-align: center;
  padding: 13px 18px; font-size: 0.9rem;
  background: var(--accent); color: #fff; border: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.87; }
.btn.primary { background: var(--accent); color: #fff; border: none; }
.btn.outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--border); }
.btn.danger-btn { background: var(--danger); color: #fff; border: none; }
.btn.full { width: 100%; }
.btn.sm { padding: 8px 13px; font-size: 0.82rem; border-radius: 8px; }
.btn.xs { padding: 6px 11px; font-size: 0.78rem; border-radius: 7px; }

/* ── Insights page ─────────────────────────────────────── */
.pills { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; margin-bottom: 10px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  background: var(--surface); border: 1.5px solid var(--border); color: var(--ink-soft);
  border-radius: 20px; padding: 6px 13px;
  font: inherit; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.custom-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 0.82rem; }
.custom-row input {
  flex: 1; min-width: 0; height: 36px;
  border: 1.5px solid var(--border); border-radius: 8px; padding: 0 9px;
  font: inherit; font-size: 0.82rem; color: var(--ink); background: var(--surface);
}

.filter-row { display: flex; gap: 8px; margin-bottom: 12px; }
.fsel {
  flex: 1; min-width: 0; height: 38px; padding: 0 10px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 0.82rem; color: var(--ink); background: var(--surface); cursor: pointer;
}

.ins-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.ik { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 7px; text-align: center; }
.ik-val { font-size: 0.9rem; font-weight: 700; word-break: break-all; }
.ik-lbl { font-size: 0.66rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px; }

/* ── Tabs ──────────────────────────────────────────────── */
.tab-bar { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.tab {
  flex: 1; background: none; border: none; border-radius: 8px;
  padding: 8px 4px; font: inherit; font-size: 0.8rem; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Category bars ─────────────────────────────────────── */
.cat-bars { display: flex; flex-direction: column; gap: 8px; }
.cat-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
.cat-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.cat-name { font-size: 0.86rem; font-weight: 600; }
.cat-pct { font-size: 0.78rem; color: var(--ink-soft); }
.cat-track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s; }
.cat-amt { font-size: 0.76rem; color: var(--ink-soft); margin-top: 5px; }

/* ── Trend chart ───────────────────────────────────────── */
.trend-chart {
  display: flex; align-items: flex-end; gap: 5px;
  height: 140px; padding-bottom: 24px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.trend-chart::-webkit-scrollbar { display: none; }
.t-bar-wrap { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 30px; }
.t-bar { width: 22px; min-height: 4px; background: var(--accent); border-radius: 4px 4px 0 0; }
.t-bar.today-bar { background: var(--danger); }
.t-lbl { font-size: 0.58rem; color: var(--ink-soft); margin-top: 4px; white-space: nowrap; }

/* ── Budget ────────────────────────────────────────────── */
.budget-add { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.budget-inp {
  flex: 1; min-width: 0; height: 38px;
  border: 1.5px solid var(--border); border-radius: 8px; padding: 0 10px;
  font: inherit; font-size: 0.82rem; color: var(--ink); background: var(--surface);
}
.budget-list { display: flex; flex-direction: column; gap: 8px; }
.b-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
.b-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.b-name { font-size: 0.86rem; font-weight: 600; }
.b-badge { font-size: 0.74rem; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.b-badge.ok { background: #dcfce7; color: var(--good); }
.b-badge.warn { background: #fef9c3; color: var(--warn); }
.b-badge.over { background: #fee2e2; color: var(--danger); }
.b-track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-bottom: 5px; }
.b-fill { height: 100%; border-radius: 3px; }
.b-amts { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--ink-soft); }

/* ── Loans ─────────────────────────────────────────────── */
.page-hint { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 12px; line-height: 1.5; }
.loan-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.loan-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.loan-hdr { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.loan-name { font-size: 0.93rem; font-weight: 700; }
.loan-bank { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }
.loan-actions { display: flex; gap: 6px; flex-shrink: 0; }
.loan-edit, .loan-del {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font: inherit; font-size: 0.74rem; cursor: pointer; color: var(--ink-soft);
}
.loan-del { color: var(--danger); border-color: #fee2e2; }
.loan-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.loan-stat { text-align: center; }
.loan-sval { font-size: 0.86rem; font-weight: 700; }
.loan-slbl { font-size: 0.66rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.loan-prog { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.loan-prog-fill { height: 100%; background: var(--warn); border-radius: 3px; }
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; margin-top: 12px; }
.form-card h3 { font-size: 0.93rem; font-weight: 700; margin-bottom: 14px; }

/* ── More / cards ──────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 0.93rem; font-weight: 700; margin-bottom: 12px; }
.card-sub { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 10px; line-height: 1.5; }

.checklist { display: flex; flex-direction: column; gap: 7px; }
.cl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; transition: background 0.15s;
}
.cl-item.done { background: #dcfce7; border-color: #bbf7d0; }
.cl-item input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--good); cursor: pointer; flex-shrink: 0; }
.cl-item span { font-size: 0.86rem; font-weight: 500; }

.trip-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.income-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.income-card-header h3 { margin: 0; }
.income-badge { background: var(--accent); color: #fff; font-size: 0.82rem; font-weight: 700; padding: 3px 12px; border-radius: 20px; }
.income-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.income-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border); }
.inc-icon { font-size: 1.3rem; flex-shrink: 0; }
.inc-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inc-src { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.inc-desc { font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inc-date { font-size: 0.74rem; color: var(--ink-soft); }
.inc-amt { font-size: 0.95rem; font-weight: 700; color: var(--good); flex-shrink: 0; }
.income-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.inc-row { display: flex; gap: 8px; align-items: center; }
.inc-field { flex: 1; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r); font-size: 0.9rem; color: var(--ink); background: var(--surface); box-sizing: border-box; appearance: none; -webkit-appearance: none; }
.trip-num { font-size: 2.2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.trip-lbl { font-size: 0.86rem; color: var(--ink-soft); }
.trip-spend { font-size: 0.8rem; color: var(--warn); font-weight: 600; background: #fef9c3; padding: 3px 10px; border-radius: 20px; }
.trip-btns { display: flex; gap: 7px; margin-left: auto; }

.import-setup { display: flex; flex-direction: column; gap: 8px; }
.upload-lbl { cursor: pointer; display: block; }
.upload-lbl input { display: none; }
.preview-hdr { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); margin-top: 10px; flex-wrap: wrap; gap: 8px; }
.preview-hdr > div { display: flex; gap: 7px; }
.preview-count { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
.tbl-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th { background: var(--bg); padding: 9px 10px; text-align: left; font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.bs-cat-sel { height: 32px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 0.76rem; color: var(--ink); background: var(--surface); max-width: 120px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 10px);
  left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 9px 18px; border-radius: 20px;
  font-size: 0.82rem; font-weight: 500; z-index: 200;
  max-width: 300px; text-align: center; pointer-events: none;
  opacity: 0; transition: opacity 0.2s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; }

/* ── Desktop shadow ────────────────────────────────────── */
@media (min-width: 501px) {
  .app { box-shadow: 0 0 0 1px var(--border), 0 12px 40px rgba(0,0,0,.1); }
}
