/* ============================================================
   StackDaddy — design system
   Light + dark, Inter, tabular figures, soft elevation.
   ============================================================ */

:root {
  /* Brand */
  --brand: #5b5bf0;
  --brand-600: #4a47e0;
  --brand-700: #3d39c4;
  --brand-soft: #eceaff;
  --brand-grad: linear-gradient(135deg, #6d6bff 0%, #8a5bf0 100%);

  /* Semantic */
  --pos: #0e9f6e;
  --pos-soft: #e3f6ee;
  --neg: #e5484d;
  --neg-soft: #fdeaea;
  --warn: #b7791f;
  --warn-soft: #fbf2e0;

  /* Neutrals (light) */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --surface-3: #eceef4;
  --line: #e7e9f0;
  --line-strong: #d6d9e3;
  --text: #15171f;
  --text-2: #5a6072;
  --text-3: #767d92; /* bumped for WCAG contrast */

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, .05), 0 1px 3px rgba(20, 23, 31, .04);
  --shadow-md: 0 4px 12px rgba(20, 23, 31, .07), 0 2px 4px rgba(20, 23, 31, .04);
  --shadow-lg: 0 16px 40px rgba(20, 23, 31, .12), 0 4px 12px rgba(20, 23, 31, .06);
  --ring: 0 0 0 3px rgba(91, 91, 240, .18);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  --ease: cubic-bezier(.4, 0, .2, 1);
  /* motion system — one set of springs & durations everything obeys */
  --spring: cubic-bezier(.22, 1, .36, 1);        /* smooth settle */
  --spring-back: cubic-bezier(.34, 1.56, .64, 1); /* gentle overshoot */
  --dur-1: .16s; --dur-2: .3s; --dur-3: .5s;
  --glow: 0 8px 30px color-mix(in srgb, var(--brand) 40%, transparent);
}

/* manual dark (Settings → Appearance) */
:root[data-theme="dark"] {
  --brand: #8b8bff;
  --brand-600: #9d9dff;
  --brand-700: #b3b3ff;
  --brand-soft: #211f3d;
  --pos: #3ddc97;
  --pos-soft: #11271f;
  --neg: #ff6b6f;
  --neg-soft: #2a1416;
  --warn: #f0c25c;
  --warn-soft: #2a2310;
  --bg: #0c0d12;
  --surface: #14161d;
  --surface-2: #1a1d26;
  --surface-3: #222530;
  --line: #262a35;
  --line-strong: #353a48;
  --text: #eef0f6;
  --text-2: #a3a9ba;
  --text-3: #8189a0; /* bumped for WCAG contrast */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(139, 139, 255, .25);
}

