/* GESMA Finance. Colours follow gesma.ch (navy + blue on white).
   Mobile first: tables become cards under 760px. */

@font-face {
  font-family: "DM Sans";
  src: url(/dm-sans.woff2) format("woff2");
  font-weight: 100 1000;
  font-display: swap;
}

/* The hidden attribute always wins, even over .btn's display. Buttons
   that need the script start hidden and are shown by it. */
[hidden] { display: none !important; }

:root {
  --navy: #0f2044;
  --navy-mid: #1a3260;
  --blue: #2555a0;
  --blue-hover: #1d4686;
  --sky: #4a90d9;
  --blue-bg: #eef4fd;
  --page: #f4f6fb;
  --card: #ffffff;
  --ink: #0d1b2a;
  --ink-mid: #2c3e55;
  --ink-soft: #5a6a7e;
  --line: rgba(15, 32, 68, 0.1);
  --line-strong: rgba(15, 32, 68, 0.2);

  /* Status: text colours all pass 4.5:1 on their backgrounds. */
  --paid: #17643f;
  --paid-bg: #e3f4ea;
  --partial: #8a4b00;
  --partial-bg: #fff0d9;
  --due: #b42318;
  --due-bg: #fdeae8;

  --r: 12px;
  --r-sm: 8px;
  --r-lg: 16px;
  --head-bg: #f7f9fc;
  --shadow: 0 1px 2px rgba(15, 32, 68, 0.06), 0 4px 16px rgba(15, 32, 68, 0.05);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.34, 1.5, 0.64, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  font-variant-numeric: tabular-nums;
}

a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--blue-hover); }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 8px; }

:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 4px; }

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

.skip { position: absolute; left: 8px; top: -60px; background: var(--card); padding: 8px 12px; z-index: 100; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }

