/*
 * FairShare: the tool's own components, styled in the site's design language (9 Nov 2026, on the UltraCompress Pro
 * template, after FreelanceIQ and the tools before it, whose shared block the first part of this file copies).
 * Base: /libs/site-pages.css (tokens, Inter and Space Grotesk, buttons, theme toggle, focus rings) and /libs/shared-nav.css
 * (the site's header and footer). The second part is the original's components (the settle-up map, balances, expenses, the
 * expense form, repeating bills, fair rent, insights) on the site's tokens, each part of a view a card. Light is the default;
 * dark applies when <html> has no data-theme.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;
    --surface-2: #f3f4f8;
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --radius-lg: 16px;
    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.24);
    --ok: #166534;
    --ok-soft: rgba(22, 101, 52, 0.09);
    --bad: #b91c1c;
    --bad-soft: rgba(185, 28, 28, 0.08);
    --warn: #92400e;
    --warn-soft: rgba(217, 119, 6, 0.1);
    --stage: #f3f4f8;
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.26);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.1);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.1);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.1);
    --stage: #1c1c2b;
}

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container { max-width: calc(var(--app-max) + 2 * var(--content-gutter)); margin-top: 16px; }
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- The site header is the first thing on the page and stays at the top ----- */
body { padding-top: 0; }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: 90px; }
@media (max-width: 639.98px) { .theme-toggle { top: 75px; } } /* the header is 81 px tall from 640 px, 65 px below */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ----- Hero ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--text-strong); }
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Small helpers ----- */
main [hidden], .dialog [hidden] { display: none !important; } /* the script hides fields that carry their own display */
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-2); }
.small { font-size: 0.9rem; }
.block { display: block; }
.hint { color: var(--text-3); font-size: 0.8rem; font-weight: 400; line-height: 1.45; }
.err { color: var(--bad); font-size: 0.85rem; font-weight: 600; }
.err:empty { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link:hover { color: var(--link-hover); }
code { font-size: 0.85em; padding: 1px 6px; border-radius: 6px; background: var(--code-bg); color: var(--code-text); }
kbd { font-family: inherit; font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--chip-border); background: var(--chip); color: var(--text-strong); }

