/* ============================================================
   PotPilot — mobile-first savings PWA stylesheet
   Sibling to MyShift Pro, distinct teal accent.
   Plain CSS, no preprocessor. Tokens as CSS variables so a
   dark theme can be layered later. No emoji anywhere.
   ============================================================ */

:root {
  /* ---- Ground / surfaces (shared with MyShift Pro) ---- */
  --bg:            #F7F8FB;   /* soft off-white ground */
  --card:          #FFFFFF;   /* pure-white cards */
  --card-sunk:     #F2F4F9;   /* recessed surface */
  --border:        #e6e8ef;   /* shared hairline border */
  --border-strong: #d6dae6;

  /* ---- Ink ---- */
  --ink:    #0B1220;
  --muted:  #6b7280;
  --faint:  #9aa1ad;

  /* ---- OUR ACCENT: teal (MyShift uses indigo) ---- */
  --accent:       #0FB4A6;
  --accent-deep:  #0a8c81;
  --accent-tint:  #e6f7f5;
  --accent-ink:   #06655d;

  /* ---- Semantic ---- */
  --money-in: #16A34A;        /* emerald money-in (shared) */
  --pos:      #16A34A;
  --neg:      #E7625F;        /* shortfall coral */
  --coral:    #E7625F;
  --amber:    #E0A63A;
  --danger:   #E7625F;
  --danger-deep: #c94b48;

  /* ---- Shape ---- */
  --radius:    0.9rem;        /* shared card radius */
  --radius-sm: 0.6rem;
  --radius-lg: 1.25rem;
  --radius-pill: 999px;

  /* ---- Soft shadows ---- */
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.04), 0 1px 3px rgba(11, 18, 32, 0.03);
  --shadow:    0 1px 2px rgba(11, 18, 32, 0.04), 0 8px 20px rgba(11, 18, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(11, 18, 32, 0.07), 0 18px 40px rgba(11, 18, 32, 0.10);
  --shadow-accent: 0 6px 18px rgba(15, 180, 166, 0.28);

  /* ---- Metrics ---- */
  --app-max:       460px;
  --header-height: 56px;
  --nav-height:    62px;
  --gap:           14px;

  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
}

/* ---------------- Reset / base ---------------- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

html, body {
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent-deep); text-decoration: none; }

/* Any figure that represents money uses tabular figures for clean columns. */
.hero-value, .ha-strip-value, .pot-card-balance, .lr-amount, .goal-donut-bal,
.pnl-net, .pot-pick-bal, .vp-bal, .pp-bal, .goal-target, .t-pos, .t-neg,
#total-balance, #avg-monthly, #saving-value, #month-spend, #subs-monthly,
#goals-saving, .split-pct {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------------- boxicons graceful fallback ----------------
   app.js emits <i class='bx …'> glyphs. Per the design system we
   favour clean line icons; there is no icon CDN in this build, so
   we neutralise the boxicon font gracefully: give each icon a fixed
   box so layout never collapses, and let currentColor drive it.
   Where a glyph is missing it simply renders as empty reserved space
   rather than a broken tofu box. */
.bx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  line-height: 1;
  font-style: normal;
  color: currentColor;
  vertical-align: -0.15em;
  flex: none;
}
.bx-spin { animation: pp-spin 0.9s linear infinite; }
@keyframes pp-spin { to { transform: rotate(360deg); } }

