/* =====================================================================
   Wrights Family Fortunes
   Light, roomy, pink and yellow. Its own look — nothing borrowed.
   The whole palette is here and nowhere else.
   ===================================================================== */
:root {
  --paper:      #F2EFEC;   /* warm light grey ground */
  --card:       #FFFFFF;
  --card-2:     #FAF7F4;
  --edge:       #E4DDD6;
  --edge-soft:  #EFE9E3;

  --ink:        #2E2732;
  --muted:      #6F6674;
  --faint:      #9A919F;

  --pink:       #E8467C;
  --pink-soft:  #FFE3EC;
  --pink-ink:   #B32255;

  --sun:        #FFC93C;
  --sun-soft:   #FFF2CE;
  --sun-ink:    #8A6200;

  --grow:       #17916B;   /* money coming in */
  --grow-soft:  #DCF3EA;

  --r:    22px;
  --r-s:  14px;
  --r-pill: 999px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system,
               BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
}

a { color: inherit; }

.wrap { max-width: 460px; margin: 0 auto; }

/* -------------------------------------------------------- masthead --- */

header.masthead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin: calc(20px + env(safe-area-inset-top)) 4px 16px;
}
header.masthead .mark {
  font-size: 21px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--ink);
}
header.masthead .mark em { font-style: normal; color: var(--pink); }
.who { font-size: 13px; color: var(--faint); }
.who a { text-decoration: none; border-bottom: 1.5px solid var(--edge); }

/* --------------------------------------------------------- caveat ---- */

.caveat {
  background: var(--sun-soft);
  border-radius: var(--r-s);
  padding: 12px 15px;
  font-size: 13px; line-height: 1.45; color: var(--sun-ink);
  margin-bottom: 22px;
}
.caveat b { font-weight: 800; }

/* ------------------------------------------------------- sections ---- */

h2.sec {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 26px 4px 10px;
}
h2.sec .t {
  font-size: 13px; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--pink);
}
h2.sec .s { font-size: 12px; color: var(--faint); font-weight: 500; text-align: right; }

/* ------------------------------------------------------------ pot ---- */

details.pot {
  background: var(--card);
  border-radius: var(--r);
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(46, 39, 50, 0.05);
  overflow: hidden;
}
details.pot > summary {
  list-style: none; cursor: pointer; padding: 16px 18px;
  display: block;
}
details.pot > summary::-webkit-details-marker { display: none; }
details.pot > summary:focus-visible { outline: 3px solid var(--pink); outline-offset: -3px; }

.pot-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.pot-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.pot-val {
  font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums;
  white-space: nowrap; letter-spacing: -0.02em;
}
.pot-val .of { font-size: 14px; font-weight: 500; color: var(--faint); }
.pot-val i { font-style: normal; font-size: 14px; font-weight: 500; color: var(--faint); }
.pot-val.grow { color: var(--grow); }
.pot-val.spend { color: var(--pink); }

.pot-sub { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.pot-sub b { font-weight: 700; color: var(--ink); }
.pot-sub b.over { color: var(--pink-ink); }

.meter {
  height: 8px; border-radius: var(--r-pill); background: var(--edge-soft);
  margin: 12px 0 2px; overflow: hidden;
}
.meter > span { display: block; height: 100%; background: var(--sun); border-radius: var(--r-pill); }
.meter > span.over { background: var(--pink); }

.open-hint { margin-top: 8px; font-size: 12px; color: var(--faint); font-weight: 600; }
details.pot[open] .open-hint { display: none; }

/* --------------------------------------------------------- inside ---- */

.inside { padding: 2px 18px 16px; border-top: 1px solid var(--edge-soft); }
.txn {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 11px 0; border-bottom: 1px solid var(--edge-soft);
}
.txn:last-child { border-bottom: 0; }
.txn .d { font-size: 15px; line-height: 1.35; }
.txn .m { font-size: 12px; color: var(--faint); margin-top: 2px; }
.txn .a {
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; text-align: right;
}
.txn .a.grow { color: var(--grow); }

.tag {
  display: inline-block; margin-left: 5px; padding: 1px 8px;
  border-radius: var(--r-pill); font-size: 11px; font-weight: 700;
  vertical-align: 1px;
}
.tag.default { background: var(--sun-soft); color: var(--sun-ink); }
.tag.draft   { background: var(--pink-soft); color: var(--pink-ink); }
.tag.ded     { background: var(--grow-soft); color: var(--grow); }

.empty { padding: 14px 0 4px; font-size: 14px; color: var(--faint); }

/* ---------------------------------------------------------- bills ---- */

.bill {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 12px 18px; background: var(--card);
  border-radius: var(--r-s); margin-bottom: 7px;
}
.bill .n { font-size: 15px; font-weight: 600; }
.bill .n small { display: block; font-size: 12px; color: var(--faint); font-weight: 400; }
.bill .st { font-size: 12px; font-weight: 700; white-space: nowrap; }
.bill .st.feed { color: var(--muted); }
.bill .st.none { color: var(--pink-ink); }

/* ----------------------------------------------------------- form ---- */

form.entry { padding: 14px 0 2px; display: flex; flex-direction: column; gap: 10px; }
form.entry .fields { display: flex; gap: 8px; }
form.entry label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 4px; }
form.entry input, form.entry select {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  background: var(--card-2); color: var(--ink);
  border: 1.5px solid var(--edge); border-radius: var(--r-s);
}
form.entry input:focus, form.entry select:focus { outline: 3px solid var(--pink); border-color: transparent; }
form.entry button {
  padding: 14px; font-size: 16px; font-weight: 800; font-family: inherit;
  background: var(--pink); color: #fff; border: 0; border-radius: var(--r-s);
  cursor: pointer;
}

