/* Contas da casa. Two people, two colours: every mark of "who" uses them. */
:root {
  --paper: #EEF2F0;
  --surface: #FFFFFF;
  --ink: #17262A;
  --muted: #56676B;
  --line: #D3DCD9;
  --line-strong: #B9C6C2;
  --cassio: #2D63D8;
  --cassio-ink: #1F4FB8;
  --cassio-soft: #DCE6FB;
  --julye: #D69213;
  --julye-ink: #8A5A00;
  --julye-soft: #F8EBCF;
  --danger: #B3261E;
  --focus: #2D63D8;
  --shadow: 0 1px 2px rgba(23, 38, 42, .06), 0 8px 24px rgba(23, 38, 42, .08);

  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-text: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-s: 10px;
  --radius-l: 22px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1615;
    --surface: #172120;
    --ink: #E4ECEA;
    --muted: #97A7A4;
    --line: #26332F;
    --line-strong: #364540;
    --cassio: #7DA4FF;
    --cassio-ink: #9DBBFF;
    --cassio-soft: #1C2A48;
    --julye: #F0B54A;
    --julye-ink: #F3C46E;
    --julye-soft: #392C12;
    --danger: #FF8A80;
    --focus: #9DBBFF;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.amount-xl { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── people ─────────────────────────────────────────────── */
.who { font-weight: 650; }
.who-cassio { color: var(--cassio-ink); }
.who-julye { color: var(--julye-ink); }
.dot { display: inline-block; border-radius: 50%; }
.dot-cassio { background: var(--cassio); }
.dot-julye { background: var(--julye); }

/* ── top bar ────────────────────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
}
.bar-inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter);
}
.bar-sub { padding-top: 0; }
.months { display: flex; align-items: center; gap: 4px; min-width: 0; }
.month-title {
  margin: 0 4px;
  font: 650 1.45rem/1.1 var(--font-display);
  letter-spacing: -.015em;
  white-space: nowrap;
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--ink); text-decoration: none; flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.today { font-size: .9rem; color: var(--muted); white-space: nowrap; padding: 10px 0; }

.account { position: relative; }
.account summary { list-style: none; cursor: pointer; }
.account summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  font: 650 1rem/1 var(--font-display); color: #fff;
}
.avatar-cassio { background: var(--cassio); }
.avatar-julye { background: var(--julye); color: #2B1D00; }
.account-menu {
  position: absolute; right: 0; top: 46px; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  box-shadow: var(--shadow); padding: 6px;
}
.account-menu p { margin: 0; padding: 8px 10px; color: var(--muted); font-size: .9rem; }
.account-menu a { display: block; padding: 10px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.account-menu a:hover { background: var(--paper); }

/* segmented control (links and radios share it) */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 12px;
}
.seg > a, .seg > label {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 38px; padding: 6px 14px; border-radius: 9px;
  font-weight: 600; font-size: .95rem; text-decoration: none; color: var(--muted);
  cursor: pointer; position: relative;
}
.seg > a[aria-selected="true"], .seg > label:has(input:checked) {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.seg > label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg-fill { display: flex; width: 100%; }
.seg-fill > label { flex: 1 1 0; line-height: 1.2; }
.pick-cassio:has(input:checked) { color: var(--cassio-ink); box-shadow: inset 0 -3px 0 var(--cassio), 0 1px 2px rgba(0,0,0,.12); }
.pick-julye:has(input:checked) { color: var(--julye-ink); box-shadow: inset 0 -3px 0 var(--julye), 0 1px 2px rgba(0,0,0,.12); }

/* ── page layout ────────────────────────────────────────── */
.page {
  max-width: 1120px; margin: 0 auto;
  padding: 20px var(--gutter) calc(120px + env(safe-area-inset-bottom));
  display: grid; gap: 28px;
}
@media (min-width: 900px) {
  .page { grid-template-columns: minmax(320px, 400px) 1fr; align-items: start; gap: 48px; padding-top: 32px; }
  .summary { position: sticky; top: 132px; }
}

/* ── settlement: the one loud thing ─────────────────────── */
.verdict {
  margin: 0 0 20px;
  font: 600 1.35rem/1.25 var(--font-display);
  letter-spacing: -.01em;
  text-wrap: balance;
}
.amount-xl {
  display: block;
  font: 700 clamp(2.6rem, 11vw, 3.4rem)/1.02 var(--font-display);
  letter-spacing: -.035em;
  margin: 4px 0 2px;
}
.split {
  position: relative; display: flex; height: 14px; border-radius: 7px; overflow: hidden;
  background: var(--line); margin-bottom: 18px;
}
.split-part { min-width: 3px; }
.split-cassio { background: var(--cassio); }
.split-julye { background: var(--julye); }
.split-mid {
  position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px;
  background: var(--ink); border-radius: 1px;
}
.ledger { margin: 0; border-top: 1px solid var(--line); }
.ledger > div {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.ledger dt { color: var(--muted); }
.ledger dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }

/* ── expense list ───────────────────────────────────────── */
.group + .group { margin-top: 8px; }
.group-transfers { margin-bottom: 26px; }
.group-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 0 8px; padding: 0 2px;
  font: 600 1.05rem/1.3 var(--font-display);
}
.group-head .num { font: 600 .95rem/1 var(--font-text); color: var(--muted); }
.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border-radius: var(--radius-s);
  border: 1px solid var(--line);
}
.rows li + li { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  min-height: 60px; padding: 10px 14px; text-decoration: none;
}
.row:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.rows li:first-child .row { border-radius: var(--radius-s) var(--radius-s) 0 0; }
.rows li:last-child .row { border-radius: 0 0 var(--radius-s) var(--radius-s); }
.row-dot { width: 10px; height: 10px; border-radius: 50%; }
.row-main { display: grid; min-width: 0; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title-quiet { font-weight: 500; color: var(--muted); }
.row-meta { font-size: .85rem; color: var(--muted); }
.row-amount { font-weight: 600; white-space: nowrap; }

.empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-s);
  padding: 32px 20px; text-align: center; color: var(--muted);
}
.empty p { margin: 0; }
.empty-title { color: var(--ink); font-weight: 600; margin-bottom: 4px !important; }

