/* hosting.wombat.studio: phone first, the page scrolls normally (nothing pinned to the
   screen height), light or dark following the device. Colours after the family portal. */
:root {
  --bg: #e7ebf1;
  --surface: #ffffff;
  --border: #d5dbe3;
  --text: #1f2937;
  --muted: #5b6472;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --due: #b91c1c;
  --due-bg: #fee2e2;
  --header: #1e293b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.09), 0 1px 2px rgba(15, 23, 42, 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #60a5fa;
    --primary-dark: #93c5fd;
    --ok: #34d399;
    --ok-bg: rgba(16, 185, 129, 0.16);
    --due: #f87171;
    --due-bg: rgba(248, 113, 113, 0.16);
    --header: #020617;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }

/* ---- Header ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem max(1rem, env(safe-area-inset-left));
  background: var(--header);
  color: #fff;
}
.brand { display: flex; align-items: baseline; gap: 0.55rem; color: #fff; text-decoration: none; }
.brand-name { font-weight: 800; letter-spacing: 0.06em; font-size: 1.1rem; }
.brand-sub { font-size: 0.85rem; color: #cbd5e1; text-transform: uppercase; letter-spacing: 0.12em; }
.signout { display: flex; align-items: center; gap: 0.75rem; margin: 0; font-size: 0.9rem; }
.who { color: #cbd5e1; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout .link-button { color: #fff; }

/* ---- Page ---- */
.page { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
h1 { font-size: 1.5rem; margin: 0.25rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.narrow { max-width: 420px; margin: 1.5rem auto; }
.muted { color: var(--muted); font-size: 0.9rem; }
.center { text-align: center; }
.due { color: var(--due); font-weight: 600; }
.ok { color: var(--ok); }
.back { margin: 0 0 0.75rem; }
.back a { text-decoration: none; }
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.5rem 1rem 2.5rem; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; }
input[type="email"], input[type="text"] {
  width: 100%;
  font-size: 1.1rem;           /* 16px+ so phones don't zoom in */
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
#code { letter-spacing: 0.3em; text-align: center; font-size: 1.4rem; }
.button {
  display: inline-block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.button:hover { background: var(--primary-dark); }
.button.secondary { width: auto; background: transparent; color: var(--primary); border: 1px solid var(--border); }
.link-button { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }
.small-form { margin-top: 1rem; font-size: 0.9rem; }
.alert { padding: 0.7rem 0.9rem; border-radius: 8px; margin: 0 0 1rem; }
.alert-error { background: var(--due-bg); color: var(--due); }
.alert-ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }

/* ---- Account ---- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-value.due { color: var(--due); }
.stat-value.ok { color: var(--ok); }
.stat-note { font-size: 0.85rem; color: var(--muted); }
.list { display: grid; gap: 0.6rem; }
.row-link { display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-decoration: none; color: var(--text); }
.row-link .amount { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); }
.table td { padding: 0.6rem 0.3rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.pill-paid { background: var(--ok-bg); color: var(--ok); }
.pill-sent { background: var(--due-bg); color: var(--due); }

/* ---- Invoice ---- */
.invoice { padding: 1.25rem; }
.invoice-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.invoice-from { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.04em; }
.invoice-title { text-align: right; }
.invoice-number { font-size: 1.2rem; font-weight: 700; }
.invoice-boxes { display: grid; grid-template-columns: 1fr; gap: 0.75rem; background: var(--bg); border-radius: 8px; padding: 0.9rem; margin-bottom: 1rem; }
.invoice-boxes .big { font-size: 1.4rem; }
.items tfoot td { border-bottom: 0; padding-top: 0.35rem; padding-bottom: 0.35rem; }
.items tfoot tr:first-child td { border-top: 2px solid var(--text); font-weight: 700; }
.note { margin-bottom: 0; white-space: normal; }
.pay { margin-top: 1rem; }
.pay h2 { margin-top: 0; }

@media (min-width: 560px) {
  .page { padding: 2rem 1.5rem 3rem; }
  .invoice-boxes { grid-template-columns: 2fr 1fr 1fr; }
  .button { width: auto; }
  .narrow .button { width: 100%; }
}

@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .invoice-boxes { background: #f1f5f9; }
}