/* ---------------- Utilities ---------------- */
.muted  { color: var(--muted); }
.small  { font-size: 12.5px; }
.center { text-align: center; }
.pad    { padding: 22px 14px; }
.t-pos  { color: var(--pos);  font-weight: 600; }
.t-neg  { color: var(--neg);  font-weight: 600; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--accent-tint) 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 30px 26px 26px;
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-deep) 100%);
  display: grid; place-items: center;
  box-shadow: var(--shadow-accent);
}
.login-logo img { width: 38px; height: 38px; filter: brightness(0) invert(1); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card > .muted { margin-bottom: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.login-submit { margin-top: 4px; width: 100%; justify-content: center; }
.login-error {
  margin-top: 4px;
  background: #fdecec;
  color: var(--danger-deep);
  border: 1px solid #f6cfce;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app-shell {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ---------------- Header ---------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 248, 251, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-left { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.header-left h1 { font-size: 19px; letter-spacing: -0.02em; }
.header-right { display: flex; align-items: center; gap: 10px; flex: none; }

/* Inline nav inside the header — hidden on narrow (bottom-nav rules); shown wide */
.app-header-nav { display: none; gap: 2px; }

.nav-icon { font-size: 20px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 20px;
  position: relative;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--card-sunk); color: var(--ink); }

/* Connection indicator */
.conn-text {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em;
  color: var(--accent-deep);
  background: var(--accent-tint);
  padding: 3px 7px; border-radius: var(--radius-pill);
}
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex: none; display: inline-block;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
}
.conn-dot-on  { background: var(--pos);  box-shadow: 0 0 0 3px rgba(22,163,74,0.15); }
.conn-dot-off { background: var(--faint); }

/* ---------------- Main / pages ---------------- */
#page-content {
  padding: 16px 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
}
#page-content > section { display: flex; flex-direction: column; gap: var(--gap); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

/* Connect Monzo call-to-action */
.connect-card {
  text-align: center;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.connect-card-icon {
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: 28px;
}
.connect-card h2 { font-size: 19px; margin-bottom: 6px; }
.connect-card .btn { margin: 16px auto 12px; }
.connect-card .small { margin-top: 4px; }

/* ============================================================
   HERO CARDS (prominent headline figures)
   ============================================================ */
.hero-card {
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: var(--shadow-accent);
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -40px; top: -60px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
}
.hero-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.82);
}
.hero-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
  line-height: 1.05;
}
.hero-sub { font-size: 13px; color: rgba(255,255,255,0.80); line-height: 1.4; }

/* Goals hero — warm teal */
.hero-goals { background: linear-gradient(145deg, #12b0a4 0%, #0a8c81 100%); }
/* Subs hero — deeper "money going out" register */
.hero-subs  { background: linear-gradient(145deg, #0f9f95 0%, #086b62 100%); }

/* ============================================================
   HA-STRIP (compact icon + figure rows)
   ============================================================ */
.ha-strip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 13px;
}
.ha-strip-icon {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: 21px;
}
.ha-strip-body { min-width: 0; flex: 1; }
.ha-strip-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.ha-strip-value { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin-top: 1px; }
.ha-strip-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.ha-strip-when {
  flex: none;
  text-align: right;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  max-width: 42%;
}

/* ============================================================
   SECTION TITLES
   ============================================================ */
.section-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 6px 2px 0;
}
.section-title.nm { margin: 0; }

/* ============================================================
   POTS GRID (dashboard)
   ============================================================ */
.pots-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.pot-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .12s, box-shadow .12s;
}
.pot-card:active { transform: scale(0.985); }
.pot-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pot-card-balance {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.pot-card-progress { display: flex; flex-direction: column; gap: 5px; }
.pot-card-bar {
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--card-sunk);
  overflow: hidden;
}
.pot-card-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-deep) 100%);
  transition: width .4s ease;
  min-width: 3px;
}
.pot-card-bar-fill.is-done {
  background: linear-gradient(90deg, var(--pos) 0%, #0f8a3e 100%);
}
.pot-card-bar-meta {
  font-size: 11.5px;
  color: var(--muted);
  display: flex; justify-content: space-between; gap: 6px;
  font-variant-numeric: tabular-nums;
}
/* top-up / needs-attention pulse (min not met) */
.pot-card.pulse {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(224,166,58,0.16), var(--shadow-sm);
  animation: pp-pulse 1.8s ease-in-out infinite;
}
@keyframes pp-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(224,166,58,0.16), var(--shadow-sm); }
  50%      { box-shadow: 0 0 0 6px rgba(224,166,58,0.06), var(--shadow-sm); }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  transition: transform .1s, box-shadow .15s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; pointer-events: none; }
.btn .bx { font-size: 1.15em; }

.btn-primary {
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(15,180,166,0.36); }

.btn-secondary {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--card-sunk); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(231,98,95,0.30);
}
.btn-danger:hover { background: var(--danger-deep); }

