/* ====================================================================
   Wedding Expense Tracker — styling
   Elegant, warm, paper-and-blush aesthetic. Light + dark.
   ==================================================================== */

:root {
  --blush: #e3e1d6;
  --cream: #e9e7dc;
  --plum: #3e4e57;
  --plum-deep: #313f47;
  --rose: #6c818b;
  --gold: #b6a079;
  --ink: #2b363c;
  --muted: #7c827f;
  --line: #d7d3c5;
  --card: #fbfaf5;
  --card2: #f1efe5;
  --soft: #e7e4d8;
  --good: #5a8a6f;
  --warn: #b0883c;
  --bad: #b56b6b;
  --shadow: 0 12px 32px rgba(46, 58, 64, .12);
  --shadow-sm: 0 2px 12px rgba(46, 58, 64, .08);
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --blush: #20282c;
  --cream: #191f23;
  --plum: #a6bac1;
  --plum-deep: #c6d4d9;
  --rose: #8ba0a8;
  --gold: #cbb78d;
  --ink: #eef1ee;
  --muted: #93a0a3;
  --line: #313d42;
  --card: #222b30;
  --card2: #283238;
  --soft: #2f3a40;
  --good: #6fae8a;
  --warn: #d2ab5f;
  --bad: #cf8a8a;
  --shadow: 0 14px 36px rgba(0, 0, 0, .46);
  --shadow-sm: 0 2px 14px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
.serif { font-family: "Inter", system-ui, -apple-system, sans-serif; letter-spacing: .2px; }
.hidden { display: none !important; }
a { color: var(--plum); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: none; border-radius: 999px; padding: 11px 20px; font-size: 13.5px;
  font-weight: 600; letter-spacing: .2px; cursor: pointer; font-family: inherit;
  color: var(--plum-deep); background: var(--soft);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn :is(i, svg) { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--plum-deep), var(--plum) 52%, var(--rose));
  color: #fff; box-shadow: 0 6px 16px rgba(58,26,97,.30);
}
.btn-primary:hover { box-shadow: 0 11px 24px rgba(58,26,97,.40); }
[data-theme="dark"] .btn-primary { color: #172023; }
.btn-ghost {
  background: var(--card); border: 1px solid var(--line); color: var(--plum);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--soft); border-color: var(--rose); color: var(--plum-deep); }
.btn-block { width: 100%; }
.icon-btn { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 9px; display: inline-flex; transition: .15s; }
.icon-btn:hover { background: var(--soft); color: var(--plum); }
.icon-btn :is(i, svg) { width: 18px; height: 18px; }
.link { color: var(--plum); font-weight: 600; font-size: 13px; }

input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(108,129,139,.20); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--bad) !important; box-shadow: 0 0 0 3px rgba(181,107,107,.32) !important; }
.phone-group { display: flex; gap: 8px; }
.cc-select { width: auto; flex: none; min-width: 88px; }
textarea { resize: vertical; }
label.stack { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.stack input, label.stack select, label.stack textarea { font-weight: 500; color: var(--ink); }

/* ============================ AUTH ============================ */
.auth-screen {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--blush), transparent),
    var(--cream);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 24px;
  box-shadow: var(--shadow); padding: 34px 30px; border: 1px solid var(--line);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-rings {
  font-family: "Inter", system-ui, -apple-system, sans-serif; font-weight: 700; font-size: 24px; letter-spacing: .5px;
  width: 62px; height: 62px; margin: 0 auto; border-radius: 50%;
  border: 1.5px solid var(--gold); color: var(--gold); display: grid; place-items: center;
}
.auth-brand h1 { margin: 10px 0 4px; font-size: 30px; font-weight: 500; text-transform: uppercase; letter-spacing: 4px; color: var(--plum-deep); }
.auth-tag { margin: 0; color: var(--muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-form input { font-weight: 500; color: var(--ink); }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.auth-msg { color: var(--bad); font-size: 13px; min-height: 0; }
.auth-msg:empty { display: none; }
.auth-foot { color: var(--muted); font-size: 12px; }
.su-master-row { flex-direction: row !important; align-items: center; gap: 9px; font-weight: 500; color: var(--muted); }
.su-master-row input { width: auto; }

/* ============================ APP SHELL ============================ */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--plum-deep), var(--plum));
  color: #fbeef4; display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #1b2429, #29343b); }
