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

/* ====================================================================
   Theme tokens — BudgetWise "Origin" look (dark default + light variant).
   Teal accent, near-black surfaces, single Inter font (bold-weight headings).
   The app keeps its original semantic var names; they are repointed here:
   --plum / --plum-deep / --rose / --gold all map to the teal accent family,
   while --cream/--card/--soft/--line/--ink/--muted are the neutral surfaces.
   ==================================================================== */
:root {
  /* default = DARK (BudgetWise ships dark) */
  --blush: #14202b;
  --cream: #070708;          /* app background */
  --plum: #2bd4b6;           /* accent */
  --plum-deep: #2bd4b6;
  --rose: #36d6c3;
  --gold: #2bd4b6;
  --accent: #2bd4b6;
  --accent-ink: #04201b;     /* text on accent */
  --shell: #0c0d10;          /* sidebar */
  --ink: #f3f4f6;
  --muted: #8b8f99;
  --line: #23252b;
  --card: #131418;
  --card2: #181a1f;
  --soft: #16181d;
  --good: #2fd07f;
  --warn: #ffb547;
  --bad: #ff5a6a;
  --shadow: 0 22px 60px rgba(0, 0, 0, .5);
  --shadow-sm: 0 8px 26px rgba(0, 0, 0, .38);
  --radius: 20px;
  --radius-sm: 13px;
}

[data-theme="light"] {
  --blush: #dff3ee;
  --cream: #f1f4f3;
  --plum: #10b497;
  --plum-deep: #0d9a81;
  --rose: #12b9a0;
  --gold: #10b497;
  --accent: #10b497;
  --accent-ink: #04201b;
  --shell: #ffffff;
  --ink: #16243a;
  --muted: #69737f;
  --line: #e6ece9;
  --card: #ffffff;
  --card2: #f4f7f6;
  --soft: #eef3f1;
  --good: #10b497;
  --warn: #d98a1a;
  --bad: #e23b53;
  --shadow: 0 10px 30px rgba(30, 60, 80, .10);
  --shadow-sm: 0 4px 16px rgba(30, 60, 80, .07);
}