.btn-sm   { padding: 8px 13px; font-size: 13.5px; }
.btn-mini { padding: 6px 11px; font-size: 12.5px; }

.export-row { margin-top: 4px; }
.export-row .btn { width: 100%; }

/* ============================================================
   CARDS-LIST + LIST ROWS (income sources, activity)
   ============================================================ */
.cards-list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lr-left { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lr-name {
  font-size: 14.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lr-meta { font-size: 12px; color: var(--muted); }
.lr-right { flex: none; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.lr-amount { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.list-row.income .lr-amount { color: var(--money-in); }
.list-row.income { border-left: 3px solid var(--money-in); }
.list-row.spend  .lr-amount { color: var(--ink); }

/* ============================================================
   PILLS (cadence tags)
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--card-sunk);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill-monthly  { background: var(--accent-tint); color: var(--accent-ink); border-color: transparent; }
.pill-biweekly { background: #eef2ff;            color: #4f46e5;           border-color: transparent; }
.pill-weekly   { background: #ecfdf5;            color: #047857;           border-color: transparent; }
.pill-4weekly  { background: #fff7ed;            color: #b45309;           border-color: transparent; }
.pill-irregular{ background: #f3f4f6;            color: #6b7280;           border-color: transparent; }

/* ============================================================
   GOALS + SUBS SHARED (donut cards)
   ============================================================ */
.goals-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}
.goals-sections { display: flex; flex-direction: column; gap: 16px; }
.goals-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.goal-section-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}
.goal-section-title .bx { color: var(--accent-deep); font-size: 16px; }

.goal-card {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.goal-card:hover  { box-shadow: var(--shadow); }
.goal-card:active { transform: scale(0.99); }
.goal-card-recur { border-left: 3px solid var(--accent); }
.sub-card        { border-left: 3px solid var(--coral); }
.sub-card-off    { opacity: 0.6; border-left-color: var(--faint); }

/* ---- Donut ----
   app.js sets  style="--pct:NN; --ring:<conic gradient>"
   We paint the passed-in ring gradient as the background and mask
   out the centre with the hole to leave a clean progress ring. */
.goal-donut {
  --pct: 0;
  --ring: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--card-sunk) 0);
  position: relative;
  width: 74px; height: 74px; flex: none;
  border-radius: 50%;
  background: var(--ring);
}
.goal-donut-hole {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--card);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: inset 0 0 0 1px rgba(11,18,32,0.03);
}
.goal-donut-bal { font-size: 13px; font-weight: 800; letter-spacing: -0.02em; }
.goal-donut-pct { font-size: 10.5px; font-weight: 600; color: var(--muted); }

