/* ==========================================================================
   Personal Budget Plan
   Palette is named after Filipino produce: ube (brand), dagat (fixed),
   kamatis (variable), pandan (savings), mangga (extra).
   ========================================================================== */

:root {
  --paper: #F6F3FA;
  --card: #FFFFFF;
  --ink: #241C3F;
  --ink-soft: #6B6486;
  --line: #E7E2F0;
  --track: #EEEAF5;

  --ube: #6B4FBB;
  --ube-deep: #2B1F52;
  --ube-tint: #EFEAFB;

  --fixed: #2F80C9;
  --variable: #EE6A4F;
  --savings: #2FA36B;
  --extra: #F2A83B;
  --danger: #D6334A;
  --ok: #2FA36B;

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;

  --sidebar-w: 268px;
  --r-card: 18px;
  --r-input: 12px;
}

[data-theme="dark"] {
  --paper: #15102A;
  --card: #1F1839;
  --ink: #F2EEFB;
  --ink-soft: #A8A1C4;
  --line: #34294F;
  --track: #2A2145;
  --ube: #9B82F0;
  --ube-tint: #2E2552;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0; }
a { color: var(--ube); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--ube); outline-offset: 2px; border-radius: 6px; }

.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* Type colours: set --c and everything inside picks it up. */
.t-fixed { --c: var(--fixed); }
.t-variable { --c: var(--variable); }
.t-savings { --c: var(--savings); }
.t-extra { --c: var(--extra); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--ube)); margin-right: 7px; flex: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
  display: flex; flex-direction: column; padding: 22px 16px 18px;
  color: #fff;
  background:
    radial-gradient(420px 260px at 0% 0%, rgba(155,130,240,.38), transparent 70%),
    linear-gradient(180deg, #2B1F52 0%, #1F163F 100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, #F2A83B, #EE6A4F); color: #2B1F52;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; line-height: 1.1; }
.brand-sub { font-size: .76rem; color: rgba(255,255,255,.62); }

.nav-group { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.09); }
.nav-group:first-of-type { border-top: 0; padding-top: 0; }
.nav-link-s {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px;
  color: rgba(255,255,255,.74); font-weight: 500; font-size: .93rem;
}
.nav-link-s i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .9; }
.nav-link-s:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link-s.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav-link-s.active i { color: #F2A83B; opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: .78rem; color: rgba(255,255,255,.5); }

.scrim { display: none; position: fixed; inset: 0; background: rgba(20,12,40,.5); z-index: 1030; }
body.nav-open .scrim { display: block; }

/* ---------- Main ---------- */
.main { margin-left: 0; min-height: 100vh; }
@media (min-width: 992px) { .main { margin-left: var(--sidebar-w); } }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
}

.topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 14px;
  padding: 16px 32px; background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.45rem; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; color: var(--ink-soft); font-size: .88rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 26px 32px 70px; max-width: 1320px; }
@media (max-width: 767.98px) {
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px 80px; }
  .topbar-title h1 { font-size: 1.15rem; }
  .btn-label { display: none; }
}

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); display: inline-grid; place-items: center; font-size: 1.05rem; cursor: pointer;
}
.icon-btn:hover { background: var(--ube-tint); }

.plan-switch { position: relative; display: inline-flex; align-items: center; }
.plan-switch i { position: absolute; left: 12px; color: var(--ube); pointer-events: none; }
.plan-switch select {
  appearance: none; -webkit-appearance: none; height: 40px; padding: 0 34px 0 36px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: .9rem; cursor: pointer;
}
@media (max-width: 575.98px) { .plan-switch select { padding: 0 24px 0 34px; } }