* { 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; font-weight: 700; }
.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: var(--accent); color: var(--accent-ink); font-weight: 700;
  box-shadow: 0 6px 18px rgba(43,212,182,.28);
}
.btn-primary:hover { background: #34e0c2; box-shadow: 0 11px 26px rgba(43,212,182,.38); }
.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(--accent); box-shadow: 0 0 0 3px rgba(43,212,182,.22); }
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(900px 520px at 18% 2%, rgba(124,77,255,.22), transparent 60%),
    radial-gradient(820px 520px at 88% 98%, rgba(43,212,182,.18), transparent 60%),
    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: 800; font-size: 24px; letter-spacing: .3px;
  width: 60px; height: 60px; margin: 0 auto; border-radius: 16px;
  background: linear-gradient(140deg, var(--accent), #36d6c3); color: var(--accent-ink); display: grid; place-items: center;
}
.auth-brand h1 { margin: 12px 0 4px; font-size: 26px; font-weight: 800; text-transform: none; letter-spacing: -.2px; color: var(--ink); }
.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: var(--shell);
  color: var(--ink); display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line);
}
.side-brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 18px; }
.side-mark {
  font-family: "Inter", system-ui, -apple-system, sans-serif; font-weight: 800; font-size: 15px; letter-spacing: .3px;
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #36d6c3); color: var(--accent-ink);
}
.side-title { font-size: 20px; font-weight: 700; line-height: 1.08; color: var(--ink); }
.side-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--muted); font-size: 14.5px; font-weight: 500; transition: .15s;
}
.nav-item :is(i, svg) { width: 18px; height: 18px; }
.nav-item:hover { background: rgba(43,212,182,.09); color: var(--ink); }
.nav-item.active { background: rgba(43,212,182,.15); color: var(--ink); font-weight: 600; }
.nav-item.active :is(i, svg) { color: var(--accent); }
.side-foot { display: flex; flex-direction: column; gap: 12px; }
#themeToggle { background: var(--card); color: var(--ink); border-color: var(--line); }
#themeToggle:hover { background: rgba(43,212,182,.12); border-color: var(--accent); color: var(--ink); }
.side-user { display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.su-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #7c4dff); color: #fff; font-weight: 700; font-size: 15px;
}
.su-meta { flex: 1; min-width: 0; }
.su-name { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.side-user .icon-btn { color: var(--muted); }
.side-user .icon-btn:hover { background: var(--soft); color: var(--ink); }

.main { padding: 26px 32px 60px; max-width: 1240px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.3px; text-transform: none; margin: 0; color: var(--ink); }
.page-sub { margin: 4px 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: 11.5px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; color: var(--muted); }
.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: 20px; box-shadow: var(--shadow-sm); }
.kpi-accent { background: linear-gradient(135deg, #0e2228 0%, #13333d 55%, #0b1316 100%); border: 1px solid var(--line); color: #fff; box-shadow: var(--shadow); }
[data-theme="light"] .kpi-accent { background: linear-gradient(135deg, #e7f7f1, #edf9f4); color: var(--ink); border-color: var(--line); }
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.1px; }
.kpi-accent .kpi-label { color: rgba(255,255,255,.78); }
[data-theme="light"] .kpi-accent .kpi-label { color: var(--muted); }
.kpi-value { font-size: 29px; font-weight: 800; margin: 10px 0 4px; letter-spacing: -.4px; }
.kpi-foot { font-size: 12px; color: var(--muted); }
.kpi-accent .kpi-foot { color: rgba(255,255,255,.8); }
[data-theme="light"] .kpi-accent .kpi-foot { color: var(--muted); }

/* ---------- 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: 9px; }
.exp-line1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.exp-vendor { font-weight: 700; font-size: 15.5px; color: var(--ink); }
/* scannable label:value detail chips */
.exp-facts { display: flex; flex-wrap: wrap; gap: 6px 7px; }
.fact { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink);
  background: var(--soft); border: 1px solid var(--line); padding: 3px 9px 3px 8px; border-radius: 8px; line-height: 1.5; max-width: 100%; }
.fact b { color: var(--muted); font-weight: 700; font-size: 9.5px; letter-spacing: .5px; text-transform: uppercase; }
.fact > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fact :is(i, svg) { width: 13px; height: 13px; color: var(--muted); flex: none; }
.exp-note { font-size: 12.5px; color: var(--muted); font-style: italic; line-height: 1.5; margin-top: 1px; padding: 8px 11px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; }
.exp-amts { text-align: right; flex: none; min-width: 132px; 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(47,208,127,.16); color: var(--good); }
.pill.partial { background: rgba(255,181,71,.18); color: var(--warn); }
.pill.due { background: rgba(255,90,106,.16); 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(--accent); color: var(--accent-ink); 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; }
.other-input { margin-top: 8px; }

/* activity log */
.log-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; }
.log-row { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 12.5px; align-items: baseline; }
.log-row:last-child { border-bottom: none; }
.log-when { color: var(--muted); white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.log-who { font-weight: 600; flex: none; }
.log-what { color: var(--ink); }
.log-empty { color: var(--muted); padding: 18px 2px; }

/* ============================ 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, #0e2228, #13333d); color: #fff; }
.chat-id { display: flex; align-items: center; gap: 10px; }
.chat-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(140deg, var(--accent), #36d6c3); color: var(--accent-ink); font-weight: 800; font-size: 12.5px; }
.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; }

/* ---------- multi-select chips (events) + labeled card tags ---------- */
.form-grid .span-2 { grid-column: 1 / -1; }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip-select .csel { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; transition: .12s; }
.chip-select .csel:hover { border-color: var(--rose); }
.chip-select .csel.on { background: linear-gradient(135deg, var(--plum-deep), var(--plum)); color: #fff; border-color: transparent; }
[data-theme="dark"] .chip-select .csel.on { color: #172023; background: linear-gradient(135deg, var(--gold), var(--rose)); }
.exp-tags { display: flex; flex-wrap: wrap; gap: 3px 16px; }
.exp-tagline { font-size: 12.5px; color: var(--muted); }
.exp-tagline b { color: var(--ink); font-weight: 600; }

/* about section */
.about-body { font-size: 13.5px; line-height: 1.6; color: var(--ink); }
.about-body h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--plum); }
.about-body ul { margin: 4px 0; padding-left: 20px; }
.about-body li { margin: 3px 0; }
.about-body p { margin: 6px 0; }

/* ---------- 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; } }

/* offline banner / confirm / filters / busy / focus */
.net-banner { position: fixed; left: 0; right: 0; top: 0; z-index: 90; background: var(--bad); color: #fff;
  text-align: center; font-size: 13px; font-weight: 600; padding: calc(9px + env(safe-area-inset-top)) 12px 9px; }
.confirm-msg { font-size: 14px; line-height: 1.55; color: var(--ink); margin: 0 0 4px; }
.date-filter { width: auto; min-width: 140px; }

/* small button variant (date panel, payer editor) */
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---- date-range dropdown (Expenses toolbar) ---- */
.daterange { position: relative; }
.daterange-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .16); padding: 12px; min-width: 250px;
}
.dr-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.dr-preset { border: 1px solid var(--line); background: var(--soft); color: var(--ink);
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; cursor: pointer; transition: .15s; }
.dr-preset:hover { border-color: var(--plum); color: var(--plum); }
.dr-custom { display: flex; gap: 8px; margin-bottom: 10px; }
.dr-custom label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); flex: 1; }
.dr-custom input { width: 100%; }
.dr-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- expense count chip ---- */
.count-chip { font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--soft); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }

