/* Ledger UI: brand stylesheet overriding Tabler. Inter + tabular nums;
   cards, sidebar, KPI tiles, chart cards, table pills, step forms, sticky bars. */

:root {
    --navy: #0b2545;
    --navy-text: #0b2545; /* navy used as TEXT (headings, links); --navy itself is a background colour */
    --link: #13315c; /* link and link-like text (was navy-2) */
    --navy-2: #13315c;
    --navy-soft: rgba(11, 37, 69, .08);
    --green: #1d7a46;
    --green-bg: #1d7a46; /* green as a BACKGROUND under white text (buttons, chips) */
    --green-soft: #e8f4ee;
    --red: #c0392b;
    --red-soft: #fbeceb;
    --amber: #b7791f;
    --amber-soft: #fdf3df;
    --blue: #206bc4;
    --blue-soft: #e6f0fb;
    --teal: #0d9488;
    --teal-soft: #e2f6f4;
    --purple: #6d28d9;
    --purple-soft: #f0e8fb;
    --indigo: #4f46e5;
    --indigo-soft: #ebebfb;
    --grey-soft: #f1f3f7;
    --bg: #f4f6fa;
    --card: #ffffff;
    --line: #e6e9f0;
    --muted: #6b7280;
    --text: #111827;
    /* Extra surface tokens (owner, 14 Oct: dark theme). They map the hard-coded
       light greys that app surfaces used (#fff, #fafbfd, #fcfdfe, #f1f3f6, #cfd5e0...)
       so the dark theme can swap them in one place. */
    --surface: #ffffff;
    --surface-hover: #fafbfd;
    --surface-2: #fcfdfe;
    --surface-strong: #f1f3f6;
    --border-strong: #cfd5e0;
    --on-dark: #ffffff;
    --on-dark-soft: rgba(255, 255, 255, .08);
    --on-dark-medium: rgba(255, 255, 255, .65);
    --on-dark-strong: rgba(255, 255, 255, .85);
    --on-dark-faint: rgba(255, 255, 255, .45);
    --on-dark-line: rgba(255, 255, 255, .14);
    --on-dark-divider: rgba(255, 255, 255, .18);
    --on-dark-hover: rgba(255, 255, 255, .06);
    --on-dark-tab-hover: rgba(255, 255, 255, .08);
    --pill-muted-bg: #f1f3f6;
    --pill-muted-fg: #8a919e;
    --text-secondary: #5b6472;
    --shadow-rgb: 16, 24, 40;
    --radius-card: 14px;
    --radius-btn: 10px;
    --shadow-soft: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .04);
    --shadow-sticky: 0 -2px 14px rgba(16, 24, 40, .08);
}

/* Dark theme (owner, 14 Oct): one block per choice. data-theme="dark" is the
   explicit pick; the media query is the "same as my device" default (a body
   that has not chosen still gets the device colour scheme). Contrast targets:
   text >= 4.5:1, muted >= 3:1 on its background. */
:root[data-theme="dark"] {
    --bg: #0b1220;
    --card: #16203a;
    --line: #2a3855;
    --muted: #9aa6c2;
    --text: #f1f5f9;
    /* Backgrounds stay dark (sidebar, badges, buttons); only navy TEXT turns light. */
    --navy: #0a1120;
    --navy-2: #1b2a4a;
    --navy-text: #c2cfe6;
    --link: #9ab0d2;
    --navy-soft: rgba(154, 176, 210, .14);
    --green: #34b26f; /* calmer than neon, still 5:1 on the dark background */
    --green-bg: #1b7d45; /* white text on it reads at 5:1 */
    --green-soft: #14331f;
    --red: #f87171;
    --red-soft: #3a1c1c;
    --amber: #fbbf24;
    --amber-soft: #3a2a0c;
    --blue: #60a5fa;
    --blue-soft: #15243f;
    --teal: #2dd4bf;
    --teal-soft: #0c2925;
    --purple: #a78bfa;
    --purple-soft: #251e3b;
    --indigo: #818cf8;
    --indigo-soft: #1d1f3f;
    --grey-soft: #1f2a44;
    --surface: #16203a;
    --surface-hover: #1d2a48;
    --surface-2: #1a2440;
    --surface-strong: #1f2a44;
    --border-strong: #3a4a6d;
    --pill-muted-bg: #1f2a44;
    --pill-muted-fg: #9aa6c2;
    --text-secondary: #9aa6c2;
    --shadow-rgb: 0, 0, 0;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .35);
    --shadow-sticky: 0 -2px 14px rgba(0, 0, 0, .55);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1220;
        --card: #16203a;
        --line: #2a3855;
        --muted: #9aa6c2;
        --text: #f1f5f9;
        --navy: #0a1120;
        --navy-2: #1b2a4a;
        --navy-text: #c2cfe6;
        --link: #9ab0d2;
        --navy-soft: rgba(154, 176, 210, .14);
        --green: #34b26f; /* calmer than neon, still 5:1 on the dark background */
        --green-bg: #1b7d45;
        --green-soft: #14331f;
        --red: #f87171;
        --red-soft: #3a1c1c;
        --amber: #fbbf24;
        --amber-soft: #3a2a0c;
        --blue: #60a5fa;
        --blue-soft: #15243f;
        --teal: #2dd4bf;
        --teal-soft: #0c2925;
        --purple: #a78bfa;
        --purple-soft: #251e3b;
        --indigo: #818cf8;
        --indigo-soft: #1d1f3f;
        --grey-soft: #1f2a44;
        --surface: #16203a;
        --surface-hover: #1d2a48;
        --surface-2: #1a2440;
        --surface-strong: #1f2a44;
        --border-strong: #3a4a6d;
        --pill-muted-bg: #1f2a44;
        --pill-muted-fg: #9aa6c2;
        --text-secondary: #9aa6c2;
        --shadow-rgb: 0, 0, 0;
        --shadow-soft: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .35);
        --shadow-sticky: 0 -2px 14px rgba(0, 0, 0, .55);
    }
}

/* ---------- Base ---------- */
html, body {
    height: 100%;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
*, .num, .tabular, table, input, select, textarea {
    font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 600;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--navy-text); }

/* ---------- App shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.app-sidebar {
    background: var(--navy);
    color: var(--on-dark);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 18px;
    border-bottom: 1px solid var(--on-dark-soft);
}
.app-logo .logo-mark {
    width: 14px;
    height: 14px;
    background: var(--green-bg);
    border-radius: 3px;
    box-shadow: 0 0 0 2px rgba(29, 122, 70, .25);
}
.app-logo .logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.app-logo .logo-text strong {
    font-size: 18px;
    font-weight: 700;
    color: var(--on-dark);
    letter-spacing: -0.01em;
}
.app-logo .logo-text span {
    font-size: 12px;
    color: var(--on-dark-medium);
    font-weight: 300;
}
.app-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.app-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--on-dark-strong);
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.app-nav li a:hover {
    background: var(--on-dark-hover);
    color: var(--on-dark);
}
.app-nav li a i {
    font-size: 18px;
    line-height: 1;
}
.app-nav li a.active {
    background: var(--navy-2);
    color: var(--on-dark);
}
.app-nav li a.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--green-bg);
    border-radius: 0 3px 3px 0;
}
.app-sidebar-footer {
    margin-top: auto;
    font-size: 11px;
    color: var(--on-dark-faint);
    padding: 0 6px;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.app-topbar .page-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.app-topbar .ask-ai-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--green);
    background: var(--surface);
    color: var(--green);
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
}
.app-topbar .ask-ai-pill:hover {
    background: var(--green-soft);
}
.app-topbar .ask-ai-pill i {
    font-size: 16px;
}

/* Theme switcher in the top bar and on the mobile bar: three icon buttons (sun / moon / device) in a
   small pill, sitting next to the language switcher. The active one shows in green, the others are
   the muted colour; the whole pill looks like one control. */
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
}
.theme-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: background-color 120ms ease, color 120ms ease;
}
.theme-btn:hover { color: var(--text); background: var(--bg); }
.theme-btn.is-on { background: var(--green-soft); color: var(--green); }

/* Same control inside the Settings → Language and look card: three big labelled buttons (icon + text). */
.theme-pick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.theme-pick {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.theme-pick i { font-size: 18px; color: var(--muted); }
.theme-pick:hover { border-color: var(--border-strong); }
.theme-pick.is-on { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.theme-pick.is-on i { color: var(--green); }

.app-content {
    padding: 24px 28px 80px;
    flex: 1;
}

/* One centred column for every page (owner, 14 Oct: pages were not centred and not consistent). */
.app-page { max-width: 1120px; margin: 0 auto; }
.home-simple, .team-page, .feedback-page, .review-page, .start-page, .how-page, .check-page, .export-page,
.agree-page, .legal-page, .admin-page, .error-page, .invoice-email-page, .invoice-preview-page { margin-left: auto; margin-right: auto; }

/* ---------- Mobile topbar (when sidebar is hidden) ---------- */
.app-mobilebar {
    display: none;
    background: var(--navy);
    color: var(--on-dark);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
}
.app-mobilebar .app-logo { padding: 0; border-bottom: none; }
.app-mobilebar .ask-ai-pill {
    border-color: rgba(255, 255, 255, .6);
    color: var(--on-dark);
}
.app-mobilebar .ask-ai-pill:hover { background: var(--on-dark-tab-hover); }
.app-mobilebar .ask-ai-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1.5px solid var(--on-dark); border-radius: 999px; font-weight: 600; font-size: 12px; line-height: 1; text-decoration: none; }
.app-mobilebar .ask-ai-pill i { font-size: 14px; }
@media (max-width: 479.98px) {
    .app-mobilebar { padding-left: 10px; padding-right: 10px; }
    /* Narrow phones: keep the business name; Ask AI and Sign out become icons (text kept for screen readers). */
    .app-mobilebar .ask-ai-pill span, .app-mobilebar .sign-out-pill span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .app-mobilebar .ask-ai-pill, .app-mobilebar .sign-out-pill { padding: 6px 8px; min-width: 36px; min-height: 36px; justify-content: center; }
    .app-mobilebar-right { gap: 6px; }
    .app-mobilebar .theme-btn { width: 28px; height: 28px; }
}

/* ---------- Mobile bottom tab bar ---------- */
.app-tabbar {
    display: none;
}

/* ---------- Flash toast ---------- */
.flash-toast {
    background: var(--green-bg);
    color: var(--on-dark);
    border-radius: var(--radius-card);
    padding: 12px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    box-shadow: var(--shadow-soft);
}
.flash-toast i { font-size: 18px; }

/* ---------- Google Sheet update banner ---------- */
.sheet-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    border-radius: var(--radius-card);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-weight: 500;
}
.sheet-banner i { font-size: 18px; }
.sheet-banner span { flex: 1 1 200px; min-width: 0; }
.sheet-banner form { margin: 0; }
.sheet-banner-pending { background: var(--amber-soft); color: var(--amber); }
.sheet-banner-failed { background: var(--red-soft); color: var(--red); border: 1px solid var(--red); }