/* ----- Buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 9999px; font-family: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2; padding: 12px 24px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid rgba(185, 28, 28, 0.35); padding: 11px 23px; }
.btn-danger:hover:not(:disabled) { background: var(--danger-strong); color: #fff; border-color: transparent; transform: translateY(-2px); }
.btn-sm { font-size: 0.85rem; padding: 9px 16px; }
.btn-secondary.btn-sm, .btn-danger.btn-sm { padding: 8px 15px; }
.btn-stack { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); flex-shrink: 0; padding: 0; font-family: inherit; transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.icon-btn:hover { border-color: var(--brand); color: var(--link); background: var(--surface); }
.icon-btn.del:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn:focus-visible, .link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Toolbar ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 1.25rem; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 10px; padding: 6px 16px 6px 10px; border-radius: 9999px; border: 1px solid var(--tint-brand-border); background: var(--tint-brand); min-width: 220px; max-width: 100%; }
.status-icon { font-size: 1.3rem; line-height: 1; }
.status-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.status-main { font-weight: 700; font-size: 0.85rem; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-sub { font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 9999px; background: var(--surface-2); max-width: 100%; }
.view-tab { padding: 8px 16px; border: 0; border-radius: 9999px; background: transparent; font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.view-tab:hover { color: var(--link); }
.view-tab.active { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.view-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.view[hidden] { display: none; }
.shell-hint { margin-top: 14px; }

/* ----- Cards ----- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.card-grid:empty { display: none; }
.card--wide { grid-column: span 2; }
.card--full { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--surface-shadow); overflow: hidden; display: flex; flex-direction: column; min-width: 0; margin-bottom: 0; }
.view > .card { margin-bottom: 20px; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-note { font-size: 0.8125rem; color: var(--text-3); }
.card-body { padding: 16px 20px 20px; flex: 1; min-width: 0; }
.card-body > * + * { margin-top: 16px; }
.form-hint { font-size: 0.8rem; color: var(--text-3); margin: 10px 0 0; line-height: 1.5; }

/* ----- Fields ----- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.label { font-weight: 600; font-size: 0.85rem; color: var(--text-strong); }
.input, .select { width: 100%; min-width: 0; min-height: 44px; padding: 10px 14px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; font-family: inherit; font-size: 0.95rem; color: var(--text); outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder { color: var(--placeholder); }
.input[aria-invalid="true"] { border-color: var(--bad); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }
input[type="time"].input { color-scheme: light; width: 9em; }
:root:not([data-theme="light"]) input[type="time"].input { color-scheme: dark; }
.select { width: auto; max-width: 100%; appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; cursor: pointer; }
.select option { color: #0a0a14; background: #fff; }
.num-input { width: 7.5em; }
.num-input.wide { width: 10em; }
.check-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 0.925rem; color: var(--text); padding: 4px 0; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--surface); font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
.seg button:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.seg button[aria-checked="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--chip); font-family: inherit; font-size: 0.8rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease; }
.chip .ico { width: 15px; height: 15px; color: var(--link); }
.chip:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Windows ----- */
.dialog { margin: auto; border: 1px solid var(--surface-border); border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 16px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); }
.dialog--narrow { width: min(420px, calc(100vw - 16px)); }
.dialog--wide { width: min(680px, calc(100vw - 16px)); }
.dialog::backdrop { background: rgba(10, 10, 20, 0.6); backdrop-filter: blur(6px); }
.dialog[open] { animation: pop 0.2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }
.dialog-head { padding: 18px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-title { margin: 0; font-size: 1.15rem; }
.dialog-close { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--chip-border); background: var(--chip); color: var(--text-strong); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: border-color 0.2s ease, color 0.2s ease; }
.dialog-close:hover { border-color: var(--brand); color: var(--link); }
.dialog-body { padding: 20px; overflow-y: auto; max-height: calc(100vh - 210px); display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { padding: 14px 20px; border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm-message { margin: 0; color: var(--text); }
.help-body h3 { margin: 6px 0 0; font-size: 1rem; }
.help-body p { margin: 0; color: var(--text-2); }

/* ----- Toasts ----- */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { pointer-events: auto; background: #0a0a14; color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); border-left: 4px solid var(--brand); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); min-width: 260px; max-width: 420px; font-size: 0.875rem; font-weight: 500; overflow-wrap: anywhere; animation: slideIn 0.3s ease; transition: opacity 0.3s ease, transform 0.3s ease; }
.toast button { background: none; border: 0; padding: 0; color: #c4b5fd; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; white-space: nowrap; }
.toast.leaving { opacity: 0; transform: translateX(40px); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast.good { border-left-color: #4ade80; }
.toast.bad { border-left-color: #f87171; }

/* ----- Information sections ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 16px; box-shadow: var(--surface-shadow); padding: 20px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.step-card { position: relative; padding-top: 24px; }
.step-num { position: absolute; top: -16px; left: 20px; width: 34px; height: 34px; border-radius: 50%; background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary { cursor: pointer; padding: 16px 20px; font-weight: 600; color: var(--text-strong); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ===== FairShare components ===== */

/* ----- The original's colours (both themes) and its names for the site's tokens ----- */
:root {
    --panel: var(--surface);
    --panel-2: var(--surface-2);
    --muted: var(--text-2);
    --faint: var(--text-3);
    --border: var(--surface-border);
    --border-strong: var(--line-strong);
    --good: var(--ok);
    --good-soft: var(--ok-soft);
    --good-bar: #2f9a66;
    --owe: #b4461c;
    --owe-soft: rgba(180, 70, 28, 0.09);
    --owe-bar: #e0743f;
    --grid: rgba(0, 0, 0, 0.08);
    --axis: var(--line-strong);
    --bar: #7c3aed;
    --bar-out: #c4c8d0;
    --tip-bg: #0a0a14;
    --tip-text: #ffffff;
    /* one colour per person, in this fixed order (checked for colour-blind separation; the original's), with the text on it */
    --p0: #2670cc; --t0: #ffffff;   /* the original's #2a78d6 gave white initials 4.42:1 */
    --p1: #eb6834; --t1: #16191f;
    --p2: #1baf7a; --t2: #16191f;
    --p3: #eda100; --t3: #16191f;
    --p4: #e87ba4; --t4: #16191f;
    --p5: #008300; --t5: #ffffff;
    --p6: #6250d6; --t6: #ffffff;
    --p7: #e34948; --t7: #16191f;
}
:root:not([data-theme="light"]) {
    --good-bar: #3fae78;
    --owe: #f2a07a;
    --owe-soft: rgba(242, 160, 122, 0.12);
    --owe-bar: #d9693a;
    --grid: rgba(255, 255, 255, 0.08);
    --bar: #a78bfa;
    --bar-out: #3c424c;
    --tip-bg: #f3f4f6;
    --tip-text: #0a0a14;
    --p0: #3987e5; --t0: #16191f;
    --p1: #d95926; --t1: #16191f;
    --p2: #199e70; --t2: #16191f;
    --p3: #c98500; --t3: #16191f;
    --p4: #d55181; --t4: #16191f;
    --p5: #008300; --t5: #ffffff;
    --p6: #9085e9; --t6: #16191f;
    --p7: #e66767; --t7: #16191f;
}

/* ----- The site's text rules (p, ul, li, table) must not reach the tool: same weight as the site's, loaded later ----- */
:where(.app-shell) p, :where(.app-shell) ul, :where(.app-shell) ol, :where(.app-shell) li, :where(.app-shell) dl,
:where(.app-shell) dd, :where(.app-shell) figure, :where(.dialog) p, :where(.dialog) ul { margin: 0; line-height: 1.5; }
:where(.app-shell) ul, :where(.app-shell) ol { padding: 0; list-style: none; }
:where(.app-shell) table, :where(.dialog) table { margin: 0; background: none; border-radius: 0; overflow: visible; }
:where(.app-shell) th, :where(.app-shell) td, :where(.dialog) th, :where(.dialog) td { border: 0; padding: 0; }
.num { font-variant-numeric: tabular-nums; }
.get { color: var(--good); }
.owe { color: var(--owe); }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.self-start { align-self: flex-start; }
.hint:empty { display: none; }
.label .muted { font-weight: 400; }
legend.label { padding: 0; margin-bottom: 6px; }
.field > .seg { align-self: flex-start; }

/* ----- The script writes the original's button classes (btn, btn primary, btn danger, btn ghost, small-btn) ----- */
.btn { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn.primary { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn.primary:hover:not(:disabled) { color: #fff; box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); }
.btn.danger { color: var(--danger); border-color: rgba(185, 28, 28, 0.35); }
.btn.danger:hover:not(:disabled) { background: var(--danger-strong); color: #fff; border-color: transparent; }
.btn.small-btn { font-size: 0.85rem; padding: 8px 15px; }
.btn:focus-visible, .chip:focus-visible, .swatch:focus-visible, details.more > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.chip[aria-pressed="true"] .ico, .chip[aria-checked="true"] .ico { color: #fff; }

/* ----- Selects, including the ones the script builds ----- */
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; cursor: pointer; }
select.input option { color: #0a0a14; background: #fff; }
textarea.share-text:not(.plain) { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; min-height: 110px; }
textarea.input.plain { min-height: 64px; }

/* ----- Toolbar, banner and tabs ----- */
.status-pill .status-main { font-size: 0.95rem; }
.app-shell > .view-tabs { margin: 0 0 1.25rem; display: flex; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.app-shell > .view-tabs[hidden] { display: none; }
.view-tab .short { display: none; }
.banner { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 0 0 1.25rem; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--tint-brand-border); background: var(--tint-brand); font-size: 0.925rem; color: var(--text); }
.banner .ico { color: var(--link); width: 20px; height: 20px; }
.banner > span { flex: 1 1 220px; min-width: 0; }
.banner.warn { background: var(--warn-soft); border-color: rgba(217, 119, 6, 0.35); }
.banner.warn .ico { color: var(--warn); }

/* ----- Views ----- */
.view > * + * { margin-top: 20px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.view-title { margin: 0; font-size: 1.35rem; }
.lead { margin-top: 4px; color: var(--text-2); max-width: 72ch; }
.view-head .short { display: none; }
.view-body { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.view-body > .seg { align-self: flex-start; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1100px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* ----- Cards: each part of a view, the site's white card with a title strip ----- */
.section, .set-block, .hero, .start, .mgroup, .filters, .view-body > .readouts > .ro {
    background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--surface-shadow); min-width: 0;
}
.section, .set-block { display: flex; flex-direction: column; gap: 14px; padding: 0 20px 20px; }
.section > :first-child:not(.section-head), .set-block > :first-child:not(h2) { margin-top: 20px; }
.section-head { margin: 0 -20px; padding: 14px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.section-head h2, .set-block > h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.set-block > h2 { margin: 0 -20px; padding: 14px 20px; border-bottom: 1px solid var(--surface-border); }
.section-head p { color: var(--text-3); font-size: 0.8125rem; }
.section-note { color: var(--text-2); font-size: 0.875rem; max-width: 72ch; }
.empty { color: var(--text-2); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 22px 8px; text-align: center; font-size: 0.925rem; display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--surface); }
.empty .actions { justify-content: center; }
.view-body > .empty { border-radius: var(--radius-lg); }

/* ----- People: each keeps one colour everywhere ----- */
.av { --pc: var(--p0); --pt: var(--t0); width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; background: var(--pc); color: var(--pt); font-size: 0.75rem; font-weight: 750; letter-spacing: 0.02em; line-height: 1; }
.av.sm { width: 24px; height: 24px; font-size: 0.62rem; }
.av.lg { width: 44px; height: 44px; font-size: 0.95rem; }
.av.gone { opacity: 0.55; }
.c0 { --pc: var(--p0); --pt: var(--t0); }
.c1 { --pc: var(--p1); --pt: var(--t1); }
.c2 { --pc: var(--p2); --pt: var(--t2); }
.c3 { --pc: var(--p3); --pt: var(--t3); }
.c4 { --pc: var(--p4); --pt: var(--t4); }
.c5 { --pc: var(--p5); --pt: var(--t5); }
.c6 { --pc: var(--p6); --pt: var(--t6); }
.c7 { --pc: var(--p7); --pt: var(--t7); }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-strong); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.74rem; font-weight: 600; padding: 1px 8px; border-radius: 9999px; background: var(--chip); border: 1px solid var(--chip-border); color: var(--text-2); white-space: nowrap; }

/* the group picker in the heading */
.group-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; border-radius: 6px; cursor: pointer; max-width: 100%; }
.group-pick:hover span { text-decoration: underline; text-underline-offset: 3px; }
.group-pick:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.group-pick .ico { width: 18px; height: 18px; color: var(--text-2); }
.group-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-select { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; font-size: 16px; }

/* ----- Start ----- */
.start { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); padding: 24px; }
@media (min-width: 1024px) { .start { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: start; } }
.start .start-title { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem); letter-spacing: -0.02em; line-height: 1.15; max-width: 20ch; }
.start .lead { font-size: 1.02rem; margin-top: 12px; }
.setup { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; max-width: 560px; }
.setup.flush { margin-top: 0; max-width: none; }
.names { display: flex; flex-direction: column; gap: 8px; }
.name-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.start-side { display: flex; flex-direction: column; gap: 22px; }
.start-steps { display: flex; flex-direction: column; counter-reset: step; }
.start-steps li { counter-increment: step; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--surface-border); }
.start-steps li:last-child { border-bottom: 0; }
.start-steps li::before { content: counter(step); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 0.85rem; }
.start-steps b { display: block; color: var(--text-strong); }
.start-steps span { color: var(--text-2); font-size: 0.9rem; }
.start-other { display: flex; flex-direction: column; gap: 8px; }
.start-other h2 { font-size: 1.05rem; margin: 0 0 4px; }
.start-other .btn { justify-content: flex-start; }

/* ----- Balances: the headline ----- */
.hero { display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.hero-top .group-title { font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--text-2); font-weight: 650; letter-spacing: 0; min-width: 0; max-width: 100%; margin: 0; }
.hero-title { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: clamp(1.8rem, 1.1rem + 3vw, 3.2rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.08; max-width: 22ch; overflow-wrap: anywhere; color: var(--text-strong); margin: 6px 0 0; }
.hero-sentence { font-size: clamp(1.02rem, 1.6vw, 1.18rem); line-height: 1.6; max-width: 64ch; color: var(--text); margin-top: 4px; }
.readouts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin-top: 10px; }
@media (min-width: 900px) { .readouts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ro { border-top: 1px solid var(--surface-border); padding: 12px 0 14px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.view-body > .readouts { gap: 20px; margin-top: 0; }
.view-body > .readouts > .ro { padding: 16px 20px; }
.ro-label { color: var(--text-2); font-size: 0.85rem; font-weight: 600; }
.ro-val { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: clamp(1.15rem, 2.2vw, 1.45rem); font-weight: 700; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; color: var(--text-strong); }
.ro-sub { color: var(--text-3); font-size: 0.82rem; }

/* ----- Settle up: the list and the map ----- */
.settle { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px 40px; align-items: start; }
@media (min-width: 1024px) { .settle { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); } }
.settle-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mode-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.count-line { font-size: 0.925rem; color: var(--text-2); }
.count-line b { color: var(--text-strong); }
.transfers { display: flex; flex-direction: column; border-top: 2px solid var(--text-strong); }
.tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--surface-border); }
.tr.on { background: linear-gradient(90deg, var(--tint-brand), transparent 85%); }
.tr-who { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.tr-who .verb { color: var(--text-2); font-size: 0.9rem; }
.tr-who b { font-weight: 650; color: var(--text-strong); }
.tr-amt { font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; color: var(--text-strong); }
.tr-acts { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
@media (min-width: 560px) {
    .tr { grid-template-columns: minmax(0, 1fr) auto auto; }
    .tr-acts { grid-column: auto; }
}
.settled-note { display: flex; gap: 10px; align-items: center; padding: 14px 0; border-top: 2px solid var(--text-strong); color: var(--text-2); }
.settled-note .ico { color: var(--good); width: 22px; height: 22px; }
.map { position: relative; width: 100%; min-width: 0; touch-action: pan-y; }
.map svg { display: block; width: 100%; overflow: visible; }
.map .ring { fill: none; stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2 5; }
.map .edge { fill: none; stroke: var(--text-strong); stroke-linecap: round; opacity: 0.62; transition: opacity 0.15s; }
.map .head { fill: var(--text-strong); opacity: 0.62; transition: opacity 0.15s; }
.map .hit { fill: none; stroke: transparent; stroke-width: 22; cursor: pointer; }
.map g.e { outline: none; }
.map g.e:focus-visible .edge { stroke: var(--brand); opacity: 1; }
.map g.e.on .edge, .map g.e.on .head { opacity: 1; }
.map.focus g.e:not(.on) .edge, .map.focus g.e:not(.on) .head, .map.focus g.e:not(.on) .lbl { opacity: 0.14; }
.map .lbl rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.map .lbl text { fill: var(--text-strong); font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.map .lbl { transition: opacity 0.15s; pointer-events: none; }
.map .node circle.dot { fill: var(--pc); stroke: var(--surface); stroke-width: 3; }
.map .node text.ini { fill: var(--pt); font-size: 12px; font-weight: 750; }
.map .node text.nm { fill: var(--text-strong); font-size: 13px; font-weight: 700; }
.map .node text.bl { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.map .node text.bl.get { fill: var(--good); }
.map .node text.bl.owe { fill: var(--owe); }
.map .node text.bl.zero { fill: var(--text-2); }
.map .center { fill: var(--text-2); font-size: 13px; }
.map .draw { animation: draw 0.7s cubic-bezier(0.3, 0.7, 0.3, 1) both; }
.map .fade { animation: fade 0.35s ease-out both; }
@keyframes draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } }
.map-cap { color: var(--text-2); font-size: 0.85rem; text-align: center; margin-top: 4px; }

/* ----- Balances: who is up and who is down ----- */
.bars { display: flex; flex-direction: column; }
.brow { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who amt" "bar bar"; gap: 6px 12px; align-items: center; padding: 12px 0; border: 0; border-bottom: 1px solid var(--surface-border); background: none; text-align: left; width: 100%; color: inherit; font: inherit; cursor: pointer; }
.brow:last-child { border-bottom: 0; }
.brow:hover { background: linear-gradient(90deg, var(--surface-2), transparent); }
.brow:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.brow .who { grid-area: who; }
.brow .who small { display: block; color: var(--text-2); font-size: 0.8rem; font-weight: 400; }
.brow .b-amt { grid-area: amt; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-strong); }
.brow .b-amt.get { color: var(--good); }
.brow .b-amt.owe { color: var(--owe); }
.brow .b-amt small { display: block; font-weight: 500; font-size: 0.78rem; }
.brow .track { grid-area: bar; position: relative; height: 14px; }
.brow .track::before { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--axis); }
.brow .fill { position: absolute; top: 2px; height: 10px; border-radius: 4px; }
.brow .fill.get { left: calc(50% + 2px); background: var(--good-bar); border-radius: 0 4px 4px 0; }
.brow .fill.owe { right: calc(50% + 2px); background: var(--owe-bar); border-radius: 4px 0 0 4px; }
.bar-key { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; color: var(--text-2); font-size: 0.8rem; }
.bar-key .k { grid-column: 1 / -1; display: flex; justify-content: space-around; }
@media (min-width: 760px) {
    .brow, .bar-key { grid-template-columns: minmax(12rem, 1fr) minmax(0, 2.2fr) 9.5rem; grid-template-areas: "who bar amt"; }
    .bar-key .k { grid-column: 2; }
}

/* ----- Bills waiting, small lists ----- */
.due { display: flex; flex-direction: column; border-top: 2px solid var(--text-strong); }
.due-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--surface-border); }
.due-row:last-child { border-bottom: 0; }
.due-row .d-txt b { display: block; font-weight: 650; color: var(--text-strong); }
.due-row .d-txt small { color: var(--text-2); font-size: 0.82rem; }
.due-row .actions { justify-content: flex-end; }
@media (max-width: 559px) { .due-row .actions { grid-column: 2 / -1; justify-content: flex-start; } }
.cico { width: 36px; height: 36px; border-radius: 10px; background: var(--tint-brand); border: 1px solid var(--tint-brand-border); display: grid; place-items: center; flex: none; color: var(--link); }
.cico .ico { width: 18px; height: 18px; }
.cico.pay { background: transparent; border-style: dashed; }

/* ----- Expenses ----- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.filters .search { position: relative; flex: 1 1 260px; min-width: 0; }
.filters .search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.filters .search .input { padding-left: 40px; }
.filters .fsel { flex: 0 1 12rem; min-width: 0; }
@media (max-width: 559px) { .filters .fsel { flex: 1 1 calc(50% - 4px); } }
.fnote { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--text-2); font-size: 0.9rem; }
.mgroup { display: flex; flex-direction: column; padding: 0 20px 6px; }
.mhead { position: sticky; top: 81px; z-index: 5; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 -20px; padding: 12px 20px 10px; background: var(--surface); border-bottom: 1px solid var(--surface-border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.mhead h2 { font-size: 1.05rem; margin: 0; }
.mhead span { color: var(--text-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.erow { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 0; border: 0; border-bottom: 1px solid var(--surface-border); background: none; width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.mgroup > .erow:last-child { border-bottom: 0; }
.erow:hover { background: linear-gradient(90deg, var(--surface-2), transparent); }
.erow:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.erow .e-main { min-width: 0; }
.erow .e-main b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-strong); }
.erow .e-main small { display: block; color: var(--text-2); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erow .e-amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.erow .e-amt b { display: block; font-weight: 700; color: var(--text-strong); }
.erow .e-amt small { display: block; font-size: 0.8rem; color: var(--text-2); }
.erow .e-amt small.get { color: var(--good); }
.erow .e-amt small.owe { color: var(--owe); }
.erow .e-date { display: none; }
@media (min-width: 900px) {
    .erow { grid-template-columns: 4.2rem 36px minmax(0, 1fr) auto; }
    .erow .e-date { display: block; color: var(--text-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
    .erow .e-main small .d { display: none; }
}
.erow.refund .e-amt b::before { content: "+"; }
.more-row { display: flex; justify-content: center; }

/* ----- One entry in detail ----- */
.info-body { gap: 16px; }
.info-body .dialog-actions { padding: 14px 0 0; margin: 4px 0 0; }
.info-body h3 { margin: 0; font-size: 1.05rem; }
.d-top { display: flex; gap: 14px; align-items: center; }
.d-top .cico { width: 44px; height: 44px; }
.d-amt { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.d-amt.get { color: var(--good); }
.d-amt.owe { color: var(--owe); }
.d-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 8px 20px; font-size: 0.9rem; }
.d-facts div { display: flex; flex-direction: column; color: var(--text); }
.d-facts span { color: var(--text-2); font-size: 0.8rem; font-weight: 600; }
.shares { display: flex; flex-direction: column; border-top: 2px solid var(--text-strong); }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--surface-border); font-variant-numeric: tabular-nums; }
.share-row .s-paid { color: var(--text-2); font-size: 0.85rem; text-align: right; }
.share-row .s-eff { font-weight: 700; text-align: right; min-width: 6.5rem; }
.share-row .s-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.share-row .s-bar i { display: block; height: 100%; background: var(--pc); border-radius: 3px; }
.confirm-body { display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.confirm-body ul { padding-left: 1.2em; list-style: disc; }
.imp-sum { display: flex; flex-direction: column; gap: 8px; font-size: 0.925rem; }
.map-people { display: flex; flex-direction: column; }
.map-people .mp-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--surface-border); }
.sw-fx { display: flex; flex-direction: column; gap: 10px; }
.sw-fx:empty { display: none; }
.sw-fx .field-row .field { flex: 0 1 14rem; }
.share-text { width: 100%; }

/* ----- The expense form ----- */
.dialog-form { margin: 0; }
.dialog-actions.split .grow { flex: 1; }
.exp-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 16px; }
@media (min-width: 620px) { .exp-top { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); } }
.amount-wrap { position: relative; display: block; }
.amount-wrap .cur { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-weight: 700; font-size: 1.3rem; pointer-events: none; }
.amount-wrap .input.amount { font-size: 1.6rem; font-weight: 750; min-height: 56px; padding-left: 40px; letter-spacing: -0.01em; }
.amount-wrap.small .cur { font-size: 1rem; left: 14px; }
.amount-wrap.small .input { padding-left: 34px; font-weight: 650; }
.amount-wrap.wide-cur .input.amount { padding-left: 66px; }
.amount-wrap.small.wide-cur .input { padding-left: 56px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 16px; }
@media (min-width: 520px) { .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .span-2 { grid-column: 1 / -1; } }
@media (min-width: 620px) { .form-grid.three { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); } } /* a hidden field takes no column */
.form-grid .check-row { align-self: center; }
.dialog .seg { align-self: flex-start; }
.box { border-top: 1px solid var(--surface-border); padding-top: 12px; }
.pchip { padding-left: 4px; }
.pchip .av { width: 26px; height: 26px; font-size: 0.62rem; }
.pchip[aria-checked="true"] .av, .pchip[aria-pressed="true"] .av { box-shadow: 0 0 0 2px #fff; }
.multi { display: flex; flex-direction: column; margin-top: 8px; }
.split-rows { display: flex; flex-direction: column; margin-top: 4px; }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(5.5rem, 8rem) minmax(5.5rem, auto); gap: 6px 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--surface-border); }
.srow.off .who b { color: var(--text-3); }
.srow .who input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; flex: none; }
.srow .who label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.srow .input { min-height: 40px; padding: 6px 10px; text-align: right; }
.srow .res { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-strong); }
.srow .res.zero { color: var(--text-3); font-weight: 500; }
.srow .unit { position: relative; }
.srow .unit .input { padding-right: 30px; }
.srow .unit.wide .input { padding-right: 48px; }
.srow .unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-size: 0.85rem; pointer-events: none; }
.srow.equal { grid-template-columns: minmax(0, 1fr) auto; }
.split-tools { display: flex; gap: 6px 14px; flex-wrap: wrap; padding: 8px 0 2px; font-size: 0.875rem; }
.split-status { font-size: 0.9rem; font-weight: 600; min-height: 1.4em; color: var(--text-2); }
.split-status.ok { color: var(--good); }
.split-status.bad { color: var(--bad); }
.period { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding-bottom: 8px; }
.period .field { flex: 1 1 9rem; }
.items { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 7rem 40px; gap: 6px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
.item .input { min-height: 40px; padding: 6px 10px; }
.item .input.num { text-align: right; }
.item .item-who { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.item .item-who .chip { padding: 2px 10px 2px 3px; font-size: 0.8rem; }
.item .item-who .chip .av { width: 22px; height: 22px; font-size: 0.58rem; }
.rest-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--surface-border); font-size: 0.9rem; }
.rest-row b { font-variant-numeric: tabular-nums; }
.item-totals { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 10px; font-size: 0.875rem; }
.item-totals span { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.more-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 16px; }
@media (min-width: 620px) { .more-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.fx-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
details.more { border-top: 1px solid var(--surface-border); padding-top: 10px; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--link); width: fit-content; }
details.more[open] > summary { margin-bottom: 12px; }
.plain-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.plain-list li { color: var(--text-2); }
.help-body ul.plain-list { list-style: disc; }