/* ── floating action ────────────────────────────────────── */
.fab-wrap {
  position: fixed; z-index: 6;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  pointer-events: none; /* only the buttons take the pointer, not the empty fan area */
}
.fab {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px;
  background: var(--ink); color: var(--paper);
  font-weight: 650; text-decoration: none; box-shadow: var(--shadow);
}
.fab svg { width: 22px; height: 22px; stroke-width: 2.4; }
.fab:active { transform: scale(.97); }

/* ── buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0;
  font: 650 1rem/1 var(--font-text); text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-quiet { background: transparent; color: var(--ink); }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-google {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); width: 100%; max-width: 320px;
}

/* ── bottom sheet form ──────────────────────────────────── */
dialog { color: var(--ink); }
.sheet {
  margin: auto auto 0; padding: 0; border: 0;
  width: 100%; max-width: 560px; max-height: 94dvh;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  background: var(--surface); box-shadow: var(--shadow);
}
.sheet::backdrop, .confirm::backdrop { background: rgba(10, 18, 17, .45); }
.sheet[open] { animation: sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: var(--radius-l); max-height: 90dvh; }
}
.sheet-form { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 4px 20px;
}
.sheet-head h2 { margin: 0; font: 650 1.3rem/1.2 var(--font-display); }
.sheet-body { overflow-y: auto; padding: 8px 20px 12px; display: grid; gap: 18px; }
.sheet-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-foot .btn-primary { flex: 1; max-width: 280px; margin-left: auto; }

.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
.field-row { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 140px; }
input:not([type=radio]):not([type=checkbox]), select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: 500 1rem/1.3 var(--font-text); color: var(--ink);
  background: var(--paper); border: 1.5px solid transparent; border-radius: 12px;
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356676B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
  padding-right: 40px;
}
input:focus, select:focus { border-color: var(--focus); outline: none; background-color: var(--surface); }
input:disabled { opacity: .45; }
.reveal { margin-top: 8px; }

