:root{font-family:system-ui,sans-serif;color:#201735;background:#f7f5fb;line-height:1.5;color-scheme:light}
*{box-sizing:border-box}
body{margin:0}
[hidden]{display:none!important}
.wrap{width:min(100% - 2rem, 67rem);margin-inline:auto}
.brand{display:flex;align-items:center;gap:.6rem;font-weight:750;font-size:1.15rem}
.intro{margin-block:1.5rem}
h1,h2,p{margin:0}
h1{font-size:clamp(2rem,5vw,3rem);letter-spacing:-.045em;line-height:1.12}
h2{font-size:1.22rem;margin-bottom:1rem}
.intro p,.muted{color:#5f536e}
.intro p{margin-top:.55rem}
.workspace,.fields{display:grid;gap:1rem}
.card{min-width:0;background:white;border:1px solid #e3dbee;border-radius:1rem;padding:clamp(1rem,3vw,1.5rem)}
label{display:block;font-weight:620;font-size:.92rem;min-width:0}
small{font-weight:400;color:#645970;font-size:.83rem}
input,select,button{font:inherit}
input,select{width:100%;min-width:0;min-height:2.85rem;margin-top:.3rem;padding:.55rem .65rem;border:1px solid #baafc9;border-radius:.55rem;background:white;color:inherit;font-size:1rem}
input[type=file]{border-style:dashed}
label:has(#photo){margin-top:1rem}
button{min-height:2.8rem;padding:.55rem .85rem;border:1px solid transparent;border-radius:.6rem;background:#513191;color:white;font-weight:660;cursor:pointer}
button.secondary{background:white;color:#452777;border-color:#cfc2e3}
button:hover{filter:brightness(.94)}
:focus-visible{outline:3px solid #895de1;outline-offset:2px}
.summary{background:#f0e9fd;align-self:start}
.summary button{width:100%;margin-top:.55rem}
.caption{color:#533b73}
output{display:block;font-weight:800;font-size:clamp(1.85rem,6vw,2.75rem);letter-spacing:-.04em;overflow-wrap:anywhere}
dl{margin:.6rem 0 1rem}
dl div{display:flex;justify-content:space-between;gap:.5rem;padding:.55rem 0;border-bottom:1px solid #dcd0ed}
dd{margin:0;font-weight:650;text-align:right;overflow-wrap:anywhere}
.error{color:#9a203a;margin-top:1rem}
#photo-preview{display:block;max-width:100%;max-height:9rem;margin:.6rem 0;border-radius:.5rem}
#notice{margin:.8rem 0;color:#513191}
#notice:empty{display:none}
.history{margin-top:1rem}
.entry{padding:1rem 0;border-top:1px solid #e6deee;overflow-wrap:anywhere}
.entry p{margin:.3rem 0 .6rem}
.entry header{display:flex;justify-content:space-between;gap:.5rem;align-items:baseline}
.badge{background:#ffebad;color:#533800;padding:.15rem .55rem;border-radius:1rem;font-size:.85rem;font-weight:650}
.badge.paid{background:#daf1de;color:#145829}
.actions{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.8rem}
@media(min-width:34rem){.fields{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(min-width:56rem){.workspace{grid-template-columns:minmax(0,1.85fr) minmax(0,1fr)}.intro{margin-block:2rem}}

:root {
  --ink: #30243c;
  --muted: #655570;
  --line: #eee4f0;
  --violet: #674297;
  --gradient: linear-gradient(130deg, #fffafd, #f7f1ff 54%, #fffbe5);
  background: var(--gradient) fixed;
  color: var(--ink);
}
.sidebar { position:fixed; inset:auto 0 0; z-index:5; background:#fffafd; border-top:1px solid var(--line); padding:.25rem .5rem max(.25rem,env(safe-area-inset-bottom)); }
.sidebar .brand,.local-note { display:none; }
.sidebar nav { display:grid;grid-template-columns:repeat(4,minmax(0,1fr)); }
.sidebar nav a { min-height:3.25rem;display:grid;place-content:center;justify-items:center;gap:.05rem;margin-inline:.15rem;border-radius:.75rem;color:var(--muted);font-size:.81rem;font-weight:700;text-decoration:none; }
.sidebar nav a span { font-size:1.3rem;line-height:1; }
.sidebar nav a[aria-current="page"] { background:#eee4fc;color:#583780; }
.mast { position:sticky;top:0;z-index:4;background:#fffafd;border-bottom:1px solid var(--line);color:var(--ink); }
.topbar { min-height:4rem;padding:.55rem 1rem;display:flex;justify-content:space-between;gap:1rem;align-items:center; }
.brand { text-decoration:none;color:inherit;font-weight:780; }
.brand img { flex:none;border-radius:.7rem; }
.wrap { padding-bottom:calc(5rem + env(safe-area-inset-bottom)); }
h1,h2,.stats strong,output { font-family:Georgia,serif; }
h1 { letter-spacing:-.04em; }
.card { border-color:var(--line);box-shadow:0 8px 24px #7559830c; }
.summary { background:linear-gradient(145deg,#f4eaff,#fff0f7); }
button,.button { background:linear-gradient(125deg,#844678,#6941a0);color:white; }
button.secondary,.button.secondary { border-color:#dfd1e8;background:white;color:#593880; }
.button { display:inline-flex;align-items:center;justify-content:center;min-height:2.8rem;padding:.55rem .85rem;border:1px solid transparent;border-radius:.6rem;font-weight:660;text-decoration:none; }
.stats { display:grid;gap:.75rem; }
.stats .card { border-top:3px solid #c4a8ef;display:grid;grid-template-columns:auto 1fr;gap:.2rem .85rem;align-items:center; }
.stats .card:nth-child(2) { border-top-color:#ef9fc1; }
.stats .card:nth-child(3) { border-top-color:#f2d66f; }
.stat-icon { grid-row:span 2;width:2.4rem;height:2.4rem;display:grid;place-items:center;border-radius:.65rem;font-weight:800; }
.lavender { background:#eee5ff;color:#6540a4; }
.rose { background:#ffe3ee;color:#943e66; }
.amber { background:#fff4bd;color:#805b00; }
.stats strong { font-size:clamp(1.18rem,3vw,1.65rem);overflow-wrap:anywhere; }
.stats p,.quick p,.intro p,.muted { color:var(--muted); }
.quick { margin-top:1rem;background:#fffafd; }
.quick h2 { margin:0; }
.history .entry:first-child { border-top:0;padding-top:0; }
.history .entry:last-child { padding-bottom:0; }
#notice:not(:empty) { padding:.6rem .85rem;background:#f0e6fb;border-radius:.65rem; }
@media(min-width:46rem) {
  .stats { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .stats .card { grid-template-columns:1fr; }
  .stat-icon { grid-row:auto;margin-bottom:.35rem; }
  .quick { display:flex;align-items:center;justify-content:space-between;gap:1rem; }
  .quick .actions { margin-top:0; }
}
@media(min-width:56rem) {
  body { padding-left:14rem; }
  .sidebar { inset:0 auto 0 0;width:14rem;display:flex;flex-direction:column;gap:1.7rem;padding:1.5rem 1rem;background:linear-gradient(180deg,#6f5a9f,#8264aa);border:0;color:white; }
  .sidebar .brand { display:flex; }
  .sidebar nav { grid-template-columns:1fr;gap:.4rem; }
  .sidebar nav a { display:flex;align-items:center;min-height:2.75rem;padding:.5rem .7rem;gap:.7rem;color:white;font-size:.95rem; }
  .sidebar nav a[aria-current="page"] { background:#ffffff29;color:white; }
  .local-note { display:block;margin-top:auto;border-top:1px solid #ffffff55;padding:.8rem .5rem 0;font-size:.88rem; }
  .mobile-brand { display:none; }
  .topbar { justify-content:flex-end;padding-inline:2rem; }
  .wrap { width:min(100% - 3.5rem,67rem);padding-bottom:3rem; }
}

#billing {
  width:min(calc(100% - 2rem), 58rem);
  max-height:calc(100dvh - 2rem);
  padding:0;
  border:1px solid var(--line);
  border-radius:1.15rem;
  background:#fffafd;
  color:var(--ink);
  overscroll-behavior:contain;
  box-shadow:0 22px 90px #29183b45;
}
#billing::backdrop { background:#2a1e3e78; }
body:has(#billing[open]) { overflow:hidden; }
.bill-dialog-header {
  position:sticky;top:0;z-index:1;
  display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;
  padding:1rem clamp(1rem,3vw,1.5rem);
  background:linear-gradient(110deg,#fff1f7,#f4ecff 72%,#fff8df);
  border-bottom:1px solid var(--line);
}
.bill-dialog-header h1 { font-size:clamp(1.65rem,4vw,2.15rem); }
.bill-dialog-header p { margin-top:.3rem;color:var(--muted);font-size:.92rem; }
#close-billing { min-width:2.8rem;font-size:1.45rem;line-height:1; }
#billing .workspace { padding:clamp(.75rem,2vw,1.25rem); }
@media(max-width:35rem) {
  #billing { width:100%;max-width:none;height:100dvh;max-height:none;margin:0;border:0;border-radius:0; }
  .bill-dialog-header { padding-top:max(1rem,env(safe-area-inset-top)); }
}

#invoice {
  width:min(calc(100% - 2rem), 39rem);
  max-height:calc(100dvh - 2rem);
  padding:0;
  border:1px solid var(--line);
  border-radius:1.15rem;
  background:#fffafd;
  color:var(--ink);
  box-shadow:0 22px 90px #29183b45;
}
#invoice::backdrop { background:#2a1e3e78; }
body:has(#invoice[open]) { overflow:hidden; }
.invoice-content { padding:1rem clamp(1rem,3vw,1.5rem); }
#invoice-household { font-weight:750; }
#invoice dt,#invoice dd { min-width:0; }
#invoice dd { max-width:65%; }
#close-invoice { min-width:2.8rem;font-size:1.45rem;line-height:1; }
#invoice-notice:not(:empty) { margin-top:.75rem;color:var(--muted); }
