/* Home Budget. Colours follow the old Excel workbook. */

:root {
  --navy: #172554;
  --blue: #2563EB;
  --orange: #EA580C;
  --teal: #0F766E;
  --purple: #7C3AED;
  --green: #15803D;
  --amber: #D97706;
  --red: #DC2626;
  --blue-t: #DBEAFE;
  --orange-t: #FFEDD5;
  --teal-t: #CCFBF1;
  --purple-t: #EDE9FE;
  --green-t: #DCFCE7;
  --amber-t: #FEF3C7;
  --red-t: #FEE2E2;
  --bg: #F3F5FA;
  --card: #FFFFFF;
  --ink: #172554;
  --ink2: #475569;
  --muted: #8A97AD;
  --line: #E3E8F0;
  --row: #F8FAFC;
  --shadow: 0 1px 2px rgba(23, 37, 84, .06), 0 4px 16px rgba(23, 37, 84, .06);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #3B82F6;
    --orange: #F97316;
    --teal: #14B8A6;
    --purple: #8B5CF6;
    --green: #22C55E;
    --amber: #F59E0B;
    --red: #F87171;
    --blue-t: #172A54;
    --orange-t: #3A1F10;
    --teal-t: #0D2F2C;
    --purple-t: #261A4D;
    --green-t: #0F2E1C;
    --amber-t: #33270B;
    --red-t: #3A1414;
    --bg: #0A0F1E;
    --card: #121A2D;
    --ink: #E6EBF5;
    --ink2: #A8B4C8;
    --muted: #66748C;
    --line: #222D44;
    --row: #0F1627;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

/* --- Top bar ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  /* lines the brand and menu up with the page edges below */
  padding: 10px max(var(--gutter), env(safe-area-inset-right), calc((100% - var(--page)) / 2 + var(--gutter)))
    10px max(var(--gutter), env(safe-area-inset-left), calc((100% - var(--page)) / 2 + var(--gutter)));
  background: color-mix(in srgb, var(--navy) 94%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 4px; margin-left: auto; }

.nav a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 10px;
  color: #C7D2FE;
  font-weight: 600;
  font-size: 14px;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255, 255, 255, .14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }

/* --- Page --------------------------------------------------------------- */

/* Uses nearly all of a big monitor; only past 1920px does space appear at the sides */
:root { --page: 1920px; --gutter: clamp(20px, 2vw, 40px); }

.view {
  max-width: var(--page);
  margin: 0 auto;
  padding: 22px var(--gutter) 64px;
}

.loading { color: var(--muted); text-align: center; padding: 80px 0; }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 26px 28px;
  margin-bottom: 20px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(124, 58, 237, .55) 0%, transparent 55%),
    radial-gradient(90% 120% at 0% 100%, rgba(37, 99, 235, .55) 0%, transparent 60%),
    var(--navy);
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; line-height: 1.15; }
.hero p { margin: 6px 0 0; color: #C7D2FE; }
.hero .hero-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero .hero-row > :first-child { flex: 1 1 260px; }

.month-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .1);
  border-radius: 14px;
  padding: 5px;
}
.month-switch select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  padding: 6px 8px;
  text-align: center;
  cursor: pointer;
}
.month-switch select option { color: #172554; }
.month-switch button, .hero .ghost {
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.month-switch button:hover, .hero .ghost:hover { background: rgba(255, 255, 255, .22); }
.hero .ghost {
  width: auto;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  text-decoration: none;
}

/* --- KPI tiles ---------------------------------------------------------- */

.tiles {
  --n: 4;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.tiles.six { --n: 6; }
.tiles.three { --n: 3; }
@media (max-width: 1100px) { .tiles.six { --n: 3; } }

.tile {
  position: relative;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 14px 16px 15px;
  overflow: hidden;
  border-top: 4px solid var(--c);
}
.tile::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--t);
  opacity: .9;
}
.tile > * { position: relative; z-index: 1; }
.tile .label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c);
}
.tile .value {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-top: 4px;
  white-space: nowrap;
}
.tile .value.neg { color: var(--red); }
.tile .sub { font-size: 12px; color: var(--ink2); margin-top: 2px; }