.money {
  display: flex; align-items: baseline; gap: 8px;
  border-bottom: 2px solid var(--line-strong); padding-bottom: 4px;
}
.money:focus-within { border-color: var(--focus); }
.money span { font: 600 1.4rem/1 var(--font-display); color: var(--muted); }
.money input {
  background: transparent !important; border: 0 !important; padding: 0 !important; min-height: 0 !important;
  font: 700 2.4rem/1.1 var(--font-display) !important; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.check {
  display: flex; align-items: center; gap: 10px; min-height: 48px;
  font-weight: 550; cursor: pointer; flex: 1 1 160px;
}
.check input { width: 22px; height: 22px; accent-color: var(--ink); }

/* ── confirm dialog ─────────────────────────────────────── */
.confirm {
  border: 0; border-radius: var(--radius-l); padding: 22px; width: min(420px, calc(100% - 32px));
  background: var(--surface); box-shadow: var(--shadow);
}
.confirm h2 { margin: 0 0 12px; font: 650 1.25rem/1.2 var(--font-display); }
.confirm p { margin: 0 0 8px; color: var(--muted); }
.options { border: 0; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; }
.options label {
  display: flex; gap: 12px; align-items: center; min-height: 48px; padding: 0 12px;
  border-radius: 12px; cursor: pointer; font-weight: 550;
}
.options label:has(input:checked) { background: var(--paper); }
.options input { width: 20px; height: 20px; accent-color: var(--danger); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ── login / offline ────────────────────────────────────── */
.gate {
  min-height: 100dvh; max-width: 440px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
}
.gate-mark { display: flex; margin-bottom: 28px; }
.gate-mark .dot { width: 44px; height: 44px; mix-blend-mode: multiply; }
.gate-mark .dot + .dot { margin-left: -16px; }
@media (prefers-color-scheme: dark) { .gate-mark .dot { mix-blend-mode: screen; } }
.gate-title { margin: 0 0 10px; font: 700 2.6rem/1.02 var(--font-display); letter-spacing: -.03em; }
.gate-lede { margin: 0 0 28px; color: var(--muted); font-size: 1.08rem; max-width: 34ch; }
.gate-foot { color: var(--muted); font-size: .9rem; margin-top: 14px; }
.notice {
  margin: 0 0 20px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--ink);
}

/* ── fan: hover or focus opens the second entry; a plain click is a new expense ── */
.fab-option {
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 18px 0 14px; border-radius: 23px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  font-weight: 600; text-decoration: none; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(14px) scale(.96);
  /* closing waits a beat so the pointer can cross the gap from the button */
  transition: opacity .16s ease .22s, transform .16s ease .22s, visibility 0s linear .38s;
}
.fab-option svg { width: 20px; height: 20px; }
.fab-option:hover { border-color: var(--line-strong); }
.fab-wrap:focus-within .fab-option { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }
@media (hover: hover) {
  .fab-wrap:hover .fab-option { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }
}

/* ── collapsible groups ─────────────────────────────────── */
.list-tools { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 6px; }
.list-title { margin: 0; font: 600 1.05rem/1.3 var(--font-display); }
.btn-link {
  min-height: 44px; padding: 0 2px; border: 0; background: none; cursor: pointer;
  font: 600 .95rem/1 var(--font-text); color: var(--cassio-ink);
}
details.group > summary { list-style: none; }
details.group > summary::-webkit-details-marker { display: none; }
summary.group-head {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px;
  min-height: 54px; margin: 0; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  cursor: pointer; font: 600 1rem/1.3 var(--font-display);
}
summary.group-head:hover { border-color: var(--line-strong); }
summary.group-head .num { font: 600 .95rem/1 var(--font-text); color: var(--ink); }
.group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count {
  font: 600 .78rem/1 var(--font-text); color: var(--muted);
  background: var(--paper); border-radius: 999px; padding: 4px 8px;
}
.chev { width: 18px; height: 18px; color: var(--muted); transition: transform .18s ease; }
details.group[open] .chev { transform: rotate(90deg); }
details.group[open] > summary.group-head { border-radius: var(--radius-s) var(--radius-s) 0 0; }
details.group[open] > .rows { border-top: 0; border-radius: 0 0 var(--radius-s) var(--radius-s); }
details.group[open] > .rows li:first-child .row { border-radius: 0; }

/* ── settlement payments ────────────────────────────────── */
.row-dot-transfer { background: transparent !important; border: 2.5px solid; }
.row-dot-transfer.dot-cassio { border-color: var(--cassio); }
.row-dot-transfer.dot-julye { border-color: var(--julye); }
.ledger-strong dt { color: var(--ink); font-weight: 600; }
.btn-outline { border: 1.5px solid var(--line-strong); background: transparent; color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); }
.settle-action { margin-top: 18px; width: 100%; }