/* ---------- Error summary ---------- */
.error-summary {
    background: var(--red-soft);
    border: 1px solid rgba(192, 57, 43, .25);
    color: var(--red);
    border-radius: var(--radius-card);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.error-summary .es-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    background: rgba(192, 57, 43, .15);
    color: var(--red);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.error-summary ul {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
}

/* ---------- Card ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
}
.card-body { padding: 20px; }
.card-header-bar {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 18px;
    border-radius: var(--radius-btn);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.btn.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn.btn-icon { width: 36px; padding: 0; }
.btn i { font-size: 16px; }
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.btn-primary {
    background: var(--green-bg);
    color: var(--on-dark);
    border-color: var(--green);
}
.btn-primary:hover { background: #166536; color: var(--on-dark); border-color: #166536; }

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
}
.btn-outline:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: rgba(var(--shadow-rgb), .06); }

.btn-danger-text {
    background: transparent;
    color: var(--red);
    border-color: transparent;
}
.btn-danger-text:hover { background: var(--red-soft); }

.btn-link {
    background: transparent;
    color: var(--link);
    border: none;
    height: auto;
    padding: 6px 8px;
}
.btn-link:hover { color: var(--navy-text); background: transparent; }

/* Page-level header row (used inside .app-content for the month page) */
.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-header-row .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Month switcher as a pill */
.month-switch {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px;
    box-shadow: var(--shadow-soft);
}
.month-switch .nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    text-decoration: none;
}
.month-switch .nav-btn:hover { background: var(--bg); }
.month-switch .month-label {
    padding: 0 14px;
    font-weight: 600;
    font-size: 15px;
    min-width: 140px;
    text-align: center;
    color: var(--text);
}

/* ---------- KPI grid ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 124px;
    min-width: 0;
    container-type: inline-size;
}
.kpi-card .kpi-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.kpi-card .kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--green);
    background: var(--green-soft);
}
.kpi-card.kpi-cost .kpi-icon { color: var(--amber); background: var(--amber-soft); }
.kpi-card.kpi-profit .kpi-icon { color: var(--blue); background: var(--blue-soft); }
.kpi-card.kpi-expenses .kpi-icon { color: var(--red); background: var(--red-soft); }
.kpi-card.kpi-net .kpi-icon { color: var(--navy-text); background: var(--navy-soft); }

.kpi-card .kpi-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}
.kpi-card .kpi-value {
    font-size: clamp(16px, 15cqi, 28px); /* shrinks so 8-digit totals fit a phone card */
    overflow-wrap: anywhere;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}
.kpi-card .kpi-value .lkr {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    margin-right: 6px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kpi-card .kpi-value.is-negative { color: var(--red); }
.kpi-card .kpi-delta {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.kpi-card .kpi-delta.up { color: var(--green); }
.kpi-card .kpi-delta.down { color: var(--red); }

/* ---------- Charts row ---------- */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 20px;
    margin-bottom: 24px;
}
.chart-card { min-height: 320px; }
.chart-card .card-body { padding: 20px; }
.chart-card h3 {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
}
.chart-note { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

/* In-bar rows: the name and the amount are written on the bar itself. */
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: block; }
.bar-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; font-size: 15px; }
.bar-name { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; overflow-wrap: anywhere; }
.bar-icon { font-size: 16px; color: var(--muted); align-self: center; }
.bar-tag { font-size: 12px; color: var(--muted); font-weight: 500; }
.bar-amount { flex: none; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-share { flex: none; width: 44px; text-align: right; white-space: nowrap; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill {
    display: block; height: 100%; width: var(--w, 0%); border-radius: 4px;
    background: color-mix(in srgb, var(--green) 55%, var(--surface));
}
.bar-top .bar-fill { background: var(--green-bg); }
.bar-loss .bar-fill { background: var(--red); }
.bar-loss .bar-amount, .bar-loss .bar-tag { color: var(--red); }
@media (max-width: 400px) { .bar-head { gap: 8px; font-size: 14px; } }

/* Profit race */
.race-card .card-body { padding: 18px 16px; }
.race-title { margin: 0 0 22px; display: flex; align-items: center; gap: 8px; }
.race-title .ti { color: var(--green); font-size: 18px; }
.race-road { position: relative; margin: 34px 12px 44px 12px; }
.race-track { position: relative; height: 14px; border-radius: 7px; background: var(--line); overflow: visible; }
.race-trail { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); border-radius: 7px; background: var(--green-bg); }
.race-car { position: absolute; top: -4px; left: var(--w, 0%); margin-left: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--green-bg); border: 3px solid var(--surface); box-shadow: 0 1px 4px rgba(15, 23, 42, .25); }
.race-flag { position: absolute; top: -24px; right: -6px; font-size: 18px; line-height: 1; color: var(--text); }
.race-pace { position: absolute; top: -6px; bottom: -6px; left: var(--w, 0%); border-left: 2px dashed var(--muted); }
.race-label { position: absolute; font-size: 13px; line-height: 1.25; color: var(--text); font-weight: 600; }
.race-label-flag { top: 22px; right: 0; text-align: right; }
.race-label-pace { top: 48px; left: var(--w, 0%); transform: translateX(-50%); text-align: center; width: 150px; margin-left: 0; }
.race-label-pace.is-right { transform: none; left: auto; right: -12px; text-align: right; width: auto; }
.race-label-pace.is-left { transform: none; left: 0; text-align: left; width: auto; }
.race-label-trophy { top: 80px; right: -12px; text-align: right; color: var(--amber); }
.race-road.has-record { margin-bottom: 110px; }
.race-sofar { margin: 0 0 10px; font-size: 15px; color: var(--muted); }
.race-sofar strong { color: var(--text); }
.race-pace-note { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.race-pace-note::before { content: ""; display: inline-block; width: 0; height: 12px; border-left: 2px dashed currentColor; margin-right: 8px; vertical-align: -1px; }
.race-big { margin: 0 0 14px; font-size: 15px; line-height: 1.5; font-weight: 400; color: var(--text); }
.race-big .ti { color: var(--green); margin-right: 4px; font-size: 18px; vertical-align: -3px; }
.race-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.race-badge { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--pill-muted-bg); color: var(--pill-muted-fg); display: inline-flex; align-items: center; gap: 4px; }
.race-badge.is-earned { background: var(--green-soft); color: var(--green); }
.race-fact { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.race-confetti { position: absolute; left: 0; right: 0; top: 0; height: 0; pointer-events: none; overflow: visible; }
.race-confetti i {
    position: absolute; top: 0; left: var(--x, 50%); width: 8px; height: 12px; border-radius: 2px;
    background: var(--c, #f5a623); opacity: 0; animation: confettiFall 2.2s ease-out var(--d, 0s) 1 both;
}
@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(150px) rotate(360deg); }
}
.race-card { position: relative; }
@media (prefers-reduced-motion: reduce) {
    .race-confetti { display: none; }
}

.chart-empty {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 40px 0;
}

/* ---------- Section tables ---------- */
.section-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    margin-bottom: 20px;
    overflow: hidden;
}
.section-card .section-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}
.section-card .section-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.section-card .count-badge {
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-2);
}
.data-table .num, .data-table td.text-end { text-align: right; }
.data-table td .cust-name { font-weight: 600; color: var(--text); }
.data-table td .cust-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Service / category pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: var(--grey-soft);
    color: var(--text);
}
.pill .pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.pill-pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-pill-green { background: var(--green-soft); color: var(--green); }
.pill-pill-teal { background: var(--teal-soft); color: var(--teal); }
.pill-pill-purple { background: var(--purple-soft); color: var(--purple); }
.pill-pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-pill-indigo { background: var(--indigo-soft); color: var(--indigo); }
.pill-pill-grey { background: var(--grey-soft); color: var(--muted); }
.pill-pill-red { background: var(--red-soft); color: var(--red); }
.pill-pill-navy { background: var(--navy-soft); color: var(--navy-text); }

.value-positive { color: var(--green); font-weight: 600; }
.value-negative { color: var(--red); font-weight: 600; }

/* Status pill (Paid/Pending) */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-paid { background: var(--green-soft); color: var(--green); }
.status-pending { background: var(--amber-soft); color: var(--amber); }

/* Empty state */
.empty-state {
    padding: 36px 20px;
    text-align: center;
    color: var(--muted);
}
.empty-state .empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.empty-state p { margin: 0 0 16px; font-size: 14px; }

/* ---------- Forms ---------- */
.form-shell {
    max-width: 720px;
    margin: 0 auto;
}
.form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.form-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}
.form-header .form-actions-top a {
    color: var(--muted);
    font-weight: 500;
    font-size: 13px;
}

.step-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    margin-bottom: 18px;
    overflow: hidden;
}
.step-card .step-head {
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
}
.step-card .step-num {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--navy);
    color: var(--on-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}
.step-card .step-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.step-card .step-body {
    padding: 22px;
}

/* Tile picker */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 12px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
    min-height: 96px;
}
.tile i { font-size: 26px; color: var(--muted); }
.tile .tile-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    line-height: 1.2;
}
.tile .tile-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--green-bg);
    color: var(--on-dark);
    font-size: 12px;
    display: none;
    align-items: center;
    justify-content: center;
}
.tile input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.tile:has(input:checked) {
    border-color: var(--green);
    background: var(--green-soft);
    box-shadow: 0 0 0 3px rgba(29, 122, 70, .08);
}
.tile:has(input:checked) i { color: var(--green); }
.tile:has(input:checked) .tile-check { display: inline-flex; }
/* The tick inside the dot stays white (the rule above colours every icon in a picked tile green). */
.tile:has(input:checked) .tile-check i { color: var(--on-dark); font-size: 14px; }
.tile:hover { border-color: var(--green); }

/* Form inputs */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.form-field label .req-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green-bg);
}
.form-field input,
.form-field select,
.form-field textarea {
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), box-shadow var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.form-field textarea { height: auto; padding: 10px 14px; min-height: 80px; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--green);
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 122, 70, .12);
}
.form-field.is-invalid input,
.form-field.is-invalid select,
.form-field.is-invalid textarea {
    border-color: var(--red);
}
.form-field .err {
    color: var(--red);
    font-size: 12px;
    font-weight: 500;
}

/* Segmented control */
.segment {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface);
}
.segment input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; min-height: 0; padding: 0; }
.segment .seg-opt {
    /* When a form stretches the control to full width, the choices share it (no empty space at the end). */
    flex: 1 1 auto;
    padding: 0 18px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border: none;
    background: transparent;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.segment .seg-opt:hover { color: var(--text); }
.segment input:checked + .seg-opt {
    background: var(--green-bg);
    color: var(--on-dark);
}

/* Sticky action bar */
.sticky-bar {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: var(--shadow-sticky);
    padding: 12px 22px;
    margin: 18px -22px -22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    z-index: 10;
}
.sticky-bar .left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.sticky-bar .left .preview-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.sticky-bar .left #profitPreview,
.sticky-bar .left #amountPreview {
    font-size: 22px;
    font-weight: 700;
    color: var(--green);
    min-width: 90px;
    text-align: left;
}
.sticky-bar .left #profitPreview.is-negative,
.sticky-bar .left #amountPreview.is-negative { color: var(--red); }
.sticky-bar .right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Error page ---------- */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}
.error-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    padding: 48px 40px;
    max-width: 480px;
    text-align: center;
}
.error-card .error-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--red-soft);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 18px;
}
.error-card h1 {
    font-size: 22px;
    margin: 0 0 8px;
}
.error-card p {
    color: var(--muted);
    margin: 0 0 24px;
}