/* ---------- Buttons ---------- */
.btn-brand, .btn-soft, .btn-ghost, .btn-danger-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  padding: 9px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; font-family: var(--font-body);
  transition: background .15s ease, transform .1s ease;
}
.btn-brand { background: var(--ube); color: #fff; }
.btn-brand:hover { background: color-mix(in srgb, var(--ube) 86%, #000); color: #fff; text-decoration: none; }
.btn-brand:active { transform: translateY(1px); }
.btn-soft { background: var(--ube-tint); color: var(--ube); }
.btn-soft:hover { background: color-mix(in srgb, var(--ube) 20%, var(--card)); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--ube-tint); color: var(--ink); text-decoration: none; }
.btn-danger-soft { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.btn-sm-s { padding: 6px 11px; font-size: .82rem; border-radius: 10px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border-radius: var(--r-input); border: 1px solid var(--line); background-color: var(--card); color: var(--ink);
  padding: .6rem .85rem; font-size: .95rem;
}
.form-control:focus, .form-select:focus {
  background-color: var(--card); color: var(--ink); border-color: var(--ube);
  box-shadow: 0 0 0 .22rem color-mix(in srgb, var(--ube) 22%, transparent);
}
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: var(--ink); }
.form-hint { font-size: .8rem; color: var(--ink-soft); margin-top: .3rem; }

.amount-field { position: relative; }
.amount-field .cur { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-family: var(--font-display); font-weight: 600; color: var(--ink-soft); }
.amount-field .form-control { padding-left: 2rem; font-family: var(--font-display); font-weight: 600; }
.amount-lg .form-control { font-size: 1.7rem; padding-top: .5rem; padding-bottom: .5rem; padding-left: 2.4rem; }
.amount-lg .cur { font-size: 1.4rem; left: 16px; }

.seg-radio { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--track); gap: 4px; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio label {
  padding: 7px 16px; border-radius: 10px; font-weight: 600; font-size: .86rem; color: var(--ink-soft); cursor: pointer; margin: 0;
}
.seg-radio input:checked + label { background: var(--card); color: var(--ube); box-shadow: 0 1px 4px rgba(36,28,63,.12); }
.seg-radio input:focus-visible + label { outline: 2px solid var(--ube); }

.icon-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick label {
  display: grid; place-items: center; height: 38px; border-radius: 10px; background: var(--track); color: var(--ink-soft);
  cursor: pointer; font-size: 1.05rem; margin: 0;
}
.icon-pick input:checked + label { background: var(--c, var(--ube)); color: #fff; }
.icon-pick input:focus-visible + label { outline: 2px solid var(--ube); }

/* ---------- Modals ---------- */
.modal-content { background: var(--card); color: var(--ink); border: 0; border-radius: 22px; }
.modal-header { border-bottom: 0; padding: 22px 24px 4px; }
.modal-body { padding: 14px 24px 8px; }
.modal-footer { border-top: 0; padding: 12px 24px 22px; gap: 8px; }
.modal-title { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.btn-close { filter: none; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* ---------- Panels, banners, chips ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title { font-size: 1.05rem; font-weight: 700; }
.panel-sub { color: var(--ink-soft); font-size: .85rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.grid-asym { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }
@media (max-width: 991.98px) { .grid-2, .grid-asym { grid-template-columns: 1fr; } }

.banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px; margin-bottom: 18px;
  background: var(--ube-tint); color: var(--ink);
}
.banner > i { font-size: 1.3rem; color: var(--ube); }
.banner > div { flex: 1; min-width: 0; }
.banner.over { background: color-mix(in srgb, var(--danger) 11%, var(--card)); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.banner.over > i { color: var(--danger); }
.banner.good { background: color-mix(in srgb, var(--ok) 12%, var(--card)); }
.banner.good > i { color: var(--ok); }
@media (max-width: 575.98px) { .banner { flex-wrap: wrap; } }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: color-mix(in srgb, var(--c, var(--ube)) 14%, transparent); color: var(--c, var(--ube)); white-space: nowrap;
}
.chip.over { --c: var(--danger); }
.chip.near { --c: #C98512; }
.chip.ok { --c: var(--ok); }
.chip.muted { --c: var(--ink-soft); }

.icon-bubble {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 1.15rem; flex: none;
  background: color-mix(in srgb, var(--c, var(--ube)) 15%, transparent); color: var(--c, var(--ube));
}
.icon-bubble.sm { width: 36px; height: 36px; border-radius: 12px; font-size: 1rem; }

.empty { text-align: center; padding: 34px 16px; color: var(--ink-soft); }
.empty i { font-size: 2rem; color: var(--ube); opacity: .7; }
.empty h3 { font-size: 1.05rem; color: var(--ink); margin: 8px 0 4px; }

/* ---------- Progress bars ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--w, 0%); border-radius: 99px; background: var(--c, var(--ube)); transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.bar.over > i { background: var(--danger); }
.bar.thin { height: 5px; }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- Period tabs ---------- */
.seg-tabs { display: inline-flex; padding: 4px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); gap: 2px; margin-bottom: 18px; flex-wrap: wrap; }
.seg-tabs a { padding: 8px 18px; border-radius: 12px; font-weight: 600; font-size: .9rem; color: var(--ink-soft); }
.seg-tabs a small { font-weight: 500; opacity: .75; margin-left: 4px; }
.seg-tabs a:hover { text-decoration: none; color: var(--ink); }
.seg-tabs a.on { background: var(--ube); color: #fff; }

/* ---------- Salary envelopes (the memorable bit) ---------- */
.env-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.env-grid.single { grid-template-columns: 1fr; }
@media (max-width: 991.98px) { .env-grid { grid-template-columns: 1fr; } }

.envelope {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 26px 26px 20px 20px;
  padding: 24px 26px 22px; box-shadow: 0 18px 40px -22px rgba(43,31,82,.35); overflow: hidden;
}
.envelope::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 56px; opacity: .55; pointer-events: none;
  background: var(--ube-tint); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.env-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.env-head h3 { font-size: 1.05rem; font-weight: 600; color: var(--ink-soft); }
.env-income { font-size: 2.5rem; font-weight: 700; line-height: 1.05; margin-top: 4px; }
.env-stamp {
  transform: rotate(-5deg); border: 2px dashed color-mix(in srgb, var(--ube) 55%, transparent); color: var(--ube);
  border-radius: 12px; padding: 5px 12px; font-family: var(--font-display); font-weight: 700; font-size: .85rem; white-space: nowrap; background: var(--card);
}

.env-wrap { position: relative; margin: 20px 0 32px; }
.env-track { display: flex; gap: 3px; height: 32px; border-radius: 12px; overflow: hidden; background: var(--track); }
.env-track .seg { flex: 0 1 var(--w); min-width: 0; height: 100%; background: var(--c); transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.env-track .gap {
  flex: 1 1 0; min-width: 0;
  background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--ink-soft) 22%, transparent) 6px 8px);
}
.env-over {
  position: absolute; top: 0; bottom: 0; left: var(--x); right: 0; border-radius: 0 12px 12px 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(214,51,74,.75) 5px 8px);
}
.env-mark { position: absolute; top: -7px; bottom: -7px; left: var(--x); width: 3px; margin-left: -1px; background: var(--ink); border-radius: 3px; }
.env-mark::after {
  content: "Salary"; position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  font-size: .68rem; font-weight: 700; color: var(--ink-soft);
}

.env-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; margin: 20px 0 0; list-style: none; font-size: .86rem; }
.env-legend li { display: flex; align-items: center; color: var(--ink-soft); }
.env-legend strong { color: var(--ink); margin-left: 6px; font-family: var(--font-display); font-weight: 600; }

.env-verdict { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 600; }
.env-verdict i { font-size: 1.1rem; }
.env-verdict.over { color: var(--danger); }
.env-verdict.ok { color: var(--ok); }
.env-verdict.under { color: var(--ink); }
.env-verdict span { font-weight: 500; color: var(--ink-soft); }

/* ---------- Stat strip ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
}
.stat { padding: 16px 18px 18px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat-label { display: flex; align-items: center; font-size: .82rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.stat-num { display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin: 4px 0 2px; letter-spacing: -0.02em; }
.stat-sub { display: block; font-size: .78rem; color: var(--ink-soft); margin-bottom: 8px; }
.stat.diff.neg .stat-num { color: var(--danger); }
.stat.diff.pos .stat-num { color: var(--ok); }
@media (max-width: 1199.98px) {
  .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 575.98px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0 !important; }
  .stat:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: .84rem; color: var(--ink-soft); }
.chart-legend span { display: inline-flex; align-items: center; }

/* ---------- Lists ---------- */
.row-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.row-item:first-of-type { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: .82rem; color: var(--ink-soft); }
.row-amt { font-family: var(--font-display); font-weight: 600; text-align: right; white-space: nowrap; }
.row-amt.neg { color: var(--ink); }
.row-amt.pos { color: var(--ok); }

.day-head { font-family: var(--font-display); font-weight: 600; font-size: .9rem; color: var(--ink-soft); margin: 22px 0 4px; display: flex; justify-content: space-between; }
.day-head:first-child { margin-top: 0; }

/* ---------- Category board cards ---------- */
.board-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: 20px; }
.board-summary > div { padding: 16px 20px; border-left: 1px solid var(--line); }
.board-summary > div:first-child { border-left: 0; }
.board-summary .big { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; display: block; letter-spacing: -0.02em; }
.board-summary .lbl { font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
@media (max-width: 575.98px) {
  .board-summary { grid-template-columns: 1fr; }
  .board-summary > div { border-left: 0; border-top: 1px solid var(--line); }
  .board-summary > div:first-child { border-top: 0; }
}

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.cat-top { display: flex; align-items: center; gap: 12px; }
.cat-top h3 { font-size: 1.05rem; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-split div { background: var(--track); border-radius: 12px; padding: 8px 12px; }
.cat-split small { display: block; color: var(--ink-soft); font-size: .76rem; font-weight: 600; }
.cat-split b { font-family: var(--font-display); font-weight: 600; }
.cat-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .86rem; color: var(--ink-soft); }
.cat-foot strong { color: var(--ink); font-family: var(--font-display); }
.cat-actions { display: flex; gap: 6px; margin-top: auto; }
.cat-add {
  border: 2px dashed var(--line); border-radius: var(--r-card); background: transparent; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 180px; cursor: pointer; font-weight: 600;
}
.cat-add:hover { border-color: var(--ube); color: var(--ube); }
.cat-add i { font-size: 1.6rem; }

/* ---------- Budget plan editor ---------- */
.editor-sticky {
  position: sticky; top: 76px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 20px; box-shadow: 0 10px 24px -18px rgba(43,31,82,.4);
}
.editor-sticky > div { padding: 12px 18px; border-left: 1px solid var(--line); }
.editor-sticky > div:first-child { border-left: 0; }
.editor-sticky .lbl { font-size: .8rem; color: var(--ink-soft); font-weight: 600; display: block; }
.editor-sticky .val { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.editor-sticky .val.neg { color: var(--danger); }
.editor-sticky .val.pos { color: var(--ok); }
@media (max-width: 767.98px) { .editor-sticky { top: 60px; grid-template-columns: 1fr; } .editor-sticky > div { border-left: 0; border-top: 1px solid var(--line); padding: 8px 16px; } .editor-sticky > div:first-child { border-top: 0; } }

.group-table { width: 100%; }
.group-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 8px; }
.group-head h2 { font-size: 1.1rem; font-weight: 700; flex: 1; }
.grow-row { display: grid; grid-template-columns: minmax(0, 1.6fr) 1fr 1fr 0.8fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.grow-row.head { border-top: 0; font-size: .8rem; font-weight: 700; color: var(--ink-soft); padding-bottom: 4px; }
.grow-row .name { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.grow-row .name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow-row .tot { text-align: right; font-family: var(--font-display); font-weight: 600; }
.grow-row.foot { font-weight: 700; border-top: 2px solid var(--line); }
.grow-row .form-control { padding-top: .45rem; padding-bottom: .45rem; }
@media (max-width: 575.98px) { .grow-row { grid-template-columns: minmax(0, 1fr) 1fr 1fr; } .grow-row .tot { display: none; } }
.save-bar { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; margin-top: 22px; }
.save-bar .btn-brand { box-shadow: 0 12px 28px -10px rgba(107,79,187,.7); padding: 12px 22px; }

/* ---------- Rings ---------- */
.ring { position: relative; width: 120px; height: 120px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--track); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--c, var(--ube)); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .9s cubic-bezier(.2,.8,.2,1); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.1; }
.ring-text strong { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.ring-text span { font-size: .72rem; color: var(--ink-soft); font-weight: 600; }

/* ---------- Ipon / goals ---------- */
.ipon-top { display: flex; align-items: center; gap: 18px; }
.ipon-top h3 { font-size: 1.05rem; font-weight: 700; }
.streak { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 38px)); gap: 6px; margin-top: 8px; }
.streak b { height: 34px; border-radius: 9px; background: var(--track); display: grid; place-items: center; font-size: .68rem; font-weight: 600; color: var(--ink-soft); }
.streak b.full { background: var(--savings); color: #fff; }
.streak b.part { background: color-mix(in srgb, var(--savings) 40%, var(--track)); color: var(--ink); }
.streak b.today { outline: 2px solid var(--ube); outline-offset: 1px; }
.goal-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px; margin-bottom: 18px; }
.goal-card.done { opacity: .78; }
.goal-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.goal-head .info { flex: 1; min-width: 220px; }
.goal-head h3 { font-size: 1.25rem; font-weight: 700; }
.goal-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0 4px; }
.goal-stats div { background: var(--track); border-radius: 14px; padding: 10px 14px; }
.goal-stats small { display: block; font-size: .76rem; color: var(--ink-soft); font-weight: 600; }
.goal-stats b { font-family: var(--font-display); font-size: 1.15rem; }
@media (max-width: 575.98px) { .goal-stats { grid-template-columns: 1fr; } }

