/*!
 * Hulog Paluwagan Planner - styles
 * Layout: passbook ledger. One summary "stamp card" on top, tabbed ledger below.
 * MIT (c) 2026 Efraim Ray
 */
:root {
  --paper: #eef2ee;
  --surface: #ffffff;
  --surface-2: #f6f8f5;
  --ink: #16202e;
  --muted: #566273;
  --line: #d5ddd4;
  --accent: #1d58c9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 88, 201, 0.10);
  --gold: #a86f00;
  --gold-soft: rgba(201, 138, 16, 0.14);
  --ok: #10794a;
  --ok-soft: rgba(16, 121, 74, 0.12);
  --warn: #9a5a00;
  --warn-soft: rgba(184, 106, 0, 0.13);
  --bad: #b8322a;
  --bad-soft: rgba(184, 50, 42, 0.11);
  --shadow: 0 1px 0 rgba(22, 32, 46, 0.04), 0 10px 30px -18px rgba(22, 32, 46, 0.35);

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --step--1: 0.82rem;
  --step-0: 1rem;
  --step-1: 1.2rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.8rem, 4vw, 2.6rem);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 36px;
  --radius: 14px;
  --radius-sm: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d131b; --surface: #141c27; --surface-2: #19232f; --ink: #e7ecf2; --muted: #9aa6b6; --line: #273343;
    --accent: #86abff; --accent-ink: #0d131b; --accent-soft: rgba(134, 171, 255, 0.14);
    --gold: #f2bc4b; --gold-soft: rgba(242, 188, 75, 0.14);
    --ok: #4fd39a; --ok-soft: rgba(79, 211, 154, 0.14); --warn: #f5ac4e; --warn-soft: rgba(245, 172, 78, 0.14);
    --bad: #ff8a7f; --bad-soft: rgba(255, 138, 127, 0.14);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 30px -18px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d131b; --surface: #141c27; --surface-2: #19232f; --ink: #e7ecf2; --muted: #9aa6b6; --line: #273343;
  --accent: #86abff; --accent-ink: #0d131b; --accent-soft: rgba(134, 171, 255, 0.14);
  --gold: #f2bc4b; --gold-soft: rgba(242, 188, 75, 0.14);
  --ok: #4fd39a; --ok-soft: rgba(79, 211, 154, 0.14); --warn: #f5ac4e; --warn-soft: rgba(245, 172, 78, 0.14);
  --bad: #ff8a7f; --bad-soft: rgba(255, 138, 127, 0.14);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 30px -18px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: var(--step-0); line-height: 1.55;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0; text-wrap: balance; }