.goal-card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.goal-name {
  font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.goal-target { font-size: 12.5px; color: var(--muted); }
.goal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.goal-sep { font-size: 12px; color: var(--muted); font-weight: 600; }
.goal-sep + .goal-sep::before {
  content: "·"; margin-right: 6px; color: var(--faint); font-weight: 700;
}
.goal-last { font-size: 12px; color: var(--money-in); font-weight: 600; margin-top: 3px; }

/* ---- Goal status pills ---- */
.goal-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.01em;
  padding: 3px 9px; border-radius: var(--radius-pill);
}
.goal-pill-good  { background: #e7f7ed; color: #0f8a3e; }
.goal-pill-ok    { background: var(--accent-tint); color: var(--accent-ink); }
.goal-pill-bad   { background: #fdecec; color: var(--danger-deep); }
.goal-pill-recur { background: #eef2ff; color: #4f46e5; }
.goal-pill-recur .bx { font-size: 13px; }

/* Sub-card donut centre */
.sub-donut-date { font-size: 10.5px; font-weight: 700; color: var(--ink); text-align: center; line-height: 1.15; }
.sub-donut-tick { color: var(--pos); font-size: 26px; }
.sub-day { color: var(--faint); }

/* ============================================================
   GOAL / SUB FORM (inside modal)
   ============================================================ */
.goal-form { display: flex; flex-direction: column; gap: 14px; }
.field-label {
  display: block;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  margin-bottom: 6px;
}
.goal-form input[type="text"],
.goal-form input[type="number"],
.goal-form input[type="date"],
.goal-form select,
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.goal-form input:focus,
.modal-body input:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.input-prefix { position: relative; display: flex; align-items: center; }
.input-prefix::before {
  content: "£";
  position: absolute; left: 13px;
  font-weight: 700; color: var(--muted);
  pointer-events: none;
}
.input-prefix input { padding-left: 26px !important; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }

.goal-feasibility {
  display: flex;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
  color: var(--muted);
}
.goal-feasibility .bx { flex: none; font-size: 17px; margin-top: 1px; }
.goal-feasibility.ok  { background: #e7f7ed; color: #0f6b32; }
.goal-feasibility.ok .bx  { color: var(--pos); }
.goal-feasibility.bad { background: #fdecec; color: var(--danger-deep); }
.goal-feasibility.bad .bx { color: var(--danger); }

.goal-recur-opts {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
  border: 1px solid var(--border);
}

/* ============================================================
   SUBS extras
   ============================================================ */
.subs-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fff8ec;
  border: 1px solid #f4e2bf;
  color: #8a6a1f;
  font-size: 12.5px;
  line-height: 1.45;
}
.subs-banner .bx { flex: none; font-size: 18px; color: var(--amber); margin-top: 1px; }

/* ============================================================
   P&L MINI CHART
   ============================================================ */
.pnl-strip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 14px 12px;
}
.pnl-legend {
  display: flex; gap: 16px; justify-content: center;
  font-size: 12px; color: var(--muted); font-weight: 600;
  margin-bottom: 14px;
}
.pnl-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.pnl-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.pnl-dot.pnl-in  { background: var(--money-in); }
.pnl-dot.pnl-out { background: var(--coral); }
.pnl-dot.pnl-net { background: var(--accent); }

.pnl-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 132px;
  max-width: 100%;
}
.pnl-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
  justify-content: flex-end;
}
.pnl-stack {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}
.pnl-bar {
  width: 42%;
  max-width: 16px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height .4s ease;
}
.pnl-bar.pnl-in  { background: linear-gradient(180deg, #22c063, var(--money-in)); }
.pnl-bar.pnl-out { background: linear-gradient(180deg, #ef7f7c, var(--coral)); }
.pnl-label { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.pnl-net {
  font-size: 11px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink);
}
.pnl-net.t-pos { color: var(--pos); }
.pnl-net.t-neg { color: var(--neg); }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  margin: 16px 2px 8px;
}
.settings-section-title .bx { color: var(--accent-deep); font-size: 16px; }
.settings-section-title.is-danger,
.settings-section-title.is-danger .bx { color: var(--danger); }

.settings-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.settings-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.settings-item:first-child { border-top: none; }
.settings-item:hover { background: var(--card-sunk); }
.settings-item-left {
  display: flex; align-items: center; gap: 12px;
  min-width: 0; flex: 1;
  font-size: 14.5px; font-weight: 600;
}
.settings-item-left > div { min-width: 0; }
.settings-item-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: 18px;
}
.settings-item-sub {
  font-size: 12px; font-weight: 400; color: var(--muted);
  margin-top: 2px; line-height: 1.35;
}
.settings-item-arrow { flex: none; color: var(--faint); font-size: 20px; display: grid; place-items: center; }
.settings-item.is-danger .settings-item-left { color: var(--danger); }
.settings-item.is-danger .settings-item-icon { background: #fdecec; color: var(--danger); }

.settings-foot {
  font-size: 11.5px; color: var(--faint);
  padding: 8px 4px 0;
  line-height: 1.4;
}
.settings-sub-title {
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 14px 0 8px;
}

/* Toggle switch */
.settings-toggle-row { cursor: pointer; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  flex: none;
  width: 46px; height: 27px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  position: relative;
  transition: background .18s;
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(11,18,32,0.25);
  transition: transform .18s;
}
.toggle-input:checked + .toggle-track { background: var(--accent); }
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(19px); }
.toggle-input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px var(--accent-tint); }

/* ============================================================
   MODAL (bottom sheet)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 18, 32, 0.44);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: pp-fade .18s ease;
}
@keyframes pp-fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: var(--app-max);
  max-height: 88vh;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pp-sheet .24s cubic-bezier(.2,.8,.2,1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes pp-sheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.modal-header::before {
  content: "";
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border-strong);
}
.modal-header h3 { font-size: 17px; }
.modal-body {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ============================================================
   POT PICKER (in modal)
   ============================================================ */
.pot-pick-list { display: flex; flex-direction: column; gap: 8px; }
.pot-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.pot-pick-row:hover { background: var(--card-sunk); }
.pot-pick-row.is-selected {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.pot-pick-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pot-pick-right { display: flex; align-items: center; gap: 10px; flex: none; }
.pot-pick-bal { font-weight: 700; font-size: 14px; }
.pot-pick-tick {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff; background: var(--accent);
  font-size: 15px; opacity: 0;
  transition: opacity .12s;
}
.pot-pick-row.is-selected .pot-pick-tick { opacity: 1; }

/* ============================================================
   VISIBLE POTS PICKER
   ============================================================ */
.vp-list-wrap, .visible-pots-picker { display: flex; flex-direction: column; gap: 8px; }
.vp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  flex-wrap: wrap;
}
.vp-check { flex: none; width: 20px; height: 20px; accent-color: var(--accent); }
.vp-name, .pp-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.vp-bal, .pp-bal { font-weight: 700; font-size: 13.5px; color: var(--muted); }
.vp-min { font-size: 12px; color: var(--muted); }
.vp-row-actions { display: flex; gap: 6px; }
.vp-move, .pp-move {
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.vp-move:hover, .pp-move:hover { background: var(--accent-tint); color: var(--accent-deep); }
.vp-row input[type="number"], .vp-min input {
  width: 88px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
}

/* ============================================================
   SOURCE ROWS (income sources / splits)
   ============================================================ */
.src-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.src-row.src-row-pick { cursor: pointer; }
.src-row.is-income { border-left: 3px solid var(--money-in); }
.src-row-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.src-row-name { font-weight: 600; font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.src-row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.src-row-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Splits editor ---- */
.splits-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.splits-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.splits-list { display: flex; flex-direction: column; gap: 8px; }
.split-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.split-pot { flex: 1; min-width: 0; }
.split-pct { flex: none; font-weight: 700; }
.split-pct-input {
  width: 70px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-sunk);
  text-align: right;
}
.split-del {
  flex: none;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: #fdecec;
}
.split-del:hover { background: #f9d9d8; }
.splits-summary {
  margin-top: 10px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  text-align: right;
}

/* ============================================================
   VC ROWS (merchant / value chooser)
   ============================================================ */
.vc-list { display: flex; flex-direction: column; gap: 8px; }
.vc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
}
.vc-row:hover { background: var(--card-sunk); }
.vc-row-main { min-width: 0; flex: 1; }
.vc-row-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vc-row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.vc-row-select { flex: none; accent-color: var(--accent); width: 20px; height: 20px; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.ha-notif-btn { position: relative; }
.ha-notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--coral);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
  font-variant-numeric: tabular-nums;
}
@keyframes pp-ping {
  0%   { box-shadow: 0 0 0 0 rgba(231,98,95,0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(231,98,95,0); }
  100% { box-shadow: 0 0 0 0 rgba(231,98,95,0); }
}
.ha-notif-ping .ha-notif-badge { animation: pp-ping 1.1s ease-out 2; }

.notif-dropdown {
  position: absolute;
  top: calc(var(--header-height) + env(safe-area-inset-top));
  right: 12px;
  width: min(340px, calc(100vw - 24px));
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 90;
  animation: pp-fade .16s ease;
}
.ha-notif-list { display: flex; flex-direction: column; }
.ha-notif-row {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.ha-notif-row:first-child { border-top: none; }
.ha-notif-row.is-unread { background: var(--accent-tint); }
.ha-notif-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--card-sunk);
  color: var(--muted);
  font-size: 18px;
}
.ha-notif-icon.is-success { background: #e7f7ed; color: var(--pos); }
.ha-notif-icon.is-error   { background: #fdecec; color: var(--danger); }
.ha-notif-body { min-width: 0; flex: 1; font-size: 13px; line-height: 1.4; }
.ha-notif-body .small, .ha-notif-body time { color: var(--muted); font-size: 11.5px; }
.ha-notif-empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  z-index: 50;
  background: rgba(255,255,255,0.94);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 6px env(safe-area-inset-bottom);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  transition: color .15s, background .15s;
}
.nav-btn .nav-icon { font-size: 22px; }
.nav-btn.active { color: var(--accent-deep); }
.nav-btn.active .nav-icon { color: var(--accent); }
.nav-btn:active { background: var(--accent-tint); }

/* Toasts container (kept hidden per markup; harmless if shown) */
.toasts {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-height) + 12px);
  z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  width: min(var(--app-max), calc(100vw - 24px));
}

/* ============================================================
   WIDER SCREENS — inline header nav, hide bottom bar
   ============================================================ */
@media (min-width: 720px) {
  .app-header-nav { display: flex; }
  .app-header-nav .nav-btn {
    flex: none;
    flex-direction: row;
    gap: 6px;
    padding: 7px 12px;
    font-size: 13px;
  }
  .app-header-nav .nav-btn .nav-icon { font-size: 18px; }
}

/* ============================================================
   Redesign fixes — classes the new markup needs (added post-audit).
   Reconciles the summary SVG donut chart cards + tabular nums + icons.
   ============================================================ */

/* Tabular figures — money lines that rely only on .tnum */
.tnum { font-variant-numeric: tabular-nums; }

/* Inline SVG line icons (replace boxicons/emoji). currentColor-driven. */
.ic {
  width: 1.15em; height: 1.15em;
  display: inline-block; vertical-align: -0.18em;
  flex: 0 0 auto;
  stroke: currentColor; fill: none;
}
.ic use { pointer-events: none; }
.ic-spin { animation: ic-spin 0.8s linear infinite; }
@keyframes ic-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ic-spin { animation: none; } }