.c-blue { --c: var(--blue); --t: var(--blue-t); }
.c-orange { --c: var(--orange); --t: var(--orange-t); }
.c-teal { --c: var(--teal); --t: var(--teal-t); }
.c-purple { --c: var(--purple); --t: var(--purple-t); }
.c-green { --c: var(--green); --t: var(--green-t); }
.c-amber { --c: var(--amber); --t: var(--amber-t); }
.c-navy { --c: var(--ink); --t: var(--line); }

/* --- Cards & sections --------------------------------------------------- */

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.grid2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

/* sections that fill two columns, each under the shorter one (see flow() in app.js) */
.flow, .flow-col { display: grid; gap: 20px; min-width: 0; align-content: start; }
.flow { margin-bottom: 20px; }
.flow.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.flow .card { margin-bottom: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
  min-width: 0;
}
.grid2 > .card { margin-bottom: 0; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--c, var(--navy));
  color: #fff;
}
.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  flex: 1;
}
.card-head .num {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .2);
  font-size: 12px;
  font-weight: 800;
}
.card-head .total { font-weight: 800; font-size: 15px; }
.card-head .add {
  border: 0;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.card-head .add:hover { background: rgba(255, 255, 255, .3); }
.card-body { padding: 16px; }
.card-note { padding: 10px 16px; font-size: 12.5px; color: var(--ink2); background: var(--row); border-top: 1px solid var(--line); }

.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty button { margin-top: 10px; }

/* --- Tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--row);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--row); }
tr.current td { background: var(--amber-t) !important; font-weight: 700; }
tr.done td { color: var(--muted); }
tfoot td { font-weight: 800; background: var(--row); border-top: 2px solid var(--line); border-bottom: 0; }
.r { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.neg { color: var(--red); }
.pos { color: var(--green); }

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--line);
  color: var(--ink2);
}
.chip.ahead { background: var(--green-t); color: var(--green); }
.chip.on { background: var(--blue-t); color: var(--blue); }
.chip.behind { background: var(--red-t); color: var(--red); }
.chip.plan { background: var(--amber-t); color: var(--amber); }
.chip.done { background: var(--teal-t); color: var(--teal); }
.chip.tag { background: var(--row); border: 1px solid var(--line); font-weight: 600; }

.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--purple)); }
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress-cell .bar { flex: 1; }

.plan-input {
  width: 120px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1.5px solid var(--orange);
  background: var(--orange-t);
  text-align: right;
  font-weight: 700;
}
.plan-input:focus { outline: 3px solid color-mix(in srgb, var(--orange) 30%, transparent); }

/* --- Buttons ------------------------------------------------------------ */

.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--row); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.seg { display: inline-flex; background: rgba(255, 255, 255, .15); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; color: #fff; padding: 4px 10px; border-radius: 7px; font-size: 12px; font-weight: 700; cursor: pointer; }
.seg button.on { background: #fff; color: var(--navy); }

/* --- Charts ------------------------------------------------------------- */

.chart-scroll { overflow-x: auto; padding: 8px 8px 4px; }
.chart-scroll svg { display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); }
.chart .zero { stroke: var(--ink2); stroke-opacity: .35; }
.chart .now { fill: var(--amber-t); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 16px 14px; font-size: 12.5px; color: var(--ink2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; }

.donut-wrap { display: flex; align-items: center; gap: 22px; padding: 18px; flex-wrap: wrap; justify-content: center; }
.donut-wrap svg { width: 170px; height: 170px; flex: none; }
.donut-wrap .center-big { fill: var(--ink); font-size: 17px; font-weight: 800; }
.donut-wrap .center-small { fill: var(--muted); font-size: 10.5px; }
.donut-legend { flex: 1 1 200px; display: grid; gap: 7px; font-size: 13.5px; }
.donut-legend div { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 8px; align-items: center; }
.donut-legend i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
.donut-legend .pct { color: var(--muted); font-size: 12px; min-width: 38px; text-align: right; }

.cat-bars { display: grid; gap: 10px; padding: 16px; }
.cat-bars .row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.cat-bars .bar { height: 10px; }

/* --- Goal cards (dashboard) --------------------------------------------- */

.goal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; padding: 16px; }
.goal-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: var(--row);
}
.goal-card .top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.goal-card .name { font-weight: 800; flex: 1; }
.goal-card .nums { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--ink2); margin-top: 7px; flex-wrap: wrap; }
.goal-card .bar { height: 10px; }

