:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c1b18;
  --muted: #6b675e;
  --line: #e4e1d8;
  --accent: #d93a1c;
  --accent-ink: #ffffff;
  --bar: #fc4f2f;
  --track: #efece4;
  --in: #15803d;
  --out: #b45309;
  --draw: #6d28d9;
  --neg: #b91c1c;
  --notice: #fef3c7;
  --notice-ink: #78350f;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12130f;
    --card: #1c1d18;
    --ink: #eceae3;
    --muted: #a19d92;
    --line: #2e2f28;
    --accent: #ff7a5c;
    --accent-ink: #1a0a05;
    --bar: #ff7a5c;
    --track: #2a2b25;
    --in: #4ade80;
    --out: #fbbf24;
    --draw: #c4b5fd;
    --neg: #f87171;
    --notice: #3a2f10;
    --notice-ink: #fde68a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; }
a { color: var(--accent); }
h1, h2 { margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 18px; }
small, .muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 8px 0 0; }

.brand { color: var(--ink); text-decoration: none; font-size: 18px; white-space: nowrap; }
.brand .mark { font-weight: 800; color: var(--bar); letter-spacing: -.01em; }
.brand .sub { font-weight: 500; color: var(--muted); }

/* App shell: fixed sidebar on wide screens, a drawer behind ☰ on phones. */
.nav-toggle { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.side {
  position: fixed; inset: 0 auto 0 0; width: 236px; z-index: 20;
  display: flex; flex-direction: column; gap: 20px; padding: 20px 14px 16px;
  background: var(--card); border-right: 1px solid var(--line);
}
.side .brand { padding: 0 8px; font-size: 17px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 600;
}
.side-nav a:hover { background: var(--bg); color: var(--ink); }
.side-nav a.on { background: color-mix(in srgb, var(--bar) 12%, transparent); color: var(--ink); }
.side-nav a.on svg { stroke: var(--bar); }
.side-nav svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-nav { flex: 1; }
.demo-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
  margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--bar) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--bar) 35%, transparent);
}
button.link.strong { color: var(--accent); font-weight: 600; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bar); color: #fff; font-size: 13px; font-weight: 700;
}
.side-foot form { margin: 0; }
.content { margin-left: 236px; min-height: 100vh; }
.content main { max-width: 1180px; margin: 0; padding: 24px 32px 64px; }
.page-title { font-size: 24px; margin: 0 0 12px; }
.mobile-bar, .scrim { display: none; }

@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .nav-toggle:checked ~ .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); }
  .nav-toggle:focus-visible ~ .content .menu-btn { outline: 2px solid var(--accent); }
  .content { margin-left: 0; }
  .content main { padding: 12px 16px 64px; margin: 0 auto; max-width: 760px; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10;
    padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--line);
  }
  .menu-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; color: var(--ink); }
  .menu-btn:hover { background: var(--bg); }
  .page-title { font-size: 20px; margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }

.card, .totals > div, .login {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.card { padding: 16px; margin-top: 16px; }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.totals > div { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.totals span { font-size: 13px; color: var(--muted); }
.totals strong { font-size: 18px; overflow-wrap: anywhere; }
.totals.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) {
  .totals { grid-template-columns: 1fr 1fr; }
  .totals > div:last-child { grid-column: 1 / -1; }
  .totals.four { grid-template-columns: 1fr 1fr; }
  .totals.four > div:last-child { grid-column: auto; }
}

.boards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.boards .card { margin-top: 16px; }
@media (max-width: 720px) { .boards { grid-template-columns: 1fr; } }
.top-hint { margin: -6px 0 12px; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; }
.bar-value { font-weight: 500; color: var(--muted); white-space: nowrap; }
.track { height: 8px; background: var(--track); border-radius: 4px; margin: 5px 0 3px; overflow: hidden; }
.fill { height: 100%; background: var(--bar); border-radius: 4px; }
.bars small { font-size: 12px; }
.bars .unset .bar-label span:first-child { color: var(--muted); font-style: italic; }
.bars .unset .fill { background: var(--muted); opacity: .45; }

.clients { list-style: none; margin: 0; padding: 0; }
.clients li + li { border-top: 1px solid var(--line); }
.clients a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; color: inherit; text-decoration: none; }
.clients a:hover .what strong { text-decoration: underline; }
.status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; color: var(--ink); }
.status.lead { border-style: dashed; }
.status.past { color: var(--muted); }
.client { font-weight: 600; color: var(--ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child { text-align: left; }
thead th { font-size: 12px; font-weight: 600; color: var(--muted); }
tbody th { font-weight: 600; }
tfoot th, tfoot td { border-bottom: 0; font-weight: 700; }
tfoot th { text-align: left; }
.neg { color: var(--neg); }
em.est { font-size: 11px; color: var(--muted); }

.flash, .notice, .alert { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.flash { background: var(--card); border: 1px solid var(--line); }
.notice { background: var(--notice); color: var(--notice-ink); }
.alert { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li + li { border-top: 1px solid var(--line); }
.entries a {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  padding: 12px 2px; color: inherit; text-decoration: none;
}
.entries a:hover .what strong { text-decoration: underline; }
.what { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.what strong { overflow-wrap: anywhere; font-weight: 600; }
.what small { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 13px; }
.amt { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex-shrink: 0; }
.amt small { font-size: 12px; white-space: nowrap; }
.amt strong { white-space: nowrap; }
.amt strong.in { color: var(--in); }
.amt em { font-style: normal; font-size: 11px; color: var(--notice-ink); background: var(--notice); padding: 0 5px; border-radius: 4px; }
.missing { color: var(--notice-ink); background: var(--notice); padding: 0 5px; border-radius: 4px; }
.kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kind.in { color: var(--in); }
.kind.out { color: var(--out); }
.kind.draw { color: var(--draw); }

.partners { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.partner { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; min-width: 0; }
.partner h3 { margin: 0 0 8px; font-size: 16px; }
.partner .label { font-size: 12px; color: var(--muted); }
.partner .owed { font-size: 18px; white-space: nowrap; }
.partner dl { margin: 10px 0 0; display: grid; gap: 2px; font-size: 13px; }
.partner dt { color: var(--muted); }
.partner dd { margin: 0 0 6px; }
.cash { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; }

form { margin: 0; }
.stack, .entry-form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
input, select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
.err { color: var(--neg); font-size: 13px; font-weight: 400; }

fieldset.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
fieldset.seg legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 4px; width: 100%; }
fieldset.seg label {
  flex-direction: row; align-items: center; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px;
}
fieldset.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
fieldset.seg label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
fieldset.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Show the partner picker only for draws and the rate only for USD; no script. */
.only-draw, .only-draw-inline, .only-usd { display: none; }
.entry-form:has(input[name=kind][value=draw]:checked) .only-draw { display: flex; }
.entry-form:has(input[name=kind][value=draw]:checked) .only-draw-inline { display: inline; }
.entry-form:has(input[name=kind][value=draw]:checked) .not-draw { display: none; }
.entry-form:has(input[name=currency][value=USD]:checked) .only-usd { display: flex; }

button.primary, button.danger {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 12px 16px; cursor: pointer; min-height: 44px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; }
button.danger { background: none; color: var(--neg); border: 1px solid var(--neg); }
.danger-zone { margin-top: 16px; }

.login { max-width: 360px; margin: 12vh auto 0; padding: 24px; }

/* Page header with an action button. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.page-head .page-title { margin: 0; }
a.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; min-height: 42px; border-radius: 10px;
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
}
a.btn.primary { background: var(--accent); color: var(--accent-ink); }
a.btn.primary:hover { filter: brightness(1.05); }
a.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* Modal: shown when its id is the URL fragment, or when the server opens it. */
.modal { display: none; position: fixed; inset: 0; z-index: 50; place-items: center; padding: 24px 16px; }
.modal:target, .modal.open { display: grid; }
.modal-scrim { position: absolute; inset: 0; background: rgba(15, 12, 8, .45); }
.modal-box {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - 48px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: modal-in .16s ease-out;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-close { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--muted); }
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 600px) {
  .modal { place-items: end stretch; padding: 0; }
  .modal-box { max-width: none; max-height: 92dvh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  @keyframes modal-in { from { transform: translateY(24px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { .modal-box { animation: none; } }

/* dashboard */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-head a { font-size: 14px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.card-head a:hover { text-decoration: underline; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-stats span { font-size: 13px; color: var(--muted); }
.mini-stats strong { font-size: 18px; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .mini-stats > div:last-child { grid-column: 1 / -1; }
}

/* Language switch: two pills, in the sidebar, on sign-in and in Settings. */
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.lang-switch button {
  border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; min-height: 32px; white-space: nowrap;
}
.lang-switch button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.side .lang-switch { margin: 0 0 12px; align-self: stretch; }
.side .lang-switch button { flex: 1; padding: 6px 6px; font-size: 12px; }
.login .lang-switch { margin-top: 16px; }

/* Two-step delete: the summary is the first button, the form the second. */
details.danger-zone { margin-top: 16px; }
details.danger-zone > summary {
  display: inline-flex; align-items: center; list-style: none; cursor: pointer;
  font-weight: 600; border-radius: 10px; padding: 12px 16px; min-height: 44px;
  color: var(--neg); border: 1px solid var(--neg);
}
details.danger-zone > summary::-webkit-details-marker { display: none; }
details.danger-zone[open] > summary { opacity: .6; }
.confirm { margin-top: 10px; padding: 14px; border: 1px solid var(--neg); border-radius: 12px; background: color-mix(in srgb, var(--neg) 6%, var(--card)); }
.confirm p { margin: 0 0 10px; }
button.danger.solid { background: var(--neg); color: #fff; border-color: var(--neg); }

/* Small phones: totals become label–amount rows so amounts never wrap, and
   the project table becomes one small card per project. */
@media (max-width: 480px) {
  .totals, .totals.four { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
  .totals > div, .totals.four > div {
    flex-direction: row; justify-content: space-between; align-items: baseline; gap: 12px;
    border: 0; border-radius: 0; padding: 12px 14px;
  }
  .totals > div + div, .totals.four > div + div { border-top: 1px solid var(--line); }
  .totals > div:last-child, .totals.four > div:last-child { grid-column: auto; }
  .totals span { font-size: 14px; }
  .totals strong { font-size: 17px; white-space: nowrap; overflow-wrap: normal; }

  .projects thead { display: none; }
  .projects, .projects tbody { display: block; }
  .projects tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .projects th, .projects td { border: 0; padding: 0; text-align: left; white-space: normal; font-size: 14px; }
  .projects th { grid-column: 1 / -1; font-size: 15px; margin-bottom: 2px; }
  .projects td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
  .table-wrap:has(.projects) { overflow: visible; }
}

/* Settings: business name, partner rows, team. */
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 240px; }
.partner-rows { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 4rem; gap: 8px 10px; align-items: center; }
.partner-rows .col-head { font-size: 12px; font-weight: 600; color: var(--muted); }
.partner-rows .remove { display: grid; place-items: center; min-height: 44px; }
.partner-rows .remove input { width: 20px; height: 20px; min-height: 0; accent-color: var(--neg); }
ul.plain { margin: 0; padding-left: 18px; }
.team { list-style: none; margin: 0 0 12px; padding: 0; }
.team li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.team .what { flex: 1; min-width: 0; }
.team .what small { overflow-wrap: anywhere; }
.team .you { color: var(--muted); }
.team details.danger-zone { margin-top: 0; }
.team details.danger-zone > summary { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.team .confirm { flex-basis: 100%; }
.add-member > summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 8px 0; }
.add-member[open] > summary { margin-bottom: 8px; }
@media (max-width: 420px) { .partner-rows { grid-template-columns: minmax(0, 1fr) 5.5rem 2.75rem; } }

/* Sign-up, reset and sign-in extras. */
.auth-title { font-size: 22px; margin: 14px 0 4px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 14px 0 0; font-size: 14px; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Trial and lock banner on every page of a business. */
.access-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: var(--card); border: 1px solid var(--line);
}
.access-banner.locked { background: color-mix(in srgb, var(--neg) 8%, var(--card)); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.access-banner .btn { min-height: 36px; padding: 6px 14px; }

/* Platform admin. */
.platform { max-width: 920px; margin: 0 auto; padding-top: 8px; }
.biz-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.biz-list .card { margin-top: 0; display: flex; flex-direction: column; gap: 6px; }
.biz-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.biz-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.biz-actions button { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.pill.locked { color: var(--neg); border-color: var(--neg); }
.pill.paid { color: var(--in); border-color: var(--in); }

/* Business ID: 4 digits, easy to read out. */
.biz-code { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.biz-id { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; }
.biz-id span { color: var(--muted); font-size: 14px; }
.biz-id strong { font-size: 22px; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