.side-brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 20px; }
.side-mark {
  font-family: "Inter", system-ui, -apple-system, sans-serif; font-weight: 700; font-size: 15px; letter-spacing: .3px;
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12); color: var(--gold);
}
.side-title { font-size: 22px; font-weight: 700; line-height: 1.05; color: #fff; }
.side-sub { font-size: 11.5px; opacity: .72; margin-top: 2px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 12px;
  color: #e6ebe8; font-size: 14px; font-weight: 600; opacity: .82; transition: .15s;
}
.nav-item :is(i, svg) { width: 18px; height: 18px; }
.nav-item:hover { background: rgba(255,255,255,.1); opacity: 1; }
.nav-item.active { background: rgba(255,255,255,.16); opacity: 1; color: #fff; }
.side-foot { display: flex; flex-direction: column; gap: 12px; }
#themeToggle { background: rgba(255,255,255,.08); color: #eef1ee; border-color: rgba(255,255,255,.28); }
#themeToggle:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.42); color: #fff; }
.side-user { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.15); }
.su-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--gold); color: #3a2410; font-weight: 700; font-size: 15px;
}
.su-meta { flex: 1; min-width: 0; }
.su-name { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { font-size: 11px; opacity: .7; text-transform: capitalize; }
.side-user .icon-btn { color: #e6ebe8; }
.side-user .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.main { padding: 26px 30px 60px; max-width: 1180px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 31px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; margin: 0; color: var(--plum-deep); }
.page-sub { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- KPIs ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.kpi-accent { background: linear-gradient(150deg, var(--plum), var(--rose)); border: none; color: #fff; box-shadow: var(--shadow); }
[data-theme="dark"] .kpi-accent { color: #fff; }
.kpi-label { font-size: 12.5px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .4px; }
.kpi-accent .kpi-label { opacity: .9; }
.kpi-value { font-size: 29px; font-weight: 700; margin: 8px 0 4px; font-family: "Inter", system-ui, -apple-system, sans-serif; letter-spacing: .3px; }
.kpi-foot { font-size: 12px; color: var(--muted); }
.kpi-accent .kpi-foot { color: rgba(255,255,255,.85); }

/* ---------- budget strip ---------- */
.budget-strip { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.bs-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--muted); }
.bar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar.big { height: 14px; margin: 14px 0 8px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--rose), var(--plum)); border-radius: 999px; transition: width .4s; }
.bar-fill.over { background: linear-gradient(90deg, #e08a8a, var(--bad)); }

/* ---------- charts / legend ---------- */
.chart-wrap { position: relative; height: 230px; display: flex; align-items: center; justify-content: center; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-item b { color: var(--ink); font-weight: 600; }

/* ---------- people ---------- */
.people-list { display: flex; flex-direction: column; gap: 12px; }
.person-row { display: flex; align-items: center; gap: 12px; }
.person-av { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--plum); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.person-meta { flex: 1; min-width: 0; }
.person-name { font-size: 13.5px; font-weight: 600; }
.person-bar { height: 6px; background: var(--soft); border-radius: 999px; margin-top: 5px; overflow: hidden; }
.person-bar > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--rose)); border-radius: 999px; }
.person-amt { font-size: 13.5px; font-weight: 700; color: var(--plum); }

/* ---------- expense list ---------- */
.exp-list { display: flex; flex-direction: column; }
.exp-row { display: flex; align-items: flex-start; gap: 14px; padding: 16px 10px; border-radius: 12px; border-bottom: 1px solid var(--line); transition: background .15s; }
.exp-row:hover { background: var(--card2); }
.exp-row:last-child { border-bottom: none; }
.exp-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; color: var(--plum); flex: none; margin-top: 1px; }
.exp-icon :is(i, svg) { width: 20px; height: 20px; }
.chip button :is(i, svg) { width: 14px; height: 14px; }
.exp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.exp-line1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.exp-vendor { font-weight: 600; font-size: 15px; color: var(--ink); }
.exp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.exp-tag { font-size: 10px; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.exp-tag.event { background: transparent; border: 1px solid var(--line); }
.exp-meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; }
.exp-meta b { color: var(--ink); font-weight: 600; }
.exp-meta span:not(:first-child)::before { content: "·"; margin: 0 8px; opacity: .55; }
.exp-note { font-size: 12.5px; color: var(--muted); font-style: italic; line-height: 1.5; margin-top: 1px; padding: 7px 11px; background: var(--soft); border-radius: 9px; }
.exp-amts { text-align: right; flex: none; min-width: 128px; padding-top: 1px; }
.exp-due { font-weight: 700; font-size: 16px; color: var(--ink); }
.exp-paid { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.pill { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.pill.paid { background: rgba(90,138,111,.18); color: var(--good); }
.pill.partial { background: rgba(176,136,60,.20); color: var(--warn); }
.pill.due { background: rgba(181,107,107,.18); color: var(--bad); }
.pill.hidden-pill { background: var(--soft); color: var(--muted); border: 1px dashed var(--muted); }
.exp-row.is-hidden { background: var(--card2); box-shadow: inset 3px 0 0 var(--muted); }
.exp-actions { display: flex; gap: 2px; flex: none; padding-top: 2px; }
.exp-empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.exp-empty .big { font-size: 46px; line-height: 1; margin-bottom: 10px; color: var(--gold); }
.exp-empty .big svg { width: 44px; height: 44px; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; display: flex; align-items: center; }
.search :is(i, svg) { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 130px; }

/* ---------- budget page ---------- */
.overall-budget { display: flex; gap: 12px; align-items: flex-end; }
.overall-budget label { flex: 1; }
.overall-foot { font-size: 13px; color: var(--muted); }
.cat-budget-list { display: flex; flex-direction: column; gap: 14px; }
.cbr { display: grid; grid-template-columns: 150px 1fr 130px; align-items: center; gap: 14px; }
.cbr-name { font-size: 13.5px; font-weight: 600; }
.cbr-bar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.cbr-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--rose), var(--plum)); }
.cbr-bar > div.over { background: linear-gradient(90deg, #e08a8a, var(--bad)); }
.cbr-cap input { padding: 7px 10px; }
.cbr-foot { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------- settings ---------- */
.user-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.user-row .su-avatar { width: 34px; height: 34px; font-size: 13px; }
.user-row .um { flex: 1; }
.user-row .un { font-size: 13.5px; font-weight: 600; }
.user-row .uu { font-size: 12px; color: var(--muted); }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: #3a2410; text-transform: uppercase; letter-spacing: .3px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--soft); font-size: 13px; font-weight: 600; }
.chip button { border: none; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; padding: 0; }
.chip button:hover { color: var(--bad); }
.chip-add { display: flex; gap: 8px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.stack { margin-bottom: 14px; }

/* ============================ MODALS ============================ */
.modal { position: fixed; inset: 0; background: rgba(45,25,38,.42); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 70; }
.modal-card { background: var(--card); border-radius: 22px; width: 100%; max-width: 560px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.modal-card.small { max-width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 23px; color: var(--plum-deep); }
.modal-body { padding: 20px 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.remaining-box output { font-weight: 700; color: var(--plum); font-size: 16px; padding-top: 4px; display: block; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.modal-foot > div { display: flex; gap: 10px; }
.addedby-note { font-size: 12px; color: var(--muted); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--cream); padding: 12px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); z-index: 80; opacity: 0; transition: .25s; }
.toast.show { opacity: 1; bottom: 34px; }

/* ---------- currency toggle ---------- */
.cur-toggle { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.cur-toggle button { border: none; background: transparent; color: var(--muted); font: 600 12.5px Inter; padding: 7px 13px; border-radius: 999px; cursor: pointer; transition: .15s; }
.cur-toggle button.active { background: linear-gradient(135deg, var(--plum-deep), var(--plum)); color: #fff; box-shadow: var(--shadow-sm); }
[data-theme="dark"] .cur-toggle button.active { color: #172023; background: linear-gradient(135deg, var(--gold), var(--rose)); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.cur-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.fx-line { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.fx-line .fx-refresh { padding: 3px; }
.fx-line .fx-refresh :is(i, svg) { width: 13px; height: 13px; }
.fx-line.spin .fx-refresh :is(i, svg) { animation: fxspin .6s linear; }
@keyframes fxspin { to { transform: rotate(360deg); } }
.cur-hint { font-size: 12.5px; color: var(--plum); font-weight: 600; min-height: 0; margin-bottom: 4px; }
.cur-hint:empty { display: none; }
.acct-sep { border: none; border-top: 1px solid var(--line); margin: 4px 0 14px; }

/* ---------- countdown table ---------- */
.countdown-table { display: flex; flex-direction: column; }
.cd-row { display: grid; grid-template-columns: 1.4fr 1fr auto; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.cd-row:last-child { border-bottom: none; }
.cd-name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; }
.cd-ic { width: 30px; height: 30px; border-radius: 9px; background: var(--soft); color: var(--plum); display: grid; place-items: center; flex: none; font-size: 15px; }
.cd-date { font-size: 13px; color: var(--muted); }
.cd-badge { font-family: "Inter", system-ui, -apple-system, sans-serif; font-weight: 700; font-size: 20px; color: var(--plum); text-align: right; min-width: 92px; }
.cd-badge small { display: block; font-family: "Inter", sans-serif; font-size: 10.5px; font-weight: 600; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.cd-badge.past { color: var(--muted); }
.cd-badge.soon { color: var(--bad); }
.cd-badge.today { color: var(--good); }
.cd-unset { font-size: 12.5px; color: var(--muted); font-style: italic; }

/* ---------- key dates editor ---------- */
.eventdate-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ed-row { display: grid; grid-template-columns: 1fr 150px auto; align-items: center; gap: 10px; }
.ed-name { font-size: 13.5px; font-weight: 600; }
.ed-row input[type="date"] { padding: 8px 10px; }

/* ---------- notes ---------- */
.note-composer { display: flex; flex-direction: column; gap: 10px; }
.note-composer select { width: auto; min-width: 160px; }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.notes-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.note-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); border-left: 4px solid var(--gold); }
.note-card h4 { margin: 0 0 6px; font-size: 15px; }
.note-topic { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--plum); background: var(--soft); padding: 2px 8px; border-radius: 999px; }
.note-body { font-size: 13.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; margin: 8px 0; }
.note-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.note-meta .person-av { width: 26px; height: 26px; font-size: 11px; }
.note-actions { margin-left: auto; display: flex; gap: 2px; }
.notes-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 36px; }

/* ---------- chatbot ---------- */
.chat-fab { position: fixed; right: 26px; bottom: 26px; width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer; z-index: 60;
  background: linear-gradient(135deg, var(--plum-deep), var(--plum) 55%, var(--rose)); color: #fff; box-shadow: 0 10px 26px rgba(58,26,97,.40); display: grid; place-items: center; transition: transform .15s; }
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }
.chat-fab :is(i, svg) { width: 26px; height: 26px; }
[data-theme="dark"] .chat-fab { color: #172023; }
.chat-panel { position: fixed; right: 26px; bottom: 96px; width: min(380px, calc(100vw - 40px)); height: min(560px, calc(100vh - 130px));
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); z-index: 60; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: linear-gradient(135deg, var(--plum-deep), var(--plum)); color: #fff; }
.chat-id { display: flex; align-items: center; gap: 10px; }
.chat-mark { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.15); color: var(--gold); font-weight: 700; font-size: 13px; }
.chat-head strong { font-size: 15px; display: block; }
.chat-sub { font-size: 11.5px; opacity: .8; }
.chat-head .icon-btn { color: #fff; }
.chat-head .icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--card2); }
.msg { max-width: 84%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--plum-deep), var(--plum)); color: #fff; border-bottom-right-radius: 4px; }
[data-theme="dark"] .msg.me { color: #172023; background: linear-gradient(135deg, var(--gold), var(--rose)); }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); }
.chat-chip { font-size: 12px; font-weight: 600; color: var(--plum); background: var(--soft); border: none; border-radius: 999px; padding: 6px 11px; cursor: pointer; }
.chat-chip:hover { background: var(--line); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; }
.chat-input .icon-btn { background: linear-gradient(135deg, var(--plum-deep), var(--plum)); color: #fff; padding: 9px; }
[data-theme="dark"] .chat-input .icon-btn { color: #172023; }

/* ---------- easter-egg confetti / hearts ---------- */
.ee-piece {
  position: fixed; top: -26px; z-index: 200; pointer-events: none; line-height: 1; will-change: transform;
  animation-name: ee-fall; animation-timing-function: cubic-bezier(.3, .5, .5, 1); animation-fill-mode: forwards;
}
@keyframes ee-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(115vh) rotate(680deg); opacity: .85; }
}
@media (prefers-reduced-motion: reduce) { .ee-piece { display: none; } }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 860px) {
  .app { display: block; }

  /* the sidebar becomes a slim TOP app bar: brand on the left, theme + logout on the right */
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; height: 54px;
    flex-direction: row; align-items: center; gap: 8px; padding: 0 12px; z-index: 50;
  }
  .side-brand { display: flex; padding: 0; flex: 1; min-width: 0; gap: 9px; }
  .side-brand > div { min-width: 0; }
  .side-brand .side-sub { display: none; }
  .side-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-mark { width: 30px; height: 30px; font-size: 12px; }

  /* nav floats to the BOTTOM as a tab bar */
  .side-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 58px; flex: none;
    flex-direction: row; justify-content: space-around; gap: 0; padding: 4px 2px;
    background: var(--plum-deep); z-index: 50; border-top: 1px solid rgba(255,255,255,.1);
  }
  .nav-item { flex: 1; flex-direction: column; gap: 3px; font-size: 9.5px; padding: 6px 2px; opacity: .82; }
  .nav-item :is(i, svg) { width: 21px; height: 21px; }
  .nav-item.active { background: transparent; box-shadow: inset 0 2px 0 var(--gold); }

  /* theme + logout live in the top bar */
  .side-foot { flex-direction: row; align-items: center; gap: 4px; padding: 0; border: none; flex: none; }
  #themeToggle { font-size: 0; width: 38px; height: 38px; padding: 0; border-radius: 50%; }
  #themeToggle :is(i, svg) { width: 18px; height: 18px; }
  .side-user { padding: 0; border: none; gap: 6px; }
  .side-user .su-meta { display: none; }
  .su-avatar { width: 32px; height: 32px; font-size: 12px; }

  .main { padding: 66px 14px 78px; max-width: none; }

  .topbar { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .page-title { font-size: 24px; }
  .topbar-actions { flex-wrap: wrap; gap: 10px; align-items: center; }
  .topbar-actions .btn-primary { flex: 1 1 100%; }   /* full-width primary action */

  .grid-2 { grid-template-columns: 1fr; }
  .legend { justify-content: center; }   /* center chart legends in their card */
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .cbr { grid-template-columns: 1fr; gap: 6px; }
  .notes-list { grid-template-columns: 1fr; }
  .ed-row { grid-template-columns: 1fr auto; }
  .cd-row { grid-template-columns: 1fr auto; }
  .cd-date { display: none; }

  .chat-panel { right: 10px; left: 10px; width: auto; bottom: 70px; height: min(68vh, 500px); }
  .chat-fab { right: 14px; bottom: 70px; width: 52px; height: 52px; }
  .cc-select { min-width: 76px; }
}

@media (max-width: 600px) {
  /* Cleaner expense card: actions pinned top-right, meta stacked, amount in its own
     section below a divider. */
  .exp-row { position: relative; flex-wrap: wrap; align-items: flex-start; padding: 16px 8px; }
  .exp-main { flex: 1 1 auto; min-width: 0; padding-right: 92px; }   /* clear the actions */
  .exp-actions { position: absolute; top: 14px; right: 2px; }
  .exp-actions .icon-btn { padding: 5px; }
  .exp-line1 { gap: 8px; }
  .exp-meta { flex-direction: column; align-items: flex-start; gap: 2px; }
  .exp-meta span:not(:first-child)::before { content: none; }       /* no leading dots when stacked */
  .exp-amts { flex: 0 0 100%; order: 5; display: block; text-align: left; min-width: 0;
              margin-top: 12px; padding-top: 12px; padding-left: 58px; border-top: 1px solid var(--line); }
  .exp-due { font-size: 18px; }
  .exp-paid { margin-top: 3px; font-size: 12.5px; }
  .page-title { font-size: 22px; letter-spacing: 1px; }
  .kpi-value { font-size: 25px; }
}