input, select, textarea {
    box-sizing: border-box;
    max-width: 100%;
}

/* Base look for any text box or drop-down that has no style of its own (same as .form-field).
   :where() keeps this at zero priority, so every styled field keeps its own look. */
:where(input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="date"],
       input[type="month"], input[type="search"], input[type="password"], input:not([type]), select, textarea) {
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}
:where(textarea) { padding: 10px 14px; min-height: 80px; }
:where(input, select, textarea):focus {
    border-color: var(--green);
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 122, 70, .12);
}

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi-card.kpi-net { grid-column: 1 / -1; }
    .chart-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 899.98px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { display: none; }
    .app-mobilebar { display: flex; }
    .app-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--line);
        box-shadow: 0 -2px 14px rgba(16, 24, 40, .06);
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0));
        z-index: 50;
    }
    .app-tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        font-size: 11px;
        color: var(--muted);
        text-decoration: none;
        padding: 6px 0;
        min-height: 44px;
    }
    .app-tabbar a i { font-size: 22px; }
    .sticky-bar { bottom: calc(61px + env(safe-area-inset-bottom, 0px)); }
    .app-tabbar a.active { color: var(--green); }
    .app-content { padding-bottom: 110px; }
    .app-topbar { padding: 12px 16px; }
    .app-content { padding: 18px 16px 110px; }
    .sticky-bar { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
    .app-topbar .ask-ai-pill, .app-topbar .theme-switch { display: none; }
}
@media (max-width: 767.98px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-card.kpi-net { grid-column: 1 / -1; }
    .chart-row { grid-template-columns: 1fr; }
    .form-row, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
    .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .step-card .step-body { padding: 18px; }
    .sticky-bar { flex-wrap: wrap; }
    .data-table th, .data-table td { padding: 10px 12px; }
    /* Hide the top-bar title only when the page shows its own big heading, so every page keeps one title. */
    .app-shell:has(.app-content h1, .app-content > .app-page > h2:first-child, .app-content > .app-page > h2:first-of-type) .app-topbar .page-title { display: none; }
    .app-shell:has(.app-content h1, .app-content > .app-page > h2:first-child, .app-content > .app-page > h2:first-of-type) .app-topbar { justify-content: flex-end; }
}
@media (max-width: 375px) {
    .app-content { padding: 14px 12px 110px; }
    .sticky-bar { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
    .app-topbar { padding: 12px; }
    .app-topbar .ask-ai-pill { padding: 6px 12px; font-size: 12px; }
}

/* ---------- Sidebar footer (signed-in user + Sign out) ---------- */
.app-sidebar-footer {
    margin-top: auto;
    padding: 16px 6px 0;
    border-top: 1px solid var(--on-dark-soft);
    font-size: 12px;
    color: var(--on-dark-medium);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.app-sidebar-footer .who {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.app-sidebar-footer .who strong {
    color: var(--on-dark);
    font-weight: 600;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.app-sidebar-footer .who span {
    color: var(--on-dark-faint);
    font-size: 11px;
}
.app-sidebar-footer .sign-out-form {
    margin: 0;
}
.app-sidebar-footer .sign-out-form .btn {
    width: 100%;
    background: var(--on-dark-soft);
    border-color: transparent;
    color: var(--on-dark-strong);
}
.app-sidebar-footer .sign-out-form .btn:hover {
    background: var(--on-dark-line);
    color: var(--on-dark);
}

/* ---------- Mobile topbar Sign-out pill ---------- */
.app-mobilebar .sign-out-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--on-dark-soft);
    color: var(--on-dark);
    font-weight: 600;
    font-size: 12px;
    border: none;
}
.app-mobilebar .sign-out-pill i { font-size: 14px; }

/* ---------- Login + not-invited page ---------- */
body.login-page {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--surface);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    padding: 36px 32px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--navy-text);
    margin-bottom: 6px;
}
.login-logo .logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}
.login-logo .logo-text strong {
    font-size: 20px;
    color: var(--navy-text);
}
.login-logo .logo-text span {
    font-size: 12px;
    color: var(--muted);
}
.login-title {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}
.login-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}
.login-email {
    background: var(--grey-soft);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 13px;
    color: var(--navy-text);
}
.google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    color: #1f1f1f;
    border: 1px solid #dadce0;
    border-radius: 8px;
    padding: 10px 18px;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    width: 100%;
    max-width: 320px;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), box-shadow var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
    margin-top: 8px;
}
.google-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(60, 64, 67, .15);
    text-decoration: none;
    color: #1f1f1f;
}
.google-btn .google-g { flex: 0 0 20px; }
.login-foot {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}
.login-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}
.login-hint a { color: var(--link); }

/* ---------- Setup page (/setup/migrate) ---------- */
.setup-form { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.setup-label { font-weight: 600; font-size: 14px; color: var(--text); }
.setup-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #cfd5e0;
    border-radius: 8px;
    font-size: 16px;
}
.setup-input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.setup-btn { width: 100%; height: 52px; font-size: 16px; margin-top: 6px; }
.setup-msg { margin: 0; font-size: 14px; line-height: 1.5; }
.setup-msg.is-error { color: var(--red); }
.setup-msg.is-ok { color: var(--green); font-weight: 600; font-size: 16px; }
.setup-key {
    width: 100%;
    margin-top: 8px;
    padding: 14px;
    border-radius: 8px;
    background: var(--grey-soft);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.setup-key-value {
    display: block;
    padding: 10px;
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    word-break: break-all;
    user-select: all;
}

/* ---------- Team page ---------- */
.team-page {
    display: grid;
    gap: 18px;
    max-width: 920px;
}
.team-card .card-header {
    padding: 18px 22px 6px;
    border-bottom: none;
}
.team-card .card-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.team-card .card-header .card-sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}
.team-card .card-body {
    padding: 14px 22px 22px;
}
.team-drive-body {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
}
.drive-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    flex: 1 1 280px;
}
.drive-status i {
    font-size: 22px;
}
.drive-status--ok {
    background: var(--green-soft);
    color: var(--green);
}
.drive-status--ok i { color: var(--green); }
.drive-status--off {
    background: var(--grey-soft);
    color: var(--muted);
}
.drive-status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.drive-status-text strong {
    font-weight: 600;
    font-size: 14px;
    color: inherit;
}
.drive-status-text code {
    font-size: 13px;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 320px;
}
.muted-note {
    flex-basis: 100%;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}
.data-table-row-inactive td { opacity: .55; }
.data-table-code {
    background: var(--grey-soft);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.data-table-action { text-align: right; width: 110px; }
.inline-form { display: inline-block; margin: 0; }
.team-section-title {
    margin: 22px 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.invite-form {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 12px;
    align-items: end;
    background: var(--grey-soft);
    padding: 14px;
    border-radius: 10px;
}
.invite-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}
.invite-form .form-row span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}
.invite-form input,
.invite-form select {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}
.invite-form input:focus,
.invite-form select:focus {
    outline: 2px solid var(--green-soft);
    border-color: var(--green);
}
.invite-actions { display: flex; align-items: end; }
@media (max-width: 720px) {
    .invite-form { grid-template-columns: 1fr; }
}

/* Team page: people as stacked cards (fits a phone), role help, permission ticks. */
.member-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.member-row {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    min-width: 0;
}
.member-row--inactive { opacity: .55; }
.member-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.member-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.member-who strong { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.member-email, .member-seen { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.member-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.member-perms { margin-top: 10px; }
.member-perms summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--link);
    padding: 6px 0;
}
.member-perms-base { margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.perm-tick {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 15px;
    cursor: pointer;
}
.perm-tick input { width: 20px; height: 20px; flex: 0 0 auto; }
.member-perms .btn { margin-top: 6px; min-width: 96px; }
.member-remove { margin-top: 8px; text-align: right; }
.role-help {
    grid-column: 1 / -1;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--muted);
}
.role-help li + li { margin-top: 4px; }

/* ---- Workbooks (Sheets) ---- */

/* Sheets pages can run wider than .team-page's default 920px (10-card gallery, list grid). */
.team-page.is-workbooks { max-width: 1080px; }

/* Numbered chip used inside wizard card titles */
.step-pill {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--navy);
    color: var(--on-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    margin-right: 4px;
}

/* ---- Step 1 inputs: label stacked above, 44px tall, rounded 10 ---- */
.wizard-input {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 480px;
    min-width: 0;
}
.wizard-input > span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.wizard-input > input {
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    transition: border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), box-shadow var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.wizard-input > input:focus {
    border-color: var(--green);
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 122, 70, .12);
}

/* ---- Step 2: responsive grid of tick cards ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.gallery-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
    min-height: 112px;
    overflow-wrap: anywhere;
}
.gallery-card .gallery-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--grey-soft);
    color: var(--navy-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.gallery-card strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
}
.gallery-card .gallery-desc {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gallery-card .gallery-err { margin-top: 2px; }
.gallery-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    margin: 0;
}
.gallery-card:has(input:checked) {
    border-color: var(--green);
    background: var(--green-soft);
    box-shadow: 0 0 0 3px rgba(29, 122, 70, .08);
}
.gallery-card:has(input:checked) .gallery-icon {
    background: var(--green-bg);
    color: var(--on-dark);
}
.gallery-card:has(input:focus-visible) {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}
.gallery-card .gallery-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--green-bg);
    color: var(--on-dark);
    font-size: 13px;
    display: none;
    align-items: center;
    justify-content: center;
}
.gallery-card:has(input:checked) .gallery-check { display: inline-flex; }

/* ---- Step 3: column rows (replaces the data-table) ---- */
.wizard-col-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}
.wizard-col-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.wizard-col-row:last-child { border-bottom: none; }
.wizard-col-row .wizard-col-tick {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--green);
}
.wizard-col-row .wizard-col-header {
    flex: 1 1 200px;
    max-width: 260px;
    min-width: 0;
}
.wizard-col-row .wizard-col-header input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
.wizard-col-row .wizard-col-header input:focus {
    outline: 2px solid var(--green-soft);
    border-color: var(--green);
}
.wizard-col-row .wizard-col-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
    min-width: 0;
}
.wizard-col-row .wizard-col-meta .pill { font-size: 10px; }
.wizard-col-row.is-required .wizard-col-tick { display: none; }
.wizard-col-row .wizard-col-required {
    display: none;
    align-items: center;
    flex: 0 0 auto;
}
.wizard-col-row.is-required .wizard-col-required { display: inline-flex; }