/* ----- Payments and the UPI code ----- */
.pay-who { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 8px; align-items: end; }
.pay-who .pay-arrow { margin-bottom: 13px; color: var(--text-2); }
.upi { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--tint-brand-border); border-radius: 14px; background: var(--tint-brand); }
.upi .qr { width: 148px; height: 148px; background: #fff; border-radius: 8px; padding: 6px; }
.upi .qr svg { display: block; width: 100%; height: 100%; }
.upi .upi-txt { display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; min-width: 0; color: var(--text); }
.upi .upi-txt b { overflow-wrap: anywhere; color: var(--text-strong); }
@media (max-width: 459px) { .upi { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } .upi .upi-txt .actions { justify-content: center; } }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--pc); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); display: grid; place-items: center; color: var(--pt); padding: 0; cursor: pointer; }
.swatch .ico { width: 18px; height: 18px; opacity: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text-strong); }
.swatch[aria-checked="true"] .ico { opacity: 1; }

/* ----- Repeating bills and fair rent ----- */
.bill-list { display: flex; flex-direction: column; border-top: 2px solid var(--text-strong); }
.bill-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--surface-border); }
.bill-row:last-child { border-bottom: 0; }
.bill-row .b-txt { min-width: 0; }
.bill-row .b-txt b { display: block; font-weight: 650; color: var(--text-strong); }
.bill-row .b-txt small { display: block; color: var(--text-2); font-size: 0.85rem; }
.bill-row .b-next { text-align: right; font-size: 0.875rem; white-space: nowrap; color: var(--text); }
.bill-row .b-next b { display: block; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.bill-row .actions { grid-column: 2 / -1; }
.bill-row.paused .b-txt b { color: var(--text-2); }
.rent { gap: 16px; }
.rent-top { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.rent-top .field { flex: 0 1 15rem; }
.rent-top .field.how { flex: 0 1 auto; }
.rent-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px 40px; align-items: start; }
@media (min-width: 1024px) { .rent-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } .rent-grid.stack { grid-template-columns: minmax(0, 1fr); } }
.rent-in { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rent-result { display: flex; flex-direction: column; gap: 10px; }
.rent-note { color: var(--text-2); font-size: 0.875rem; max-width: 72ch; }
.suffix-wrap { position: relative; display: block; }
.suffix-wrap .input { padding-right: 34px; }
.suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

/* ----- Tables ----- */
.tbl-wrap { overflow-x: auto; min-width: 0; }
.tbl-wrap:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
.tbl th { text-align: left; font-size: 0.8rem; color: var(--text-2); font-weight: 600; padding: 8px 10px 8px 0; border-bottom: 2px solid var(--text-strong); white-space: nowrap; }
.tbl td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--surface-border); vertical-align: middle; color: var(--text); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.r { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl td.r.get { color: var(--good); }
.tbl td.r.owe { color: var(--owe); }
.tbl tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--text-strong); color: var(--text-strong); }
.tbl .input { min-height: 40px; padding: 6px 10px; }
.tbl .input.num { text-align: right; width: 7.5rem; min-width: 5.5rem; }
.tbl .suffix-wrap { display: inline-block; }
.tbl .suffix-wrap .input { padding-right: 30px; }
.tbl td.who-cell { min-width: 8rem; }
.bids .input.num { width: 6.5rem; min-width: 5rem; }
.tbl .input.room-name { width: 8rem; min-width: 6rem; }
@media (max-width: 559px) {
    .tbl .input.num { width: 5.6rem; min-width: 4.5rem; }
    .tbl td.who-cell { min-width: 6.5rem; }
    .tbl th, .tbl td { padding-right: 6px; }
}