/* system dark (unless the user forced light) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #8b8bff;
    --brand-600: #9d9dff;
    --brand-700: #b3b3ff;
    --brand-soft: #211f3d;
    --pos: #3ddc97;
    --pos-soft: #11271f;
    --neg: #ff6b6f;
    --neg-soft: #2a1416;
    --warn: #f0c25c;
    --warn-soft: #2a2310;
    --bg: #0c0d12;
    --surface: #14161d;
    --surface-2: #1a1d26;
    --surface-3: #222530;
    --line: #262a35;
    --line-strong: #353a48;
    --text: #eef0f6;
    --text-2: #a3a9ba;
    --text-3: #8189a0; /* bumped for WCAG contrast */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    --ring: 0 0 0 3px rgba(139, 139, 255, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(138, 91, 240, .07), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, rgba(91, 91, 240, .06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.tnum { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
header.app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* keep the header clear of the status bar (time/battery) on ALL sizes —
     iPads in standalone PWA mode are wider than the old mobile breakpoint,
     so the inset must apply here, not just on phones */
  padding: calc(14px + env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 14px max(22px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand .logo {
  width: 38px; height: 38px; display: grid; place-items: center;
  color: var(--brand);          /* the mark inherits this — recolours with the theme */
}
.brand .logo img { width: 100%; height: 100%; display: block; }
/* The mark is the original Daddy artwork used as an alpha mask, painted with
   currentColor — full line-art fidelity, transparent, and it re-themes itself. */
.sd-mark {
  display: block; width: 100%; height: 100%;
  background-color: currentColor;
  -webkit-mask: url(/icons/logo-mask.png?v=52) center / contain no-repeat;
          mask: url(/icons/logo-mask.png?v=52) center / contain no-repeat;
}
.sd-mark.gate { width: 84px; height: 84px; margin: 0 auto; color: var(--brand); }
.brand .logo i { font-size: 17px; }

.who { display: flex; align-items: center; gap: 10px; }
.who .me {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text-2);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #fff;
  background: var(--brand-grad);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
  flex: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.muted { background: linear-gradient(135deg, #9aa0b3, #767c90); }

/* ---------- layout ---------- */
main { max-width: 960px; margin: 0 auto; padding: 26px 22px 60px; }

.grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid.two { grid-template-columns: 1.05fr .95fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.card h3 {
  margin: 22px 0 10px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-3);
}

/* ---------- hero net summary ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  padding: 26px 28px;
  margin-bottom: 22px;
  color: #fff;
  /* aurora mesh: layered radial blobs that drift, over the brand gradient */
  background:
    radial-gradient(60% 90% at 12% 10%, rgba(255, 120, 220, .55), transparent 60%),
    radial-gradient(55% 80% at 92% 20%, rgba(90, 200, 255, .5), transparent 60%),
    radial-gradient(70% 90% at 70% 110%, rgba(150, 110, 255, .6), transparent 65%),
    var(--brand-grad);
  background-size: 200% 200%, 200% 200%, 200% 200%, 100% 100%;
  animation: aurora 18s var(--ease) infinite alternate;
  box-shadow: var(--shadow-md), var(--glow);
}
@keyframes aurora {
  0%   { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
  100% { background-position: 40% 30%, 60% 20%, 30% 70%, 0 0; }
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(420px 200px at 88% -40%, rgba(255, 255, 255, .3), transparent 70%);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { .hero { animation: none; } }
.hero .label { font-size: 13px; opacity: .85; margin: 0 0 4px; }
.hero .big { font-size: 46px; font-weight: 800; letter-spacing: -.035em; margin: 2px 0 0; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 2px 20px rgba(0,0,0,.15); }
.hero .sub { font-size: 13px; opacity: .85; margin: 8px 0 0; position: relative; }
.hero .chips { display: flex; gap: 8px; margin-top: 16px; position: relative; flex-wrap: wrap; }
.hero .chip {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--r-pill);
  padding: 5px 12px; font-size: 12.5px; font-weight: 500;
  backdrop-filter: blur(6px);
}

/* ---------- forms ---------- */
label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-2); margin: 12px 0 5px;
}
input, select, textarea {
  width: 100%;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
/* iOS date inputs have a stubborn intrinsic width — make them behave like the others */
input[type="date"] {
  -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 100%; display: block;
  min-height: 44px; text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--ring); }
select { cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- buttons ---------- */
button {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 11px 16px;
  transition: transform .08s var(--ease), border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
button:hover { border-color: var(--text-3); background: var(--surface-2); }
button:active { transform: scale(.97); }
button:focus-visible { box-shadow: var(--ring); }

button.primary {
  color: #fff; border: none;
  background: var(--brand-grad);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .2);
  font-weight: 600;
  width: 100%; padding: 12px 16px;
  transition: transform var(--dur-1) var(--spring-back), box-shadow var(--dur-2) var(--ease), filter var(--dur-1) var(--ease);
}
button.primary:hover { filter: brightness(1.06); box-shadow: var(--shadow-md), var(--glow); }
button.primary:active { transform: scale(.97); }
button.ghost { background: transparent; }
button.small { padding: 7px 12px; font-size: 13px; border-radius: var(--r-sm); }
button.danger:hover { border-color: var(--neg); color: var(--neg); background: var(--neg-soft); }

/* segmented toggle (split equally / all mine) */
.seg { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 4px; }
.seg button { border: none; background: transparent; padding: 6px 14px; border-radius: var(--r-pill); font-size: 13px; color: var(--text-2); box-shadow: none; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg button:hover { background: var(--surface); }

/* ---------- split & payer rows ---------- */
.split-rows { display: flex; flex-direction: column; gap: 8px; }
.split-row {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .15s var(--ease);
}
.split-row:hover { border-color: var(--line-strong); }
.split-row .name { flex: 1; font-size: 14px; }
.split-row input { width: 96px; flex: none; background: var(--surface); }
.split-row .pname { flex: 1; width: auto; }
.split-row .pamt { width: 110px; flex: none; }
.split-row .chk { width: 18px; height: 18px; flex: none; accent-color: var(--brand); cursor: pointer; }

.split-row .sval { width: 78px; flex: none; background: var(--surface); text-align: right; }
.split-row .owedout { width: 76px; flex: none; text-align: right; font-size: 13px; color: var(--text-2); font-weight: 500; }
.expense .right .conv { font-size: 11px; color: var(--text-3); }
.expense .exp-actions { display: flex; gap: 4px; }
/* desktop: actions appear on hover; touch keeps them visible */
@media (hover: hover) and (pointer: fine) {
  .expense .exp-actions { opacity: 0; transition: opacity .15s var(--ease); }
  .expense:hover .exp-actions, .expense:focus-within .exp-actions { opacity: 1; }
}

/* activity timeline */
.act-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.act-row:last-child { border-bottom: none; }
.act-icon { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--pos-soft); color: var(--pos); font-size: 16px; }
.act-main { flex: 1; min-width: 0; }
.act-title { font-size: 14px; }
.act-meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* people modal rows */
.person-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.person-row:last-child { border-bottom: none; }
.person-row .pr-name { flex: 1; min-width: 0; }
.person-row .pr-email { flex: 1.2; min-width: 0; }
.person-row .pr-save { flex: none; }

/* receipt field */
.receipt-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.receipt-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); cursor: pointer; }

/* favorites chips */
.favorites { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.favorites:empty { display: none; }
.fav-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); padding: 7px 8px 7px 14px; font-size: 13px;
}
.fav-chip .fav-x { color: var(--text-3); border-radius: 50%; padding: 2px 5px; line-height: 1; }
.fav-chip .fav-x:hover { color: var(--neg); background: var(--neg-soft); }
.fav-chip .fav-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
#splitHint { font-size: 12.5px; margin-top: 8px; display: flex; align-items: center; gap: 6px; font-weight: 500; }

/* ---------- balances ---------- */
.balance {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.balance:last-child { border-bottom: none; }
.balance .person { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.amt { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.amt.pos { color: var(--pos); }
.amt.neg { color: var(--neg); }
.amt.zero { color: var(--text-3); font-weight: 500; }

.owe-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; margin-bottom: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 13.5px; color: var(--text-2);
}
.owe-line:last-child { margin-bottom: 0; }
.owe-line b { color: var(--text); font-weight: 600; }
.owe-line .settle-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.owe-line .settle-cur { font-size: 12px; color: var(--text-3); }
.owe-line .settle-amt { width: 84px; flex: none; text-align: right; padding: 7px 9px; background: var(--surface); }

/* ---------- expense list ---------- */
.expense {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: 9px; background: var(--surface);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease);
}
.expense:last-child { margin-bottom: 0; }
.expense:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.expense .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.expense .title { font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; }
.expense .meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.expense .meta.note { color: var(--text-3); font-style: italic; }
.expense .meta.note i { vertical-align: -2px; margin-right: 2px; font-style: normal; }
.expense .right { text-align: right; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.expense .right .val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand-700);
  vertical-align: 1px;
}

/* ---------- expenses: monthly view ---------- */
.exp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; row-gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.exp-head .seg button { padding: 6px 13px; font-size: 12.5px; }

/* search & filter bar */
.exp-filter { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.exp-filter input[type="search"] { flex: 1 1 180px; min-width: 150px; }
.exp-filter select { flex: none; width: auto; max-width: 170px; }
.exp-filter #expFilterClear { flex: none; }

/* spend bar chart (Trends) */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 184px; padding-top: 8px; overflow-x: auto; }
.bar-col { flex: 1; min-width: 26px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar { width: 62%; max-width: 34px; background: var(--brand); border-radius: 6px 6px 0 0; transition: height .35s var(--ease); }
.bar.now { background: var(--brand-grad); }
.bar-val { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-lbl { font-size: 11px; color: var(--text-2); }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 14px; }
.month-nav .month-label { font-weight: 600; font-size: 14px; min-width: 150px; text-align: center; }
.month-nav button[disabled] { opacity: .4; cursor: default; }
.month-nav button[disabled]:hover { background: var(--surface); border-color: var(--line-strong); }

.period {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 14px;
}
.period-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.period-lbl { font-size: 12px; color: var(--text-2); }
.period-total { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.period-share { text-align: right; }
.period-share .tnum { font-size: 16px; }

.cats { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.cat-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.cat-name { width: 116px; flex: none; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-ico { margin-right: 6px; font-size: 14px; vertical-align: -2px; color: hsl(var(--ch) 65% 48%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cat-ico { color: hsl(var(--ch) 70% 65%); } }
:root[data-theme="dark"] .cat-ico { color: hsl(var(--ch) 70% 65%); }

/* colored category pills */
.pill.cat { background: hsl(var(--ch) 75% 50% / .13); color: hsl(var(--ch) 65% 36%); border: 1px solid hsl(var(--ch) 70% 50% / .3); }
.pill.cat i { font-size: 11.5px; margin-right: 3px; vertical-align: -1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.cat { color: hsl(var(--ch) 75% 72%); background: hsl(var(--ch) 70% 55% / .16); } }
:root[data-theme="dark"] .pill.cat { color: hsl(var(--ch) 75% 72%); background: hsl(var(--ch) 70% 55% / .16); }

/* day group headers in the expense list */
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 16px 3px 7px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
}
.day-head:first-child { margin-top: 2px; }
.day-head .tnum { font-weight: 600; letter-spacing: 0; }
.cat-bar { flex: 1; height: 7px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.cat-bar > span { display: block; height: 100%; background: var(--brand-grad); border-radius: var(--r-pill); }
.cat-bar > span.warn { background: linear-gradient(90deg, #f2a516, #ed7014); }
.cat-bar > span.over { background: linear-gradient(90deg, var(--neg), #c53035); }
.cat-amt { width: 78px; flex: none; text-align: right; color: var(--text); font-weight: 500; }
.bud-amt { flex: none; text-align: right; color: var(--text); font-weight: 500; white-space: nowrap; }
@media (max-width: 560px) { .bud-amt .muted { display: none; } }

.pending-line { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.pending-line b { color: var(--text); }
.pending-line.ok { color: var(--text-3); }
.pending-line i { vertical-align: -2px; margin-right: 4px; }
.pending-line .amt { font-size: 13px; }

/* months overview (Summary view) */
.month-row {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px;
  margin-bottom: 8px; background: var(--surface); cursor: pointer;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease);
}
.month-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.month-row:active { transform: scale(.99); }
.month-row .mr-name { font-weight: 600; font-size: 14.5px; }
.month-row .mr-sub { font-size: 12.5px; margin-top: 2px; }
.month-row .mr-sub .amt { font-size: 12.5px; }
.month-row .mr-bar { height: 5px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; margin-top: 8px; max-width: 220px; }
.month-row .mr-bar > span { display: block; height: 100%; background: var(--warn); border-radius: var(--r-pill); }
.month-row .mr-right { text-align: right; white-space: nowrap; }
.month-row .mr-spent { font-weight: 700; font-size: 15px; }
.month-row .mr-pending { font-size: 12px; margin-top: 2px; }
.month-row .mr-pending.warn { color: var(--warn); }
.month-row .mr-pending.ok { color: var(--text-3); }

/* ---------- quick-add bar ---------- */
.quick-add {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 8px 8px 8px 14px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.quick-add i { font-size: 18px; color: var(--brand); flex: none; }
.quick-add input { border: none; background: transparent; padding: 8px 4px; box-shadow: none; font-size: 14.5px; }
.quick-add input:focus { box-shadow: none; }
.quick-add button { flex: none; }
#quickMic.listening { color: var(--neg); border-color: var(--neg); animation: micpulse 1s var(--ease) infinite; }
@keyframes micpulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.quick-split { display: flex; gap: 8px; margin-bottom: 12px; }
.quick-split button { padding: 6px 12px; }

/* import picker (cards) */
.import-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 10px; font-size: 13px; }
.chk-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); cursor: pointer; }
.chk-label input { width: auto; accent-color: var(--brand); }
#txPreview { margin-left: auto; }
.tx-list { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow-y: auto; }
.tx-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; background: var(--surface); }
.tx-card.dupe { opacity: .65; }
.tx-card .txc { width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.tx-card .tx-main { flex: 1; min-width: 0; }
.tx-card .tx-desc { width: 100%; border: none; background: transparent; padding: 2px 0; font-size: 14px; font-weight: 500; box-shadow: none; }
.tx-card .tx-desc:focus { box-shadow: none; }
.tx-card .tx-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.tx-card .tx-date { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.tx-card .tx-cat { width: 118px; flex: none; padding: 4px 8px; font-size: 12px; background: var(--surface-2); border-radius: var(--r-sm); }
.tx-card .tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-card .tx-amt.in { color: var(--pos); }
.tx-card .tx-group { width: 150px; flex: none; padding: 7px 9px; font-size: 12.5px; background: var(--surface-2); }
.tx-card.assigned { border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-soft); }
.tx-card .warnpill { background: var(--warn-soft); color: var(--warn); }
.tx-card .pospill { background: var(--pos-soft); color: var(--pos); }
.import-modal { max-width: 720px; }
@media (max-width: 560px) {
  .tx-card { flex-wrap: wrap; }
  .tx-card .tx-main { flex-basis: 100%; order: 1; }
  .tx-card .tx-amt { order: 2; }
  .tx-card .tx-group { order: 3; margin-left: auto; }
}

.map-panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; margin-bottom: 12px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.map-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.map-grid select { font-size: 13px; }

/* ---------- mobile ---------- */
@media (max-width: 560px) {
  main { padding: 16px 13px 56px; }
  header.app { padding: calc(11px + env(safe-area-inset-top)) max(13px, env(safe-area-inset-right)) 11px max(13px, env(safe-area-inset-left)); gap: 8px; }
  .who { gap: 7px; }
  #whoami .txt { display: none; } /* avatar-only chip on phones */
  .brand { font-size: 16px; }
  .tabbar { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
  .tabbar button { white-space: nowrap; flex: none; padding: 8px 13px; }
  .seg { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; }
  .hero { padding: 18px 18px; } .hero .big { font-size: 30px; }
  .card { padding: 16px; }
  .tx-card .tx-cat { width: 96px; }
}
@media (max-width: 480px) {
  .row { flex-wrap: wrap; }
  .row > * { flex-basis: 140px; }
  .row > .full { flex-basis: 100%; } /* payers editor takes the whole line */
}
@media (max-width: 560px) {
  .quick-split { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .quick-split::-webkit-scrollbar { display: none; }
  .quick-split button { white-space: nowrap; flex: none; }
  .seg button { flex: none; }
  #payersEditor .split-row .pay { width: 96px; }
  .sheet { padding-left: 16px; padding-right: 16px; }
}

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--r-lg);
  padding: 38px 26px; text-align: center; color: var(--text-2);
  transition: .18s var(--ease); cursor: pointer; background: var(--surface-2);
}
.dropzone .dz-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  display: grid; place-items: center; font-size: 26px;
  background: var(--brand-soft); color: var(--brand);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.dropzone.drag { transform: scale(1.01); }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
thead th {
  color: var(--text-3); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  position: sticky; top: 0; background: var(--surface);
}
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
input[type="checkbox"] { accent-color: var(--brand); }

/* ---------- tabs ---------- */
.tabbar {
  display: inline-flex; gap: 4px; margin-bottom: 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 5px; box-shadow: var(--shadow-sm);
}
.tabbar button {
  border: none; background: transparent; box-shadow: none;
  padding: 9px 16px; border-radius: var(--r-pill); font-size: 13.5px;
  color: var(--text-2); display: inline-flex; align-items: center; gap: 7px;
}
.tabbar button i { font-size: 16px; }
.tabbar button:hover { background: var(--surface-2); }
.tabbar button.active { background: var(--brand-grad); color: #fff; font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- misc ---------- */
.muted { color: var(--text-2); }
.empty {
  color: var(--text-3); text-align: center; padding: 30px 20px; font-size: 14px;
}
.empty i { display: block; font-size: 30px; margin-bottom: 10px; color: var(--line-strong); }
.hidden { display: none !important; }
.no-scroll { overflow: hidden; }

/* view switches ease in instead of snapping */
#view-group:not(.hidden), #view-groups:not(.hidden) { animation: viewin .22s var(--ease); }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

button[disabled] { opacity: .55; cursor: default; pointer-events: none; }

/* ---------- responsive: tablet & mobile ---------- */
.exp-card { margin-top: 18px; }

/* tablet / desktop: balances beside expenses */
@media (min-width: 940px) {
  .track-cols { display: grid; grid-template-columns: 2fr 3fr; gap: 18px; align-items: start; }
  .track-cols > .exp-card { margin-top: 0; }
}

/* touch niceties */
body { -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .exp-actions button, .month-nav button, .chip-x { min-width: 38px; min-height: 34px; }
  .tabbar { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
}

/* phones: stop iOS focus-zoom, respect the notch */
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; }
  /* header top/side insets are handled globally on header.app now */
  main {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .fab { right: max(18px, env(safe-area-inset-right)); }
  .me-chip .me span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal { max-height: 88dvh; overflow-y: auto; }
}

/* ---------- add-expense sheet + FAB + bottom nav ---------- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / .45);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px); animation: fadein .18s var(--ease);
}
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; max-height: 90dvh;
  overflow-y: auto; overflow-x: hidden; padding: 8px 20px 26px; border-radius: 20px 20px 0 0;
  border: 1px solid var(--line); border-bottom: none;
  padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 18px));
  animation: sheetup .28s var(--ease);
}
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 6px auto 12px; }
@keyframes sheetup { from { transform: translateY(48px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 721px) {
  .sheet-overlay { align-items: center; padding: 28px; }
  .sheet { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); max-height: 86vh; }
  .sheet-handle { display: none; }
}

.fab {
  position: fixed; right: 18px; bottom: 24px; width: 60px; height: 60px; z-index: 55;
  border: none; border-radius: 50%; background: var(--brand-grad); color: #fff;
  font-size: 27px; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 10px 28px rgb(0 0 0 / .32);
  transition: transform .18s var(--ease), filter .15s var(--ease);
}
/* keep the gradient no matter the state — `button:hover` used to win here and
   repaint the FAB with --surface-2 (white), which then stuck on touch devices */
.fab, .fab:hover, .fab:focus, .fab:focus-visible, .fab:active, .fab.open {
  background: var(--brand-grad); color: #fff; border: none;
}
.fab:hover { filter: brightness(1.08); transform: translateY(-1px); }
.fab:active { filter: brightness(.96); transform: scale(.94); }
.fab:focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 40%, transparent), 0 10px 28px rgb(0 0 0 / .32); }
@media (hover: none) {                       /* no sticky hover after a tap */
  .fab:hover { filter: none; transform: none; }
}
.fab.open { transform: rotate(135deg); }

/* speed-dial menu above the FAB */
.fab-menu {
  position: fixed; right: 18px; bottom: 96px; z-index: 56;
  display: flex; flex-direction: column; align-items: flex-end; gap: 9px;
}
.fab-menu button {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-pill); padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); cursor: pointer;
  animation: fabitem .22s var(--ease) both;
}
.fab-menu button:nth-child(1) { animation-delay: .06s; }
.fab-menu button:nth-child(2) { animation-delay: .04s; }
.fab-menu button:nth-child(3) { animation-delay: .02s; }
.fab-menu button i { color: var(--brand); font-size: 17px; }
.fab-menu button:hover { border-color: var(--brand); }
@keyframes fabitem { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }

.bottom-nav { display: none; }
.more-menu {
  position: fixed; right: 12px; bottom: 70px; z-index: 56; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column;
  animation: sheetup .18s var(--ease);
}
.more-menu button { background: none; border: none; text-align: left; padding: 11px 12px; border-radius: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.more-menu button:hover { background: var(--surface-2); }
.more-menu button i { margin-right: 8px; vertical-align: -2px; color: var(--text-2); }

@media (max-width: 720px) {
  body.in-group .tabbar { display: none; }
  body.in-group .bottom-nav {
    position: fixed; left: 14px; right: 14px; z-index: 50; display: flex; gap: 4px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 6px;
    box-shadow: var(--shadow-lg);
  }
  .bottom-nav button {
    flex: 1; background: none; border: 1px solid transparent; border-radius: var(--r-pill); cursor: pointer;
    padding: 7px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10.5px; font-weight: 600; color: var(--text-3);
    transition: background .18s var(--ease), color .18s var(--ease);
  }
  .bottom-nav button i { font-size: 20px; }
  .bottom-nav button:hover, .bottom-nav button:focus { background: none; border-color: transparent; }
  .bottom-nav button.active {
    color: var(--brand);
    background: var(--brand-soft);
    border-color: color-mix(in srgb, var(--brand) 35%, transparent);
  }
  body.in-group main { padding-bottom: 108px; }
  body.in-group #fabAdd { bottom: calc(88px + env(safe-area-inset-bottom)); }
  body.in-group #fabMenu { bottom: calc(158px + env(safe-area-inset-bottom)); }
  body.in-group .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(16px) scale(.96);
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--surface);
  border-radius: var(--r-pill); padding: 12px 20px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 80;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--spring-back); pointer-events: none;
  display: flex; align-items: center; gap: 9px; overflow: hidden;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); pointer-events: auto; }
.toast.err { background: var(--neg); color: #fff; }
/* undo countdown bar */
.toast.action::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2.5px; width: 100%;
  background: currentColor; opacity: .45; transform-origin: left;
  animation: toastbar 5.2s linear forwards;
}
@keyframes toastbar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast-act {
  background: rgb(255 255 255 / .18); color: inherit; border: none; cursor: pointer;
  border-radius: var(--r-pill); padding: 5px 13px; font-size: 12.5px; font-weight: 700; margin-left: 2px;
}
.toast-act:hover { background: rgb(255 255 255 / .3); }

/* swipe-to-delete (touch) */
.exp-swipe { position: relative; margin-bottom: 9px; }
.exp-swipe .expense { margin-bottom: 0; position: relative; z-index: 1; }
.exp-under {
  position: absolute; inset: 0; z-index: 0; display: flex; justify-content: flex-end;
  background: var(--neg); border-radius: var(--r-md); overflow: hidden;
}
.exp-under button { background: none; border: none; color: #fff; width: 84px; font-size: 20px; cursor: pointer; }

/* skeleton shimmer */
.skel {
  border-radius: var(--r-md); margin-bottom: 9px;
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%; animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* confetti */
.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; height: 13px; width: 8px; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(660deg); } }

/* ---------- auth gate (Clerk) ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(138, 91, 240, .12), transparent 60%),
    radial-gradient(800px 400px at -10% 0%, rgba(91, 91, 240, .1), transparent 55%),
    var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-box { text-align: center; max-width: 420px; width: 100%; }
.auth-box h1 { margin: 14px 0 4px; font-size: 24px; letter-spacing: -.02em; }
.auth-box > p { margin: 0 0 22px; }
#clerkSignIn { display: flex; justify-content: center; }

/* settings: account card */
.account-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px;
}
.account-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.account-img { border-radius: 50%; flex: none; }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* update banner */
.install-bar.update { border-color: color-mix(in srgb, var(--brand) 55%, transparent); }
.install-bar.update i { color: var(--brand); }

/* people modal: group membership editor */
.pm-h { margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.member-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.member-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 5px 7px 5px 6px;
}
.member-chip .chip-x {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  padding: 2px; font-size: 13px; border-radius: 50%; display: grid; place-items: center;
}
.member-chip .chip-x:hover { color: var(--neg); background: var(--neg-soft); }

/* ---------- finance health (stats) ---------- */
.stats-overlay {
  position: fixed; inset: 0; z-index: 70; overflow-y: auto;
  background: rgb(0 0 0 / .45); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px 40px;
  animation: fadein .18s var(--ease);
}
.stats-panel {
  width: 100%; max-width: 780px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 20px;
}
.stats-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stats-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.stats-head h2 i { color: var(--brand); }
.stats-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.stats-filters select, .stats-filters input { width: auto; flex: 1 1 150px; min-width: 130px; }
.stats-filters #stClear { flex: none; }

.stat-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--brand-grad); color: #fff; border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 14px;
}
.stat-hero-lbl { font-size: 12.5px; opacity: .9; }
.stat-hero-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; }
.stat-hero-sub { font-size: 12.5px; opacity: .92; }
.stat-hero-sub .amt { color: #fff; background: rgb(255 255 255 / .18); border-radius: var(--r-pill); padding: 2px 9px; font-weight: 600; }
@property --sc { syntax: "<number>"; initial-value: 0; inherits: false; }
.health-ring {
  --sc: 0; flex: none; width: 88px; height: 88px; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--sc) * 1%), rgb(255 255 255 / .25) 0);
  display: grid; place-items: center;
  transition: --sc 1.1s var(--spring);
}
.stat-hero { animation: rise var(--dur-2) var(--spring) both; }
.donut { animation: donutin var(--dur-3) var(--spring) both; }
@keyframes donutin { from { opacity: 0; transform: rotate(-28deg) scale(.85); } to { opacity: 1; transform: none; } }
.stat-kpis .kpi { animation: rise var(--dur-2) var(--spring) both; }
.stat-kpis .kpi:nth-child(1) { animation-delay: .04s; }
.stat-kpis .kpi:nth-child(2) { animation-delay: .09s; }
.stat-kpis .kpi:nth-child(3) { animation-delay: .14s; }
.stat-kpis .kpi:nth-child(4) { animation-delay: .19s; }
.stat-card { animation: rise var(--dur-2) var(--spring) both; }
.stat-spark { display: block; height: 26px; margin-top: 8px; opacity: .9; }
.health-inner { width: 66px; height: 66px; border-radius: 50%; background: var(--brand-700); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.health-inner span { font-size: 26px; font-weight: 800; }
.health-inner small { font-size: 10px; color: #fff; opacity: .8; margin-top: 2px; }

.stat-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 10px; text-align: center; }
.kpi-v { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.kpi-l { font-size: 11px; color: var(--text-3); margin-top: 3px; }
@media (max-width: 560px) { .stat-kpis { grid-template-columns: repeat(2, 1fr); } .stat-hero-big { font-size: 28px; } }

.stat-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-bottom: 14px; }
.stat-card h3 { margin: 0 0 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.stat-note { margin: 0; font-size: 14px; line-height: 1.55; }
.stat-persona {
  display: flex; align-items: center; gap: 8px; margin: -4px 0 14px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: var(--r-md); padding: 11px 14px;
}
.stat-persona i { color: var(--brand); font-size: 16px; flex: none; }
.big-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.big-row:last-child { border-bottom: none; }

/* trends: category donut */
.cat-flex { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.donut {
  width: 156px; height: 156px; border-radius: 50%; flex: none;
  display: grid; place-items: center; margin: 0 auto;
}
.donut-hole {
  width: 100px; height: 100px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  box-shadow: inset 0 0 0 1px var(--line);
}
.donut-hole small { font-weight: 500; font-size: 10.5px; color: var(--text-3); margin-top: 1px; }

/* group-card sparkline */
.gc-net .spark { display: block; width: 78px; height: 28px; margin: 0 0 6px auto; }

/* staggered card entrance */
#groupList .group-card { animation: cardin var(--dur-2) var(--spring) both; }
#groupList .group-card:nth-child(1) { animation-delay: .02s; }
#groupList .group-card:nth-child(2) { animation-delay: .06s; }
#groupList .group-card:nth-child(3) { animation-delay: .10s; }
#groupList .group-card:nth-child(4) { animation-delay: .14s; }
#groupList .group-card:nth-child(5) { animation-delay: .18s; }
#groupList .group-card:nth-child(6) { animation-delay: .22s; }
#groupList .group-card:nth-child(n+7) { animation-delay: .26s; }
@keyframes cardin { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #groupList .group-card { animation: none; } }

/* printable statement */
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; font: 12px/1.5 Georgia, serif; color: #000; }
  #printArea h1 { font-size: 20px; margin: 0 0 2px; }
  #printArea .sub { color: #555; margin: 0 0 16px; }
  #printArea table { width: 100%; border-collapse: collapse; }
  #printArea th, #printArea td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #ddd; }
  #printArea th { border-bottom: 2px solid #000; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
  #printArea .r { text-align: right; font-variant-numeric: tabular-nums; }
  #printArea h3 { margin: 18px 0 6px; }
  #printArea .foot { margin-top: 24px; color: #777; font-style: italic; }
}

/* subscription suggestions */
.sub-sugg {
  background: var(--brand-soft); border: 1px dashed color-mix(in srgb, var(--brand) 40%, transparent);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 14px;
}

/* debt aging chips */
.age {
  display: inline-block; font-size: 10.5px; font-weight: 600; vertical-align: 1px;
  background: var(--warn-soft); color: var(--warn);
  border-radius: var(--r-pill); padding: 2px 8px; margin-left: 5px;
}
.age.old { background: var(--neg-soft); color: var(--neg); }

/* Daddy's shortcut toggle */
.simplify-line {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2);
  margin-bottom: 10px; cursor: pointer;
}
.simplify-line i { color: var(--brand); font-size: 15px; }

/* ---------- what's-new dot + changelog modal ---------- */
#whatsNew { position: relative; }
#whatsNew.has-news::after,
#settingsBtn.has-news::after {
  content: ""; position: absolute; top: 4px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  border: 2px solid var(--surface);
}
#settingsBtn { position: relative; }

/* header identity chip (opens Settings) */
.me-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 5px 12px 5px 6px; font: inherit; font-size: 13px; color: var(--text-2);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.me-chip:hover { border-color: var(--line-strong); background: var(--surface-3); }
.me-chip .me { display: inline-flex; align-items: center; gap: 7px; }

/* settings modal about row */
.about-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
#themeSeg button i { margin-right: 4px; vertical-align: -1px; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 11, 16, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  width: min(540px, 100%); max-height: 84vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 22px;
  animation: rise .25s var(--ease) both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.cl-entry { padding: 14px 0; border-bottom: 1px solid var(--line); }
.cl-entry:last-child { border-bottom: none; }
.cl-head { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cl-ver {
  font-size: 12px; font-weight: 700; color: var(--brand-700);
  background: var(--brand-soft); border-radius: var(--r-pill); padding: 2px 9px;
  font-variant-numeric: tabular-nums;
}
.cl-notes { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13.5px; }
.cl-notes li { margin: 4px 0; }

/* ---------- install prompt bar ---------- */
.install-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  width: min(440px, calc(100vw - 28px));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 8px 8px 8px 18px;
  box-shadow: var(--shadow-lg); z-index: 70; font-size: 13.5px;
}
.install-bar span { display: flex; align-items: center; gap: 8px; }

/* ---------- entrance animation ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card, .hero { animation: rise var(--dur-2) var(--spring) both; }
.exp-swipe { animation: rise .28s var(--spring) both; }
#expenseList .exp-swipe:nth-child(1) { animation-delay: .02s; }
#expenseList .exp-swipe:nth-child(2) { animation-delay: .05s; }
#expenseList .exp-swipe:nth-child(3) { animation-delay: .08s; }
#expenseList .exp-swipe:nth-child(4) { animation-delay: .11s; }
#expenseList .exp-swipe:nth-child(5) { animation-delay: .14s; }
#expenseList .exp-swipe:nth-child(n+6) { animation-delay: .16s; }

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

/* ---------- groups home ---------- */
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.view-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

#groupList { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { #groupList { grid-template-columns: 1fr 1fr; } }

.group-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--spring-back);
}
.group-card:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.group-card:active { transform: scale(.985); }
.group-card .emoji { transition: transform var(--dur-2) var(--spring-back); }
.group-card:hover .emoji { transform: scale(1.08) rotate(-4deg); }
.group-card .drag-handle {
  flex: none; display: grid; place-items: center; width: 22px; margin: -4px 0 -4px -6px;
  color: var(--text-3); cursor: grab; touch-action: none; align-self: stretch;
}
.group-card .drag-handle:active { cursor: grabbing; }
.group-card .drag-handle i { font-size: 18px; }
.group-card.dragging { opacity: .9; box-shadow: var(--shadow-lg); border-color: var(--brand); transform: scale(1.01); }
.group-card .emoji {
  width: 46px; height: 46px; flex: none; border-radius: 13px;
  background: var(--brand-soft); display: grid; place-items: center; font-size: 24px;
}
.group-card .gc-body { flex: 1; min-width: 0; }
.group-card .gc-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.group-card .gc-meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.group-card .gc-net { text-align: right; white-space: nowrap; }
.group-card .gc-net .lbl { font-size: 11px; color: var(--text-3); }
.group-card .gc-net .val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); }
.avatar-stack .avatar:not(:first-child) { margin-left: -9px; }

