:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #eaf0ec;
  --line: #d6dfd9;
  --rule: #c3d6cc;
  --fg: #15201b;
  --muted: #5a6a62;
  --accent: #1d6b56;
  --accent-fg: #ffffff;
  --accent-soft: #dcede5;
  --red: #b3261e;
  --red-soft: #f8e3e1;
  --amber: #8a5a00;
  --amber-soft: #fbefd6;
  --scrim: rgba(12, 20, 17, 0.55);
  --font-display: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513; --surface: #161e1b; --surface-2: #1c2622; --line: #2a3632; --rule: #2f4a3f;
    --fg: #e5ece8; --muted: #93a39b; --accent: #56c0a0; --accent-fg: #0b1512; --accent-soft: #1d3a31;
    --red: #f08a80; --red-soft: #3a1e1c; --amber: #e9b75a; --amber-soft: #3a2e14; --scrim: rgba(0, 0, 0, 0.65);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1513; --surface: #161e1b; --surface-2: #1c2622; --line: #2a3632; --rule: #2f4a3f;
  --fg: #e5ece8; --muted: #93a39b; --accent: #56c0a0; --accent-fg: #0b1512; --accent-soft: #1d3a31;
  --red: #f08a80; --red-soft: #3a1e1c; --amber: #e9b75a; --amber-soft: #3a2e14; --scrim: rgba(0, 0, 0, 0.65);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 16px; padding-block: 16px 48px; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.label-caps { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-block: 4px 10px; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.brand h1 { overflow-wrap: anywhere; }
.brand .sub { color: var(--muted); font-size: 0.9rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip.ok .dot { background: var(--accent); }
.chip.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.chip.warn .dot { background: var(--amber); }

/* Business switcher */
.bizbar { display: flex; gap: 6px; overflow-x: auto; padding-block: 2px 12px; scrollbar-width: none; }
.bizbar::-webkit-scrollbar { display: none; }
.biz { appearance: none; font: inherit; font-weight: 600; font-size: 0.9rem; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 7px 14px; border-radius: 6px; cursor: pointer; }
.biz:hover { border-color: var(--accent); }
.biz[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.biz.add { color: var(--muted); border-style: dashed; font-weight: 500; }
.biz .lk { vertical-align: -1px; opacity: 0.8; }
.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; }
/* Business passcode: the lock screen replaces the tabs until the passcode is typed. */
body.biz-locked #main > .tabs, body.biz-locked #main > [role="tabpanel"] { display: none !important; }
.lockcard { max-width: 460px; margin: 28px auto; }
.lockcard .lockicon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.locknote { font-size: 0.9rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--rule); margin-bottom: 18px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { appearance: none; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--fg); }
.tab .badge { background: var(--red); color: #fff; border-radius: 999px; font-size: 0.7rem; padding: 0 6px; line-height: 1.5; }

/* Panels */
.grid2 { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 110px; min-width: 0; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Forms */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; width: 100%; min-width: 0; }
input[type="file"] { padding: 7px; font-size: 0.85rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="number"] { font-family: var(--font-num); }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--fg); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