/* Split-by-month toggle switch */
.wizard-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.wizard-toggle input[type="checkbox"] {
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: var(--line);
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
    cursor: pointer;
    flex: 0 0 auto;
    margin: 0;
    border: none;
    outline: none;
}
.wizard-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    transition: transform var(--m-base, 180ms) cubic-bezier(.2, .8, .2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.wizard-toggle input[type="checkbox"]:checked { background: var(--green-bg); }
.wizard-toggle input[type="checkbox"]:checked::before { transform: translateX(16px); }
.wizard-toggle input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

/* ---- "Add a column" rows ---- */
.wizard-extra-stack {
    display: grid;
    gap: 8px;
}
.wizard-extra-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 2fr auto;
    gap: 8px;
    align-items: center;
}
.wizard-extra-row.is-hidden { display: none; }
.wizard-extra-row input,
.wizard-extra-row select {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
.wizard-extra-row input:focus,
.wizard-extra-row select:focus {
    outline: 2px solid var(--green-soft);
    border-color: var(--green);
}
.wizard-extra-row .wizard-extra-required {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}
.wizard-extra-add {
    background: transparent;
    border: 1px dashed var(--line);
    border-radius: 10px;
    padding: 8px 14px;
    color: var(--green);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-family: inherit;
    font-size: 13px;
}
.wizard-extra-add:hover {
    background: var(--green-soft);
    border-color: var(--green);
}
.wizard-extra-add:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ---- Step 4 buttons ---- */
.wizard-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ---- Preview card ---- */
.preview-tab-title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.preview-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 10px;
}
.preview-chip-row .pill {
    overflow-wrap: anywhere;
    max-width: 100%;
}
.preview-example {
    width: 100%;
    max-width: 360px;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 4px;
}
.preview-example td {
    padding: 4px 10px;
    border-bottom: 1px solid var(--line);
}
.preview-example td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.preview-example tr:last-child td { border-bottom: none; }

/* Errors card with a red left border and a soft red fill */
.wizard-errors {
    border-left: 4px solid var(--red);
    background: var(--red-soft);
    color: var(--red);
    border-radius: 0 10px 10px 0;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.wizard-errors strong { display: block; margin-bottom: 4px; }
.wizard-errors ul { margin: 6px 0 0; padding-left: 20px; }

/* ---- Workbook list (Sheets index) ---- */
.workbook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.workbook-grid .card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.workbook-grid .wb-name {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}
.workbook-grid .wb-meta {
    color: var(--muted);
    font-size: 12px;
    margin: 0;
    overflow-wrap: anywhere;
}
.workbook-grid .wb-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 4px;
}
.workbook-grid .wb-partner { align-self: flex-start; }

/* ---- Workbook show (detail): responsive pages table ---- */
.pages-table-wrap { overflow-x: auto; }
.pages-table-wrap .data-table { min-width: 520px; }
@media (max-width: 719.98px) {
    .pages-table-wrap { overflow: visible; }
    .pages-table-wrap .data-table,
    .pages-table-wrap .data-table thead,
    .pages-table-wrap .data-table tbody,
    .pages-table-wrap .data-table tr,
    .pages-table-wrap .data-table td,
    .pages-table-wrap .data-table th {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .pages-table-wrap .data-table thead { display: none; }
    .pages-table-wrap .data-table tr {
        border-bottom: 1px solid var(--line);
        padding: 10px 0;
    }
    .pages-table-wrap .data-table tr:last-child { border-bottom: none; }
    .pages-table-wrap .data-table td {
        padding: 4px 12px;
        border: none;
    }
    .pages-table-wrap .data-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 600;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 2px;
    }
}

/* ---- Phone width: prevent horizontal page scroll ---- */
@media (max-width: 375px) {
    .team-page.is-workbooks { max-width: 100%; }
    .gallery-grid { grid-template-columns: 1fr; }
    .workbook-grid { grid-template-columns: 1fr; }
    .wizard-extra-row { grid-template-columns: 1fr; }
    .preview-chip-row { gap: 4px; }
}@media (max-width: 719.98px) {
    .pages-table-wrap .data-table { min-width: 0; width: 100%; }
}

/* ---- Settings: service details ---- */

/* Segmented tab control at the top of /settings/lists and /settings/details */
.settings-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--grey-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    align-self: start;
}
.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: none;
    text-decoration: none;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.settings-tab i { font-size: 16px; line-height: 1; }
.settings-tab:hover {
    color: var(--text);
    text-decoration: none;
}
.settings-tab.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(11, 37, 69, .08), 0 0 0 1px rgba(11, 37, 69, .04);
}

/* Wider team-page so detail cards breathe a little on desktop. */
.team-page.is-settings { max-width: 980px; }

/* Set card header: title block on the left, icon group on the right. */
.set-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.set-card-title-block {
    min-width: 0;
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.set-card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    line-height: 1.25;
}
.set-card-title .pill { font-size: 11px; }
.set-card-meta {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.set-used-by {
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
    overflow-wrap: anywhere;
    min-width: 0;
    max-width: 100%;
}

/* Icon-only button group (up / down / rename / hide / required). */
.set-icon-actions,
.field-icon-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    line-height: 1;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.icon-btn i { font-size: 16px; line-height: 1; }
.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-hover);
    text-decoration: none;
}
.icon-btn:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}
.icon-btn[disabled] {
    opacity: .35;
    cursor: not-allowed;
    background: var(--surface);
    color: var(--muted);
}
.icon-btn[disabled]:hover {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--line);
}

/* Rename inline (no JS, <details><summary>) */
.list-settings-rename { position: relative; display: inline-block; }
.list-settings-rename > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.list-settings-rename > summary::-webkit-details-marker { display: none; }
.list-settings-rename > summary.icon-btn { width: 32px; padding: 0; }
.list-settings-rename .list-settings-inline {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 8px 20px rgba(11, 37, 69, .08);
    min-width: 220px;
}
.list-settings-rename .list-settings-inline input[type="text"] {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.list-settings-rename .list-settings-inline input[type="text"]:focus {
    outline: 2px solid var(--green-soft);
    border-color: var(--green);
}

/* Field list (clean, no bullets, stacked card rows) */
.field-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    flex-wrap: wrap;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.field-row.is-hidden { opacity: .55; }
.field-row-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1 1 220px;
}
.field-row-label .field-name {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    overflow-wrap: anywhere;
}
.field-row-label .field-options-note {
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* "Required" / "Optional" toggle-looking button on each field row. */
.field-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1), border-color var(--m-fast, 120ms) cubic-bezier(.2, .8, .2, 1);
}
.field-toggle i { font-size: 14px; line-height: 1; }
.field-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.field-toggle.is-required {
    background: var(--green-soft);
    color: var(--green);
    border-color: var(--green);
}
.field-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* "Add a field" form: tidy single row on desktop, stacks on phones */
.add-field-form {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr auto auto;
    gap: 8px;
    align-items: center;
    background: var(--grey-soft);
    padding: 12px;
    border-radius: 10px;
    margin-top: 12px;
}
.add-field-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    min-width: 0;
}
.add-field-form .form-row.span-required {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}
.add-field-form .form-row > span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}
.add-field-form .form-row input[type="text"],
.add-field-form .form-row select {
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.add-field-form .form-row input[type="text"]:focus,
.add-field-form .form-row select:focus {
    outline: 2px solid var(--green-soft);
    border-color: var(--green);
}
.add-field-form .form-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    height: 40px;
}
.add-field-form .form-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--green);
    margin: 0;
}
.add-field-form .add-field-submit {
    height: 40px;
    padding: 0 14px;
}