/* --- Quick checks ------------------------------------------------------- */

.checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.checks.six { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1000px) { .checks.six { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .checks.six { grid-template-columns: repeat(2, 1fr); } }
.checks > div { background: var(--card); padding: 14px 16px; }
.checks .k { font-size: 12px; color: var(--ink2); font-weight: 700; }
.checks .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.checks .bar { margin-top: 8px; }

.howto { margin: 0; padding: 14px 16px 16px 34px; color: var(--ink2); font-size: 14px; display: grid; gap: 6px; }

/* --- Forms & modal ------------------------------------------------------ */

.modal {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
.modal::backdrop { background: rgba(10, 15, 30, .55); backdrop-filter: blur(3px); }
.modal form { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.modal .m-head { padding: 18px 22px 6px; display: flex; align-items: center; gap: 10px; }
.modal .m-head h3 { margin: 0; font-size: 19px; flex: 1; }
.modal .m-head .x { border: 0; background: var(--row); width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 18px; color: var(--ink2); }
.modal .m-body { padding: 10px 22px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.modal .m-foot { padding: 14px 22px 20px; display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); margin-top: 6px; }
.modal .m-foot .spacer { flex: 1; }

.field { display: grid; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink2); }
.field .help { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--row);
  font-size: 15px;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid color-mix(in srgb, var(--blue) 30%, transparent); border-color: var(--blue); }
.field .check { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; color: var(--ink); }
.field .check input { width: 20px; height: 20px; flex: none; margin: 0; }

.preview {
  grid-column: 1 / -1;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--purple-t);
  color: var(--ink);
  font-size: 14px;
}
.preview b { color: var(--purple); font-size: 17px; }
.form-error { grid-column: 1 / -1; color: var(--red); font-weight: 700; font-size: 13.5px; }

/* --- Settings ----------------------------------------------------------- */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; padding: 16px; }
.settings-grid .field.full textarea { min-height: 60px; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; padding: 16px; font-size: 14px; }
.info-list dt { color: var(--ink2); font-weight: 700; }
.info-list dd { margin: 0; word-break: break-all; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 0 16px 16px; }