/* ---------- group detail header ---------- */
.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.group-head .group-title { flex: 1; display: flex; align-items: center; gap: 11px; }
.group-head .group-title .emoji {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brand-soft);
  display: grid; place-items: center; font-size: 20px;
}
.group-head .group-title .gt-name { font-weight: 700; font-size: 18px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-head .group-title .gt-meta { font-size: 12.5px; color: var(--text-2); }
.group-head .gt-stack { margin-left: auto; flex: none; }
@media (max-width: 480px) { .group-head .gt-stack { display: none; } }

/* ---------- share portal specifics ---------- */
.portal { max-width: 460px; }
.portal .etransfer {
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-radius: var(--r-md); padding: 14px; margin: 16px 0;
}
.portal .etransfer .lbl { font-size: 11px; color: var(--brand-700); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.portal .etransfer .em { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.portal .etransfer b { font-size: 15px; color: var(--brand-700); }
.progress { height: 7px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; margin: 14px 0 4px; }
.progress > span { display: block; height: 100%; background: var(--pos); border-radius: var(--r-pill); transition: width .5s var(--ease); }

/* ---------- multiple payers ---------- */
#payersEditor .split-row .pay { width: 96px; flex: none; background: var(--surface); text-align: right; }
#payHint { font-size: 12.5px; margin-top: 6px; }

/* ---------- itemized split ---------- */
#itemsEditor { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
}
.item-row .it-desc { flex: 1 1 120px; min-width: 90px; }
.item-row .it-amt { width: 84px; flex: none; text-align: right; }
.item-row .it-people { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
.item-row .it-person {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--text-2); font-size: 11px; font-weight: 700; cursor: pointer;
  display: grid; place-items: center; opacity: .5; transition: all .12s var(--ease);
}
.item-row .it-person.active { opacity: 1; border-color: var(--brand); background: var(--brand-soft); color: var(--brand-700); }
.item-row .it-del { flex: none; }

/* ---------- archived groups ---------- */
.group-card.archived { opacity: .62; cursor: default; }
.group-card.archived:hover { transform: none; box-shadow: none; border-color: var(--line); }
.group-card.archived .gc-net button { white-space: nowrap; }