/* "New detail set" card: dashed border, plus icon */
.new-set-card {
    border: 1.5px dashed var(--line);
    background: transparent;
    box-shadow: none;
}
.new-set-card .card-header h2 {
    color: var(--green);
    display: flex;
    align-items: center;
    gap: 8px;
}
.new-set-card .card-header h2 i {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--green-soft);
    color: var(--green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.new-set-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.new-set-form input[type="text"] {
    flex: 1 1 240px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.new-set-form input[type="text"]:focus {
    outline: 2px solid var(--green-soft);
    border-color: var(--green);
}
.new-set-form .btn { height: 40px; padding: 0 16px; }

/* Phone width: prevent horizontal page scroll */
@media (max-width: 375px) {
    .set-card-head { flex-direction: column; align-items: stretch; }
    .set-icon-actions,
    .field-icon-actions { width: 100%; }
    .set-icon-actions .icon-btn,
    .field-icon-actions .icon-btn { flex: 1 1 0; min-width: 0; }
    .field-row-label { flex: 1 1 100%; }
    .field-row-label .field-options-note { max-width: 100%; }
    .add-field-form { grid-template-columns: 1fr; }
    .add-field-form .add-field-submit { width: 100%; }
    .new-set-form { flex-direction: column; align-items: stretch; }
    .new-set-form .btn { width: 100%; }
    .list-settings-rename .list-settings-inline {
        right: auto;
        left: 0;
        min-width: 0;
        width: max-content;
        max-width: calc(100vw - 32px);
    }
}

/* ---------- Change this sheet (workbook_design / workbook_design_preview) ---------- */
.design-page .btn.btn-sm { height: 40px; padding: 0 14px; font-size: 13px; }
.design-intro { margin: 0 0 14px; }
.design-cols { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.design-col {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--card);
    min-width: 0;
}
.design-col.is-hidden { background: var(--grey-soft); color: var(--muted); }
.design-col.is-hidden .design-col-name { color: var(--muted); }
.design-col-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.design-col-name { font-size: 15px; overflow-wrap: anywhere; min-width: 0; }
.design-col-meaning { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.design-col-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: flex-start; }
.design-col-actions > form { margin: 0; }
.design-action { min-width: 0; max-width: 100%; }
.design-action > summary { list-style: none; cursor: pointer; }
.design-action > summary::-webkit-details-marker { display: none; }
.design-action[open] { flex: 1 1 100%; }
.design-action[open] > summary { margin-bottom: 10px; }
.design-tab-action { margin: 4px 0; }
.design-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    max-width: 520px;
    min-width: 0;
}
.design-form .btn { align-self: flex-start; }
.design-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.design-field[hidden] { display: none; }
.design-field > span, .design-choices > legend { font-size: 13px; font-weight: 600; color: var(--text); }
.design-field select,
.design-field textarea,
.design-field input {
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.design-field textarea { min-height: 110px; resize: vertical; }
.design-multiply { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.design-choices { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.design-choice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    font-size: 14px;
}
.design-choice input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; }
.design-choice small { color: var(--muted); }
.design-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.design-check input { width: 18px; height: 18px; }
.design-summary { margin: 0 0 14px; padding-left: 20px; font-size: 15px; line-height: 1.5; }
.design-summary li { overflow-wrap: anywhere; }
.design-example th { font-size: 12px; color: var(--muted); text-align: right; padding: 4px 10px; }
.design-example td:nth-child(2) { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.design-example tr.is-changed td { font-weight: 600; }
.design-confirm { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.design-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.design-history li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
}
.design-history li:last-child { border-bottom: none; }
.design-history-when { font-size: 12px; color: var(--muted); }
@media (max-width: 480px) {
    .design-multiply { grid-template-columns: 1fr; }
    .design-form { padding: 12px; }
    .design-confirm .btn, .design-form .btn { width: 100%; align-self: stretch; }
}

/* ---------- Simple home (people who may not see profit) ---------- */
.home-simple { max-width: 720px; }
.home-greeting { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.home-sub { margin: 0 0 20px; color: var(--muted); font-size: 15px; }
.home-back { margin: 0 0 12px; font-size: 15px; }
.home-actions { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 24px; }
.home-action {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 0 20px;
    border-radius: var(--radius-card);
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-soft);
}
.home-action:hover { text-decoration: none; color: var(--text); border-color: var(--border-strong); }
.home-action:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.home-action i { font-size: 28px; }
.home-action-job { background: var(--green-bg); border-color: var(--green); color: var(--on-dark); }
.home-action-job:hover { background: #166536; border-color: #166536; color: var(--on-dark); }
.home-action-expense i { color: var(--blue); }
.home-action-owed i { color: var(--amber); }
.home-action-count {
    margin-left: auto;
    min-width: 32px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 15px;
    text-align: center;
}
.home-list-title {
    margin: 0;
    padding: 14px 20px 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.home-list { list-style: none; margin: 0; padding: 0; }
.home-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
}
.home-row-main { min-width: 0; }
.home-row-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.home-row-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.home-row-phone { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 15px; font-weight: 600; }
.home-row-amount { flex-shrink: 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
.home-more { font-size: 15px; }
@media (min-width: 720px) {
    .home-actions { grid-template-columns: repeat(3, 1fr); }
    .home-action { flex-direction: column; justify-content: center; min-height: 120px; padding: 16px; text-align: center; gap: 8px; }
    .home-action-count { margin-left: 0; }
}
@media (max-width: 375px) {
    .home-row { padding: 12px 14px; }
    .home-list-title { padding: 12px 14px 6px; }
}

/* ---------- Partners ---------- */
.partner-note {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: var(--radius-btn);
    background: var(--amber-soft);
    color: var(--text);
    font-size: 14px;
}
.partner-note i { color: var(--amber); font-size: 18px; }
.partner-cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.partner-card {
    display: block;
    padding: 16px 18px;
    border-radius: var(--radius-card);
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow-soft);
}
.partner-card:hover { text-decoration: none; color: var(--text); border-color: var(--border-strong); }
.partner-card:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.partner-card-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 18px;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.partner-card-name i { color: var(--muted); font-size: 20px; }
.partner-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 0; }
.partner-figure dt { font-size: 13px; font-weight: 500; color: var(--muted); }
.partner-figure dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.partner-in { color: var(--green); }
.partner-out { color: var(--red); }
.partner-paid { color: var(--green); }
.partner-unpaid { color: var(--amber); font-weight: 600; }
@media (min-width: 720px) {
    .partner-cards { grid-template-columns: 1fr 1fr; }
}

/* ---------- C2a: phone usability ---------- */
.table-wrap { overflow-x: auto; }
.setup-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; margin-bottom: 16px; text-decoration: none; color: inherit;
    border-left: 4px solid var(--green); min-height: 44px;
}
.setup-banner-sub { display: block; color: var(--muted); }
.form-field-wide { grid-column: 1 / -1; }
.show-stacked { display: none; }

.more-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.more-group-title { margin: 20px 0 10px; padding: 0 4px; font-size: 16px; line-height: 1.3; color: var(--text); }
.more-row {
    display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 12px 16px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
    color: inherit; text-decoration: none;
}
.more-row > i:first-child { font-size: 24px; color: var(--green); flex: none; }
.more-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.more-text strong { font-size: 16px; }
.more-text span { color: var(--muted); font-size: 13px; }
.more-go { color: var(--muted); flex: none; }
.more-signout .btn { width: 100%; justify-content: center; }
.more-language { margin: 18px 0; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); }
.more-language-title { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.more-language-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.more-language-choices .btn { flex: 1 1 40%; justify-content: center; min-height: 44px; }

.tr-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.tr-row { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 12px; margin-bottom: 10px; }
.tr-key { font-size: 12px; color: var(--muted); word-break: break-all; margin: 0 0 4px; }
.tr-en { margin: 0 0 8px; font-weight: 600; }
.tr-row textarea { width: 100%; min-height: 64px; box-sizing: border-box; font: inherit; padding: 8px; }
.tr-ok { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.tr-save { position: sticky; bottom: 70px; padding: 10px 0; }
.tr-save .btn { width: 100%; justify-content: center; }
@media (min-width: 900px) {
    .tr-row { display: grid; grid-template-columns: 1fr 1fr 140px; gap: 12px; align-items: start; }
    .tr-ok { margin-top: 0; }
    .tr-save { bottom: 0; }
}

.customer-cards { display: grid; gap: 12px; }
.customer-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
    padding: 14px 16px; color: inherit;
}
.customer-card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    min-height: 44px; color: inherit; text-decoration: none;
}
.customer-card-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.customer-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 8px 0 0; }
.customer-figure dt { color: var(--muted); font-size: 12px; font-weight: 500; }
.customer-figure dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.customer-out { color: var(--red); }
.customer-phone { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.customer-phone-call, .customer-phone-wa {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: 10px; color: var(--green); text-decoration: none;
}
.customer-phone-big { font-size: 18px; }
.customer-search-row { display: flex; gap: 8px; }
.customer-search-input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; }
.customer-search-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.invoice-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-card); padding: 18px; max-width: 640px; }
.invoice-doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.invoice-doc-title { font-weight: 700; text-transform: uppercase; color: var(--muted); }
.invoice-doc-meta { display: grid; gap: 6px; margin: 0 0 14px; }
.invoice-doc-meta div { display: flex; justify-content: space-between; gap: 12px; }
.invoice-doc-meta dt { color: var(--muted); font-weight: 500; }
.invoice-doc-meta dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.invoice-doc-table { width: 100%; border-collapse: collapse; }
.invoice-doc-table td, .invoice-doc-table th { padding: 8px 0; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.invoice-doc-table .right { text-align: right; white-space: nowrap; padding-left: 12px; }
.invoice-line-name { overflow-wrap: anywhere; }
.invoice-doc-table tr.balance th, .invoice-doc-table tr.balance td { font-weight: 700; }
.invoice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.invoice-actions .btn { min-height: 44px; }
.invoice-message pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.invoice-email-form .form-field input, .invoice-email-form .form-field textarea { width: 100%; }

@media (max-width: 767.98px) {
    .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
    .stack-table thead { display: none; }
    .stack-table tr {
        border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--card);
        padding: 8px 14px; margin-bottom: 12px;
    }
    .stack-table td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        padding: 8px 0 !important; border: 0; text-align: right !important; overflow-wrap: anywhere;
    }
    .stack-table td[data-label]::before {
        content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500;
        text-align: left; flex: none;
    }
    .stack-table td.row-action { justify-content: flex-end; }
    .stack-table td.row-action .btn { width: 100%; justify-content: center; min-height: 44px; }
    .show-stacked { display: inline; margin-left: 6px; }
    .segment .seg-opt { min-height: 44px; }
    .sticky-bar .right, .sticky-bar .right .btn { width: 100%; }
    .sticky-bar .right { flex-direction: column; }
    .invoice-actions .btn { width: 100%; justify-content: center; }
    .customer-search-row .btn { flex: none; }
}