/* Summary chart cards on Goals + Subscriptions (the pie/donut cards). */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: var(--gap);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chart-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink);
}
.chart-card-head .muted { font-weight: 600; }

.donut-wrap {
  position: relative;
  width: 140px; height: 140px;
  margin: 2px auto 0;
}
.donut { display: block; width: 140px; height: 140px; }
.donut-track { stroke: var(--card-sunk); }
.donut-arc   { stroke: var(--accent); transition: stroke-dasharray 0.5s ease; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.donut-center-value { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.donut-center-label { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }

/* Legend under the donut — one row per slice */
.chart-legend { display: flex; flex-direction: column; gap: 8px; }
.chart-legend-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--ink);
}
.chart-legend-row .lg-sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend-row .lg-nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.chart-legend-row .lg-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Dashboard "Average monthly income" hero variant — teal treatment */
.hero-income {
  background: linear-gradient(145deg, var(--accent-tint), var(--card));
  border: 1px solid var(--border);
}
.hero-income .hero-label { color: var(--accent-ink); }
.hero-income .hero-value { color: var(--ink); }

/* Login/signup mode toggle */
.login-toggle-row { text-align: center; margin-top: 14px; }
.login-toggle { color: var(--accent-deep); font-weight: 600; text-decoration: none; margin-left: 4px; }
.login-toggle:hover { text-decoration: underline; }

/* Read-only (aggregator) connection banner + alt connect link */
.readonly-banner {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--accent-tint); border: 1px solid #bfe9e3;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: var(--gap);
}
.readonly-banner .icon { color: var(--accent-deep); margin-top: 2px; flex: 0 0 auto; }
.readonly-banner strong { display: block; font-size: 0.9rem; color: var(--accent-ink); }
.readonly-banner span { display: block; font-size: 0.82rem; color: #35635c; line-height: 1.45; margin-top: 2px; }
.connect-alt { margin-top: 14px; }
.connect-alt a { color: var(--accent-deep); font-weight: 600; text-decoration: none; }
.connect-alt a:hover { text-decoration: underline; }