/* ----------------------------------------------------------- tail ---- */

.dormant { margin: 4px 6px 0; font-size: 12px; color: var(--faint); line-height: 1.45; }

.tail { margin-top: 26px; padding: 16px 18px; background: var(--card-2);
        border-radius: var(--r); }
.tail-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; color: var(--muted); padding: 3px 0;
}
.tail-row b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.tail-row b.grow { color: var(--grow); }
.tail-row b.spend { color: var(--pink); }
.tail-note { margin-top: 10px; font-size: 12px; color: var(--faint); line-height: 1.5; }

.back { display: inline-block; margin: 4px 4px 14px; font-size: 14px;
        font-weight: 700; color: var(--pink); text-decoration: none; }

/* ---------------------------------------------------------- login ---- */

.login { padding-top: 14vh; }
.login h1 { font-size: 27px; margin: 0 0 6px; letter-spacing: -0.02em; }
.login h1 em { font-style: normal; color: var(--pink); }
.login p { color: var(--muted); font-size: 15px; margin: 0 0 22px; }
.login label { display: block; font-size: 12px; font-weight: 700;
               color: var(--muted); margin: 16px 0 6px; }
.login input {
  width: 100%; padding: 14px 16px; font-size: 16px; font-family: inherit;
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--edge); border-radius: var(--r-s);
}
.login input:focus { outline: 3px solid var(--pink); border-color: transparent; }
.login button {
  width: 100%; margin-top: 22px; padding: 15px;
  background: var(--pink); color: #fff; border: 0; border-radius: var(--r-s);
  font-size: 17px; font-weight: 800; font-family: inherit; cursor: pointer;
}
.err { margin-top: 16px; padding: 12px 15px; border-radius: var(--r-s);
       background: var(--pink-soft); color: var(--pink-ink); font-size: 14px; }

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

/* ------------------------------------------------ period selector ---- */

.periods {
  display: flex; flex-wrap: wrap; gap: 7px; margin: 0 2px 6px;
}
.chip {
  font: inherit; font-size: 13px; font-weight: 700;
  padding: 8px 14px; border-radius: var(--r-pill); cursor: pointer;
  background: var(--card); color: var(--muted);
  border: 2px solid var(--edge);
}
.chip.on { background: var(--pink); color: #fff; border-color: var(--pink); }
.chip:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

details.custom > summary { list-style: none; display: inline-block; }
details.custom > summary::-webkit-details-marker { display: none; }
details.custom.on > summary { background: var(--pink); color: #fff; border-color: var(--pink); }
.range {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: end;
  margin-top: 9px; width: 100%;
}
.range label { font-size: 12px; font-weight: 700; color: var(--muted); }
.range input {
  display: block; margin-top: 4px; padding: 9px 11px; font: inherit;
  font-size: 15px; background: var(--card); color: var(--ink);
  border: 2px solid var(--edge); border-radius: var(--r-s);
}
.range .go {
  font: inherit; font-size: 14px; font-weight: 800; padding: 10px 16px;
  background: var(--pink); color: #fff; border: 0;
  border-radius: var(--r-s); cursor: pointer;
}

/* -------------------------------------------- pink outlined pots ----- */

details.pot { border: 2px solid var(--pink-soft); }
details.pot[open] { border-color: var(--pink); }

/* ------------------------------------------- bills inside a pot ------ */

.inbill {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 10px;
  padding: 11px 0; border-bottom: 1px solid var(--edge-soft);
  align-items: baseline;
}
.inbill .n { font-size: 15px; font-weight: 600; }
.inbill .n small { display: block; font-size: 12px; color: var(--faint); font-weight: 400; }
.inbill .st { font-size: 12px; text-align: right; white-space: nowrap; }
.inbill .st b { font-weight: 700; }
.inbill .st b.ok  { color: var(--grow); }
.inbill .st b.gap { color: var(--pink-ink); }
.inbill .st i { font-style: normal; color: var(--faint); }
.inbill select {
  grid-column: 1 / -1; margin-top: 5px; padding: 7px 10px; font: inherit;
  font-size: 13px; background: var(--card-2); color: var(--muted);
  border: 1.5px solid var(--edge); border-radius: var(--r-s);
}

.bill .move select {
  padding: 9px 12px; font: inherit; font-size: 14px; font-weight: 600;
  background: var(--pink-soft); color: var(--pink-ink);
  border: 2px solid var(--pink); border-radius: var(--r-s); cursor: pointer;
}