.btn { appearance: none; font: inherit; font-weight: 600; border-radius: 6px; padding: 10px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--fg); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding: 6px 8px; }
.btn.ghost:hover { color: var(--fg); }
.btn.danger { color: var(--red); }
.btn.confirm { background: var(--red); color: #fff; border-color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Payment method picker */
.pay { display: flex; flex-wrap: wrap; gap: 6px; position: relative; }
.pay input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pay label { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 500; font-size: 0.9rem; background: var(--surface); user-select: none; }
.pay input:checked + label { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pay input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Receipt breakdown */
.receipt { background: var(--surface-2); border-radius: 6px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.receipt .ln { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.receipt .ln.minus span:last-child { color: var(--red); }
.receipt .ln.total { border-top: 1px dashed var(--rule); margin-top: 6px; padding-top: 8px; font-weight: 600; font-size: 1.05rem; }
.receipt .ln.total span:last-child { color: var(--accent); }
.receipt .ln.total.neg span:last-child { color: var(--red); }
.receipt .ln.total.warn span:last-child { color: var(--amber); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.stat .v { font-family: var(--font-num); font-size: 1.35rem; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.hl { background: var(--accent-soft); border-color: transparent; }
.stat.hl .v { color: var(--accent); }
.stat .v.neg { color: var(--red); }

/* Notices */
.notice { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--r); background: var(--amber-soft); color: var(--amber); font-size: 0.9rem; border: 0; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.notice.over { background: var(--red-soft); color: var(--red); }
.notice b { font-weight: 600; }

/* Ledger lists */
.ledger { display: flex; flex-direction: column; }
.entry { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .what { min-width: 0; }
.entry .what b { font-weight: 600; overflow-wrap: anywhere; }
.entry .meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.entry .amt { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.entry .amt small { display: block; font-size: 0.78rem; color: var(--muted); }
.entry .amt .p { color: var(--accent); }
.entry .amt .p.neg, .entry .amt.neg { color: var(--red); }
.entry .act { display: flex; gap: 2px; flex-wrap: nowrap; }
.entry.editing { background: var(--accent-soft); border-radius: 6px; padding-inline: 8px; }
.tag { font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
.tag.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.tag.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
@media (max-width: 520px) {
  .entry { grid-template-columns: 1fr auto; }
  .entry .act { grid-column: 1 / -1; justify-self: end; }
}

.entry.two { grid-template-columns: 1fr auto; }
.entry.zero .what b, .entry.zero .amt { color: var(--muted); }
.entry.total { border-top: 2px solid var(--rule); border-bottom: 0; }
.entry.total .what b, .entry.total .amt { font-weight: 700; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty b { color: var(--fg); font-family: var(--font-display); font-size: 1.05rem; }

/* Report statement */
.periods { display: flex; flex-wrap: wrap; gap: 6px; }
.periods button { appearance: none; font: inherit; font-size: 0.88rem; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.periods button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.statement { display: flex; flex-direction: column; }
.statement .ln { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.statement .ln .num { white-space: nowrap; }
.statement .ln.minus .num { color: var(--red); }
.statement .ln.sub { font-weight: 600; border-bottom: 2px solid var(--rule); }
.statement .ln.grand { font-weight: 700; font-size: 1.15rem; border-bottom: 3px double var(--rule); padding-block: 12px; }
.statement .ln.grand .num { color: var(--accent); }
.statement .ln.grand.neg .num { color: var(--red); }
.statement .ln.note { color: var(--muted); font-size: 0.88rem; }
.statement .ln .d { min-width: 0; }
.statement .ln .d small { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 400; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--rule); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
td.r, th.r { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--rule); }

.methods-edit { display: flex; flex-direction: column; gap: 8px; }
.method-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
@media (max-width: 480px) { .method-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .method-row .nm { grid-column: 1 / -1; } }

.splitbox { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px dashed var(--rule); border-radius: 6px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.split-row input.auto { background: var(--surface-2); }
.split-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.88rem; }
#splitStatus.ok { color: var(--accent); }
#splitStatus.bad { color: var(--red); font-weight: 600; }
.repeatbox { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px dashed var(--rule); border-radius: 6px; }
.topright { display: flex; gap: 8px; align-items: center; }
svg.lk { vertical-align: -1px; margin-right: 5px; }
.bizlist { display: flex; flex-direction: column; }
.bizrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bizrow:last-child { border-bottom: 0; }
.bizrow b { font-weight: 600; }

/* Deadlines */
.dl { display: grid; grid-template-columns: 76px 1fr auto; gap: 4px 14px; align-items: start; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.dl:last-child { border-bottom: 0; }
.dl .date { font-family: var(--font-num); text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; background: var(--surface-2); }
.dl .date .m { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.dl .date .d { font-size: 1.3rem; font-weight: 600; line-height: 1.1; }
.dl .date .y { font-size: 0.7rem; color: var(--muted); }
.dl .body { min-width: 0; }
.dl .body b { font-weight: 600; }
.dl .body .meta { font-size: 0.82rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; align-items: center; }
.dl .body .amt { font-size: 0.88rem; margin-top: 4px; }
.dl.done { opacity: 0.6; }
.dl.done .date { background: none; }
@media (max-width: 520px) { .dl { grid-template-columns: 64px 1fr; } .dl .check { grid-column: 2; } }

/* Drawer */
.drawer .ln { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.drawer .ln input { width: 140px; text-align: right; }
.drawer .ln .num { white-space: nowrap; }
.drawer .ln.sub { font-weight: 600; border-bottom: 2px solid var(--rule); }
.drawer .ln .d small { display: block; color: var(--muted); font-size: 0.78rem; }
.drawer .result { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 6px; font-weight: 700; font-size: 1.1rem; background: var(--surface-2); }
.drawer .result.ok { background: var(--accent-soft); color: var(--accent); }
.drawer .result.over { background: var(--amber-soft); color: var(--amber); }
.drawer .result.short { background: var(--red-soft); color: var(--red); }

/* Modal */
.modal { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; z-index: 20; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 640px) { .modal { align-items: center; } }
.modal .sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; }
.modal img.rcpt { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--surface-2); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 6px; font-weight: 500; font-size: 0.9rem; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
.banner { background: var(--amber-soft); color: var(--amber); padding: 10px 14px; border-radius: 6px; font-size: 0.88rem; margin-bottom: 16px; }
.setup { max-width: 460px; margin: 24px auto; }
@media (prefers-reduced-motion: no-preference) { .btn, .tab, .biz, .pay label { transition: background-color .12s, color .12s, border-color .12s; } }

/* ---------- Added for the hosted site ---------- */
html, body { margin: 0; }
body { min-height: 100vh; }
a { color: var(--accent); }
.brandmark { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--fg); font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.01em; }
.brandmark svg { flex: none; }
.userbtn { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; }
.userbtn .avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; font-size: 0.75rem; flex: none; }
.userbtn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.trial { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.banner.red { background: var(--red-soft); color: var(--red); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }

/* Auth and onboarding */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.auth header { padding-inline: 16px; padding-block: 18px; max-width: 1120px; width: 100%; margin: 0 auto; }
.auth main { display: grid; place-items: start center; padding-inline: 16px; padding-block: 24px 48px; }
.auth .card { width: 100%; max-width: 420px; }
.auth footer { text-align: center; padding-inline: 16px; padding-block: 16px 28px; font-size: 0.82rem; color: var(--muted); }
.auth footer a { color: var(--muted); }
.authswitch { font-size: 0.9rem; color: var(--muted); text-align: center; }
.linkbtn { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.formmsg { font-size: 0.88rem; padding: 10px 12px; border-radius: 6px; background: var(--red-soft); color: var(--red); }
.formmsg.ok { background: var(--accent-soft); color: var(--accent); }
.invitebox { background: var(--accent-soft); color: var(--fg); border-radius: 6px; padding: 12px 14px; font-size: 0.92rem; }

/* Team and platform */
.member { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.member:last-child { border-bottom: 0; }
.member .who b { font-weight: 600; }
.member .who .meta { font-size: 0.82rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.member .bizchecks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-family: var(--font-num); font-size: 0.82rem; }
.danger-zone { border-color: var(--red-soft); }
.platform-table td, .platform-table th { white-space: nowrap; vertical-align: top; }
.platform-table td.wrap { white-space: normal; min-width: 160px; }
.platform-table tr.suspended td { color: var(--muted); }
.progress { font-size: 0.88rem; color: var(--muted); }

/* Employees see only what they need */
body.role-employee .owner-only { display: none !important; }
body:not(.is-platform-admin) .admin-only { display: none !important; }