/* ---------- Income ---------- */
.income-hero { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.income-hero .big { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; letter-spacing: -0.03em; }

/* ---------- History ---------- */
.hist-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.hist-row:first-of-type { border-top: 0; }
.hist-row h3 { font-size: 1.05rem; font-weight: 700; }
.hist-bar { display: flex; gap: 2px; height: 14px; border-radius: 8px; overflow: hidden; background: var(--track); }
.hist-bar i { display: block; width: var(--w); background: var(--c); }
.hist-nums { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; font-size: .84rem; color: var(--ink-soft); }
.hist-nums b { color: var(--ink); font-family: var(--font-display); font-weight: 600; }
@media (max-width: 767.98px) { .hist-row { grid-template-columns: 1fr; gap: 10px; } }

/* ---------- Tables ---------- */
.table-s { width: 100%; border-collapse: collapse; }
.table-s th { text-align: left; font-size: .8rem; color: var(--ink-soft); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table-s td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.table-s .r { text-align: right; font-family: var(--font-display); font-weight: 600; }
.table-s tr:last-child td { border-bottom: 0; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 2000; width: max-content; max-width: calc(100vw - 32px); }
.toast-pill {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 14px; background: var(--ube-deep); color: #fff; font-weight: 600;
  box-shadow: 0 16px 36px -12px rgba(0,0,0,.45); animation: toast-in .3s ease both;
}
.toast-pill i { color: #7BE0A9; }
.toast-pill.error { background: #7A1F2E; }
.toast-pill.error i { color: #FFB4C0; }
.toast-pill.hide { opacity: 0; transition: opacity .4s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Misc ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.filter-bar .form-control, .filter-bar .form-select { max-width: 240px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--ink-soft); }
.text-over { color: var(--danger); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 991.98px) { .settings-grid { grid-template-columns: 1fr; } }

.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-page h1 { font-size: 2rem; margin: 10px 0; }

@media print {
  .sidebar, .topbar, .no-print, .scrim, .toast-wrap { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .panel { break-inside: avoid; }
}

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

/* ---------- Additions ---------- */
.divide-top { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.chip.primary { --c: var(--ube); }
.grow-row.foot span:nth-child(2), .grow-row.foot span:nth-child(3) { text-align: left; padding-left: 2rem; }
.hist-bar i { display: block; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.inline-form { display: inline; margin: 0; }

@media (max-width: 575.98px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-actions { margin-left: auto; }
  .topbar-title { order: 3; flex: 1 1 100%; }
  .topbar-title p { display: none; }
}
.streak-cap { margin-top: 16px; font-size: .82rem; color: var(--ink-soft); font-weight: 600; }

/* ---------- Signed-in user chip (sidebar) ---------- */
.sidebar-user { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: #fff; padding: 6px 8px; border-radius: 12px; }
.user-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #F2A83B, #EE6A4F); color: #2B1F52; font-family: var(--font-display); font-weight: 700;
}
.user-name { font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; }
.logout-btn:hover { background: rgba(255,255,255,.18); }

/* ---------- Visitors: landing page, login and register ---------- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 20px 20px 48px; }
.auth-top { width: 100%; max-width: 1080px; display: flex; align-items: center; justify-content: space-between; padding: 6px 0 26px; }
.auth-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.auth-brand:hover { color: var(--ink); text-decoration: none; }
.auth-brand .brand-sub { color: var(--ink-soft); }
.auth-card {
  width: 100%; max-width: 480px; background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 30px 30px 26px; box-shadow: 0 24px 50px -30px rgba(43,31,82,.45);
}
.auth-card h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: 6px; }
.auth-card h2 { font-size: 1.05rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 12px; }
.auth-card hr { border-color: var(--line); opacity: 1; }
.auth-card .row > * { flex: 0 0 100%; width: 100%; max-width: 100%; margin-left: 0; }
.auth-wide { width: 100%; max-width: 1080px; }

.landing { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; padding: 24px 0; }
.landing h1 { font-size: clamp(2.3rem, 5.2vw, 3.7rem); line-height: 1.04; font-weight: 700; letter-spacing: -0.03em; }
.landing .lead { color: var(--ink-soft); font-size: 1.1rem; max-width: 34rem; margin: 18px 0 28px; }
@media (max-width: 899.98px) { .landing { grid-template-columns: 1fr; gap: 32px; } }

/* Bootstrap buttons used by the login pages */
.btn-primary {
  --bs-btn-bg: var(--ube); --bs-btn-border-color: var(--ube); --bs-btn-hover-bg: color-mix(in srgb, var(--ube) 86%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--ube) 86%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--ube) 78%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--ube) 78%, #000); --bs-btn-disabled-bg: var(--ube); --bs-btn-disabled-border-color: var(--ube);
  border-radius: 12px; font-weight: 600;
}
.btn-outline-primary, .btn-link { --bs-btn-color: var(--ube); --bs-btn-border-color: var(--ube); --bs-btn-hover-bg: var(--ube); --bs-btn-hover-border-color: var(--ube); border-radius: 12px; }
.nav-pills { --bs-nav-pills-link-active-bg: var(--ube); }
.form-floating > label { color: var(--ink-soft); }
.form-check-input:checked { background-color: var(--ube); border-color: var(--ube); }
.text-danger { color: var(--danger) !important; }
.alert { border-radius: 14px; }

.auth-card h3 { font-size: 1.05rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 8px; }
.auth-card .row > * + * { margin-top: 26px; }
.auth-card .checkbox label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.auth-card form p { margin-bottom: .5rem; }
.auth-card .btn-primary { margin-bottom: 14px; }

.nav { --bs-nav-link-color: var(--ube); --bs-nav-link-hover-color: var(--ink); }
.content > h1, .content > h2, .content > h3 { margin-bottom: 14px; }