/* --- Toasts ------------------------------------------------------------- */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: grid; gap: 8px; }
.toast {
  background: var(--navy);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  font-weight: 600;
  font-size: 14px;
  animation: pop .18s ease-out;
}
.toast.error { background: var(--red); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.banner { background: var(--red-t); color: var(--red); border-radius: 12px; padding: 12px 16px; font-weight: 700; margin-bottom: 16px; }

/* --- Phones ------------------------------------------------------------- */

@media (max-width: 900px) {
  .grid2.wide-left { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  /* a backdrop-filter here would trap the fixed bottom tab bar inside the top bar */
  .topbar {
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--navy);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    justify-content: space-around;
    padding: 6px 6px max(8px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--navy) 96%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 8px; }
  .nav svg { width: 22px; height: 22px; }
  .view { padding: 14px 12px 100px; }
  .hero { padding: 20px; border-radius: 16px; }
  .hero h1 { font-size: 23px; }
  .tiles, .tiles.six, .tiles.three { --n: 2; gap: 10px; }
  .tiles > .tile:last-child:nth-child(odd) { grid-column: span 2; }
  .tile { padding: 12px 13px; }
  .tile .value { font-size: 19px; }
  .modal .m-body { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .toasts { left: 12px; right: 12px; bottom: 90px; }

  /* tables become stacked cards */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 700; text-align: left; }
  table.stack td.lead { font-weight: 800; font-size: 15.5px; text-align: left; }
  table.stack td.lead::before { display: none; }
  table.stack td:empty { display: none; }
  table.stack tfoot { display: block; }
  table.stack tfoot tr { display: flex; flex-wrap: wrap; gap: 4px 16px; background: var(--row); }
  table.stack tfoot td { width: auto; background: none; border: 0; }
  table.stack tfoot td::before { margin-right: 6px; }
}

/* --- Ledger, phone-only month stepper ------------------------------------ */

.head-buttons { display: flex; gap: 6px; }

.only-mobile { display: none; }

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.stepper button {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--row);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper-title { flex: 1; text-align: center; display: grid; }
.stepper-title b { font-size: 17px; }
.stepper-title span { font-size: 12px; color: var(--muted); }
.stepper-open { display: grid; place-items: center; }

@media (max-width: 760px) {
  .only-desktop { display: none; }
  .only-mobile { display: block; }
  .nav a { flex: 1; min-width: 0; padding: 6px 2px; font-size: 10px; }
  .card-head .head-buttons .add { padding: 6px 9px; }
}
.hero-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- Tap to flip "Left after saving" -------------------------------------- */

.tappable { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; transition: transform .12s ease; }
.tappable:active { transform: scale(.97); }
.tappable:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 2px; }
.tappable .label::after, .tappable .k::after { content: "\00a0⇄"; opacity: .55; }
.checks .k-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Both faces share one grid cell, so the tile is always as tall as the taller face */
.flip { display: grid; }
.flip > .face { grid-area: 1 / 1; transition: opacity .22s ease, transform .22s ease, visibility 0s; }
.flip > .face:nth-child(2), .flip.flipped > .face:nth-child(1) {
  opacity: 0;
  transform: translateY(5px);
  visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.flip.flipped > .face:nth-child(2) { opacity: 1; transform: none; visibility: visible; transition: opacity .22s ease, transform .22s ease, visibility 0s; }

/* --- Folding sections (month view) ------------------------------------------ */

/* a section opening beside a closed one shouldn't stretch the closed one */
.grid2 { align-items: start; }

.card.fold > .card-head { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.card.fold > .card-head:focus-visible { outline: 3px solid rgba(255, 255, 255, .7); outline-offset: -4px; }
.card.fold .card-head .total { font-size: 14px; white-space: nowrap; }

.chevron {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, .18);
  transition: transform .32s cubic-bezier(.2, .7, .2, 1);
}
.chevron svg { width: 16px; height: 16px; }
.card.fold.open .chevron { transform: rotate(180deg); }

.fold-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .34s cubic-bezier(.2, .7, .2, 1); }
.card.fold.open > .fold-body { grid-template-rows: 1fr; }
.fold-inner {
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility 0s linear .34s;
}
.card.fold.open .fold-inner { opacity: 1; visibility: visible; transition: opacity .3s ease .06s, visibility 0s; }

@media (prefers-reduced-motion: reduce) {
  .fold-body, .fold-inner, .chevron, .flip > .face { transition: none !important; }
}
@media (max-width: 760px) {
  .card.fold .card-head .total { font-size: 13px; }
}

/* --- Cash count ----------------------------------------------------------- */

.cash-form { display: grid; gap: 16px; padding: 16px; }
.denoms { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 4px; }
.denom {
  min-width: 70px;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: var(--row);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}
.denom.on { border-color: var(--teal); background: var(--teal-t); color: var(--teal); }
.cash-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.cash-line { border-radius: 12px; padding: 12px 14px; background: var(--green-t); font-size: 15px; }
.cash-line b { color: var(--green); font-size: 19px; }

/* the phone's bottom bar uses the short labels */
.nav .short { display: none; }
@media (max-width: 760px) {
  .nav .long { display: none; }
  .nav .short { display: inline; }
  .cash-row { gap: 8px; }
  .denom { min-width: 0; flex: 1 1 28%; }
}

/* folding headers: full button text on wide screens, an icon on phones */
.card-head .add .short { display: none; }
.card-head .add svg { width: 16px; height: 16px; display: block; }
@media (max-width: 760px) {
  .card.fold > .card-head { padding: 12px 12px 12px 14px; gap: 8px; }
  .card.fold > .card-head h2 { font-size: 12px; letter-spacing: .04em; min-width: 0; }
  .card.fold .card-head .add { width: 32px; height: 30px; padding: 0; display: grid; place-items: center; font-size: 19px; flex: none; }
  .card.fold .card-head .add .long { display: none; }
  .card.fold .card-head .add .short { display: block; }
  .card.fold .card-head .total { font-size: 12.5px; flex: none; }
}

/* Sections only fold on phones; on wider screens they're always open */
@media (min-width: 761px) {
  .card.fold > .fold-body { grid-template-rows: 1fr; transition: none; }
  .card.fold .fold-inner { opacity: 1; visibility: visible; transition: none; }
  .card.fold > .card-head { cursor: default; }
  .card.fold .chevron { display: none; }
}