.muted { color: var(--ink-soft); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.small { font-size: 0.875rem; }
.warn-text { color: var(--partial); font-weight: 500; }

/* ── Top bar ─────────────────────────────────────────────────── */
.top { background: var(--navy); color: #fff; }
.top-inner {
  max-width: 1180px; margin: 0 auto; padding: 8px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; min-height: 44px; }
.brand:hover { color: #fff; }
.brand em { font-style: normal; font-weight: 400; opacity: 0.75; }
.brand-mark { display: block; flex: none; width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14); }
.brand-mark.big { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto; box-shadow: 0 10px 24px -8px rgba(15, 32, 68, 0.55); }
.top nav { display: flex; flex-wrap: wrap; gap: 2px; order: 3; width: 100%; margin: 0 -8px; }
.top nav a {
  color: rgba(255, 255, 255, 0.78); text-decoration: none; padding: 10px 12px; border-radius: var(--r-sm);
  min-height: 44px; display: inline-flex; align-items: center; font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}
.top nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.top nav a[aria-current="page"] { color: #fff; background: var(--navy-mid); box-shadow: inset 0 -2px 0 var(--sky); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.875rem; }
.who-name { opacity: 0.8; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .link { color: #fff; }

@media (max-width: 759px) {
  .top nav a { padding: 10px 8px; }
}
@media (min-width: 760px) {
  .top nav { order: 0; width: auto; margin: 0; }
}
.nav-group, .who-avatar { display: none; }
.top nav .icon, .who-out .icon { display: none; }

/* Desktop: the top bar becomes a white sidebar. */
@media (min-width: 1000px) {
  body.has-side { padding-left: 256px; }
  .top {
    position: fixed; inset: 0 auto 0 0; width: 256px; z-index: 20; overflow-y: auto;
    background: var(--card); color: var(--ink); border-right: 1px solid var(--line);
  }
  .top-inner { min-height: 100%; max-width: none; padding: 20px 16px 16px; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; }
  .brand { color: var(--navy); font-size: 1.1rem; padding: 0 8px 18px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
  .brand:hover { color: var(--navy); }
  .brand em { color: var(--ink-soft); opacity: 1; }
  .brand .brand-mark { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 4px 10px -4px rgba(15, 32, 68, 0.5); }
  .top nav { flex-direction: column; flex-wrap: nowrap; gap: 2px; }
  .nav-group { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); padding: 0 12px; margin: 6px 0 6px; }
  .nav-group ~ .nav-group { margin-top: 22px; }
  /* Hover: the Originkit "dotted offset" effect. The link lifts up and
     left, a sky block shows where it was, and a dashed border appears;
     the springy curve gives the small overshoot. */
  .top nav a {
    gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-mid);
    border: 1px dashed transparent;
    transition:
      transform 300ms var(--ease-spring), box-shadow 300ms var(--ease-spring),
      background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  }
  .top nav .icon { display: block; color: var(--ink-soft); transition: color 150ms ease; }
  .top nav a:hover { color: var(--ink); }
  .top nav a:hover .icon { color: var(--ink); }
  .top nav a[aria-current="page"] {
    background: var(--navy); color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 6px 14px -6px rgba(15, 32, 68, 0.55);
  }
  .top nav a[aria-current="page"] .icon { color: #fff; }
  .who {
    margin: 24px 0 0; margin-top: auto; padding: 10px 8px 10px 12px; gap: 10px;
    display: grid; grid-template-columns: auto 1fr auto; align-items: center;
    background: var(--page); border: 1px solid var(--line); border-radius: 12px;
  }
  .who-avatar {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--blue-bg); color: var(--blue); font-weight: 700;
  }
  .who-name { opacity: 1; max-width: none; font-weight: 600; color: var(--ink); font-size: 0.9rem; }
  .who .link.who-out { color: var(--ink-soft); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; }
  .who-out .icon { display: block; }
  .who-out span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .has-side .wrap { padding-top: 32px; }
}
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  .who .link.who-out:hover { color: var(--due); background: var(--card); }
  .top nav a:hover {
    transform: translate(-3px, -3px);
    background: var(--card); border-color: var(--navy);
    box-shadow: 3px 3px 0 var(--sky);
  }
  .top nav a[aria-current="page"]:hover { background: var(--navy); border-color: var(--sky); box-shadow: 3px 3px 0 var(--sky); }
  /* Pressing settles it back down, like the original. */
  .top nav a:active { transform: none; box-shadow: 0 0 0 var(--sky); }
}

/* ── Page ────────────────────────────────────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 64px; }
.wrap.narrow { max-width: 440px; padding-top: 10vh; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.sub { color: var(--ink-soft); margin: 0; }
.h-sub { font-weight: 400; color: var(--ink-soft); }
.owes { color: var(--due); }
.crumbs { font-size: 0.875rem; color: var(--ink-soft); margin-bottom: 6px; }

.block { margin-top: 32px; }
.block-head, .term-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.block-head h2 { margin: 0; margin-right: auto; }
.term-block + .term-block { margin-top: 20px; }
.term-head .btn { margin-left: auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.card-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 2px; }
.card-title { font-weight: 600; margin: 0 0 2px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.note-box { margin-top: 12px; padding: 12px 16px; background: var(--blue-bg); border-radius: var(--r-sm); color: var(--ink-mid); white-space: pre-line; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  touch-action: manipulation; white-space: nowrap;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--navy); border-color: var(--navy); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 12px -4px rgba(15, 32, 68, 0.5);
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue); }
.btn.danger { background: var(--due); border-color: var(--due); color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
.btn.block { width: 100%; }
.btn:disabled, .btn[data-busy] { opacity: 0.55; cursor: progress; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: var(--blue); color: var(--blue); }
  .btn.primary:hover { background: var(--navy-mid); border-color: var(--navy-mid); color: #fff; }
  .btn.danger:hover { background: #911c13; color: #fff; }
  .btn.ghost:hover { background: var(--blue-bg); border-color: transparent; }
}
button.link {
  background: none; border: 0; padding: 10px 4px; min-height: 44px; font: inherit; color: var(--blue);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* ── Status ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 700; white-space: nowrap; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 22%, transparent);
}
.badge-paid { color: var(--paid); background: var(--paid-bg); }
.badge-partial { color: var(--partial); background: var(--partial-bg); }
.badge-due { color: var(--due); background: var(--due-bg); }
.tag { margin-left: 8px; font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; background: var(--page); color: var(--ink-soft); font-weight: 600; }

/* ── Messages ────────────────────────────────────────────────── */
.flash {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 12px 10px 16px; border-radius: var(--r-sm); margin-bottom: 16px; border: 1px solid;
  animation: flash-in 220ms var(--ease-out);
}
.flash p { margin: 0; }
.flash-ok { background: var(--paid-bg); border-color: rgba(23, 100, 63, 0.25); color: var(--paid); }
.flash-warn { background: var(--partial-bg); border-color: rgba(138, 75, 0, 0.25); color: var(--partial); }
.flash-error { background: var(--due-bg); border-color: rgba(180, 35, 24, 0.25); color: var(--due); }
.flash .btn.ghost { color: inherit; text-decoration: underline; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  background: var(--blue-bg); border: 1px solid rgba(37, 85, 160, 0.2); border-left: 3px solid var(--blue); border-radius: var(--r); padding: 12px 16px; margin-bottom: 16px;
}
.notice p { margin: 0; }

.empty { text-align: center; padding: 48px 16px; background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty-title { font-weight: 700; font-size: 1.05rem; }
.empty form { margin-top: 12px; }

/* ── Summary ─────────────────────────────────────────────────── */
/* Stat cards follow the dashboard: the main one is the navy hero,
   status ones carry their mark in a tinted circle. */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: border-color 150ms ease, box-shadow 200ms ease, transform 160ms var(--ease-out);
}
a.stat:active { transform: scale(0.98); }
.stat-main { grid-column: 1 / -1; }
.stat-label { display: flex; align-items: center; gap: 10px; min-height: 30px; font-size: 0.875rem; color: var(--ink-mid); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; margin-top: 6px; }
.stat-main .stat-value { font-size: 1.6rem; }
@media (max-width: 479px) { .stat-value, .stat-main .stat-value { font-size: 1.3rem; } }
.stat-foot, .of { font-size: 0.8125rem; color: var(--ink-soft); font-weight: 400; letter-spacing: 0; }
.stat-paid .stat-value { color: var(--paid); }
.stat-partial .stat-value { color: var(--partial); }
.stat-due .stat-value { color: var(--due); }
.stat-icon, .stat:is(.stat-paid, .stat-partial, .stat-due):not(:has(.stat-icon)) .stat-label::before {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 10px;
  background: var(--blue-bg); color: var(--blue); font-size: 0.8rem; font-weight: 800;
}
.stat-icon .icon { width: 17px; height: 17px; }
.stat-paid .stat-icon, .stat-paid:not(:has(.stat-icon)) .stat-label::before { background: var(--paid-bg); color: var(--paid); }
.stat-partial .stat-icon, .stat-partial:not(:has(.stat-icon)) .stat-label::before { background: var(--partial-bg); color: var(--partial); }
.stat-due .stat-icon, .stat-due:not(:has(.stat-icon)) .stat-label::before { background: var(--due-bg); color: var(--due); }
.stat-paid:not(:has(.stat-icon)) .stat-label::before { content: "✓"; }
.stat-partial:not(:has(.stat-icon)) .stat-label::before { content: "◐"; }
.stat-due:not(:has(.stat-icon)) .stat-label::before { content: "!"; }
a.stat[aria-current="true"] { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy) inset, var(--shadow); }
@media (hover: hover) and (pointer: fine) {
  a.stat:hover { border-color: var(--line-strong); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 32, 68, 0.06), 0 10px 24px -8px rgba(15, 32, 68, 0.16); }
}
@media (min-width: 760px) {
  .summary { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .stat-main { grid-column: auto; }
}

.stat-main {
  color: #fff; border-color: transparent;
  background:
    radial-gradient(90% 80% at 100% 0%, rgba(74, 144, 217, 0.45), transparent 60%),
    linear-gradient(150deg, var(--blue) 0%, var(--navy-mid) 55%, var(--navy) 100%);
  box-shadow: 0 12px 28px -10px rgba(15, 32, 68, 0.55);
}
.stat-main .stat-label { color: #fff; }
.stat-main .stat-icon { background: rgba(255, 255, 255, 0.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.stat-main .stat-value, .stat-main .stat-value .money { color: #fff; }
.stat-main .stat-foot, .stat-main .of { color: rgba(255, 255, 255, 0.75); }
.stat-main progress { background: rgba(255, 255, 255, 0.18); }
.stat-main progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.18); }
.stat-main progress::-webkit-progress-value { background: #fff; }
.stat-main progress::-moz-progress-bar { background: #fff; }

progress {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px; margin-top: 6px;
  border: 0; border-radius: 999px; background: var(--page); overflow: hidden; color: var(--paid);
}
progress::-webkit-progress-bar { background: var(--page); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--paid); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--paid); border-radius: 999px; }

/* ── Filters ─────────────────────────────────────────────────── */
/* A toolbar card. On wider screens it joins the table below it into
   one card, like an invoice list. */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; padding: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.filters .grow { flex: 1 1 220px; }
.filters input, .filters select { border-radius: 10px; }
.chips { display: flex; gap: 2px; border: 0; margin: 0; padding: 4px; flex-wrap: wrap; background: var(--page); border-radius: 12px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 9px;
  border: 0; background: transparent; color: var(--ink-soft); font-weight: 600; font-size: 0.875rem;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.chip:hover span { color: var(--ink); }
.chip input:checked + span { background: var(--card); color: var(--navy); box-shadow: 0 1px 2px rgba(15, 32, 68, 0.1), 0 0 0 1px var(--line); }
.chip-paid input:checked + span { color: var(--paid); }
.chip-partial input:checked + span { color: var(--partial); }
.chip-due input:checked + span { color: var(--due); }
.chip input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: 2px; }
@media (min-width: 760px) {
  .filters:has(+ table), .filters:has(+ .count + table) { margin-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: none; }
  .filters + .count:has(+ table) { margin: 0; padding: 10px 16px; background: var(--card); border: 1px solid var(--line); border-top: 0; }
  .filters + table, .filters + .count + table { border-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .filters + table thead th, .filters + .count + table thead th { border-radius: 0 !important; }
}
.count { font-size: 0.875rem; color: var(--ink-soft); margin: 0 0 8px; }
.foot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 20px; }
.foot-actions p { margin: 0; }

/* ── Forms ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.wide { grid-column: 1 / -1; margin-top: 12px; }
.field-label { font-size: 0.875rem; font-weight: 600; color: var(--ink-mid); }
.field-hint { font-size: 0.8125rem; color: var(--ink-soft); }
.field-error { font-size: 0.8125rem; color: var(--due); font-weight: 600; }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 12px; min-height: 44px; width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field.inline select, .field.inline input { width: auto; }
.field.inline.grow input { width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.3); }
[aria-invalid="true"] { border-color: var(--due); }

.stack > * + * { margin-top: 14px; }
fieldset.card { margin: 0; }
fieldset.card legend { font-weight: 700; padding: 0 6px; margin-left: -6px; }
.grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--blue); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 16px; }
.inline-form .field { flex: 0 1 260px; }
.term-pick .field-label { color: var(--ink-soft); }

/* ── Tables ──────────────────────────────────────────────────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
.fees, .list {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.fees th, .fees td, .list th, .list td { text-align: left; padding: 14px 16px; vertical-align: top; }
thead th {
  font-size: 0.8125rem; color: var(--ink-soft); font-weight: 600; background: var(--head-bg);
  border-bottom: 1px solid var(--line); padding-top: 11px; padding-bottom: 11px;
}
:is(.fees, .list) thead th:first-child { border-top-left-radius: var(--r-lg); }
:is(.fees, .list) thead th:last-child { border-top-right-radius: var(--r-lg); }
@media (hover: hover) and (pointer: fine) and (min-width: 760px) {
  :is(.fees, .list) tbody tr > * { transition: background-color 150ms ease; }
  :is(.fees, .list) tbody tr:hover > * { background: #fafbfe; }
}
tbody tr + tr > * { border-top: 1px solid var(--line); }
tbody th { font-weight: 600; }
tfoot th, tfoot td { border-top: 1px solid var(--line-strong); font-weight: 700; }
.list.compact th, .list.compact td { padding: 10px 16px; }
.num { text-align: right !important; white-space: nowrap; }
.money { font-variant-numeric: tabular-nums; }
.fam { font-weight: 700; text-decoration: none; color: var(--ink); }
.fam:hover { color: var(--blue); text-decoration: underline; }
.fam-sub { display: block; font-size: 0.8125rem; color: var(--ink-soft); font-weight: 400; }
.person { display: flex; align-items: flex-start; gap: 12px; }
.person-text { min-width: 0; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: var(--blue-bg); color: var(--blue); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(37, 85, 160, 0.12);
}
.row-paid .avatar { background: var(--paid-bg); color: var(--paid); box-shadow: none; }
.row-partial .avatar { background: var(--partial-bg); color: var(--partial); box-shadow: none; }
.row-due .avatar { background: var(--due-bg); color: var(--due); box-shadow: none; }
.inactive .avatar { background: var(--page); color: var(--ink-soft); }
.avatar.big { width: 56px; height: 56px; font-size: 1.1rem; background: linear-gradient(160deg, var(--navy-mid), var(--navy)); color: #fff; box-shadow: 0 8px 18px -8px rgba(15, 32, 68, 0.6); }
.fam-head { display: flex; align-items: center; gap: 16px; }
.parent .person { gap: 14px; }
.parent .person-text { display: flex; flex-direction: column; gap: 2px; }
.parent .card-title { margin: 2px 0 4px; font-size: 1.05rem; }
.parent-line { font-size: 0.875rem; color: var(--ink-mid); }
.cat { display: inline-flex; padding: 2px 10px; border-radius: 999px; background: var(--page); border: 1px solid var(--line); font-size: 0.8125rem; font-weight: 500; color: var(--ink-mid); white-space: nowrap; }
.kids { list-style: none; margin: 0; padding: 0; }
.kids li + li { margin-top: 2px; }
.kid-class { margin-left: 6px; font-size: 0.8125rem; color: var(--ink-soft); }
.kids .inactive, tr.inactive th, tr.inactive td { color: var(--ink-soft); }
.phones span { display: block; }
.actions { text-align: right; }
.done { font-size: 0.875rem; color: var(--paid); font-weight: 600; white-space: nowrap; }
tr.voided th, tr.voided td { color: var(--ink-soft); }
tr.voided .money { text-decoration: line-through; }
.void-note { color: var(--due); }
.details { font-size: 0.875rem; }

/* The family you just paid for is highlighted when the page returns. */
tr:target > * { animation: row-flash 1.6s var(--ease-out); }
@keyframes row-flash { from { background: var(--blue-bg); } }

/* Record payment */
.pay { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.btn.pay-full { background: var(--blue-bg); border-color: rgba(37, 85, 160, 0.25); color: var(--blue); }
@media (hover: hover) and (pointer: fine) { .btn.pay-full:hover { background: var(--blue); color: #fff; } }
details.more > summary {
  list-style: none; cursor: pointer; font-size: 0.875rem; color: var(--blue); font-weight: 500;
  min-height: 36px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 8px;
  text-decoration: underline; text-underline-offset: 2px; border: 1px dashed transparent; white-space: nowrap;
  transition:
    transform 300ms var(--ease-spring), box-shadow 300ms var(--ease-spring),
    background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
/* Same "dotted offset" hover as the sidebar, a notch smaller. */
@media (hover: hover) and (pointer: fine) {
  details.more > summary:hover {
    color: var(--navy); background: var(--blue-bg); border-color: var(--navy); text-decoration: none;
    transform: translate(-2px, -2px); box-shadow: 2px 2px 0 var(--sky);
  }
  details.more > summary:active { transform: none; box-shadow: 0 0 0 var(--sky); }
}
details.more[open] > summary { color: var(--navy); background: var(--blue-bg); text-decoration: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { font-weight: 700; }
.pay-form {
  display: grid; gap: 10px; text-align: left; margin-top: 6px; padding: 12px; width: min(300px, 80vw);
  background: var(--page); border: 1px solid var(--line); border-radius: var(--r-sm);
  animation: open 180ms var(--ease-out);
}
@keyframes open { from { opacity: 0; transform: translateY(-4px); } }

/* Phones: each row becomes a card. */
@media (max-width: 759px) {
  .fees, .list { background: none; border: 0; box-shadow: none; }
  .fees thead, .list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fees tbody, .list tbody, .fees tr, .list tr, .list tfoot { display: block; }
  .fees tbody tr, .list tbody tr {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
    padding: 12px 14px; margin-bottom: 10px;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px;
  }
  .fees tbody tr > *, .list tbody tr > *, .list.compact tbody tr > * { border: 0 !important; padding: 0; }
  .fees tbody th, .list tbody th, .fees td[data-label="Children"], .list td[data-label="Children"],
  .list td[data-label="For"], .list td[data-label="Details"], .list td[data-label="WhatsApp"], .list td[data-label="Description"],
  .fees td.actions, .list td.actions { grid-column: 1 / -1; }
  .fees td[data-label]::before, .list td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.6875rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--ink-soft); font-weight: 600;
  }
  .fees td[data-label="Children"]::before, .fees td[data-label="Status"]::before, .list td[data-label="Status"]::before { display: none; }
  .fees .num, .list .num { text-align: left !important; }
  .fees td[data-label="Status"] { grid-column: 1 / -1; }
  .fees .pay { align-items: stretch; }
  .fees .pay .btn { width: 100%; }
  .actions { text-align: left; }
  .pay-form { width: 100%; }
  .list tfoot tr { display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px 14px; }
  .list tfoot th { grid-column: 1 / -1; }
  .list tfoot td:empty, .list tbody td:empty { display: none; }
  .list tfoot > tr > * { border: 0; padding: 0; }
  .list tfoot td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.6875rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--ink-soft); font-weight: 600;
  }
}

/* ── Teachers ────────────────────────────────────────────────── */
.tabs {
  display: flex; width: fit-content; max-width: 100%; gap: 2px; padding: 4px; margin: 8px 0 24px; overflow-x: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.tabs a {
  padding: 0 16px; min-height: 40px; display: inline-flex; align-items: center; white-space: nowrap; border-radius: 9px;
  color: var(--ink-soft); font-weight: 600; text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}
.tabs a:hover { color: var(--ink); background: var(--page); }
.tabs a[aria-current="page"] { color: #fff; background: var(--navy); box-shadow: 0 4px 10px -4px rgba(15, 32, 68, 0.5); }

.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.day-nav [aria-disabled="true"] { opacity: 0.35; pointer-events: none; }
.day-pick .field-label { text-align: center; }
.day-pick input { text-align: center; font-weight: 600; }
.month-title { margin: 0; font-size: 1.25rem; }

.fridays { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; }
.fridays a {
  display: flex; flex-direction: column; padding: 8px 10px; min-height: 44px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); text-decoration: none; color: var(--ink);
  transition: border-color 150ms ease, transform 160ms var(--ease-out);
}
.fridays a:active { transform: scale(0.97); }
.fridays a[aria-current="date"] { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; }
.f-date { font-weight: 700; font-size: 0.9rem; }
.f-state { font-size: 0.75rem; color: var(--ink-soft); }
.fridays .marked .f-state { color: var(--paid); font-weight: 600; }
.fridays .open .f-state { color: var(--partial); font-weight: 600; }
.fridays .future { opacity: 0.6; }
.fridays .holiday .f-state { color: var(--ink-soft); font-style: italic; }
.badge-holiday { color: var(--ink-soft); background: var(--line); }
.holiday-form { margin-top: 16px; }

.attendance { max-width: 560px; }
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.att-head h2 { margin: 0; }
.att-list { list-style: none; margin: 12px 0 16px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.att-list li + li { border-top: 1px solid var(--line); }
.att-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 56px; cursor: pointer; }
.att-row input { width: 24px; height: 24px; min-height: 0; flex: none; accent-color: var(--paid); }
.att-name { font-weight: 600; }
.att-class { margin-left: auto; font-size: 0.8125rem; color: var(--ink-soft); }
.att-row:has(input:not(:checked)) .att-name { color: var(--ink-soft); text-decoration: line-through; }
.no-class { margin-top: 12px; }

.summary.three { grid-template-columns: repeat(2, 1fr); }
.summary.three .stat:first-child { grid-column: 1 / -1; }
@media (min-width: 760px) { .summary.three { grid-template-columns: repeat(3, 1fr); } .summary.three .stat:first-child { grid-column: auto; } }

/* ── Books ───────────────────────────────────────────────────── */
.order-card { display: grid; gap: 12px; margin-bottom: 16px; }
.order-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; }
.order-facts > div { display: flex; flex-direction: column; font-size: 0.9rem; }
@media (min-width: 760px) { .order-facts { grid-template-columns: repeat(4, 1fr); } }
.order-ledger { border-top: 1px solid var(--line); padding-top: 10px; }
.order-ledger p { margin: 0 0 4px; }
.pay-form.wide-form { width: min(420px, 100%); }
.collect { margin: 6px 0 2px; }
.chip-btn {
  font: inherit; font-size: 0.8125rem; font-weight: 600; min-height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px dashed var(--line-strong); background: var(--card); color: var(--ink-mid); cursor: pointer;
  transition: background-color 150ms ease, transform 160ms var(--ease-out);
}
.chip-btn:active { transform: scale(0.97); }
.chip-btn.done-chip { border-style: solid; border-color: transparent; background: var(--paid-bg); color: var(--paid); }
.add-box > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; list-style: none; }
.add-box > summary::-webkit-details-marker { display: none; }
.add-box > summary::before { content: "+"; font-weight: 700; color: var(--blue); width: 1em; }
.add-box[open] > summary::before { content: "−"; }
.add-box[open] > summary { margin-bottom: 8px; }

/* ── Settings ──────────────────────────────────────────────── */
/* Label and explanation on the left, the fields in a card on the right. */
.set-row { display: grid; gap: 12px 32px; }
.set-row + .set-row { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
.set-intro h2 { font-size: 1.05rem; margin: 0 0 4px; }
.set-intro p { font-size: 0.875rem; color: var(--ink-soft); margin: 0; max-width: 42ch; }
.set-actions { flex-direction: column; align-items: flex-start; gap: 4px; }
.set-actions .check { font-weight: 500; }
.block.set-row { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
@media (min-width: 1000px) {
  .set-row { grid-template-columns: 280px 1fr; }
  .set-actions { padding-left: calc(280px + 32px); }
}

/* ── Ledger ──────────────────────────────────────────────────── */
.ledger-filters .field.inline input[type="date"] { width: auto; }
.ledger-filters .grow { flex-basis: 160px; }
.ledger-filters select { max-width: 190px; }
.money-in .money { color: var(--paid); font-weight: 600; }
.money-out .money { color: var(--due); font-weight: 600; }
tr.reversal th, tr.reversal td { color: var(--ink-soft); background: var(--page); }
/* Double entry: references, accounts, and the journal's grouping. */
.ref { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: 0.8125rem; color: var(--blue); white-space: nowrap; }
a.ref { text-decoration: none; }
a.ref:hover { text-decoration: underline; }
.acct { color: var(--ink); text-decoration: none; font-weight: 500; }
.acct:hover { text-decoration: underline; }
/* Credit lines indented, as a journal is written. */
.acct-cr { padding-left: 1.5em; }
.journal tr.entry-start > * { border-top: 1px solid var(--line-strong); }
.journal tr.opening td { color: var(--ink-soft); font-style: italic; }
.ledger .num { white-space: nowrap; }
.ok-text { color: var(--paid); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.summary.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .summary.four { grid-template-columns: repeat(4, 1fr); } }
a.stat { text-decoration: none; color: inherit; }

/* "New entry": a list of links under one button. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 260px; display: grid; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.menu-list a { display: flex; gap: 8px; align-items: baseline; padding: 9px 12px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.menu-list a:hover { background: var(--page); }

/* Entry lines typed in a form. */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th, table.lines td { padding: 6px 8px 6px 0; text-align: left; vertical-align: middle; }
table.lines th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); font-weight: 600; }
table.lines .num, table.lines th.num { text-align: right; }
table.lines input, table.lines select { width: 100%; min-width: 0; }
table.lines td.num input { min-width: 90px; max-width: 130px; text-align: right; }
table.lines td[data-label="Memo"] input { min-width: 110px; }
table.lines select { min-width: 200px; }
table.lines tfoot td { font-weight: 700; }
table.lines output { font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  table.lines thead { display: none; }
  table.lines tr { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.lines td { padding: 0; }
  table.lines td.num input { max-width: none; text-align: left; }
}

.entry-facts { display: grid; gap: 8px 24px; margin: 16px 0; }
.entry-facts dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); font-weight: 600; }
.entry-facts dd { margin: 0; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }

/* Reports */
.report caption { text-align: left; font-weight: 700; padding: 0 0 10px; color: var(--ink-mid); }
.report tr.report-head th { background: var(--head-bg); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
.report tr.report-total td { font-weight: 700; border-top: 1px solid var(--line); }

/* Bank: statement against the books, and teacher months to tick. */
.reconcile { display: grid; gap: 10px 24px; margin-bottom: 16px; }
@media (min-width: 760px) { .reconcile { grid-template-columns: repeat(3, 1fr); } .reconcile p { grid-column: 1 / -1; margin: 0; } }
.reconcile strong { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.reconcile.ok { border-color: var(--paid); }
.tick-list { border: 0; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.inline-toggle { display: inline-block; margin-left: 8px; }
.chips.big .chip span { min-height: 44px; font-size: 0.95rem; }
.chips.big legend { margin-bottom: 6px; }

/* ── Dashboard ───────────────────────────────────────────────── */
/* Layout after OripioFin: KPI row with one navy hero card, then two
   rows of panels. Colours stay GESMA navy / blue / sky. */
.dash-head { align-items: center; justify-content: flex-start; gap: 8px 14px; margin-bottom: 18px; }
.dash-head h1 { margin: 0; }
.term-pill {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 0.875rem; font-weight: 600; color: var(--ink-mid);
}
.kpis { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .kpis { grid-template-columns: 1.25fr 1fr 1fr 1fr; } }

.kpi {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 18px 18px 0; border-radius: 16px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform 300ms var(--ease-spring), box-shadow 300ms var(--ease-spring), border-color 150ms ease;
}
.kpi:active { transform: scale(0.99); }
.kpi-head { display: flex; align-items: center; gap: 12px; }
.kpi-icon {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px;
  background: var(--blue-bg); color: var(--blue);
}
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi-title { display: block; font-weight: 600; line-height: 1.3; }
.kpi-sub { display: block; font-size: 0.8125rem; color: var(--ink-soft); }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; margin-top: 6px; }
.kpi-value.owes { color: var(--due); }
.kpi-cur { font-size: 0.55em; font-weight: 600; letter-spacing: 0; color: var(--ink-soft); vertical-align: 0.35em; }
.kpi-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.8125rem; color: var(--ink-soft); margin-top: -4px; }
.kpi-meta .warn-text { flex-basis: 100%; }
.kpi-meta progress { flex-basis: 100%; margin-top: 4px; }
.kpi-pill {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  font-weight: 700; font-size: 0.75rem; background: var(--paid-bg); color: var(--paid);
}
.kpi-foot {
  display: flex; align-items: center; justify-content: space-between; margin: auto 0 16px; padding: 10px 12px;
  border-radius: 10px; background: var(--page); border: 1px dashed transparent;
  font-size: 0.875rem; font-weight: 600; color: var(--ink-mid);
}
.kpi-foot .icon { transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .kpi:hover {
    color: var(--ink); transform: translate(-3px, -3px);
    border-style: dashed; border-color: var(--navy); box-shadow: 4px 4px 0 var(--sky);
  }
  .kpi-hero:hover { color: #fff; border-color: #fff; box-shadow: 4px 4px 0 var(--sky); }
  .kpi:hover .kpi-foot .icon { transform: translateX(3px); }
}

.kpi-hero {
  color: #fff; border-color: transparent;
  background:
    radial-gradient(90% 80% at 100% 0%, rgba(74, 144, 217, 0.45), transparent 60%),
    linear-gradient(150deg, var(--blue) 0%, var(--navy-mid) 55%, var(--navy) 100%);
  box-shadow: 0 12px 28px -10px rgba(15, 32, 68, 0.55);
}
.kpi-hero .kpi-icon { background: rgba(255, 255, 255, 0.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.kpi-hero .kpi-sub, .kpi-hero .kpi-meta, .kpi-hero .kpi-cur { color: rgba(255, 255, 255, 0.75); }
.kpi-hero .kpi-pill { background: rgba(255, 255, 255, 0.16); color: #fff; }
.kpi-hero .kpi-foot { color: #fff; background: rgba(255, 255, 255, 0.12); }
.kpi-hero progress { background: rgba(255, 255, 255, 0.18); }
.kpi-hero progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.18); }
.kpi-hero progress::-webkit-progress-value { background: #fff; }
.kpi-hero progress::-moz-progress-bar { background: #fff; }

.dash-row { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 1000px) {
  .dash-row { grid-template-columns: 5fr 7fr; }
  .dash-row.lower { grid-template-columns: 7fr 4fr; align-items: start; }
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.panel-sub { margin: 2px 0 0; font-size: 0.8125rem; color: var(--ink-soft); }
.panel-head .btn.small { border-radius: 999px; }

.fam-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fam-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px; min-height: 44px; border-radius: 12px;
  text-decoration: none; background: var(--page); border: 1px solid var(--line);
  transition: transform 160ms var(--ease-out), border-color 150ms ease;
}
.fam-tile:active { transform: scale(0.97); }
.fam-tile strong { font-size: 1.75rem; line-height: 1.1; color: var(--ink); letter-spacing: -0.02em; }
.fam-tile span:last-child { font-size: 0.8125rem; font-weight: 600; }
.fam-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 0.8rem; font-weight: 800; margin-bottom: 8px; }
.tile-paid, .tile-paid:hover { color: var(--paid); } .tile-paid .fam-mark { background: var(--paid-bg); }
.tile-partial, .tile-partial:hover { color: var(--partial); } .tile-partial .fam-mark { background: var(--partial-bg); }
.tile-due, .tile-due:hover { color: var(--due); } .tile-due .fam-mark { background: var(--due-bg); }
@media (hover: hover) and (pointer: fine) { .fam-tile:hover { border-color: var(--line-strong); } }
.fam-bar { margin-top: 16px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--page); }
.fam-bar svg { display: block; width: 100%; height: 100%; animation: bar-wipe 700ms 120ms var(--ease-out) both; }
@keyframes bar-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.fam-facts { margin: 18px 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.fam-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.fam-facts div:last-child { border-bottom: 0; padding-bottom: 0; }
.fam-facts dt { color: var(--ink-soft); }
.fam-facts dd { margin: 0; font-weight: 600; }
.fam-facts dd.owes { color: var(--due); }
.panel-empty { margin: 0; padding: 24px 16px; text-align: center; color: var(--ink-soft); background: var(--page); border-radius: 12px; font-size: 0.9rem; }
.seg-paid { fill: var(--paid); } .seg-partial { fill: #d98a1c; } .seg-due { fill: var(--due); }

.panel-kicker { font-size: 0.875rem !important; font-weight: 500; color: var(--ink-soft); }
.flow-total { margin: 2px 0 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; font-size: 0.8125rem; color: var(--ink-soft); }
@media (max-width: 639px) { .panel-head:has(.legend) { flex-wrap: wrap; } .legend { width: 100%; justify-content: flex-start; } }
.legend li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.key { width: 10px; height: 10px; border-radius: 3px; }
.key-in { background: var(--blue); } .key-out { background: #b8cdea; }

.flow-plot { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.flow-axis { display: flex; flex-direction: column; justify-content: space-between; height: 200px; font-size: 0.75rem; color: var(--ink-soft); text-align: right; translate: 0 -0.5em; }
.flow-axis span { line-height: 1; }
.flow-area { min-width: 0; }
.flow-area svg {
  display: block; width: 100%; height: 200px; overflow: visible;
  background: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 50px);
  border-bottom: 1px solid var(--line-strong);
}
.bar-in { fill: var(--blue); } .bar-out { fill: #b8cdea; }
/* On load the bars grow from the baseline, month by month, "out" just
   behind "in". Once per page load, kept short: the dashboard is opened
   many times a day. */
.flow-area rect {
  transform-box: fill-box; transform-origin: 50% 100%;
  animation: bar-rise 520ms var(--ease-out) both;
}
.flow-area .bar-out { animation-delay: 40ms; }
.flow-area g:nth-child(2) rect { animation-delay: 50ms; }  .flow-area g:nth-child(2) .bar-out { animation-delay: 90ms; }
.flow-area g:nth-child(3) rect { animation-delay: 100ms; } .flow-area g:nth-child(3) .bar-out { animation-delay: 140ms; }
.flow-area g:nth-child(4) rect { animation-delay: 150ms; } .flow-area g:nth-child(4) .bar-out { animation-delay: 190ms; }
.flow-area g:nth-child(5) rect { animation-delay: 200ms; } .flow-area g:nth-child(5) .bar-out { animation-delay: 240ms; }
.flow-area g:nth-child(6) rect { animation-delay: 250ms; } .flow-area g:nth-child(6) .bar-out { animation-delay: 290ms; }
@keyframes bar-rise { from { transform: scaleY(0); } }
.now .bar-in { fill: var(--navy); } .now .bar-out { fill: var(--sky); }
.flow-months { display: flex; margin-top: 8px; }
.flow-months span { flex: 1; text-align: center; font-size: 0.8125rem; color: var(--ink-soft); }
.flow-months .now { color: var(--ink); font-weight: 700; }

.pay-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.pay-table th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); padding: 8px 10px; background: var(--page); }
.pay-table th:first-child { border-radius: 8px 0 0 8px; } .pay-table th:last-child { border-radius: 0 8px 8px 0; }
.pay-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pay-table tr:last-child td { border-bottom: 0; }
.pay-what { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
.pay-what:hover { color: var(--blue); text-decoration: underline; }
.pay-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pay-dot.in { background: var(--paid); } .pay-dot.out { background: var(--due); }
.pay-date, .pay-by { color: var(--ink-soft); white-space: nowrap; }
.pay-table .money-in, .pay-table .money-out { font-weight: 700; }
.pay-table .money-in { color: var(--paid); } .pay-table .money-out { color: var(--due); }
@media (max-width: 759px) {
  .pay-table thead { display: none; }
  .pay-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .pay-table tr:last-child { border-bottom: 0; }
  .pay-table td { padding: 0; border: 0; }
  .pay-table td:first-child { grid-column: 1; }
  .pay-table td.num { grid-column: 2; grid-row: 1; }
  .pay-table .pay-date { grid-column: 1; font-size: 0.8125rem; padding-left: 18px; }
  .pay-table .pay-by { display: none; }
}

.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--partial-bg); color: var(--partial); font-weight: 700; font-size: 0.8125rem; }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo-list a {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 12px 10px 14px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-weight: 500; font-size: 0.9rem;
  background: var(--page); border: 1px solid var(--line); border-left: 3px solid var(--sky);
  transition: background-color 150ms ease, border-color 150ms ease;
}
.todo-list a span { flex: 1; }
.todo-list .icon { color: var(--ink-soft); transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .todo-list a:hover { background: var(--blue-bg); color: var(--ink); }
  .todo-list a:hover .icon { transform: translateX(2px); color: var(--blue); }
}
/* Dashboard buttons share the sidebar's "dotted offset" hover. */
.kpi-foot, .dash-row .panel-head .btn, .todo-list a {
  transition:
    transform 300ms var(--ease-spring), box-shadow 300ms var(--ease-spring),
    background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.dash-row .panel-head .btn { border-style: dashed; border-color: var(--line-strong); }
@media (hover: hover) and (pointer: fine) {
  .kpi:hover .kpi-foot { background: var(--navy); color: #fff; }
  .kpi-hero:hover .kpi-foot { background: #fff; color: var(--navy); }
  .kpi:active { transform: none; box-shadow: 0 0 0 var(--sky); }
  .dash-row .panel-head .btn:hover, .todo-list a:hover {
    transform: translate(-3px, -3px);
    background: var(--card); color: var(--ink); border-color: var(--navy);
    box-shadow: 3px 3px 0 var(--sky);
  }
  .todo-list a:hover { border-left-width: 1px; border-style: dashed; }
  .dash-row .panel-head .btn:active, .todo-list a:active { transform: none; box-shadow: 0 0 0 var(--sky); }
}

.todo-done { display: flex; align-items: center; gap: 8px; color: var(--paid); font-weight: 600; margin: 0; }

/* ── Activity ────────────────────────────────────────────────── */
.chip-link {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 9px;
  color: var(--ink-soft); font-weight: 600; font-size: 0.875rem; text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.chip-link:hover { color: var(--ink); }
.chip-link.on { background: var(--card); color: var(--navy); box-shadow: 0 1px 2px rgba(15, 32, 68, 0.1), 0 0 0 1px var(--line); }
.incident > summary { cursor: pointer; min-height: 24px; }
.incident[open] > summary { margin-bottom: 12px; }
.incident ol { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 10px; }
pre { margin: 6px 0; padding: 10px 12px; overflow-x: auto; background: var(--navy); color: #e6eefb; border-radius: var(--r-sm); font-size: 0.8125rem; }
.signins {
  list-style: none; margin: 0 0 10px; padding: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.signins li { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 12px 16px; }
.signins li + li { border-top: 1px solid var(--line); }
.si-what { font-weight: 600; }
.signins li.failed .si-what { color: var(--due); }
.si-where { font-size: 0.875rem; color: var(--ink-soft); text-align: right; }
.signins .fam-sub { grid-column: 1 / -1; }

/* ── Export ──────────────────────────────────────────────────── */
.export-warning { margin-top: 16px; background: var(--partial-bg); border-color: rgba(138, 75, 0, 0.25); color: var(--partial); }
.export-all, .export-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.export-list li { justify-content: flex-start; gap: 12px 16px; }
.export-text { flex: 1 1 200px; min-width: 0; }
.export-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--blue-bg); color: var(--blue); }
@media (min-width: 640px) { .export-list li { flex-wrap: nowrap; } }
.export-all {
  color: #fff; border-color: transparent;
  background: radial-gradient(90% 120% at 100% 0%, rgba(74, 144, 217, 0.45), transparent 60%), linear-gradient(150deg, var(--blue), var(--navy-mid) 55%, var(--navy));
  box-shadow: 0 12px 28px -10px rgba(15, 32, 68, 0.55);
}
.export-all .muted { color: rgba(255, 255, 255, 0.75); }
.export-all .btn.primary { background: #fff; border-color: #fff; color: var(--navy); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.3); }
@media (hover: hover) and (pointer: fine) { .export-all .btn.primary:hover { background: var(--blue-bg); border-color: var(--blue-bg); color: var(--navy); } }
.export-all { margin-bottom: 16px; }
.export-all h2, .export-list h2 { margin: 0 0 2px; font-size: 1.05rem; }
.export-all p, .export-list p { margin: 0; font-size: 0.9rem; }
.export-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .export-list { grid-template-columns: 1fr 1fr; } }
.export-buttons { display: flex; gap: 8px; }

/* ── Login ───────────────────────────────────────────────────── */
/* Split card: form on the left, brand panel with an app preview on the
   right. The panel is decoration and drops away under 900px. */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth-shell {
  width: 100%; max-width: 1120px; min-height: min(680px, calc(100dvh - 32px));
  display: grid; grid-template-columns: 1fr;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 8px;
  box-shadow: 0 1px 2px rgba(15, 32, 68, 0.04), 0 12px 32px -8px rgba(15, 32, 68, 0.1), 0 40px 80px -24px rgba(15, 32, 68, 0.14);
  animation: auth-in 500ms var(--ease-out) both;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
@media (min-width: 900px) { .auth-shell { grid-template-columns: 1fr 1.05fr; } }

.auth-form { display: grid; place-items: center; padding: 40px 16px; }
.auth-inner { width: 100%; max-width: 380px; text-align: center; }
.auth-inner h1 { font-size: 1.85rem; letter-spacing: -0.025em; margin: 20px 0 6px; }
.auth-inner .sub { margin-bottom: 28px; }
.auth-inner .flash { text-align: left; }

.auth-fields { display: grid; gap: 18px; text-align: left; }
.auth-fields .field { gap: 6px; }
.auth-fields .field-label { color: var(--ink); font-weight: 500; }
.auth-input { position: relative; display: block; }
.auth-input > .icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--ink-soft); pointer-events: none; }
.auth-input input { min-height: 50px; padding-left: 44px; border-radius: 12px; border-color: var(--line-strong); }
.auth-input input:has(~ .auth-reveal:not([hidden])) { padding-right: 52px; }
.auth-input:focus-within > .icon { color: var(--blue); }

.auth-reveal {
  position: absolute; right: 3px; top: 3px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 10px; color: var(--ink-soft); cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}
.auth-reveal[aria-pressed="true"] { color: var(--blue); }
@media (hover: hover) and (pointer: fine) { .auth-reveal:hover { color: var(--ink); background: var(--page); } }

.btn.auth-submit {
  min-height: 52px; margin-top: 8px; border-radius: 12px; font-size: 1rem;
  background: var(--navy); border-color: var(--navy);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 16px -6px rgba(15, 32, 68, 0.6);
}
@media (hover: hover) and (pointer: fine) { .btn.auth-submit:hover { background: var(--navy-mid); border-color: var(--navy-mid); } }

.auth-foot { display: inline-flex; align-items: center; gap: 6px; margin: 28px 0 0; font-size: 0.875rem; color: var(--ink-soft); }
.auth-foot .icon { width: 16px; height: 16px; }

/* Brand panel */
.auth-art { display: none; }
@media (min-width: 900px) {
  .auth-art {
    display: block; position: relative; overflow: hidden; border-radius: 18px; isolation: isolate;
    background:
      radial-gradient(60% 50% at 85% 10%, rgba(125, 180, 245, 0.55), transparent 70%),
      radial-gradient(70% 60% at 0% 100%, rgba(74, 144, 217, 0.45), transparent 70%),
      linear-gradient(155deg, #2a5fae 0%, var(--navy-mid) 45%, var(--navy) 100%);
  }
  /* Fine grid, fading out towards the bottom. */
  .auth-art::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: linear-gradient(to bottom, #000, transparent 75%);
  }
}
.auth-art-copy { padding: 44px 44px 0; color: #fff; max-width: 460px; }
.auth-art-kicker { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); margin: 0 0 12px; }
.auth-art-line { font-size: 1.75rem; line-height: 1.25; font-weight: 500; letter-spacing: -0.02em; margin: 0; }

.auth-preview {
  position: absolute; left: 18%; top: 40%; width: 110%; height: 80%;
  display: flex; background: #fff; border-radius: 16px 0 0 0; overflow: hidden;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.4), 0 30px 60px -12px rgba(8, 18, 40, 0.55);
  animation: auth-rise 700ms 120ms var(--ease-out) both;
}
@keyframes auth-rise { from { opacity: 0; transform: translateY(24px); } }
.auth-preview-side { width: 190px; flex: none; padding: 18px 14px; background: #f7f9fc; border-right: 1px solid var(--line); }
.auth-preview-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--navy); margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.auth-preview-brand .brand-mark { width: 24px; height: 24px; border-radius: 7px; box-shadow: none; }
.auth-preview-menu { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); margin: 0 0 8px; }
.auth-preview-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.auth-preview-side li { font-size: 0.875rem; color: var(--ink-soft); padding: 7px 10px; border-radius: 8px; }
.auth-preview-side li.on { background: var(--blue-bg); color: var(--blue); font-weight: 600; }
.auth-preview-main { flex: 1; padding: 22px; display: grid; align-content: start; gap: 16px; }
.auth-preview-stats { display: grid; grid-template-columns: repeat(2, 180px); gap: 12px; }
.sk-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.sk { display: block; height: 8px; border-radius: 99px; background: #e8edf5; }
.sk-title { width: 140px; height: 12px; background: #dde4ef; }
.sk-s { width: 60%; }
.sk-l { width: 85%; height: 14px; background: #dde4ef; }
.auth-preview-chart { display: flex; align-items: flex-end; gap: 10px; height: 120px; width: 372px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.auth-preview-chart i { flex: 1; border-radius: 4px 4px 0 0; background: #dbe6f6; }
.auth-preview-chart i:nth-child(1) { height: 40%; }
.auth-preview-chart i:nth-child(2) { height: 62%; }
.auth-preview-chart i:nth-child(3) { height: 48%; }
.auth-preview-chart i:nth-child(4) { height: 80%; background: var(--sky); }
.auth-preview-chart i:nth-child(5) { height: 58%; }
.auth-preview-chart i:nth-child(6) { height: 70%; }
.auth-preview-chart i:nth-child(7) { height: 90%; background: var(--blue); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0ms !important; }
  .btn:active, a.stat:active, .kpi:active, .fam-tile:active { transform: none; }
}

/* ── Classes ─────────────────────────────────────────────────── */
/* Jump links: one pill per class with its head count. */
.class-jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.class-jump a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 6px 0 14px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--ink-mid); font-size: 0.875rem; font-weight: 600; text-decoration: none;
  transition: transform 160ms var(--ease-out), border-color 150ms ease, color 150ms ease;
}
.class-jump a:active { transform: scale(0.97); }
.jump-n {
  display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  background: var(--page); color: var(--ink-soft); font-size: 0.8125rem;
}
.class-jump .jump-waiting { color: var(--partial); border-color: rgba(138, 75, 0, 0.3); }
.class-jump .jump-waiting .jump-n { background: var(--partial-bg); color: var(--partial); }
@media (hover: hover) and (pointer: fine) {
  .class-jump a:hover { border-color: var(--blue); color: var(--blue); }
}

/* A jumped-to section or row clears the top bar on phones. */
.block[id], .class-list tr[id] { scroll-margin-top: 16px; }
.class-help { margin: -4px 0 12px; max-width: 70ch; }
.class-empty { padding: 14px 16px; background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--r); margin: 0; }

/* Waiting: choose a class and place, side by side. */
.place-form { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.place-form .field { width: 210px; }

/* Move / Remove: the open one drops below, full width of the cell. */
.row-actions { display: flex; justify-content: flex-end; align-items: flex-start; gap: 4px; }
.row-actions details[open] { display: flex; flex-direction: column; align-items: flex-end; }
.class-list .actions { width: 1%; white-space: nowrap; }
.class-list:not(.compact) tbody > tr > *, .class-list.compact tbody > tr > * { vertical-align: middle; }
.class-list tbody > tr > :has(details[open]) { vertical-align: top; }
details.more.danger > summary { color: var(--due); }
details.more.danger[open] > summary { color: var(--due); background: var(--due-bg); }
@media (hover: hover) and (pointer: fine) {
  details.more.danger > summary:hover { color: var(--due); background: var(--due-bg); border-color: var(--due); box-shadow: 2px 2px 0 rgba(180, 35, 24, 0.35); }
}
.class-list .pay-form { white-space: normal; }

/* Left: collapsed by default; it is history, not work. */
.left-list > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px;
  margin-bottom: 10px; width: fit-content; border-radius: var(--r-sm);
}
.left-list > summary::-webkit-details-marker { display: none; }
.left-list > summary h2 { margin: 0; color: var(--ink-mid); }
.left-list > summary::before {
  content: ""; width: 8px; height: 8px; margin: 0 2px 0 4px;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: rotate(-45deg); transition: transform 200ms var(--ease-out);
}
.left-list[open] > summary::before { transform: rotate(45deg); }

@media (max-width: 759px) {
  .class-list .actions { width: auto; white-space: normal; }
  .place-form { justify-content: stretch; }
  .place-form .field { flex: 1; width: auto; }
  .row-actions { justify-content: flex-start; }
  .row-actions details[open] { align-items: stretch; flex: 1; }
  .row-actions details[open] > summary { align-self: flex-start; }
  .class-list .pay-form { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .class-jump a, .left-list > summary::before { transition: none; }
}

/* Settings → Siblings: four share boxes in a row from tablet up. */
.grid-4 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.rates-hint { margin: 10px 0 0; }

/* Ledger → By category: collapsible totals above the entries. */
.by-cat { margin: 0 0 20px; }
.by-cat > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px;
  width: fit-content; margin-bottom: 8px;
}
.by-cat > summary::-webkit-details-marker { display: none; }
.by-cat > summary h2 { margin: 0; }
.by-cat > summary::before {
  content: ""; width: 8px; height: 8px; margin: 0 2px 0 4px;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: rotate(-45deg); transition: transform 200ms var(--ease-out);
}
.by-cat[open] > summary::before { transform: rotate(45deg); }
@media (max-width: 759px) {
  .by-cat-list tbody tr { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .by-cat > summary::before { transition: none; } }

/* ── Books: tabs between charges and stock ───────────────────── */
.book-tabs { display: flex; gap: 4px; margin: 4px 0 20px; border-bottom: 1px solid var(--line); }
.book-tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  color: var(--ink-soft); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 150ms ease, border-color 150ms ease;
}
.book-tabs a[aria-current="page"] { color: var(--navy); border-bottom-color: var(--blue); }
@media (hover: hover) and (pointer: fine) { .book-tabs a:hover { color: var(--blue); } }
.tab-badge {
  display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--due-bg); color: var(--due); font-size: 0.75rem; font-weight: 700;
}

/* ── Book stock ──────────────────────────────────────────────── */
.on-hand { font-size: 1.05rem; }
.low-badge { margin-left: 8px; font-size: 0.75rem; padding: 1px 8px; vertical-align: 1px; }
.stock-list tr.stock-low > * { background: color-mix(in srgb, var(--due-bg) 45%, transparent); }
.stock-actions .add-box[open] { grid-column: 1 / -1; }
.qty-grid { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.qty-grid legend { margin-bottom: 6px; }
.qty {
  display: grid; grid-template-columns: 1fr 76px; grid-template-areas: "name input" "hint input"; align-items: center; gap: 0 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--page);
}
.qty-name { grid-area: name; font-size: 0.875rem; font-weight: 600; color: var(--ink-mid); }
.qty-hint { grid-area: hint; font-size: 0.75rem; color: var(--ink-soft); }
.qty input { grid-area: input; text-align: right; min-height: 40px; padding: 6px 10px; }
.stock-history .money-in { color: var(--paid); font-weight: 700; }
.stock-history .money-out { color: var(--due); font-weight: 700; }
@media (max-width: 759px) {
  .stock-list tbody tr { grid-template-columns: repeat(3, 1fr); }
  .book-tabs { overflow-x: auto; }
}
a.chip-btn { text-decoration: none; display: inline-flex; align-items: center; }

.stock-history tbody th { white-space: nowrap; }

/* "Continue with Google": Google's own button style, white with the G. */
.btn.auth-google { background: #fff; color: #1f1f1f; border-color: #747775; gap: 10px; font-weight: 600; }
.g-mark { width: 20px; height: 20px; flex: none; }
.auth-google-hint { text-align: center; margin-top: 8px; }
@media (hover: hover) and (pointer: fine) {
  .btn.auth-google:hover { background: #f8f9fa; color: #1f1f1f; border-color: #747775; }
}

/* After Google: the account about to be used, then Continue. */
.auth-who { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--page); }
.auth-who-text { display: flex; flex-direction: column; min-width: 0; }
.auth-who-text .muted { font-size: 0.875rem; overflow-wrap: anywhere; }
.auth-who + form { margin-top: 14px; }

/* ── WhatsApp messages ──────────────────────────────────────── */
.wa { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-bottom: 8px; }
.wa-send { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; }
.btn.wa-btn { background: #e7f6ec; border-color: rgba(23, 100, 63, 0.3); color: var(--paid); }
.btn.wa-btn:hover { background: #d6efdf; }
.btn.primary.wa-btn { background: var(--paid); border-color: var(--paid); color: #fff; }
.btn.wa-fix { background: var(--partial-bg); border-color: rgba(138, 75, 0, 0.3); color: var(--partial); text-decoration: none; }
.btn.wa-fix:hover { background: #ffe6bf; color: var(--partial); }
.wa-log { margin: 0; font-size: 0.8125rem; color: var(--ink-soft); text-align: right; }
.wa-toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px; border-radius: var(--r); background: var(--navy); color: #fff;
  box-shadow: 0 8px 32px rgba(15, 32, 68, 0.3); font-size: 0.9rem;
}
.wa-toast[hidden] { display: none; }
.wa-toast .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, 0.35); background: transparent; }
textarea.template { font-family: inherit; line-height: 1.5; min-height: 240px; }
.wa-dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--card); color: var(--ink); box-shadow: 0 12px 48px rgba(15, 32, 68, 0.25);
}
.wa-dialog::backdrop { background: rgba(13, 27, 42, 0.45); }
.wa-dialog[open] { animation: wa-in 200ms var(--ease-out); }
@keyframes wa-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .wa-dialog[open] { animation: none; } }
.wa-box { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.wa-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wa-head h2 { margin: 0; font-size: 1.1rem; }
.wa-box textarea { min-height: 280px; line-height: 1.5; }
.wa-warn { margin: 0; padding: 10px 14px 10px 30px; background: var(--partial-bg); color: var(--partial); border-radius: var(--r-sm); font-size: 0.875rem; }
.wa-actions { align-items: center; }
.wa-status { font-size: 0.875rem; }
@media (max-width: 479px) {
  .wa-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .wa-box textarea { min-height: 45dvh; }
}

/* Hand out / receive: whole sets first, single books folded away */
.qty-grid.sets { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.qty-grid.sets .qty { background: var(--blue-bg); border-color: rgba(37, 85, 160, 0.2); }
.singles > summary { cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--blue); padding: 4px 0; }
.singles[open] > summary { margin-bottom: 8px; }

/* WhatsApp filters and send queue */
.chips-msg { align-items: center; }
.chips-label { float: left; font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); padding: 6px 8px 6px 6px; }
.chip-count { display: inline-block; margin-left: 6px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--line); font-size: 0.75rem; font-weight: 700; text-align: center; }
.count-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.count-row .count { margin: 0; }
.btn.wa-btn.is-sent { background: var(--card); border-color: rgba(23, 100, 63, 0.3); color: var(--paid); }
.wa-dialog-send { justify-content: flex-start; }
.wa-progress { margin: 0 0 2px; font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); }
.wa-queue-nav { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.wa-queue-nav[hidden] { display: none; }
.wa-queue-spacer { flex: 1; }

/* Payment QR */
.wa-qr { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.wa-qr-row { display: flex; flex-direction: column; gap: 6px; }
.wa-qr-row .wa-qr { justify-content: flex-start; }
.qr-card { display: flex; flex-direction: column; gap: 14px; }
.qr-current { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qr-current img { width: 160px; height: 160px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px; }
.count-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
/* Families list: families whose children have all left, folded away. */
details.left-families { margin-top: 20px; }
details.left-families > .list { margin-top: 10px; }
/* Bank: statement upload and the payments to match. */
.bank-upload { margin-bottom: 20px; }
.bank-old { margin-bottom: 16px; }
.bank-old .count-row { margin: 12px 0 0; }
a.chip { text-decoration: none; }
a.chip[aria-current="page"] span { background: var(--card); color: var(--navy); box-shadow: 0 1px 2px rgba(15, 32, 68, 0.1), 0 0 0 1px var(--line); }
.bank-top { display: grid; grid-template-columns: auto 1fr auto; gap: 10px 12px; align-items: start; }
.bank-top > div, .bank-alt > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bank-plan { font-size: 0.875rem; color: var(--ink); }
.bank-alt { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.bank-match details.more { margin-top: 8px; }
@media (max-width: 720px) {
  .bank-top { grid-template-columns: 1fr; }
  .bank-alt { flex-direction: column; }
}
.bank-acts { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.bank-acts { max-width: 260px; }
.bank-acts .field.inline { display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; }
.bank-acts .field.inline select { width: 100%; }
.bank-match-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 6px 12px; padding: 4px 0; }
.pay-form.bank-form { width: min(680px, 100%); }
.journal th, .journal td { padding-top: 8px; padding-bottom: 8px; }