/* ---- payers (split) editor in the expense modal ---- */
div.stack { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.payers-list { display: flex; flex-direction: column; gap: 6px; }
.payer-row { display: flex; gap: 6px; align-items: center; }
.payer-row .payer-name { flex: 2; min-width: 0; font-weight: 500; color: var(--ink); }
.payer-row .payer-amt { flex: 1; min-width: 0; max-width: 120px; font-weight: 500; color: var(--ink); }
.payers-list.single .payer-amt, .payers-list.single .payer-del { display: none; }
.payers-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#splitInfo.split-bad { color: var(--bad); font-weight: 700; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: default; transform: none; box-shadow: none; }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }

/* ---- potential (master-only what-if tables) ---- */
.pot-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pot-bar p { margin: 0; }
.pot-bar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.pot-card { margin-bottom: 16px; }
.pot-name { font-weight: 700; font-size: 15px; color: var(--ink); width: min(320px, 60%);
  border: 1px solid transparent; background: transparent; padding: 6px 9px; border-radius: 9px; }
.pot-name:hover, .pot-name:focus { border-color: var(--line); background: var(--card2); }
.pot-actions { display: flex; gap: 6px; align-items: center; }
.pot-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.pot-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pot-table th, .pot-table td { border: 1px solid var(--line); min-width: 110px; text-align: center; }
.pot-table th { background: var(--card2); font-weight: 700; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; position: relative; }
.pot-th { display: flex; align-items: center; }
.pot-th .pot-cell { flex: 1; padding: 8px 22px; outline: none; text-align: center; }
.pot-table td.pot-cell { padding: 8px 10px; outline: none; color: var(--ink); text-align: center; }
.pot-table .pot-cell:focus { background: var(--soft); box-shadow: inset 0 0 0 2px var(--rose); }
.pot-delcol { position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 6px; visibility: hidden; }
.pot-table th:hover .pot-delcol { visibility: visible; }
.pot-delcol:hover { color: var(--bad); }
.pot-table .pot-rowdel { min-width: 30px; width: 30px; text-align: center; border-left: none; background: transparent; border-color: transparent; }
.pot-rowdel button { border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px 7px; visibility: hidden; }
.pot-table tr:hover .pot-rowdel button { visibility: visible; }
.pot-rowdel button:hover { color: var(--bad); }
.pot-table .pot-sum { padding: 8px 10px; font-weight: 700; color: var(--plum); background: var(--card2); outline: none; }
.pot-table .pot-sum.auto { font-style: italic; }   /* computed column sum (cleared cells fall back to it) */
.pot-grand-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.pg-name { font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-val { min-width: 120px; text-align: right; padding: 6px 10px; border-radius: 8px; font-weight: 700; color: var(--plum); outline: none; }
.pg-val:focus { background: var(--soft); box-shadow: inset 0 0 0 2px var(--rose); }
.pg-val.auto { font-style: italic; }
.pot-grand-total { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; font-size: 15px; font-weight: 600; color: var(--muted); }
.pot-grand-total b { color: var(--plum); font-size: 18px; }

/* ============================ 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: calc(54px + env(safe-area-inset-top));
    flex-direction: row; align-items: center; gap: 8px; padding: env(safe-area-inset-top) 12px 0; z-index: 50;
  }
  /* 16px inputs stop iOS from auto-zooming when a field is focused */
  input, select, textarea { font-size: 16px; }
  .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: calc(58px + env(safe-area-inset-bottom)); flex: none;
    flex-direction: row; justify-content: space-around; gap: 0; padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    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); }
  /* keep the bottom tab bar dark in dark mode (its default bg var flips light) */
  [data-theme="dark"] .side-nav { background: #232e34; }

  /* 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: calc(64px + env(safe-area-inset-top)) 14px calc(82px + env(safe-area-inset-bottom)); 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: 8px; left: 8px; width: auto; bottom: calc(74px + env(safe-area-inset-bottom)); height: min(70vh, 540px); }
  .chat-fab { right: 16px; bottom: calc(74px + env(safe-area-inset-bottom)); width: 54px; height: 54px; }
  .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-facts .fact > span { white-space: normal; }   /* let long values wrap on phones */
  .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: 23px; letter-spacing: -.2px; }
  .kpi-value { font-size: 25px; }
}
