/* Celonix Personal Fund Manager — one stylesheet for the public site and the admin. */
:root {
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #f2f4f7;
  --bg: #f7f8fa;
  --card: #ffffff;
  --brand: #0b5c4a;
  --brand-ink: #084236;
  --brand-soft: #e7f3ef;
  --ok: #067647;
  --ok-soft: #e6f6ee;
  --warn: #b54708;
  --warn-soft: #fef4e6;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #175cd3;
  --info-soft: #eaf2fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg);
  font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- admin shell ---------- */
.admin { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 650; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex: none;
}
.brand small { display: block; font-weight: 500; font-size: 11.5px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.nav a {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--line-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.topbar { display: none; }
.main { min-width: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 28px 64px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head p { color: var(--muted); margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- pieces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 16px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { color: var(--muted); font-size: 12.5px; }
.tile .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile.bad .v { color: var(--bad); }
.tile.ok .v { color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font: 600 13.5px var(--font);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-danger { color: var(--bad); border-color: #f3c9c4; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-wa { color: #0a7c42; border-color: #bfe5cf; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.b-paid, .b-ok, .b-published, .b-active { background: var(--ok-soft); color: var(--ok); }
.b-partial, .b-pending, .b-drawn, .b-paused, .b-open { background: var(--warn-soft); color: var(--warn); }
.b-overdue, .b-void, .b-bad { background: var(--bad-soft); color: var(--bad); }
.b-upcoming, .b-none, .b-completed, .b-expired, .b-cancelled { background: var(--line-2); color: var(--muted); }
.b-info { background: var(--info-soft); color: var(--info); }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fbfbfc; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfd; }
tfoot td { font-weight: 650; background: #fbfbfc; border-top: 1px solid var(--line); border-bottom: 0; }
td.void, tr.void td { color: var(--muted); text-decoration: line-through; }
tr.void td .badge, tr.void td .actions { text-decoration: none; }
.who { font-weight: 600; color: var(--ink); }
.who small { display: block; font-weight: 400; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.bar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.thin { height: 6px; }

/* the season sheet (laid out like the spreadsheet) */
.sheet th, .sheet td { padding: 7px 10px; border-right: 1px solid var(--line-2); font-size: 13px; }
.sheet th { text-align: right; }
.sheet th:nth-child(-n+2), .sheet td.fix { text-align: left; }
.sheet th small { display: block; font-weight: 500; }
.sheet td.fix { background: var(--card); position: sticky; left: 0; z-index: 1; }
.sheet .kno { width: 46px; text-align: center; font-weight: 650; color: var(--ink-2); background: #fbfbfc; }
.cell { display: block; width: 100%; min-width: 62px; text-align: right; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 3px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.cell:hover { outline: 1px solid var(--brand); }
.c-paid { color: var(--ok); }
.c-partial { background: var(--warn-soft); color: var(--warn); }
.c-overdue { background: var(--bad-soft); color: var(--bad); }
.c-pending { color: var(--warn); }
.c-upcoming, .c-none { color: #b3b9c4; }
.cur { background: #f3faf7 !important; }

/* forms */
form.inline { display: inline; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); }
label small { font-weight: 400; }
input[type=text], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=month], input[type=email], input[type=search], input[type=file], select, textarea {
  width: 100%; margin-top: 5px; height: 38px; padding: 0 11px; border: 1px solid #d0d5dd; border-radius: 8px;
  font: 14px var(--font); color: var(--ink); background: #fff;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; }
input[type=file] { padding: 7px 11px; height: auto; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .cell:focus-visible { outline: 2px solid #9fd3c4; outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters label { min-width: 130px; flex: 1 1 130px; max-width: 220px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; font-weight: 400; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-weight: 600; font-size: 13px; }
.tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tabs a:hover { text-decoration: none; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 24px 60px rgba(16, 24, 40, .25); color: var(--ink); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-body { padding: 18px 20px; display: grid; gap: 12px; max-height: min(70vh, 640px); overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fbfbfc; border-radius: 0 0 14px 14px; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; }

.toasts { position: fixed; top: 16px; right: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(16, 24, 40, .25); font-weight: 500; }
.toast.err { background: var(--bad); }
.note { padding: 12px 14px; border-radius: 10px; background: var(--info-soft); color: #1849a9; border: 1px solid #c7dcfb; }
.note.warn { background: var(--warn-soft); color: #93370d; border-color: #f9dbaf; }
.note.good { background: var(--ok-soft); color: #085d3a; border-color: #b7e4cc; }
.code { font: 600 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); }

/* the draw */
.winner { text-align: center; padding: 28px 18px; background: linear-gradient(180deg, #f3faf7, #fff); border: 1px solid #b7e4cc; border-radius: var(--radius); }
.winner .no { font-size: 64px; font-weight: 700; letter-spacing: -.03em; color: var(--brand); line-height: 1; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; background: var(--card); font-size: 12.5px; }
.chip b { font-variant-numeric: tabular-nums; }

/* ---------- sign-in pages ---------- */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth { width: min(420px, 100%); display: grid; gap: 16px; }
.auth .card { padding: 26px; display: grid; gap: 14px; }
.auth h1 { font-size: 20px; }

/* ---------- public site ---------- */
.pub-top { background: var(--card); border-bottom: 1px solid var(--line); }
.pub-top .in { max-width: 960px; margin: 0 auto; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pub { max-width: 960px; margin: 0 auto; padding: 28px 20px 72px; }
.hero { padding: 18px 0 26px; }
.hero h1 { font-size: 30px; letter-spacing: -.02em; }
.hero p { color: var(--muted); font-size: 16px; margin-top: 8px; max-width: 56ch; }
.season-card { display: block; padding: 20px; color: inherit; }
.season-card:hover { text-decoration: none; border-color: var(--brand); }
.season-card h2 { font-size: 19px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; color: var(--ink-2); }
.facts b { font-variant-numeric: tabular-nums; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; padding: 16px 18px; }
.name { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 650; font-size: 12.5px; flex: none; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.d-paid { background: var(--ok); }
.dot.d-partial { background: #f79009; }
.dot.d-overdue { background: var(--bad); }
.dot.d-pending { background: #fdb022; }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 0 0; }
.pay { max-width: 420px; margin: 0 auto; text-align: center; }
.pay .amount { font-size: 38px; font-weight: 700; letter-spacing: -.02em; }
.pay .qr { margin: 14px auto; width: 232px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-sizing: content-box; }
.pay .qr svg { display: block; width: 232px; height: 232px; }

/* ---------- receipt ---------- */
.receipt { width: min(520px, 100%); margin: 24px auto; }
.receipt .card { padding: 28px; }
.receipt .amt { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
.receipt hr { border: 0; border-top: 1px dashed var(--line); margin: 18px 0; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .admin { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .topbar .brand { padding: 0; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(16, 24, 40, .2); }
  .side.open { transform: none; }
  .wrap { padding: 16px 14px 56px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  th, td { padding: 9px 10px; }
  .hero h1 { font-size: 24px; }
}
@media (max-width: 700px) {
  /* the collection list becomes one card per member, with the buttons in reach */
  table.cards thead { display: none; }
  table.cards, table.cards tbody { display: block; }
  table.cards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 14px; border-bottom: 1px solid var(--line); }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 0; text-align: left; background: none !important; }
  table.cards td[data-l]::before { content: attr(data-l); display: block; color: var(--muted); font-size: 11.5px; }
  table.cards td.first { grid-column: 1 / 3; grid-row: 1; }
  table.cards td.st { grid-column: 3; grid-row: 1; text-align: right; }
  table.cards td[data-l="Kuri no."] { grid-column: 1 / -1; grid-row: 2; display: flex; gap: 6px; align-items: baseline; }
  table.cards td[data-l="Kuri no."]::before { display: inline; }
  table.cards td.act { grid-column: 1 / -1; }
  table.cards td.act .actions { justify-content: stretch !important; }
  table.cards td.act .btn { flex: 1; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } .tile .v { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  body { background: #fff; }
  .noprint, .side, .topbar, .toasts { display: none !important; }
  .admin { display: block; }
  .card, .tile { box-shadow: none; }
  .wrap { padding: 0; max-width: none; }
}