/* ----- Insights ----- */
.chart { position: relative; width: 100%; min-width: 0; outline: none; border-radius: 12px; touch-action: pan-y; }
.chart:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .col { fill: var(--bar); }
.chart .col.out { fill: var(--bar-out); }
.chart .col.on { filter: brightness(1.12); }
.chart .col-hit { fill: transparent; cursor: default; }
.tip { position: fixed; z-index: 70; pointer-events: none; max-width: 290px; background: var(--tip-bg); color: var(--tip-text); border-radius: 10px; padding: 8px 10px; font-size: 0.85rem; line-height: 1.4; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.tip b { display: block; margin-bottom: 2px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.cats { display: flex; flex-direction: column; }
.cat-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; border: 0; border-bottom: 1px solid var(--surface-border); background: none; width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.cat-row:last-child { border-bottom: 0; }
.cat-row:hover { background: linear-gradient(90deg, var(--surface-2), transparent); }
.cat-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.cat-row .c-name { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cat-row .c-name b { font-weight: 600; font-size: 0.925rem; color: var(--text-strong); }
.cat-row .c-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.cat-row .c-bar i { display: block; height: 100%; background: var(--bar); border-radius: 4px; }
.cat-row .c-amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-row .c-amt b { display: block; color: var(--text-strong); }
.cat-row .c-amt small { color: var(--text-2); font-size: 0.8rem; }
.ppl { display: flex; flex-direction: column; border-top: 2px solid var(--text-strong); }
.ppl-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--surface-border); }
.ppl-row:last-child { border-bottom: 0; }
.ppl-row .p-bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.ppl-row .p-bar i { display: block; height: 100%; background: var(--pc); border-radius: 4px; }
.ppl-row .p-amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ppl-row .p-amt b { display: block; color: var(--text-strong); }
.ppl-row .p-amt small { color: var(--text-2); font-size: 0.8rem; }
@media (max-width: 559px) { /* the amount and its "paid, covered by others" line go under the name and wrap */
    .ppl-row { grid-template-columns: minmax(0, 1fr); }
    .ppl-row .p-amt { text-align: left; white-space: normal; }
}

/* ----- People and group ----- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1024px) { .settings-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field-row .field { flex: 1 1 11rem; }
.person-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; border: 0; border-bottom: 1px solid var(--surface-border); background: none; width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.person-row:hover { background: linear-gradient(90deg, var(--surface-2), transparent); }
.person-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.person-row .who small { display: block; color: var(--text-2); font-size: 0.8rem; font-weight: 400; }
.person-row .who > span { min-width: 0; }
.person-row .pr-edit { color: var(--link); display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 600; }
.group-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
.group-row b { display: block; color: var(--text-strong); }
.group-row small { color: var(--text-2); font-size: 0.82rem; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.set-block .field > .input:not(select), .set-block .field > select.input { max-width: 26rem; }
@media (forced-colors: active) {
    .av, .swatch, .brow .fill, .cat-row .c-bar i, .ppl-row .p-bar i, .share-row .s-bar i { forced-color-adjust: none; }
}

/* ----- The printed statements: only the sheet, in black on white ----- */
.print-sheet { display: none; }
@media print {
    @page { margin: 16mm; }
    body { background: #fff; color: #000; }
    body:has(#printSheet:not(:empty)) > *:not(#printSheet) { display: none !important; }
    .print-sheet:not(:empty) { display: block !important; font-family: 'Inter', sans-serif; font-size: 10.5pt; color: #000; }
    .print-sheet h1 { font-size: 18pt; margin: 0 0 2pt; color: #000; }
    .print-sheet h2 { font-size: 12pt; border-bottom: 1.5pt solid #000; padding-bottom: 3pt; margin: 14pt 0 4pt; color: #000; }
    .print-sheet .sub { color: #444; margin: 0 0 12pt; }
    .print-sheet table { width: 100%; border-collapse: collapse; margin: 0; background: none; }
    .print-sheet td, .print-sheet th { padding: 3pt 0; border: 0; border-bottom: 0.5pt solid #ccc; color: #000; text-align: left; vertical-align: top; }
    .print-sheet th { font-size: 9pt; color: #444; border-bottom: 1pt solid #000; }
    .print-sheet td.v, .print-sheet th.v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8pt; }
    .print-sheet .page { page-break-after: always; }
    .print-sheet .page:last-child { page-break-after: auto; }
    .print-sheet .note { margin-top: 18pt; color: #555; font-size: 9pt; }
}

/* ----- Tablets ----- */
@media (max-width: 1023px) {
    .info-section .info-grid { grid-template-columns: repeat(2, 1fr); }
    .info-three { grid-template-columns: 1fr; }
}

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .app-toolbar { gap: 10px; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .status-pill { flex: 1 1 100%; min-width: 0; }
    .toolbar-right .btn { flex: 1 1 auto; }
    .app-shell > .view-tabs { width: 100%; }
    .app-shell > .view-tabs .view-tab { flex: 1 1 auto; justify-content: center; padding: 8px 6px; font-size: 0.85rem; }
    .view-tab .long, .view-head .long { display: none; }
    .view-tab .short, .view-head .short { display: inline; }
    .view-head .actions { width: 100%; }
    .view-head .actions .btn { flex: 1; padding: 9px 10px; }
    .section, .set-block { padding: 0 16px 16px; }
    .section-head, .set-block > h2 { margin: 0 -16px; padding: 12px 16px; }
    .section > :first-child:not(.section-head), .set-block > :first-child:not(h2) { margin-top: 16px; }
    .mgroup { padding: 0 16px 6px; }
    .mhead { top: 65px; margin: 0 -16px; padding: 12px 16px 10px; }
    .hero, .start { padding: 16px; }
    .view-body > .readouts > .ro { padding: 14px 16px; }
    .view-body > .readouts { gap: 12px; }
    .toasts { bottom: 16px; right: 16px; left: 16px; align-items: stretch; }
    .toast { min-width: 0; max-width: none; }
    .dialog-body, .dialog-head, .dialog-actions { padding-left: 16px; padding-right: 16px; }
    .info-body .dialog-actions { padding-left: 0; padding-right: 0; }
    #expSaveAnother { display: none; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .info-card, .dialog, .toast, .chip, .seg button, .view-tab, .swatch { transition: none; animation: none; }
    .map .draw, .map .fade { animation: none; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026). The map and the chart are drawings and keep their
   own sizes; buttons inside a sentence read as links (WCAG 2.5.8). */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"]:not(g),
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]) { min-height: 44px; }
    main .chip, main .seg button, main .view-tab, main .icon-btn { min-height: 44px; min-width: 44px; }
    main .icon-btn { width: 44px; height: 44px; }
    main .srow .who input[type="checkbox"] { width: 24px; height: 24px; }
    main .check-row, .dialog .check-row { min-height: 44px; align-items: center; }
    main .group-pick { min-height: 44px; }
    .name-row { grid-template-columns: 32px minmax(0, 1fr) 44px; }
    main :is(p:not(.hero-title):not(.d-amt), li, td, th, .hint, .muted, .small, .label, .lead, .ro-label, .ro-sub, .count-line,
        .tr-who .verb, .brow small, .b-amt small, .d-txt small, .e-main small, .e-amt small, .mhead span, .b-txt small, .b-next,
        .c-amt small, .p-amt small, .person-row small, .pr-edit, .group-row small, .tag, .map-cap, .fnote, .bar-key, .start-steps span,
        .section-head p, .section-note, .rent-note, .status-sub, .form-hint, .err, .input, kbd) { font-size: 1rem; }
    .dialog button, .dialog .btn, .dialog select, .dialog input:not([type="checkbox"]), .dialog summary { min-height: 44px; }
    .dialog .dialog-close { width: 44px; height: 44px; }
    .dialog .swatch { width: 44px; height: 44px; }
    .dialog .srow .input, .dialog .item .input, .dialog .tbl .input { min-height: 44px; }
    .dialog .srow .who label { min-height: 44px; }
    .dialog .icon-btn { width: 44px; height: 44px; }
    .dialog .item { grid-template-columns: minmax(0, 1fr) 7rem 44px; }
    .dialog :is(p, li, .hint, .input, .label, .seg button, .check-row, .err, .split-status, .split-tools, .rest-row, .item-totals,
        .s-paid, .d-facts span, .d-facts div, .srow .unit span, .imp-sum, .tbl td, .tbl th, .confirm-body) { font-size: 1rem; }
}