/* --- Search button in the top bar ------------------------------------------- */

.search-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  margin-left: -16px; /* sits with the menu, not a full gap away */
  border-radius: 10px;
  color: #C7D2FE;
}
.search-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.search-link.on { background: rgba(255, 255, 255, .14); color: #fff; }
.search-link svg { width: 19px; height: 19px; }
@media (max-width: 760px) {
  .search-link { margin-left: auto; width: 40px; height: 40px; }
  .search-link svg { width: 21px; height: 21px; }
}

/* --- Search page ---------------------------------------------------------- */

.search-bar { display: grid; gap: 12px; padding: 14px 16px; }
.search-field { position: relative; }
.search-field svg {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 13px 14px 13px 46px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--row);
  font-size: 17px; /* 16px or more, so iPhone Safari doesn't zoom in */
}
.search-input:focus { outline: 3px solid color-mix(in srgb, var(--blue) 30%, transparent); border-color: var(--blue); }
.kinds { display: flex; gap: 8px; flex-wrap: wrap; }
.kind {
  border: 1.5px solid var(--line);
  background: var(--row);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.kind:hover { border-color: var(--blue); }
.kind.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.suggest { display: grid; gap: 12px; padding: 16px; }
.search-count { font-size: 13.5px; font-weight: 700; color: var(--ink2); margin: 0 2px 10px; }
.tiles.two { --n: 2; }
@media (max-width: 760px) {
  .search-bar > .kinds { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
}

/* --- Spending limits ------------------------------------------------------- */

.limits { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; padding: 16px; }
.limit { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--row); }
.limit.near { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.limit.over { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); background: var(--red-t); }
.limit-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; margin-bottom: 8px; }
.limit-top > span { color: var(--ink2); white-space: nowrap; font-size: 13px; }
.limit-top > span b { color: var(--ink); font-size: 14px; }
.limit .bar { height: 10px; }
.limit-sub { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--ink2); margin-top: 6px; }
.limit.near .limit-sub { color: var(--amber); font-weight: 700; }
.limit.over .limit-sub { color: var(--red); font-weight: 700; }
.form-intro { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink2); }
.toast.warn { background: #B45309; }

/* --- Wrap-up ---------------------------------------------------------------- */

.switch-label { color: #fff; font-weight: 700; min-width: 84px; text-align: center; }
.month-switch button:disabled { opacity: .35; cursor: default; }
.cat { display: inline-flex; align-items: center; gap: 8px; }
.cat i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.tile .sub .pos, .tile .sub .neg { font-weight: 700; }

/* --- Notification settings --------------------------------------------------- */

.notify-option { gap: 3px; }
.notify-option .help { padding-left: 29px; }
.inline-field { display: flex; align-items: center; gap: 10px; padding-left: 29px; margin-top: 6px; }
.inline-field label { font-size: 12.5px; font-weight: 700; color: var(--ink2); }
.field .inline-field select { width: auto; padding: 7px 10px; }
.test-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.field .inline-field input { width: 130px; padding: 7px 10px; }
.preview:empty { display: none; }

/* --- Fitting every screen ------------------------------------------------------ */

/* Form boxes never push past the edge: grid columns may shrink below a box's own
minimum width (iPhone Safari gives date, month and time boxes a wide one) */
.modal .m-body, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }
.head-title { display: contents; }

@media (max-width: 760px) {
  .modal .m-body, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  /* 16px or more, or iPhone Safari zooms the page in when a box is tapped */
  .field input, .field select, .field textarea, .plan-input, .month-switch select { font-size: 16px; }
  /* iPhone Safari draws date boxes its own way: wider than the column, text centred,
  and collapsed in height when empty */
  .field input[type="date"], .field input[type="month"], .field input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-height: 44px;
    line-height: 1.3;
  }
  .field input::-webkit-date-and-time-value { text-align: left; }

  /* folding headers: the summary goes under the title, so a long title keeps its width */
  .card.fold .head-title { display: flex; flex-direction: column; align-items: flex-start; flex: 1; min-width: 0; gap: 1px; }
  .card.fold .head-title h2 { flex: none; }
  .card.fold .card-head .total { font-size: 12.5px; font-weight: 700; opacity: .9; white-space: normal; }
}