/* Feedback */
.feedback-page { max-width: 640px; }
.feedback-kinds { display: grid; gap: 10px; margin-bottom: 16px; }
.feedback-kind { display: flex; align-items: center; gap: 12px; padding: 16px; border: 2px solid var(--line); border-radius: 12px; font-size: 17px; font-weight: 600; cursor: pointer; color: var(--text); }
.feedback-kind input { width: 22px; height: 22px; }
.feedback-kind:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.feedback-page textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 12px; }
.feedback-page .btn-block { display: block; width: 100%; text-align: center; box-sizing: border-box; margin-top: 14px; padding: 14px; font-size: 17px; }
.export-links { margin: 8px 0 14px; font-size: 14px; }
.export-page { max-width: 640px; }
.export-page select { width: 100%; box-sizing: border-box; font: inherit; padding: 12px; }
.export-page .btn-block { display: block; width: 100%; text-align: center; box-sizing: border-box; margin-top: 14px; padding: 14px; font-size: 17px; }
.feedback-error { color: var(--red); font-weight: 600; }
.feedback-tabs { display: flex; gap: 10px; margin-bottom: 14px; }
.feedback-item { margin-bottom: 12px; }
.feedback-meta { margin: 0 0 6px; font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.feedback-message { margin: 8px 0 12px; overflow-wrap: anywhere; }
.feedback-actions { display: flex; gap: 10px; }
.feedback-foot { text-align: center; margin: 24px 0 0; font-size: 12px; }
.feedback-foot a { color: var(--text-secondary); }

/* ---- How numbers work, and the (i) next to a number ---- */
.how-page { max-width: 980px; color: var(--text); }
.how-intro { font-size: 15px; margin: 0 0 14px; color: var(--text); }
.how-jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.how-chip { display: inline-flex; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; }
.how-chip:hover, .how-chip:focus { background: var(--green-soft); border-color: var(--green); color: var(--green); text-decoration: none; }
.how-group { margin: 0 0 18px; }
.how-group-title { margin: 0 0 10px; font-size: 18px; font-weight: 600; color: var(--text); scroll-margin-top: 70px; }
.how-group:target .how-group-title { color: var(--green); }
.how-group-cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 900px) {
    .how-group-cards { grid-template-columns: 1fr 1fr; gap: 12px; }
}
.how-banner { font-size: 14px; margin: 0 0 12px; color: var(--text); }
.how-banner-waiting { color: var(--text); }
.how-last { margin: 0 0 14px; }
.how-last p { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.how-line { margin-bottom: 10px; scroll-margin-top: 70px; color: var(--text); }
.how-line h2 { font-size: 17px; margin: 0 0 6px; color: var(--text); }
.how-line p { margin: 0 0 6px; font-size: 14px; overflow-wrap: anywhere; color: var(--text); }
.how-line .how-says, .how-line .how-feeds, .how-line .how-where { color: var(--text); }
.how-line .how-feeds strong, .how-line .how-where strong { color: var(--text); }
.how-line .how-check { color: var(--text); }
.how-line:target { outline: 2px solid var(--green); }
.how-ic { font-size: 18px; vertical-align: -3px; }
.how-ic-matched { color: var(--green); }
.how-ic-mismatch { color: var(--amber); }
.how-ic-waiting, .how-ic-none { color: var(--muted); }
.why-i { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; margin-left: 4px; font-size: 15px; color: var(--muted); text-decoration: none; vertical-align: middle; }
.why-i:hover, .why-i:focus { color: var(--green); }
.num-wrap { position: relative; display: block; }
.num-wrap > .why-i { position: absolute; top: 4px; right: 4px; }
.num-wrap > .dash-card, .num-wrap > .glance-item { height: 100%; box-sizing: border-box; }
.num-wrap .glance-label { padding-right: 22px; }
.num-wrap > .dash-card + .why-i { top: auto; bottom: 6px; }

/* ---- Check my numbers ---- */
.check-page { max-width: 680px; }
.check-intro { font-size: 15px; margin: 0 0 14px; }
.check-empty { font-size: 15px; }
.check-filter { margin: 0 0 12px; }
.check-month { margin-bottom: 10px; padding: 0; }
.check-month > summary { display: block; padding: 14px 16px; cursor: pointer; list-style: none; }
.check-month > summary::-webkit-details-marker { display: none; }
.check-title { display: block; font-weight: 600; font-size: 15px; }
.check-sum { display: block; margin-top: 2px; font-size: 14px; overflow-wrap: anywhere; }
.check-month.check-match { border-left: 5px solid var(--green); }
.check-month.check-explained { border-left: 5px solid var(--muted); }
.check-month.check-differs { border-left: 5px solid var(--amber); }
.check-body { padding: 0 16px 14px; }
.check-lines { margin: 0 0 8px; padding-left: 18px; }
.check-lines li { margin-bottom: 6px; overflow-wrap: anywhere; }
.check-tabs, .check-hint, .check-where { font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.check-summary-card { margin: 0 0 14px; }
.check-summary-card p { margin: 0 0 4px; font-size: 14px; }
.check-ic { font-size: 18px; vertical-align: -3px; }
.check-ic-match { color: var(--green); }
.check-ic-differs { color: var(--amber); }
.check-ic-explained { color: var(--muted); }
.check-extra { font-size: 13px; color: var(--muted); margin: 6px 0; }
.check-other { font-size: 13px; color: var(--amber); }
.check-spot select { width: 100%; box-sizing: border-box; font: inherit; padding: 12px; margin: 4px 0 8px; }
.check-spot .btn-block { display: block; width: 100%; text-align: center; box-sizing: border-box; padding: 14px; font-size: 17px; }
.check-job { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.check-job p { margin: 2px 0; overflow-wrap: anywhere; }
.check-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.check-month.check-review { border-left: 5px solid var(--amber); background: var(--amber-soft); }
.check-review-link { display: block; margin-top: 6px; font-weight: 600; }
.check-left-out { font-size: 13px; color: var(--muted); margin: 6px 0; }
.review-page { max-width: 680px; }
.review-intro { font-size: 15px; margin: 0 0 14px; }
.review-flash { background: var(--green-soft); color: var(--green); padding: 10px 12px; border-radius: 10px; margin: 0 0 12px; }
.review-month { font-size: 18px; margin: 20px 0 8px; }
.review-card { margin-bottom: 12px; }
.review-card p { margin: 0 0 6px; overflow-wrap: anywhere; }
.review-head { font-size: 16px; }
.review-detail { font-size: 15px; }
.review-problem { color: var(--amber); font-size: 14px; }
.review-meta { font-size: 13px; color: var(--muted); }
.review-error { background: var(--red-soft); color: var(--red); padding: 8px 10px; border-radius: 8px; }
.review-form label { display: block; margin: 10px 0 4px; font-size: 14px; }
.review-form input[type=text], .review-form input[type=date] { width: 100%; box-sizing: border-box; font: inherit; padding: 12px; }
.review-form .btn-block, .review-bulk .btn-block { display: block; width: 100%; text-align: center; box-sizing: border-box; padding: 14px; font-size: 16px; margin-top: 8px; }
.review-bulk { margin: 0 0 12px; }
.how-worked { margin: 6px 0 0; font-size: 12px; color: var(--text-secondary); }
.how-worked summary { cursor: pointer; }
.how-worked p { margin: 4px 0 0; overflow-wrap: anywhere; }

/* Terms, Privacy Policy, agreement screen and "Privacy and AI" */
.legal-body { background: var(--bg); margin: 0; }
.legal-page { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; background: var(--surface); min-height: 100vh; box-sizing: border-box; font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.legal-page h1 { font-size: 24px; margin: 12px 0 4px; }
.legal-page h2 { font-size: 18px; margin: 24px 0 6px; }
.legal-meta { font-size: 13px; color: var(--text-secondary); }
.legal-draft { background: var(--amber-soft); border: 2px solid var(--amber); color: var(--amber); padding: 12px 14px; border-radius: 10px; font-weight: 700; margin: 0 0 12px; }
.legal-links { margin-top: 28px; }
.agree-points { padding-left: 20px; margin: 12px 0; }
.agree-points li { margin: 8px 0; }
.agree-check { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 2px solid var(--line); border-radius: 12px; font-size: 16px; font-weight: 600; margin: 12px 0; cursor: pointer; }
.agree-check input { width: 22px; height: 22px; flex: none; }
.agree-notnow { margin-top: 10px; }
.agree-history { list-style: none; padding: 0; margin: 8px 0 0; }
.agree-history li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.agree-history .legal-meta { display: block; }

/* Invoice sending row, private link page and printing */
.invoice-actions [hidden], .invoice-send-note[hidden] { display: none; }
.invoice-actions .btn { min-height: 48px; flex: 1 1 140px; font-size: 15px; }
.invoice-send-note { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); }
.invoice-link-off { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.invoice-link-off .home-sub { flex: 1 1 220px; margin: 0; }
.invoice-public { max-width: 640px; margin: 0 auto; padding: 20px 16px 48px; box-sizing: border-box; overflow-wrap: anywhere; }
.invoice-public h1 { font-size: 22px; margin: 16px 0 8px; }
.invoice-public-sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.invoice-public-actions { margin: 16px 0; }
.invoice-public-actions .btn { width: 100%; min-height: 48px; font-size: 16px; }
.invoice-doc-business { font-weight: 700; font-size: 18px; }
@media print {
    @page { size: A4; margin: 15mm; }
    .app-sidebar, .app-mobilebar, .app-topbar, .app-tabbar, .feedback-foot, .licence-banner,
    .invoice-actions, .invoice-send-note, .invoice-link-off, .invoice-message, .invoice-amount-changed,
    .invoice-preview-page > h2, .invoice-preview-page > .home-sub, .invoice-public-actions { display: none !important; }
    .app-shell { display: block; }
    .app-content { padding: 0; }
    .app-page { max-width: none; }
    body, .legal-body { background: #fff; }
    .invoice-doc { border: 0; padding: 0; max-width: none; }
}

/* ---------- "Show the adding" tape and month statement ---------- */
.kpi-tape { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--blue); text-decoration: none; }
.kpi-tape:hover { text-decoration: underline; }

.tape-page { max-width: 420px; margin: 0 auto; }
.tape-paper {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
    padding: 18px 16px 26px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--text);
}
.tape-paper::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -8px; height: 8px;
    background: linear-gradient(135deg, #fffef9 50%, transparent 50%) 0 0 / 12px 8px,
                linear-gradient(225deg, #fffef9 50%, transparent 50%) 0 0 / 12px 8px;
}
.tape-head { display: flex; justify-content: space-between; gap: 8px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.tape-line { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.tape-date { flex: none; width: 46px; color: var(--muted); }
.tape-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tape-amt { flex: none; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tape-sub { margin: 0 0 4px 54px; font-size: 12px; color: var(--muted); }
.tape-sub a { color: var(--blue); }
.tape-rule { border-top: 2px dashed #6b7280; margin: 10px 0 6px; }
.tape-total { font-weight: 700; font-size: 15px; }
.tape-empty { color: var(--muted); }
.tape-verdict { margin: 14px 0 0; font-family: Inter, system-ui, sans-serif; font-size: 13px; font-weight: 600; }
.tape-ok { color: var(--green); }
.tape-bad { color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; }
.tape-actions { margin-top: 18px; }

.stmt-page { max-width: 794px; margin: 0 auto; }
.stmt-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stmt-range { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 10px 0; }
.stmt-range label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; }
.stmt-sheet { background: #fff; border: 1px solid var(--line); padding: 20px 16px; color: #000; }
.stmt-head { text-align: center; border-bottom: 2px solid #000; margin-bottom: 14px; padding-bottom: 8px; }
.stmt-head h2 { margin: 0; font-size: 20px; }
.stmt-head p { margin: 2px 0; }
.stmt-printed { font-size: 12px; color: var(--muted); }
.stmt-section { margin-bottom: 18px; }
.stmt-section h3 { margin: 0 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.stmt-section h4 { margin: 12px 0 4px; font-size: 13px; }
.stmt-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.stmt-table th, .stmt-table td { border: 1px solid #333; padding: 4px 6px; vertical-align: top; }
.stmt-table th { background: var(--grey-soft); text-align: left; }
.stmt-table tfoot td { font-weight: 700; }
.stmt-date { white-space: nowrap; }
@media (max-width: 480px) {
    .stmt-sheet { padding: 14px 8px; }
    .stmt-table { font-size: 12px; }
    .stmt-table th, .stmt-table td { padding: 4px 3px; }
    .stmt-date { white-space: normal; }
}
.stmt-num { text-align: right; white-space: nowrap; }
.stmt-none { color: var(--muted); font-style: italic; }
.stmt-summary { border: 2px solid #000; padding: 10px; page-break-inside: avoid; }
.stmt-sign { margin-top: 36px; }

/* ---------- Phone and tablet polish ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; } /* stable: pages do not jump sideways when one is short enough to need no scrollbar */
body { overflow-x: hidden; }
.app-content img, .app-content video { max-width: 100%; height: auto; }

/* Install row on the More page (shown by app.js only when the browser can install the app). */
.more-install-box > .more-row { margin-bottom: 18px; }
button.more-row { width: 100%; font: inherit; text-align: left; cursor: pointer; box-sizing: border-box; }
.more-row[hidden] { display: none; }
.more-note-close {
    flex: none; width: 44px; height: 44px; margin: -6px -8px -6px 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 999px; color: var(--muted); font-size: 20px; cursor: pointer;
}

/* "Install Elekwa Ledger" card and its how-to sheet. */
.install-card { padding-right: 8px; }
.install-card > .install-icon { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.install-card .install-go { flex: none; min-height: 44px; padding-left: 16px; padding-right: 16px; }
.install-card .more-note-close { margin: 0; }
.install-done > i:first-child { font-size: 24px; color: var(--green); }
.install-sheet {
    position: fixed; inset: auto 0 0 0; margin: auto auto 0; padding: 0; border: 0;
    width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
    background: var(--card); color: var(--text);
    border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(var(--shadow-rgb), .25);
}
.install-sheet::backdrop { background: rgba(15, 23, 42, .6); }
.install-sheet-body { padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0px)); }
.install-sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.install-sheet-head .install-icon { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.install-sheet-head h2 { flex: 1; margin: 0; font-size: 18px; }
.install-sheet-head .more-note-close { margin: 0; }
.install-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.install-steps[hidden] { display: none; }
.install-steps > li {
    counter-increment: step; display: flex; align-items: center; gap: 12px;
    padding: 12px; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius-card);
}
.install-steps > li::before {
    content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--green); color: var(--on-dark); font-weight: 700; font-size: 14px;
}
.install-step-icon { flex: none; width: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; color: var(--text); }
.install-step-text { flex: 1; min-width: 0; font-size: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.install-copy { min-height: 44px; }
.install-arrow { text-align: center; font-size: 34px; color: var(--green); margin-top: 8px; }
.install-arrow[hidden] { display: none; }
.install-arrow i { display: inline-block; animation: install-bounce 1.2s ease-in-out infinite; }
@keyframes install-bounce { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .install-arrow i { animation: none; } }

/* Notches and rounded corners (installed app, landscape): keep the bars and the page clear of them. */
.app-mobilebar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app-topbar {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app-content {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app-tabbar {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
@media (min-width: 900px) {
    .app-content, .app-topbar {
        padding-left: max(28px, env(safe-area-inset-left, 0px));
        padding-right: max(28px, env(safe-area-inset-right, 0px));
    }
}

/* Phones and tablets with touch: 16px fields (stops the iPhone zooming in) and 44px touch targets. */
@media (max-width: 899.98px), (pointer: coarse) {
    input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]),
    select, textarea {
        font-size: 16px !important;
    }
    .btn, .btn.btn-sm, .btn.btn-icon { min-height: 44px; }
    .btn.btn-sm { height: 44px; }
    .btn.btn-icon { width: 44px; }
    .month-switch .nav-btn { width: 44px; height: 44px; }
    .ask-ai-pill, .app-topbar .ask-ai-pill, .app-mobilebar .sign-out-pill { min-height: 44px; box-sizing: border-box; }
    .segment .seg-opt, .tile { min-height: 44px; }
    .app-nav a, .more-row, .customer-card-head { min-height: 44px; }
    .sticky-bar .btn, .sticky-bar a, .sticky-bar button, .app-tabbar a, .more-row a { min-height: 44px; box-sizing: border-box; }
}

/* Tick boxes inside a form field keep their own size, inline with their label. */
.form-field input[type="checkbox"], .form-field input[type="radio"] {
    width: 22px; height: 22px; padding: 0; flex: none; margin: 0; accent-color: var(--green); vertical-align: middle;
}
.form-field .check-line { display: flex; flex-direction: row; align-items: center; gap: 10px; min-height: 44px; margin-top: 6px; font-weight: 500; cursor: pointer; }

/* Small phones: nothing may be wider than the screen. */
@media (max-width: 480px) {
    .month-switch .month-label { min-width: 0; padding: 0 8px; }
    .header-actions { flex-wrap: wrap; }
    .data-table, .table-wrap { max-width: 100%; }
}

/* Tablet, portrait (the side menu is hidden below 900px): wider cards instead of a stretched phone page. */
@media (min-width: 768px) and (max-width: 899.98px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi-card.kpi-net { grid-column: 1 / -1; }
    .form-row, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
    .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .chart-row { grid-template-columns: 1fr 1fr; }
}

/* Phone held sideways: a slimmer bottom tab bar so the page keeps its height. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 899.98px) {
    .app-tabbar { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
    .app-tabbar a { flex-direction: row; gap: 8px; padding: 0; }
    .app-tabbar a i { font-size: 20px; }
    .sticky-bar { bottom: calc(53px + env(safe-area-inset-bottom, 0px)); }
    .app-mobilebar { padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-bottom: 6px; }
}

@media print {
    .app-sidebar, .app-mobilebar, .app-topbar, .app-tabbar, .flash-toast, .no-print { display: none !important; }
    .app-shell { display: block; }
    .app-content { padding: 0; }
    .app-page { max-width: none; }
    body { background: #fff; color: #000; }
    .tape-paper { box-shadow: none; border: 1px solid #000; background: #fff; }
    .tape-paper::after { display: none; }
    .tape-ok, .tape-bad { color: #000; background: none; }
    .stmt-sheet { border: 0; padding: 0; }
    .stmt-section { page-break-inside: auto; }
    .stmt-table tr { page-break-inside: avoid; }
    .stmt-table thead { display: table-header-group; }
    @page { size: A4; margin: 14mm; }
}

/* Contacts book */
.contact-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.contact-head .btn { min-height: 44px; }
.contact-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; -webkit-overflow-scrolling: touch; }
.contact-chip {
    flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line);
    border-radius: 999px; color: inherit; text-decoration: none; font-size: 14px; background: var(--card);
}
.contact-chip.active { background: var(--green-bg); border-color: var(--green); color: var(--on-dark); }
.contact-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.contact-row {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; color: inherit; text-decoration: none;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card);
}
.contact-avatar {
    flex: none; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--grey-soft); color: var(--muted); font-weight: 700;
}
.contact-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.contact-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.contact-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.contact-balance { font-size: 13px; color: var(--muted); }
.contact-why { display: block; font-size: 13px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.contact-owes { color: var(--red); font-weight: 600; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.contact-actions .btn { min-height: 44px; }
.contact-notes { margin: 0; padding: 0 16px 14px; overflow-wrap: anywhere; }
.contact-tickrow { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.contact-tick { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.contact-form textarea { width: 100%; }

/* Type-ahead on the job and expense forms */
.ta-wrap { position: relative; }
/* In the page, not floating: the form's cards hide anything that spills over their edge (overflow: hidden), so a
   floating list was cut off on computer screens (13 Oct). The list now pushes the fields below it down. */
.ta-list {
    position: static; margin: 6px 0 0; padding: 4px; list-style: none;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 12px rgba(var(--shadow-rgb), .08);
    max-height: 320px; overflow-y: auto;
}
.ta-item { display: flex; flex-direction: column; gap: 2px; min-height: 48px; padding: 8px 12px; border-radius: 8px; cursor: pointer; justify-content: center; }
.ta-item[aria-selected="true"], .ta-item:hover { background: var(--grey-soft); }
.ta-name { font-weight: 600; }
.ta-sub { font-size: 12px; color: var(--muted); }
.ta-note { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
/* Phone: the matching customers are a big in-page list of tap rows, not a small floating dropdown (each row 56px+). */
/* @media screen max-width: 640px { */
@media (max-width: 640px) {
    .ta-list { position: static; max-height: 60vh; margin-top: 8px; padding: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .ta-item { min-height: 56px; padding: 10px 14px; border-radius: 0; border-bottom: 1px solid var(--line); }
    .ta-item:last-child { border-bottom: 0; }
    .ta-name { font-size: 16px; }
    .ta-sub { font-size: 14px; }
}
.pp-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0; }
.pp-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; cursor: pointer; overflow: hidden; }
.pp-btn input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.pp-btn:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
.pp-cam-dialog { padding: 0; border: none; border-radius: 12px; max-width: 520px; width: calc(100% - 24px); }
.pp-cam-dialog::backdrop { background: rgba(15, 23, 42, 0.6); }
.pp-cam-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.pp-cam-body video { width: 100%; height: auto; background: #000; border-radius: 8px; }
.pp-cam-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.sp-card .sp-list { margin: 6px 0; padding-left: 18px; }
.ta-add { border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.ta-add .ta-name { color: var(--teal); }
.ta-update { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-top: 8px; font-size: 14px; }
.ta-filter { width: 100%; min-height: 40px; margin-bottom: 6px; }

/* Page builder blocks (note, table, button) and the "Customise this page" link */
.block-note { margin: 0 0 12px; }
.block-note h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.block-note-text { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.block-table { margin: 0 0 12px; }
.block-table-list { list-style: none; margin: 0; padding: 0; }
.block-table-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.block-table-list li:last-child { border-bottom: 0; }
.block-table-main { font-weight: 600; font-size: 14px; }
.block-table-sub { display: block; font-size: 12px; color: var(--muted); }
.block-table-amount { font-weight: 600; white-space: nowrap; }
.block-table-more { display: inline-block; margin-top: 8px; font-size: 14px; }
.block-button { margin: 0 0 12px; }
.block-button .btn { width: 100%; min-height: 48px; justify-content: center; }
.customise-link { margin: 0 0 12px; text-align: right; }
.customise-link .btn { min-height: 44px; }

/* ---------- Language buttons (top of every page, sign-in, invoice link, More) ---------- */
.app-topbar-actions { display: flex; align-items: center; gap: 12px; }
.app-mobilebar-right { display: flex; align-items: center; gap: 8px; }
.app-mobilebar-right .sign-out-form { margin: 0; }
.lang-switch-inline { display: inline-flex; align-items: center; gap: 2px; margin: 0; padding: 3px; background: var(--grey-soft); border-radius: 999px; }
.lang-btn {
    min-width: 36px; min-height: 32px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent;
    color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
}
a.lang-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.lang-btn:hover { background: var(--surface); color: var(--text); }
.lang-btn.is-current { background: var(--navy); color: var(--on-dark); }
.lang-btn:focus-visible, .lang-sheet-btn:focus-visible, .lang-menu-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (pointer: coarse) { .lang-btn { min-width: 40px; min-height: 40px; } }
@media (max-width: 899.98px) { .app-topbar .lang-switch-inline { display: none; } }

.lang-switch-menu { position: relative; }
.lang-menu-btn {
    list-style: none; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 6px 10px; border-radius: 999px;
    background: var(--on-dark-soft); color: var(--on-dark); font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
}
.lang-menu-btn::-webkit-details-marker { display: none; }
.lang-menu-btn i { font-size: 16px; }
.lang-menu-sheet {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 180px; margin: 0; padding: 6px;
    display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
}
.lang-sheet-btn {
    min-height: 44px; padding: 10px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--text);
    font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.lang-sheet-btn:hover { background: var(--grey-soft); }
.lang-sheet-btn.is-current { background: var(--green-soft); color: var(--green); font-weight: 600; }

.login-lang { display: flex; justify-content: flex-end; width: 100%; margin: -8px 0 0; }
.invoice-public-lang { display: flex; justify-content: flex-end; margin: 0 0 8px; }

.lang-order { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lang-order-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.lang-order-pick { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 600; min-height: 44px; flex: 1 1 auto; cursor: pointer; }
.lang-order-pick input { width: 20px; height: 20px; }
.lang-order-short { color: var(--muted); font-weight: 500; font-size: 12px; }
.lang-order-move { display: inline-flex; gap: 6px; }
.lang-order-move .btn { min-width: 44px; min-height: 44px; justify-content: center; }
.lang-bar-pick { display: flex; align-items: center; gap: 10px; margin-top: 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.lang-bar-pick input { width: 20px; height: 20px; }
.lang-settings .card + .card, .lang-settings .card + .btn { margin-top: 16px; }
@media print { .lang-switch, .login-lang, .invoice-public-lang { display: none !important; } }

/* Print: the invoice / statement sheets always print light (owner, 14 Oct: the
   dark theme is for the app; a printed bill or statement must look like paper,
   no matter which theme the user picked). Force the light tokens back on. */
@media print {
    :root, :root[data-theme="dark"] {
        --bg: #ffffff;
        --card: #ffffff;
        --line: #e6e9f0;
        --muted: #6b7280;
        --text: #111827;
        --navy: #0b2545;
        --navy-text: #0b2545;
        --link: #13315c;
        --navy-2: #13315c;
        --navy-soft: rgba(11, 37, 69, .08);
        --green: #1d7a46;
        --green-bg: #1d7a46;
        --green-soft: #e8f4ee;
        --red: #c0392b;
        --red-soft: #fbeceb;
        --amber: #b7791f;
        --amber-soft: #fdf3df;
        --blue: #206bc4;
        --blue-soft: #e6f0fb;
        --teal: #0d9488;
        --teal-soft: #e2f6f4;
        --purple: #6d28d9;
        --purple-soft: #f0e8fb;
        --indigo: #4f46e5;
        --indigo-soft: #ebebfb;
        --grey-soft: #f1f3f7;
        --surface: #ffffff;
        --surface-hover: #fafbfd;
        --surface-2: #fcfdfe;
        --surface-strong: #f1f3f6;
        --border-strong: #cfd5e0;
        --pill-muted-bg: #f1f3f6;
        --pill-muted-fg: #8a919e;
        --text-secondary: #5b6472;
        --shadow-rgb: 16, 24, 40;
    }
    .invoice-doc, .stmt-sheet, .tape-paper, .legal-page {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: #e6e9f0 !important;
    }
    .invoice-doc *, .stmt-sheet *, .tape-paper * { color: #000000 !important; }
    .stmt-sheet a, .stmt-sheet a * { color: var(--navy-text) !important; text-decoration: none; }
}

/* ---------- Customise this page / Build with AI buttons, and the "seeing it as" strip ---------- */
.cz-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.cz-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 14px; line-height: 1; text-decoration: none; cursor: pointer; }
.cz-btn:hover { background: var(--grey-soft); }
.cz-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.cz-btn i { font-size: 18px; }
.cz-btn.cz-ai { border-color: var(--green); color: var(--green); }
.cz-btn.cz-ai:hover { background: var(--green-soft); }
.cz-status { font-size: 13px; color: var(--muted); min-height: 18px; }
.cz-status.is-bad { color: var(--red); }
.cz-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; background: var(--indigo-soft); border-bottom: 1px solid var(--line); font-size: 14px; position: sticky; top: 0; z-index: 40; }
.cz-strip-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; }
.cz-strip select { min-height: 40px; border: 1.5px solid var(--line); border-radius: var(--radius-btn); padding: 0 10px; background: var(--surface); font: inherit; }
.cz-strip-note { color: var(--muted); }
@media (max-width: 640px) { .cz-btn { flex: 1 1 auto; } }

/* Settings > Type of business */
.kit-cards{display:grid;gap:12px;grid-template-columns:1fr}
.kit-card .card-body{display:flex;flex-direction:column;gap:8px}
.kit-card h2{margin:0;font-size:1.05rem}
.kit-card.is-open{border-color:var(--green);box-shadow:0 0 0 3px var(--green-soft)}
.kit-pic{width:52px;height:52px;border-radius:14px;display:grid;place-items:center;background:var(--green-soft);color:var(--green);font-size:1.7rem}
.kit-tiles,.kit-changes{list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap;gap:6px}
.kit-tiles li{padding:4px 10px;border:1px solid var(--line);border-radius:999px;font-size:.85rem;background:var(--surface)}
.kit-changes{flex-direction:column}
@media (min-width:700px){.kit-cards{grid-template-columns:1fr 1fr}}

/* Pages that do not load motion.css (sign-in, public invoice): hover colour changes become instant. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* A tick box with its words beside it (quote on the new-job form, "money given back" on a payment). */
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
label.check input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 auto; margin: 0; }
.form-quote { margin: 12px 0; flex-wrap: wrap; }
/* Page access grid (Team > person) */
.access-grid { display: grid; gap: 12px; margin-top: 12px; }
.access-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0; min-width: 0; }
.access-row legend { font-weight: 600; padding: 0 6px; }
.access-hint, .access-default, .access-note { margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.access-fixed { margin: 4px 0 0; font-size: 14px; }
.access-options { display: flex; flex-wrap: wrap; gap: 6px; }
.access-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.access-options label {
    flex: 1 1 30%; min-width: 96px; min-height: 44px; display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px;
}
.access-options input:checked + label { background: var(--navy-2); color: var(--on-dark); border-color: transparent; }
.access-options input:focus-visible + label { outline: 2px solid var(--navy-2); outline-offset: 2px; }
.access-options input:disabled + label { opacity: .45; cursor: not-allowed; }
.member-access-link { display: inline-block; margin-top: 6px; font-size: 14px; font-weight: 600; }

/* Partner deal sheet (3 steps): big kind buttons with a worked example, the live example, the check step. */
.pd-kinds { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pd-kind { display: flex; align-items: flex-start; gap: 12px; padding: 14px; min-height: 48px; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-soft); color: var(--text);
    text-decoration: none; }
.pd-kind:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.pd-kind > .ti:first-child { font-size: 22px; color: var(--navy-text); flex: none; margin-top: 2px; }
.pd-kind-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.pd-kind-example { font-size: 13px; color: var(--text); background: var(--grey-soft); border-radius: 8px; padding: 8px 10px;
    overflow-wrap: anywhere; }
.pd-example { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; padding: 10px 12px; font-size: 14px;
    background: var(--blue-soft); border-radius: 10px; overflow-wrap: anywhere; }
.pd-example .ti { color: var(--blue); flex: none; margin-top: 2px; }
.pd-summary-lead { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.pd-summary { margin: 0 0 14px; font-size: 16px; overflow-wrap: anywhere; }

/* Items on the bill (job form): one line per card, phone first. Stock pick and kind on top, the item, then qty x price = total. */
.line-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; margin: 0 0 8px; border: 1px solid var(--line);
    border-radius: 10px; background: var(--card); align-items: center; }
.line-row > [data-line-stock], .line-row > [data-line-item] { grid-column: 1 / -1; }
.line-row select, .line-row input { min-height: 44px; min-width: 0; width: 100%; }
.line-row .line-total { font-weight: 600; text-align: right; }
.line-row [data-line-remove] { justify-self: end; min-height: 44px; }
@media (min-width: 640px) {
    .line-row { grid-template-columns: 1fr 2fr .8fr 1fr auto auto; }
    .line-row > [data-line-stock] { grid-column: 1 / -1; }
    .line-row > [data-line-item] { grid-column: auto; }
}

/* Phones and touch screens: a file picker is a 44px touch target too (from the phone-layout audit). */
@media (max-width: 899.98px), (pointer: coarse) {
    input[type="file"] { min-height: 44px; padding: 8px 0; box-sizing: border-box; }
}

/* Record payment to a supplier (partner page). */
.pay-row { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.pay-row input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.pay-foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 12px 16px 16px; }
.pay-date { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }

/* Two equal buttons that share the row (no empty space beside them), e.g. "You took out" / "You put in". */
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 520px; }
.btn-pair .btn { justify-content: center; }
/* A 2-column tile grid with an odd number of tiles: the last tile takes the whole row, no half-empty row. */
@media (max-width: 767.98px) {
    .tile-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* Customers page: room to breathe on a phone (owner, 15 Oct). Same in light and dark; colours are tokens only. */
.customer-cards { gap: 12px; }
.customer-card { padding: 16px; }
.customer-figures { gap: 12px 16px; margin-top: 12px; }
.customer-figure { display: flex; flex-direction: column; gap: 4px; }
.customer-figure dt { color: var(--muted); font-size: 12px; line-height: 1.3; }
.customer-figure dd { color: var(--text); }
.customer-figure dd.customer-out { color: var(--red); }
.customer-phone { flex-wrap: nowrap; gap: 8px; margin-top: 16px; }
.customer-phone-call, .customer-phone-wa { flex: 1 1 0; min-width: 0; justify-content: center; min-height: 44px; }
.customer-search { margin: 16px 0; }
.people-chips { flex-wrap: nowrap; gap: 8px; overflow-x: auto; }
.people-chips .contact-chip { flex: none; white-space: nowrap; }

/* "Install the app" banner on the month page: phones only, one card, hidden when empty (16 Oct). */
.install-banner { margin: 0 0 12px; }
.install-banner:not(:has(> :not([hidden]))) { display: none; }
@media (min-width: 900px) { .install-banner { display: none; } }
/* Save bar on job and expense forms: one compact row on phone and computer (owner, 16 Oct). */
.sticky-bar { padding: 8px 16px; gap: 10px; flex-wrap: nowrap; }
.sticky-bar .left { flex-direction: column; align-items: flex-start; gap: 0; flex: none; }
.sticky-bar .left .preview-label { font-size: 11px; line-height: 1.2; }
.sticky-bar .left #profitPreview, .sticky-bar .left #amountPreview { font-size: 18px; line-height: 1.2; min-width: 0; }
.sticky-bar .right { flex: 1 1 auto; justify-content: flex-end; flex-direction: row; gap: 8px; width: auto; }
.sticky-bar .right .btn { width: auto; min-height: 44px; padding-top: 0; padding-bottom: 0; }
.sticky-bar .right .btn-primary { flex: 0 1 auto; padding-left: 20px; padding-right: 20px; }
.sticky-bar .right .btn-ghost, .sticky-bar .right .btn-danger-text { padding-left: 10px; padding-right: 10px; }
@media (max-width: 479.98px) {
    .sticky-bar { padding: 8px 12px; }
    .sticky-bar .right .btn-primary { flex: 1 1 auto; justify-content: center; }
}

/* Customer page: Call on its own line, WhatsApp and SMS together below it, room before the figures (16 Oct). */
.customer-phone { flex-wrap: wrap; }
.customer-phone-big { margin: 8px 0 18px; gap: 8px; }
.customer-phone-big .customer-phone-call { flex: 1 1 100%; }
.customer-phone-big .customer-phone-wa { flex: 1 1 0; }

/* Tabler's own components (cards, lists, tables, muted text) follow the app's light/dark colours instead of Tabler's
   fixed light-mode text colour (dark text on dark cards in dark mode, found by the 16 Oct dark-mode scan). */
:root, [data-bs-theme] {
    --tblr-body-color: var(--text);
    --tblr-emphasis-color: var(--text);
    --tblr-heading-color: var(--text);
    --tblr-card-color: var(--text);
    --tblr-secondary-color: var(--muted);
    --tblr-muted: var(--muted);
}
.card { color: var(--text); }

/* Section cards have no inner padding: their header and rows add 20px themselves. Anything else placed straight inside
   (paragraphs, summaries, forms, small lists) got none and its text touched the card edge. :where() keeps this rule
   weaker than any component's own padding, so headers, rows and tables keep their own look (owner, 16 Oct). */
:where(.section-card) > :where(p, h2, h3, h4, dl, form, div, section, label, article, details, ul.jobcard-list) { padding-left: 20px; padding-right: 20px; }
@media (max-width: 479.98px) { :where(.section-card) > :where(p, h2, h3, h4, dl, form, div, section, label, article, details, ul.jobcard-list) { padding-left: 14px; padding-right: 14px; } }

/* Customer page job rows (16 Oct): the amount sits beside the job name, the send buttons get the full width below. */
.customer-job-row .home-row-main { flex: 1 1 auto; }
.customer-job-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.customer-job-row .invoice-actions-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.customer-job-row .invoice-actions-mini .btn { width: auto; min-height: 44px; flex: none; }