h1 { font-size: var(--step-3); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: var(--step-2); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: var(--step-1); font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { top: calc(12px + env(safe-area-inset-top, 0px)); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.eyebrow { font-family: var(--font-mono); font-size: var(--step--1); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- Top bar ---- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-block: 10px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; color: var(--accent); flex: none; }
.brand-text { display: grid; line-height: 1; }
.brand-text b { font-family: var(--font-display); font-size: 1.45rem; font-weight: 800; letter-spacing: -0.03em; }
.brand-text small { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.topbar-tools { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }

/* ---- Controls ---- */
.btn {
  font: inherit; font-weight: 600; font-size: 0.92rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer; transition: transform .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn-danger:hover { border-color: var(--bad); }
.btn-icon { width: 40px; padding: 0; background: transparent; color: var(--ink); border-color: var(--line); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 0.84rem; }
.select, .input {
  font: inherit; min-height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); max-width: 100%; min-width: 0;
}
.select { max-width: 260px; }
textarea.input { padding: 10px 12px; min-height: 140px; width: 100%; font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus { border-color: var(--accent); }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: 0.92rem; }
.field .hint { font-size: var(--step--1); color: var(--muted); }
.field .err { font-size: var(--step--1); color: var(--bad); }

/* ---- Hero / summary ---- */
.hero { padding-block: var(--space-6) var(--space-5); display: grid; gap: var(--space-4); }
.hero-head { display: grid; gap: 6px; }
.hero-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--space-3); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); min-width: 0; }
.next-card { position: relative; overflow: hidden; box-shadow: var(--shadow); display: grid; gap: var(--space-3); }
.next-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.next-who { font-family: var(--font-display); font-size: var(--step-2); font-weight: 800; }
.next-amt { font-family: var(--font-mono); font-size: var(--step-1); font-weight: 700; color: var(--gold); }
.stamp {
  flex: none; width: 70px; height: 70px; border-radius: 50%; border: 2.5px dashed var(--accent); color: var(--accent);
  display: grid; place-items: center; text-align: center; transform: rotate(-8deg); font-family: var(--font-mono); line-height: 1.05;
}
.stamp b { display: block; font-size: 1.35rem; }
.stamp small { font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; }
.meter { height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
.meter-row { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--step--1); color: var(--muted); flex-wrap: wrap; }
.stat { display: grid; gap: 4px; align-content: start; }
.stat-val { font-family: var(--font-mono); font-size: var(--step-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: var(--step--1); color: var(--muted); }
.behind-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* ---- Chips ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-done { color: var(--ok); background: var(--ok-soft); }
.chip-collecting { color: var(--accent); background: var(--accent-soft); }
.chip-late { color: var(--bad); background: var(--bad-soft); }
.chip-upcoming { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.chip-gold { color: var(--gold); background: var(--gold-soft); }
.chip-gold::before { display: none; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); scrollbar-width: thin; }
.tabs button {
  font: inherit; font-weight: 600; font-size: 0.93rem; background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 12px 14px; border-bottom: 3px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.panel { display: grid; gap: var(--space-4); padding-bottom: var(--space-6); animation: rise .25s ease; }
@keyframes rise { from { transform: translateY(4px); opacity: .6; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.panel-head p { color: var(--muted); max-width: 62ch; }
.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.money, th.money { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.is-current td, tr.is-current th { background: var(--accent-soft); }
.round-no { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line); font-family: var(--font-mono); font-size: 0.82rem; font-weight: 700; }
tr.is-current .round-no { border-color: var(--accent); color: var(--accent); border-style: dashed; }
tr.st-done .round-no { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.date-cell { white-space: nowrap; }
.who { font-weight: 600; }

/* ---- Tracker grid ---- */
.grid-table th[scope="row"] { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; font-weight: 600; }
.grid-table thead th { text-align: center; }
.grid-table thead th:first-child { text-align: left; position: sticky; left: 0; z-index: 2; }
.grid-table td { text-align: center; padding: 6px; }
.tick {
  width: 34px; height: 34px; border-radius: 9px; border: 1.5px dashed var(--line); background: transparent; color: var(--ok);
  cursor: pointer; display: inline-grid; place-items: center; font: inherit; font-weight: 800; transition: transform .12s ease;
}
.tick:hover { border-color: var(--ok); }
.tick[aria-pressed="true"] { background: var(--ok-soft); border: 1.5px solid var(--ok); }
.tick[aria-pressed="true"]::after { content: "\2713"; }
.tick.is-late { border-color: var(--bad); background: var(--bad-soft); }
.tick.is-recipient { box-shadow: inset 0 0 0 2px var(--gold); }
.col-current { background: var(--accent-soft); }
.grid-legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--step--1); color: var(--muted); }
.grid-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 16px; height: 16px; border-radius: 5px; display: inline-block; border: 1.5px dashed var(--line); }
.lg-paid { background: var(--ok-soft); border: 1.5px solid var(--ok); }
.lg-late { background: var(--bad-soft); border-color: var(--bad); }
.lg-rec { box-shadow: inset 0 0 0 2px var(--gold); }
tfoot td, tfoot th { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 0; background: var(--surface-2); }

/* ---- Members ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-items: start; }
.member-list, .order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.member-list li, .order-list li { display: flex; align-items: center; gap: var(--space-2); padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.member-list li:last-child, .order-list li:last-child { border-bottom: 0; }
.member-list .input { flex: 1; min-width: 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); flex: none; }
.stepper button { font: inherit; width: 32px; height: 36px; border: 0; background: none; color: var(--ink); cursor: pointer; font-weight: 700; }
.stepper output { min-width: 3.4em; text-align: center; font-family: var(--font-mono); font-size: 0.82rem; }
.order-list .slot-no { font-family: var(--font-mono); color: var(--muted); width: 2.2em; flex: none; font-size: 0.85rem; }
.order-list .slot-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.order-list .slot-date { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); flex: none; }
.order-list li.is-moved { animation: flash .6s ease; }
@keyframes flash { from { background: var(--gold-soft); } to { background: transparent; } }
.draw-box { display: grid; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--line); }
.draw-box .row .input { flex: 1; min-width: 140px; }
.shuffling .slot-name { filter: blur(1.5px); }

/* ---- Settings ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.input-group { display: flex; min-width: 0; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); font-family: var(--font-mono); }
.input-group .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; flex: 1; width: 100%; }
.radio-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; }
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---- Share ---- */
.share-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--space-4); align-items: start; }
.share-preview { white-space: pre-wrap; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); max-height: 420px; overflow: auto; margin: 0; }
.stack { display: grid; gap: var(--space-3); min-width: 0; }

/* ---- About ---- */
.about { border-top: 1px solid var(--line); padding-block: var(--space-6); display: grid; gap: var(--space-4); }
.about-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.about-grid > div { display: grid; gap: var(--space-2); align-content: start; }
.about-grid h3 { font-size: 1.02rem; margin-top: var(--space-2); }
.about-grid p, .about-grid li { color: var(--muted); font-size: 0.94rem; }
.about-grid ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }
.about-links a { font-weight: 600; }
.fine { font-size: var(--step--1); color: var(--muted); }

.foot { border-top: 1px solid var(--line); background: var(--surface); }
.foot-in { display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding-block: var(--space-4); font-size: var(--step--1); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.confirm-bar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--ink); }
.empty { padding: var(--space-5); text-align: center; color: var(--muted); }

/* Standalone (showcase) build: file downloads and print are not available there. */
html[data-build="standalone"] .site-only { display: none !important; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .next-card { grid-column: 1 / -1; }
  .two-col, .share-grid, .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .hero { padding-block: var(--space-5) var(--space-4); }
  .hero-grid { grid-template-columns: 1fr; }
  .topbar-tools { width: 100%; flex-wrap: nowrap; }
  .topbar-tools .select { flex: 1; max-width: none; }
  .brand-text small { display: none; }
  th, td { padding: 9px 10px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .tabs, .about, .foot, .btn, .toast, .skip, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .panel[hidden] { display: none !important; }
  .card, .table-wrap { border-color: #999; box-shadow: none; }
}
