/* Zoni: calm, neutral business UI. One accent (blue); colour otherwise only carries meaning (paid / part / unpaid). */
:root {
  --bg: #f6f7f9; --surface: #fff; --surface-2: #f9fafb; --ink: #111827; --ink-2: #374151; --muted: #6b7280; --faint: #9ca3af;
  --line: #e5e7eb; --line-2: #eef0f3;
  --accent: #2f5bea; --accent-hover: #2349c8; --accent-soft: #eef2fe; --accent-ring: rgba(47, 91, 234, .18);
  --ok: #067647; --ok-soft: #ecfdf3; --warn: #b54708; --warn-soft: #fffaeb; --bad: #b42318; --bad-soft: #fef3f2;
  --r: 12px; --r-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .22);
  --side: 236px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; }
h1, h2, h3 { margin: 0 0 4px; color: var(--ink); letter-spacing: -.015em; }
h1 { font-size: 24px; font-weight: 650; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; line-height: 1.4; }
a { color: var(--accent); }
.wrap { width: min(1240px, 100% - 48px); margin-inline: auto; }
.muted { color: var(--muted); margin: 0 0 12px; }
.muted-inline { color: var(--muted); font-size: 13px; font-weight: 400; }
.fine { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.kicker { font-size: 12px; font-weight: 500; color: var(--muted); margin: 0 0 2px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---- Brand ---- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand .mark { width: 28px; height: 28px; flex: none; }
.brand span { font-size: 15px; font-weight: 500; letter-spacing: -.01em; color: var(--ink-2); }
.brand b { font-weight: 700; color: var(--ink); }

/* ---- Buttons & inputs ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 500 14px/1 inherit; font-family: inherit;
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: #d1d5db; color: var(--ink); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; height: 40px; }
/* main action: solid accent */
.btn:not(.ghost):not(.danger):not(.primary-off) { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:not(.ghost):not(.danger):not(.primary-off):hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #fecdca; }
.btn.danger:hover { background: var(--bad-soft); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.linkish.danger { color: var(--bad); }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 500; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field small { font-weight: 400; color: var(--faint); }
input, select, textarea { font: inherit; font-size: 14px; width: 100%; height: 38px; padding: 0 12px; border: 1px solid #d0d5dd; border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; box-shadow: none; accent-color: var(--accent); }
select { padding-right: 32px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
textarea { height: auto; min-height: 140px; padding: 10px 12px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.field.invalid input, .field.invalid select { border-color: #fda29b; }
.field.invalid input:focus { box-shadow: 0 0 0 4px rgba(240, 68, 56, .15); }
.field .err { display: none; color: var(--bad); font-size: 12.5px; margin-top: 5px; font-style: normal; }
.field.invalid .err { display: block; }
.msg { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px; border: 1px solid transparent; }
.msg.err { background: var(--bad-soft); color: var(--bad); border-color: #fee4e2; }
.msg.ok { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.stack { display: grid; gap: 2px; }

/* ---- Login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { font-size: 20px; }
.login-split { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--faint); font-size: 12px; font-weight: 500; }
.login-split::before, .login-split::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn.google { background: var(--surface); color: var(--ink); border-color: var(--line); gap: 10px; text-decoration: none; }
.btn.google:hover:not(:disabled) { background: var(--surface-2); border-color: #d1d5db; color: var(--ink); }
.btn.google svg { flex: none; }

/* ---- App shell: sidebar + content ---- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.side > .brand { padding: 4px 8px 18px; }
.tabs { display: grid; gap: 2px; }
.tabs a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px; }
.tabs a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--faint); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.tabs a[aria-current="page"] svg { stroke: var(--accent); }
.me { margin-top: auto; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.me .avatar { grid-row: span 2; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.me b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { display: block; font-size: 12px; color: var(--muted); }
.me .linkish { grid-column: 2; justify-self: start; font-size: 12.5px; color: var(--muted); }
.page { min-width: 0; padding: 28px 0 64px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side > .brand { padding: 0; }
  .tabs { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 4px; }
  .tabs a { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .tabs a svg { display: none; }
  .me { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; }
  .me .avatar, .me small { display: none; }
  .me b { font-size: 13px; font-weight: 500; }
  .wrap { width: min(1240px, 100% - 32px); }
  .page { padding-top: 20px; }
}

/* ---- Page header & cards ---- */
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head-row .muted { margin: 2px 0 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions select { width: auto; min-width: 180px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.card h2 { margin-bottom: 12px; }
.card.empty { text-align: center; padding: 48px 20px; }
.card.empty h2 { font-size: 17px; margin-bottom: 6px; }
.warn-card { background: var(--warn-soft); border-color: #fedf89; color: #93370d; }
.warn-card a { color: inherit; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid2 > .card { margin: 0 0 16px; }

/* stat cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat span { display: block; order: -1; font-size: 13px; color: var(--muted); }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat b { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat.red b { color: var(--bad); }
.stat .meter { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 2px; }
.stat .meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
@media (max-width: 560px) { .cards { grid-template-columns: 1fr 1fr; } .stat { padding: 12px 14px; } .stat b { font-size: 18px; } }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list small { color: var(--muted); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 56px minmax(60px, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; color: var(--ink-2); }
.bar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* ---- Toolbar, filters, menus ---- */
.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tool-left, .tool-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px; min-width: 260px; }
.menu-pop a { display: block; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); text-decoration: none; font-size: 13.5px; }
.menu-pop a:hover { background: var(--surface-2); color: var(--ink); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.lock-note { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px; font-size: 13.5px; color: var(--ink-2); margin: 0 0 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input { max-width: 300px; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.seg button { border: 0; background: none; font: 500 13px inherit; font-family: inherit; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
table.pay { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.pay th, table.pay td { padding: 11px 14px; border-top: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
table.pay thead th { border-top: 0; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.pay tbody tr:hover { background: #fafbfc; }
table.pay td b { font-weight: 600; }
table.pay tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
table.pay td small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.cell-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px; margin: -3px -6px; font: inherit; cursor: pointer; color: inherit; text-align: inherit; }
.cell-btn:hover:not(:disabled) { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-sm); color: var(--accent); }
.cell-btn:disabled { cursor: default; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.paid { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.pill.part { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.pill.unpaid { background: var(--bad-soft); color: var(--bad); border-color: #fecdca; }
.pill.off { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.receipt-link { font-size: 12.5px; text-decoration: none; }
.receipt-link:hover { text-decoration: underline; }

/* ---- Dialogs ---- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(560px, 100% - 24px); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog::backdrop { background: rgba(17, 24, 39, .4); backdrop-filter: blur(2px); }
dialog form { padding: 24px; max-height: 88vh; overflow: auto; }
dialog h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
dialog.wide { width: min(820px, 100% - 24px); }
.dlg-actions { display: flex; flex-direction: row-reverse; gap: 8px; justify-content: flex-start; flex-wrap: wrap; margin: 20px -24px -24px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
.preview { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 10px; }
.preview table { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview td, .preview th { padding: 7px 10px; border-top: 1px solid var(--line-2); text-align: left; }
.preview tr:first-child td, .preview tr:first-child th { border-top: 0; }
.drop { display: block; border: 1px dashed #d0d5dd; border-radius: var(--r-sm); padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop.has { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 13.5px; font-weight: 500; z-index: 100; box-shadow: var(--shadow-lg); }
.stat span::first-letter { text-transform: uppercase; }
#pr-table td:nth-child(2), #st-table td:nth-child(2) { min-width: 190px; }
#pr-table td:nth-child(2) small, #st-table td:nth-child(2) small { white-space: nowrap; }
#pr-table td:nth-child(3) { min-width: 180px; }
#pr-table td:nth-child(4) { min-width: 170px; }

/* Staff multi-select */
table.pay th.ck, table.pay td.ck { width: 1%; padding-right: 4px; }
.pay tr.sel td { background: #eef2ff; }
.selbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 0 12px; border: 1px solid #c7d2fe; background: #eef2ff; border-radius: 10px; font-size: 14px; }
.selbar span { margin-right: auto; }
.danger-card { border-color: #fecdca; }

/* Pasted spreadsheet text: keep each row on one line, columns lined up, scroll sideways if wide */
textarea[wrap=off] { white-space: pre; overflow: auto; tab-size: 22; -moz-tab-size: 22; }
.preview .total td { border-top: 1px solid var(--line, #e4e7ec); font-weight: 600; }
.preview small.was { color: var(--faint, #98a2b3); }
.preview .num { text-align: right; }

/* ---- Step-by-step month guide ---- */
.steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface, #fff); border: 1px solid var(--line, #e4e7ec); border-radius: 12px; padding: 14px; }
.steps li.done { background: #f6fef9; border-color: #abefc6; }
.steps .num-badge { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: #eef2ff; color: var(--accent, #2f5bea); }
.steps li.done .num-badge { background: #12b76a; color: #fff; }
.steps b { font-size: 14px; }
.steps p { margin: 3px 0 10px; font-size: 13px; color: var(--muted, #667085); line-height: 1.45; }
.steps p b { color: var(--ink, #101828); font-size: 13px; }
.steps .btn { white-space: normal; text-align: left; }
.tool-left input[type=search] { width: 220px; }
.table-hint { margin: 0 0 8px; }
.name-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.name-btn:hover b { color: var(--accent, #2f5bea); text-decoration: underline; }
.pay .of, .preview .of { color: var(--faint, #98a2b3); font-weight: 400; }
.pay .minus, .preview .minus { color: #d92d20; }
.pay .plus { color: #079455; }
.pay .faint { color: var(--faint, #98a2b3); }
.pay b.big { font-size: 15px; }
.pay td small.minus { display: block; }
.warn-text { color: #b54708; }
.seg.src { margin: 4px 0 12px; }
label.check { display: flex; gap: 8px; align-items: center; margin: 12px 0 4px; font-size: 14px; cursor: pointer; }
label.check input { width: 16px; height: 16px; }
.preview tr.sub td, table.pay tr.sub td { background: #f9fafb; font-size: 12px; color: var(--muted, #667085); font-weight: 600; }
.preview tr.zeroed td { color: #b42318; }
#paste-box textarea { margin-bottom: 8px; }

.wd-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.wd-picks .chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.wd-picks .chip.on { border-color: var(--accent); background: #eef2ff; color: var(--accent); }
#pr-sub .linkish { font-size: inherit; }