/* the smallest phones: tighter dialog edges so Delete, Cancel and Save fit in a row */
@media (max-width: 400px) {
  .modal .m-head, .modal .m-body, .modal .m-foot { padding-left: 16px; padding-right: 16px; }
  .modal .m-foot { gap: 6px; }
  .modal .m-foot .btn { padding: 9px 12px; }
}

/* tablets and narrow windows: menu labels go under their icons so the menu fits */
@media (min-width: 761px) and (max-width: 1159px) {
  .topbar { gap: 16px; }
  .nav { gap: 2px; }
  .nav a { flex-direction: column; gap: 2px; padding: 5px 9px; font-size: 11px; }
  .nav .long { display: none; }
  .nav .short { display: inline; }
  .search-link { margin-left: -8px; }
}
@media (min-width: 761px) and (max-width: 899px) {
  .brand span { display: none; }
  .tiles { --n: 2; }
}

/* --- Profiles ---------------------------------------------------------------- */

.avatar {
  --pc: #64748B;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--pc) 72%, #fff), var(--pc) 62%);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}
.avatar.tiny { width: 20px; height: 20px; border-radius: 6px; font-size: 11px; }
.avatar.small { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.avatar.mid { width: 72px; height: 72px; border-radius: 18px; font-size: 32px; }
.avatar.big { width: 108px; height: 108px; border-radius: 24px; font-size: 48px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.swatch { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: var(--pc); cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--pc); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the sign-in screen: the same in light and dark */
.gate {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow-y: auto;
  background: radial-gradient(120% 70% at 50% 0%, #1E3A8A 0%, #172554 48%, #0A0F1E 100%);
  color: #fff;
}
.gate::backdrop { background: #0A0F1E; }
.gate-inner {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: max(64px, calc(env(safe-area-inset-top) + 56px)) 20px max(32px, env(safe-area-inset-bottom));
  text-align: center;
}
.gate h1 { margin: 2px 0 8px; font-size: clamp(26px, 5vw, 38px); letter-spacing: -.02em; line-height: 1.15; }
.gate .pin-name { margin: 0; font-size: 24px; }
.gate-msg { margin: 0; max-width: 420px; color: #C7D2FE; }
.gate-note { margin: 0; max-width: 340px; color: #FDE68A; font-size: 14px; }
.gate-error { margin: 0; max-width: 330px; min-height: 20px; color: #FCA5A5; font-weight: 700; font-size: 14px; }
.gate-small { margin: -4px 0 0; color: #8A97AD; font-size: 12.5px; }
.gate-back {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  padding: 8px 15px 8px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .09);
  color: #C7D2FE;
  font-weight: 700;
  cursor: pointer;
}
.gate-back:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.profiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; max-width: 720px; margin-top: 6px; }
.profile {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 120px;
  padding: 0;
  border: 0;
  background: none;
  color: #C7D2FE;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.profile .avatar { transition: transform .15s ease, box-shadow .15s ease; }
.profile:hover, .profile:focus-visible { color: #fff; outline: none; }
.profile:hover .avatar, .profile:focus-visible .avatar { transform: scale(1.04); box-shadow: 0 0 0 3px #0F1A3D, 0 0 0 6px #fff; }
.profile:active .avatar { transform: scale(.97); }
.p-name { max-width: 100%; overflow-wrap: anywhere; }
.p-note { min-height: 16px; margin-top: -6px; color: #FDE68A; font-size: 12px; font-weight: 500; }

.dots { display: flex; justify-content: center; gap: 14px; min-height: 16px; margin-top: 4px; }
.dots i { width: 14px; height: 14px; border: 2px solid #94A3C8; border-radius: 50%; transition: background .1s; }
.dots i.on { background: #fff; border-color: #fff; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px 24px; margin: 2px 0 6px; }
.key {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 28px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.key:hover { background: rgba(255, 255, 255, .17); }
.key:active { background: rgba(255, 255, 255, .3); }
.key:focus-visible { outline: 2px solid #93C5FD; outline-offset: 2px; }
.key.del { background: transparent; font-size: 24px; }
.key.ok { background: #2563EB; font-size: 17px; font-weight: 800; }
.key.ok:disabled { opacity: .35; cursor: default; }

.gate-check { display: flex; align-items: center; gap: 10px; max-width: 330px; color: #E0E7FF; font-size: 15px; text-align: left; cursor: pointer; }
.gate-check input { width: 20px; height: 20px; flex: none; margin: 0; accent-color: #3B82F6; }
.gate-form { display: grid; gap: 8px; width: 100%; max-width: 340px; text-align: left; }
.gate-form label, .gate-label { color: #C7D2FE; font-size: 13px; font-weight: 700; }
.gate-label { margin-top: 6px; }
.gate-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 17px;
}
.gate-input::placeholder { color: #8A97AD; }
.gate-input:focus { outline: 2px solid #60A5FA; outline-offset: 1px; }
.gate .swatch[aria-checked="true"] { box-shadow: 0 0 0 3px #172554, 0 0 0 5px #fff; }
.gate-btn { margin-top: 4px; padding: 13px 24px; border: 0; border-radius: 12px; background: #2563EB; color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; }
.gate-btn:hover { filter: brightness(1.1); }

@media (max-width: 760px) {
  .avatar.big { width: 92px; height: 92px; border-radius: 21px; font-size: 40px; }
  .profile { width: 104px; }
  .profiles { gap: 22px 18px; }
}
@media (max-height: 720px) {
  .gate-inner { gap: 9px; padding-top: max(58px, calc(env(safe-area-inset-top) + 52px)); }
  .avatar.mid { width: 60px; height: 60px; border-radius: 15px; font-size: 27px; }
  .gate .pin-name { font-size: 21px; }
  .keypad { grid-template-columns: repeat(3, 62px); gap: 10px 22px; }
  .key { width: 62px; height: 62px; font-size: 25px; }
}
@media (max-height: 620px) {
  .gate-inner { gap: 7px; padding-top: max(50px, calc(env(safe-area-inset-top) + 46px)); padding-bottom: 14px; }
  .avatar.mid { width: 48px; height: 48px; border-radius: 13px; font-size: 22px; }
  .gate .pin-name { font-size: 19px; }
  .keypad { grid-template-columns: repeat(3, 56px); gap: 8px 22px; margin: 0 0 4px; }
  .key { width: 56px; height: 56px; font-size: 23px; }
  .gate-small { display: none; }
  /* the name-and-colour screens (first setup, and Add profile) fit without scrolling */
  .gate-logo { display: none; }
  .gate-inner > .avatar.big { width: 60px; height: 60px; border-radius: 15px; font-size: 27px; }
}

/* the profile button at the top right, and its menu */
.me-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  margin-left: -18px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
}
.me-btn:hover, .me-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .1); }
.me-btn[hidden], .me-menu[hidden] { display: none; }
.me-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: max(var(--gutter), env(safe-area-inset-right), calc((100% - var(--page)) / 2 + var(--gutter)));
  z-index: 30;
  width: 270px;
  max-width: calc(100vw - 24px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 14px 36px rgba(10, 15, 30, .28);
}
.me-head { display: flex; align-items: center; gap: 11px; padding: 8px 10px 4px; }
.me-head b { display: block; font-size: 15.5px; }
.me-head span { color: var(--muted); font-size: 12.5px; }
.me-note { margin: 4px 10px 8px; color: var(--ink2); font-size: 12.5px; }
.me-menu a, .me-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.me-menu a:hover, .me-menu button:hover { background: var(--row); text-decoration: none; }
.me-menu svg { width: 18px; height: 18px; color: var(--ink2); }

.added-by { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.who { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; }
.me-row { display: flex; align-items: center; gap: 14px; }
.me-row b { font-size: 17px; }
.settings-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 4px; }
.sub-head { grid-column: 1 / -1; margin: 6px 0 0; font-size: 15px; }

@media (max-width: 760px) {
  .me-btn { margin-left: 2px; }
  .me-menu { right: 12px; }
  .settings-grid.three { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 761px) and (max-width: 1159px) {
  .me-btn { margin-left: -10px; }
}

/* --- Fields side by side line up ---------------------------------------------- */

/* A field never stretches to match a taller neighbour (one with a hint under it):
stretched, its label and box grew and its box sat lower than the one beside it */
.field { align-content: start; }
/* Text boxes, date boxes and drop-downs are all the same height */
.field input:not([type="checkbox"]):not([type="radio"]), .field select { height: 44px; }
.field .inline-field input, .field .inline-field select { height: 36px; }
/* Colour circles and the test buttons: their first row sits level with a 44px box
beside them, also when they wrap onto a second row */
.field > .swatches { padding: 6px 0; }
.field > .test-buttons { padding: 5px 0; }
.field > .test-buttons > * { min-height: 34px; }

/* --- Year and month drop-downs ------------------------------------------------- */

/* A month is picked as a year and a month side by side; with "Ongoing (no end)"
chosen there's no month, and the year drop-down takes the whole width */
.month-pick { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 8px; }
.month-pick.no-month { grid-template-columns: minmax(0, 1fr); }
.month-pick select[hidden] { display: none; }
.month-switch select + select { padding-left: 2px; }

/* --- Add profile, on the sign-in screen ------------------------------------------- */

.avatar.add-face {
  background: transparent;
  border: 2px dashed rgba(199, 210, 254, .55);
  color: #C7D2FE;
  font-weight: 400;
}
.profile.add:hover .add-face, .profile.add:focus-visible .add-face { border-color: #fff; color: #fff; }
/* a tile whose note runs onto two lines doesn't stretch the others: names stay level */
.profile { align-content: start; }

/* --- Unplanned expenses: the lightning mark ---------------------------------------- */

.bolt { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; color: var(--amber); }
.bolt svg, .check-icon svg { width: 15px; height: 15px; fill: currentColor; }
.bolt.plain { color: inherit; margin-right: 3px; }
.check-icon { display: inline-grid; place-items: center; color: var(--amber); margin-right: -4px; }
.field .check-help { padding-left: 29px; margin-top: -2px; }
.unpl-cell { display: inline-flex; align-items: center; white-space: nowrap; }
.unpl-sum { white-space: nowrap; }
/* the month-by-month table: its long headers ("Available before saving") wrap onto
two lines when the screen is too narrow for them, instead of the table scrolling */
.perf-table th { white-space: normal; vertical-align: bottom; }
/* the unplanned amount: on the Month page's Total expenses tile, in the Expenses header
(not on phones, where the tile says it), and in the dashboard's column (wide screens) */
.unpl-line { margin-top: 3px; }
.perf-table .unpl-amt { font-weight: 400; color: var(--ink2); }
@media (max-width: 760px) { .unpl-sum .unpl-amt { display: none; } }
@media (max-width: 1159px) { .perf-table .unpl-amt { display: none; } }

/* --- Ledgers: the row for switching between them ------------------------------------ */

.ledger-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.ledger-pill {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 120px;
  max-width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.ledger-pill b { font-size: 14px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-pill span { font-size: 12.5px; color: var(--ink2); font-weight: 600; }
.ledger-pill span.neg { color: var(--red); }
.ledger-pill:hover { border-color: color-mix(in srgb, var(--teal) 60%, var(--line)); }
.ledger-pill[aria-current="page"] { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: var(--teal-t); }
.ledger-pill.new { align-items: center; border-style: dashed; color: var(--ink2); font-size: 14px; font-weight: 700; background: transparent; }
.ledger-pill.new:hover { color: var(--ink); }
/* a header with a pair of buttons (Counted, Ledger) puts them on a second line, at the
right, when the title, total and buttons don't fit on one (the smallest phones) */
.card-head:has(> .head-buttons) { flex-wrap: wrap; row-gap: 8px; }
.card-head > .head-buttons { margin-left: auto; }
/* phones: the ledgers in two even columns */
@media (max-width: 760px) {
  .ledger-pills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-pill { min-width: 0; }
  .ledger-pill b { max-width: 100%; }
}

/* --- Money received and expenses linked to a ledger ---------------------------------- */

.ledger-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--teal-t);
  color: var(--teal);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: 1px;
}
.ledger-tag svg, .linked svg { width: 12px; height: 12px; flex: none; }
.linked { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--teal); font-size: 12px; font-weight: 600; }

/* ===== Budgets for other people: the link to send =============================== */
.link-box { display: flex; gap: 8px; align-items: center; }
.link-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--row);
  color: var(--ink);
}
.link-box .btn { flex: none; }
