﻿/* ArcTerra staff site. Every colour comes from a token; the tokens come from the logo.
   See docs/brand.md for where each value was measured and why blue leads. */

:root {
    color-scheme: light dark;

    /* Brand - sampled from the logo */
    --brand-blue: #26556F;
    --brand-blue-deep: #1A3F55;
    --brand-blue-light: #3B718D;
    --brand-green: #4E7859;
    --brand-green-deep: #3C5F46;
    --brand-sage: #618263;
    --brand-navy: #0F2A3F;
    --brand-arc: linear-gradient(135deg, #26556F 0%, #3B718D 45%, #618263 78%, #4E7859 100%);

    /* Neutrals - cool, biased toward the logo's paper */
    --canvas: #F4F9FC;
    --surface: #FFFFFF;
    --well: #E9F0F5;
    --line: #D3DEE6;
    --line-soft: #E2EAF0;
    --ink: #14212B;
    --ink-2: #3E5060;
    --ink-3: #5E7282;
    --ink-on-brand: #FFFFFF;

    /* Status - outside the brand hues so a pill never reads as branding */
    --ok: #2F8A5B;        --ok-wash: #E1F2E8;      --ok-ink: #1E5C3D;
    --warn: #A8721C;      --warn-wash: #FBF0DA;    --warn-ink: #6E4A0E;
    --danger: #B0392E;    --danger-wash: #FBE8E5;  --danger-ink: #7F2820;
    --info: #26556F;      --info-wash: #E3EDF4;    --info-ink: #1A3F55;

    /* Sidebar - the arc turned vertical, navy into deep green */
    --sidebar-bg: linear-gradient(180deg, #0F2A3F 0%, #1A3F55 62%, #2F4E3E 100%);
    --sidebar-ink: #D6E3EC;
    --sidebar-muted: #8FA8BA;
    --sidebar-hover: rgba(255, 255, 255, .08);
    --sidebar-active: rgba(255, 255, 255, .16);

    --shadow: 0 1px 2px rgba(20, 33, 43, .06), 0 8px 24px -16px rgba(20, 33, 43, .25);
    --radius: 8px;
    /* Small print. Phones lift all three to the 14 px text floor in one place (the phone block at the end). */
    --fs-small: .85rem;
    --fs-smaller: .8rem;
    --fs-fine: .75rem;
    /* The select chevron, stroked in --ink (a data URI cannot read a token, so each scheme sets its own). */
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2314212B' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

    /* Names the rest of the stylesheet grew up with. Kept as aliases so nothing else moves. */
    --bg: var(--canvas);
    --border: var(--line);
    --text: var(--ink);
    --muted: var(--ink-3);
    --primary: var(--brand-blue);
    --primary-deep: var(--brand-blue-deep);
    --primary-ink: var(--ink-on-brand);
}

/* Dark follows the device unless the page says otherwise. Only tokens change here - never rules.
   Screen only: paper is white, so a printed page keeps the light tokens whatever the device says. */
@media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-blue: #6FA3C2;
        --brand-blue-deep: #8DB8D2;
        --brand-green: #86AE8F;
        --brand-green-deep: #A3C5AB;

        --canvas: #0C1820;
        --surface: #13232E;
        --well: #0F1D27;
        --line: #24394A;
        --line-soft: #1C2F3D;
        --ink: #E7EEF3;
        --ink-2: #B0C0CC;
        --ink-3: #7C909F;
        --ink-on-brand: #0C1820;

        --ok: #5DBB86;        --ok-wash: #14311F;      --ok-ink: #9FDDB7;
        --warn: #E0A64A;      --warn-wash: #2C2113;    --warn-ink: #F0C784;
        --danger: #E58072;    --danger-wash: #2E1815;  --danger-ink: #F3A89E;
        --info: #6FA3C2;      --info-wash: #16283A;    --info-ink: #B8D3E4;

        --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -16px rgba(0, 0, 0, .8);
        --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23E7EEF3' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    }
}
:root[data-theme="dark"] {
    --brand-blue: #6FA3C2;
    --brand-blue-deep: #8DB8D2;
    --brand-green: #86AE8F;
    --brand-green-deep: #A3C5AB;

    --canvas: #0C1820;
    --surface: #13232E;
    --well: #0F1D27;
    --line: #24394A;
    --line-soft: #1C2F3D;
    --ink: #E7EEF3;
    --ink-2: #B0C0CC;
    --ink-3: #7C909F;
    --ink-on-brand: #0C1820;

    --ok: #5DBB86;        --ok-wash: #14311F;      --ok-ink: #9FDDB7;
    --warn: #E0A64A;      --warn-wash: #2C2113;    --warn-ink: #F0C784;
    --danger: #E58072;    --danger-wash: #2E1815;  --danger-ink: #F3A89E;
    --info: #6FA3C2;      --info-wash: #16283A;    --info-ink: #B8D3E4;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -16px rgba(0, 0, 0, .8);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23E7EEF3' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); }
a:hover { color: var(--primary-deep); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
/* FocusOnNavigate focuses the h1 (tabindex -1) so screen readers announce the page; it is never a Tab stop,
   so no ring. Not :focus-visible: script focus on a fresh page matches it in WebKit and Chromium. */
h1:focus { outline: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
/* A token or temporary password is one long word: it breaks rather than run off the card. */
code { background: var(--well); padding: .1rem .35rem; border-radius: 4px; font-size: .95em; overflow-wrap: anywhere; }
.muted { color: var(--muted); }

/* Shell */
/* The status bar is black-translucent (App.razor), so nothing behind it is drawn unless a page draws it.
   Navy on every layout, the sign-in pages included; the inset is 0 outside the installed app. */
body::before {
    content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top);
    background: var(--brand-navy); z-index: 20;
}
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
    background: var(--sidebar-bg); color: var(--sidebar-ink);
    display: flex; flex-direction: column; padding: 1rem .75rem; gap: 1rem;
}
.sidebar .brand { display: block; padding: .25rem .5rem; text-decoration: none; }
/* The sidebar and the phone app bar are navy in both themes, so the wordmark takes the dark-set tints there regardless. */
.sidebar .brand, .appbar .brand { --brand-blue: #6FA3C2; --brand-green: #86AE8F; }
.wordmark { display: block; height: auto; }
.wordmark-sidebar { width: 100%; max-width: 190px; }
.wordmark-auth { width: 200px; margin-bottom: .25rem; }
.foot-mark { height: 1.1em; width: auto; vertical-align: -.2em; margin-right: .3em; }
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar nav a {
    color: var(--sidebar-ink); text-decoration: none; padding: .5rem .6rem; border-radius: 6px;
}
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; padding: 0 .5rem; }
/* The identity block is the way into your own account, so it has to read as a target. */
.sidebar-foot .who {
    display: flex; flex-direction: column; font-size: .9rem;
    color: inherit; text-decoration: none;
    padding: .4rem .5rem; margin: 0 -.5rem .25rem; border-radius: var(--radius);
}
.sidebar-foot .who:hover, .sidebar-foot .who:focus-visible { background: var(--sidebar-hover); }
.sidebar-foot .who span { color: var(--sidebar-muted); }
.sidebar-foot .btn-ghost { color: var(--sidebar-ink); padding-left: 0; }
.content { padding: 1.5rem 2rem; max-width: 1100px; width: 100%; }

/* Phone shell (AppBar, TabBar): only at 800 px and below, where it stands in for the sidebar. */
.appbar, .tabbar { display: none; }

@media (max-width: 800px) {
    .sidebar { display: none; }
    .shell { display: block; }
    /* The bottom padding keeps the end of every page clear of the tab bar; the side gutters clear a landscape notch. */
    .content {
        padding: 1rem max(1rem, env(safe-area-inset-left)) calc(64px + env(safe-area-inset-bottom) + 1rem) max(1rem, env(safe-area-inset-right));
        min-width: 0; overflow-x: clip;
    }

    .appbar {
        position: sticky; top: 0; z-index: 10;
        display: flex; align-items: center; gap: .25rem;
        height: calc(56px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) max(.75rem, env(safe-area-inset-right)) 0 max(.75rem, env(safe-area-inset-left));
        background: var(--brand-navy); border-bottom: 1px solid rgba(255, 255, 255, .08);
    }
    .appbar .brand { display: flex; align-items: center; min-height: 44px; }
    .wordmark-appbar { width: 110px; }
    .appbar-back {
        width: 44px; height: 44px; margin-left: -.6rem; padding: 0; align-items: center; justify-content: center;
        background: transparent; border: 0; color: var(--sidebar-ink); cursor: pointer;
    }
    /* The bar has room for the glyph only; aria-label still names it. */
    .appbar-back span { display: none; }
    .appbar-account {
        margin-left: auto; width: 44px; height: 44px; border-radius: 50%;
        display: grid; place-items: center;
        background: var(--sidebar-active); color: #fff; font-weight: 700; text-decoration: none;
    }
    .appbar-account:hover { color: #fff; }

    .tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
        display: flex; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--line);
    }
    .tab {
        flex: 1; position: relative;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
        color: var(--ink-3); font-size: 12px; font-weight: 600; text-decoration: none;
    }
    .tab:hover { color: var(--ink-3); }
    .tab.active { color: var(--brand-blue); }
    .tab.active::before {
        content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px;
        border-radius: 0 0 3px 3px; background: currentColor;
    }

    #blazor-error-ui { bottom: calc(64px + env(safe-area-inset-bottom)); }
    /* Signed in as someone else must never scroll out of mind: it rides under the app bar. */
    .founder-banner { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; }
}

/* More page: grouped rows, links with a chevron, actions without */
.more-list {
    list-style: none; margin: 0 0 1.5rem; padding: 0; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.more-list li + li { border-top: 1px solid var(--line-soft); }
.more-list form { margin: 0; }
.more-list a, .more-row {
    display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 56px; padding: .5rem 1rem;
    font: inherit; text-align: left; color: var(--ink); text-decoration: none; background: transparent; border: 0; cursor: pointer;
}
.more-list a:hover, .more-row:hover { color: var(--ink); background: var(--well); }
.more-list a::after {
    content: ""; flex: none; margin-left: auto; width: .5rem; height: .5rem;
    border: solid var(--ink-3); border-width: 2px 2px 0 0; transform: rotate(45deg);
}
/* The account row is two lines: name over company. */
.more-list .more-account { display: grid; grid-template-columns: 1fr auto; align-content: center; row-gap: 0; }
.more-account strong, .more-account span { grid-column: 1; }
.more-account span { color: var(--muted); }
.more-account::after { grid-column: 2; grid-row: 1 / span 2; }
.more-danger .more-row, .more-danger .more-row:hover { color: var(--danger); }

/* Auth */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.auth-card .brand { margin-bottom: .75rem; }

/* Cards, tables */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: var(--fs-small); }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; margin: 0; }
.empty { padding: 2rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Forms */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); margin-bottom: .75rem; }
/* 16 px is the floor below which iOS Safari zooms the page into a focused field. */
input, select, textarea {
    font: inherit; font-size: max(16px, 1em); color: var(--text); padding: .5rem .6rem; border: 1px solid var(--border);
    border-radius: 6px; background: var(--surface); width: 100%;
}
/* Our own chevron, so a dark-scheme select is not the platform's grey. */
select { appearance: none; background: var(--surface) var(--select-chevron) no-repeat right .75rem center / 12px; padding-right: 2.25rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.validation-message { color: var(--danger); font-size: var(--fs-small); }
.invalid { border-color: var(--danger); }

/* Buttons, badges, alerts */
.btn {
    display: inline-block; font: inherit; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--well); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); color: var(--primary-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
/* A destructive action offered as plain text: findable, never inviting. */
.btn-danger-link { background: transparent; border-color: transparent; color: var(--danger); font-weight: 600; }
.btn-danger-link:hover { background: var(--danger-wash); color: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: default; }
/* A pill on one line; a long one (a crew reason) wraps into a rounded box, not a blob. */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: .8em; font-size: var(--fs-smaller); font-weight: 600; }
.badge-ok { background: var(--ok-wash); color: var(--ok-ink); }
.badge-off { background: var(--well); color: var(--muted); }
.badge-warn { background: var(--warn-wash); color: var(--warn-ink); }
.alert { padding: .75rem 1rem; border-radius: 6px; margin: .75rem 0; }
.alert-error { background: var(--danger-wash); color: var(--danger-ink); }
.alert-success { background: var(--ok-wash); color: var(--ok-ink); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .5rem 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Blazor error bar */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: var(--warn-wash); color: var(--warn-ink); padding: .6rem 1.25rem; box-shadow: 0 -1px 0 var(--warn);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* Page furniture */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
/* The title block holds whatever the client typed (a long name, an email): it wraps, never widens the page. */
.page-head > div:not(.actions) { min-width: 0; overflow-wrap: anywhere; }
.page-head h1 { margin-bottom: .25rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-head .actions, .section-head .actions, .form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.form-actions { margin-top: .5rem; }
/* A draft's tax sits under the line editor's add buttons: a gap so its label does not read as theirs. */
.tax-fields { margin-top: 1rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.section-head h2 { margin: 0; }
/* A card is its content plus its padding: no paragraph margin above the first line under the
   heading, none below the last. */
.section-head + :is(p, dl) { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.crumbs { margin: 0 0 .25rem; font-size: var(--fs-small); }
.toolbar { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 360px; }
label.inline { flex-direction: row; align-items: center; gap: .4rem; margin: 0; color: var(--text); }
label.inline input { width: auto; }
.narrow { max-width: 640px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
.grid-2.top { align-items: start; }
.prewrap { white-space: pre-wrap; }
.break { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The dashboard's getting-started list for a new company (Shared/GettingStartedCard) */
.setup-steps { list-style: none; margin: 0 0 .75rem; padding: 0; }
.setup-steps li + li { border-top: 1px solid var(--line-soft); }
.setup-steps a { display: flex; align-items: center; gap: .75rem; min-height: 56px; padding: .5rem 0; color: var(--ink); text-decoration: none; }
.setup-steps a:hover .setup-label { text-decoration: underline; }
.setup-tick {
    flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
    border: 2px solid var(--primary); color: var(--primary); font-weight: 700; font-size: var(--fs-small);
}
.setup-steps .done .setup-tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup-text { display: flex; flex-direction: column; min-width: 0; }
.setup-label { font-weight: 600; }
.setup-steps .done .setup-label { color: var(--muted); font-weight: 400; text-decoration: line-through; }
.setup-hint { color: var(--muted); font-size: var(--fs-small); }
.crew-prompt { display: flex; align-items: center; gap: .5rem; }
.crew-prompt .setup-steps { flex: 1; min-width: 0; margin: 0; }
.crew-prompt form { margin: 0; flex: none; }
/* The founder's health report as JSON (Platform/PlatformHealth) */
pre.json { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--well); padding: .75rem; border-radius: 6px; font-size: var(--fs-small); margin: 0; }
tr.current td { font-weight: 700; }
.card-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-table th:first-child, .card-table td:first-child { padding-left: 1rem; }
tr.archived td { color: var(--muted); }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.badge-info { background: var(--info-wash); color: var(--info-ink); }
.badge-danger { background: var(--danger-wash); color: var(--danger-ink); }
.alert-warn { background: var(--warn-wash); color: var(--warn-ink); }

/* Dashboard cards: a job (ProjectCard, the whole card a link) or a company (FounderHome, name link and a button) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
/* A further list under the dashboard's project cards (its company locations). */
.dashboard-section { margin-top: 1.5rem; }
.project-card, .company-card {
    display: flex; flex-direction: column; gap: .35rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; color: var(--text); text-decoration: none;
}
/* Hover outlines the card but leaves its left edge alone: that colour is the job's status. */
.project-card:hover { border-top-color: var(--primary); border-right-color: var(--primary); border-bottom-color: var(--primary); box-shadow: var(--shadow); }
/* A dashboard card's head (name and pill) and its small print under a rule: project and company cards. */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.card-foot { display: flex; gap: .15rem .75rem; flex-wrap: wrap; font-size: var(--fs-small); margin-top: .25rem; padding-top: .5rem; border-top: 1px solid var(--line-soft); }
/* The coloured left edge (CardEdge) says at a glance whether it is live: brand blue, or grey once done. */
.edge-active { border-left: 4px solid var(--brand-blue); }
.edge-idle { border-left: 4px solid var(--line); }
.project-card-client { color: var(--muted); font-size: var(--fs-small); overflow-wrap: anywhere; }
.project-card-title { font-size: 1.05rem; overflow-wrap: anywhere; }
.company-card-name { font-size: 1.05rem; font-weight: 700; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.company-card form { margin: .35rem 0 0; }
.count { font-size: var(--fs-small); font-weight: 600; color: var(--muted); }

/* A two- or three-way filter as links (static SSR: the choice is the URL), the current one raised. */
.segmented { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 1rem; background: var(--well); border: 1px solid var(--line); border-radius: 10px; }
.segmented a { display: flex; align-items: center; justify-content: center; padding: .3rem 1rem; border-radius: 7px; color: var(--ink-3); font-weight: 600; text-decoration: none; }
.segmented a:hover { color: var(--ink); }
/* Raised and ringed, so the current choice reads in dark mode too, where surface and well are close. */
.segmented a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(20, 33, 43, .15); }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0; }

/* Week schedule */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1.25rem; }
.day {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .5rem; min-height: 8rem; display: flex; flex-direction: column; gap: .4rem;
}
.day.today { border-color: var(--primary); box-shadow: inset 0 2px 0 var(--primary); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: .25rem; font-size: var(--fs-small); }
.day-empty { margin: 0; }
.visit-chip {
    border: 1px solid var(--border); border-left: 3px solid var(--brand-green); border-radius: 6px;
    padding: .35rem .45rem; font-size: var(--fs-small); display: flex; flex-direction: column; gap: .1rem;
    background: var(--well); overflow-wrap: anywhere; color: var(--ink); text-decoration: none;
}
.visit-chip:hover { color: var(--ink); border-color: var(--primary); border-left-color: var(--brand-green); }
.visit-chip .badge { align-self: flex-start; }
.visit-title { color: var(--primary); font-weight: 600; }
.visit-time { font-weight: 600; }
.visit-crew { color: var(--muted); }
.visit-form { border-bottom: 1px solid var(--border); padding-bottom: .75rem; margin-bottom: .75rem; }

@media (max-width: 1000px) {
    .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .day { min-height: 0; }
}
@media (max-width: 800px) {
    .week-grid { grid-template-columns: 1fr; gap: .35rem; }
    /* A day with nothing on it is one quiet line, so the days with work stand out. */
    .day:has(.day-empty) { padding: .45rem .75rem; background: transparent; }
    .day:has(.day-empty) .day-head { color: var(--muted); }
    .day-empty { display: none; }
}

/* Job page: the status step in Details, and who is on site */
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0 0 .75rem; }
.status-line form { margin: 0; }
.on-site { margin-bottom: 1rem; }
.on-site h3 { margin: 0 0 .4rem; font-size: 1rem; }
.on-site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.on-site-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem; }

/* Job page: the website's clock, supplies and capture forms */
.field-clock { margin-bottom: 1rem; }
.field-clock form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0; }
.field-clock form > p, .field-clock form > label { flex-basis: 100%; }
.btn-punch { min-width: 10rem; min-height: 56px; font-size: 1.1rem; }
.offline-note[hidden] { display: none; }
.supply-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.supply-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .75rem; }
.supply-state { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.inline-form { display: inline; margin: 0; }
.choice { flex-direction: row; align-items: center; gap: .4rem; min-height: 44px; margin: 0; padding: 0 .8rem; color: var(--text);
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; }
.choice input { width: auto; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--info-wash); }
/* The same choices one under another, for options a sentence long (Company's clock-in rule): each wraps in its box. */
.choice-stack { border: 0; padding: 0; margin: 0 0 .75rem; min-width: 0; display: grid; gap: .4rem; }
.choice-stack legend { padding: 0; margin-bottom: .25rem; font-size: .9rem; color: var(--muted); }
.choice-stack .choice { border-radius: var(--radius); padding: .5rem .8rem; gap: .6rem; }
.choice-stack .choice input { flex: none; }

/* Team: permission toggles, grouped */
permission-presets { display: block; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .75rem; margin: .25rem 0 1rem; }
.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: .25rem .75rem .5rem; margin: 0; min-width: 0; }
.perm-group legend { font-weight: 600; padding: 0 .25rem; color: var(--text); }
.perm-toggle { flex-direction: row; align-items: flex-start; gap: .6rem; min-height: 44px; margin: 0; padding: .4rem 0; color: var(--text); cursor: pointer; }
.perm-toggle input { width: auto; margin-top: .2rem; flex: none; }
.perm-toggle small { display: block; color: var(--muted); font-size: var(--fs-smaller); }
.perm-toggle:has(input:disabled) { cursor: default; opacity: .65; }

/* Crew chips */
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.chip-toggle {
    flex-direction: row; align-items: center; gap: .35rem; margin: 0; color: var(--text);
    border: 1px solid var(--border); border-radius: 999px; padding: .3rem .7rem; background: var(--surface); cursor: pointer;
}
.chip-toggle input { width: auto; }
.chip-toggle.on { border-color: var(--primary); background: var(--info-wash); }

/* Line tables and money */
.line-table th.num, .line-table td.num, th.num, td.num { text-align: right; white-space: nowrap; }
/* Off-screen, not display:none, so every browser still treats it as the form's Enter button. */
.default-submit { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.line-table input, .line-table select { padding: .3rem .4rem; }
.line-table select { padding-right: 2rem; }
.line-table td.num input { text-align: right; min-width: 5rem; }
.line-table td { vertical-align: middle; }
tr.past td { color: var(--muted); }
/* No column gap: the space between label and figure is the figure's own padding, so the rule over
   the grand total runs unbroken across both. */
.totals { display: grid; grid-template-columns: 1fr max-content; gap: .2rem 0; margin: .75rem 0 0; max-width: 22rem; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; padding-left: 1rem; text-align: right; }
.totals .grand { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); padding-top: .3rem; }

/* Client link */
.link-box { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; }
.link-box label { flex: 1 1 20rem; margin: 0; }
.link-box input { background: var(--well); }

/* Client-facing pages */
.public-shell { min-height: 100%; padding: 1.5rem 1rem 2rem; display: flex; flex-direction: column; align-items: center; }
.public-card {
    width: 100%; max-width: 720px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.public-card h1 { font-size: 1.35rem; }
.public-card h2 { margin-top: 1.5rem; }
.public-company { font-weight: 700; color: var(--primary); margin: 0 0 .5rem; }
.public-foot { margin: 1rem 0 0; font-size: var(--fs-small); }
.alert-neutral { background: var(--well); color: var(--text); }
.addons { list-style: none; margin: .5rem 0; padding: 0; }
.addons li {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
    border-bottom: 1px solid var(--border); padding: .5rem 0;
}

@media (max-width: 480px) {
    .public-shell { padding: .75rem .5rem 1.5rem; }
    .public-card { padding: 1rem; }
    .line-table th, .line-table td { padding: .4rem .25rem; }
}

/* Crew invites */
.invite { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.invite-link { flex: 1 1 22rem; min-width: 0; }
.invite-link p { margin: .35rem 0 0; }
/* A QR code has to stay dark-on-white to scan, whatever the theme. */
.qr { display: block; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: .4rem; }

/* Field activity */
/* Tiles keep a tile's width however few there are, rather than stretching across the page. */
.grid-3.totals-row { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); margin-bottom: 1rem; }
.stat {
    display: flex; flex-direction: column; gap: .15rem;
    border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; background: var(--well);
}
.stat-label { color: var(--muted); font-size: var(--fs-small); }
.stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
a.stat-link { color: inherit; text-decoration: none; }
a.stat-link:hover { border-color: var(--primary); }
/* Job cost: the shared "$X of $Y · N %" line and its colour badge (JobCostLine). */
.cost-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; font-variant-numeric: tabular-nums; }
.cost-headline { font-size: 1.25rem; font-weight: 700; margin: 0 0 .25rem; }
.cost-breakdown { margin-bottom: 1rem; }
/* A card's form folded under a text-button summary: Materials' "Add an item", Job cost's "Change budget". */
.fold { margin-top: 1rem; border-top: 1px solid var(--line-soft); padding-top: .5rem; }
.fold summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: .35rem 0; }
.fold[open] summary { margin-bottom: .5rem; }

/* Job page cards (JobCard): a <details> folded to its title and hint on a phone, open with a plain heading wider.
   Named twice so the phone block's summary rule (a list-item with a triangle) does not outrank it. */
.card.job-card > summary { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .75rem; cursor: pointer; list-style: none; }
.job-card > summary::-webkit-details-marker { display: none; }
.job-card > summary h2 { margin: 0; }
.job-card-hint { color: var(--muted); font-size: var(--fs-small); }
/* The fold's chevron at the row's end, turned over when open. */
.job-card > summary::after {
    content: ""; margin-left: auto; width: 12px; height: 8px; flex: none;
    background: var(--select-chevron) no-repeat center / 12px; transition: transform .15s;
}
.job-card[open] > summary { margin-bottom: .5rem; }
.job-card[open] > summary::after { transform: rotate(180deg); }
.job-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.job-card-actions:not(:has(*)) { display: none; }
.job-card-actions > form { margin: 0; }
/* Wide: always open (the content box shown whatever the summary says), the title a heading, the buttons beside it.
   Only where ::details-content is known: an older browser (Safari before 18.4, Firefox before 143) would drop that
   rule but keep the summary's pointer-events, leaving a closed card nothing opens; there the phone's tap-to-open stays.
   The title floats left and the buttons float right: beside it while both fit, under it (still right) when a narrow
   card (two side by side) has too little room. The card's content clears both. */
@media (min-width: 801px) {
    @supports selector(::details-content) {
        .job-card { display: flow-root; }
        .job-card::details-content { display: block; content-visibility: visible; }
        .job-card > summary { float: left; max-width: 100%; margin: 0 1rem .5rem 0; cursor: default; pointer-events: none; min-height: 2.25rem; }
        .job-card > summary::after { display: none; }
        .job-card-actions { float: right; max-width: 100%; justify-content: flex-end; margin: 0 0 .5rem; }
        .job-card-actions .btn { white-space: nowrap; }
        .job-card > :not(summary, .job-card-actions) { clear: both; }
    }
}
.project-card-cost { margin-top: .35rem; }

/* The job feed (Timeline): a vertical line with a dot per entry, coloured by kind. The dot sits on
   the centre of the entry's first line; the line runs through the dots' centres (6 px in). */
.timeline { list-style: none; margin: 1rem 0 0; padding: 0 0 0 1.75rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 2px; background: var(--line); }
.timeline-item { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; padding: 0 0 1.1rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: ""; position: absolute; left: -1.75rem; top: calc(.725em - 6px); width: 12px; height: 12px;
    border-radius: 50%; background: var(--brand-blue); box-shadow: 0 0 0 3px var(--surface);
}
.timeline-item.kind-expense::before { background: var(--brand-green); }
.timeline-item.kind-photo::before { background: var(--brand-blue-light); }
.timeline-item.kind-note::before { background: var(--ink-3); }
.timeline-what { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.timeline-when { font-size: var(--fs-small); color: var(--muted); }
/* A photo link keeps a tap-sized box before its lazy image loads (or if the browser cannot show
   it, say a HEIC receipt), instead of shrinking to a 2 px line. */
.thumb {
    max-width: 200px; max-height: 200px; min-width: 48px; min-height: 48px;
    border-radius: 6px; border: 1px solid var(--border); display: block; background: var(--well);
}

/* A receipt in a table row: enough to recognise, full size one tap away. */
.thumb-small { width: 48px; height: 48px; object-fit: cover; }

.photo-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem;
}
.photo-grid .thumb { width: 100%; max-width: none; height: 160px; object-fit: cover; }
.photo-grid-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem; margin-top: .35rem; font-size: var(--fs-small); }
.photo-note { margin: .35rem 0 0; font-size: var(--fs-small); overflow-wrap: anywhere; }
.photo-day { display: flex; align-items: baseline; gap: .5rem; margin: 1rem 0 .5rem; font-size: 1rem; }
.photo-day .muted { font-size: var(--fs-small); font-weight: 400; }
.photo-open { margin-bottom: 1rem; }
.photo-open img { display: block; max-width: 100%; max-height: 70vh; border-radius: 6px; border: 1px solid var(--border); }

/* A file input dressed as a button (FieldCapture's camera and library): the input covers the button, unseen. */
.btn-file { position: relative; overflow: hidden; }
.btn-file input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.btn-camera { display: inline-flex; align-items: center; gap: .5rem; padding: .75rem 1.25rem; font-weight: 600; }

.auth-alt { margin: 1rem 0 0; text-align: center; font-size: .9rem; }

/* ---- Job report (JobReportView: the office page and the client's link) ---- */
.job-report-head { border-top: 4px solid var(--brand-blue); padding-top: .75rem; margin-bottom: 1rem; }
.job-report-head p { margin: 0; }
.job-report-company { font-weight: 700; color: var(--brand-blue); }
.job-report-title { margin: .25rem 0; color: var(--brand-green-deep); }
.job-report-section { border-top: 1px solid var(--line-soft); padding-top: .25rem; margin-top: 1rem; }
.job-report-section h3 { margin-top: .75rem; }
.job-report-visits, .job-report-notes { list-style: none; margin: 0; padding: 0; }
.job-report-visits li {
    display: grid; grid-template-columns: 11rem 1fr 4rem 1fr; gap: .25rem 1rem;
    padding: .5rem 0; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums;
}
.job-report-notes li { padding: .5rem 0; border-bottom: 1px solid var(--line-soft); }
.job-report-notes li p { margin: .25rem 0 0; }
.job-report-day { margin: .75rem 0 .5rem; font-size: 1rem; }
.job-report-photos { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.job-report-photos li { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; background: var(--surface); }
/* A ticked photo is outlined in the brand blue, so the picks read at a glance. */
.job-report-photos li:has(input[type=checkbox]:checked) { border-color: var(--brand-blue); box-shadow: 0 0 0 2px var(--brand-blue); }
.job-report-photos figure { margin: 0; }
.job-report-photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.job-report-photos figcaption { display: flex; flex-direction: column; gap: .1rem; margin-top: .35rem; font-size: var(--fs-small); overflow-wrap: anywhere; }
/* The whole row is the tick target, at least 44 px tall. */
.job-report-pick { flex-direction: row; align-items: center; gap: .5rem; min-height: 44px; margin: .25rem 0 0; color: var(--text); cursor: pointer; }
.job-report-pick input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }

/* Installed-app affordances */
.sidebar-foot .install-btn { padding-left: 0; text-align: left; }
/* The back control exists only when there is no browser back to lean on: in the app bar on
   phones (hidden with the bar above 800 px), above the page on wider screens. */
.standalone-back { display: none; }
.content-back {
    align-items: center; gap: .25rem; font: inherit; background: transparent; border: 0; color: var(--primary);
    min-height: 44px; padding: 0 .5rem 0 0; margin: -.5rem 0 .5rem; cursor: pointer;
}
@media (display-mode: standalone) {
    /* Once it is on the home screen the install button has done its job, row and all. */
    .install-btn, .more-list li:has(> .install-btn) { display: none; }
    .standalone-back { display: inline-flex; }
}
@media (display-mode: standalone) and (max-width: 800px) {
    .content-back { display: none; }
}
/* Opened from the phone app (the fo.phone-app cookie): only its window, an installed app's, swaps Today for Home
   and offers the way back from the login page. A browser tab sharing that cookie stays the plain website. */
.tab.in-phone-app, .btn.phone-app-back { display: none; }
@media (display-mode: standalone) {
    .tab.in-phone-app { display: flex; }
    .tab.not-in-phone-app { display: none; }
    .btn.phone-app-back { display: flex; }
}

/* Modal (native <dialog>) */
.modal {
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
    padding: 1.25rem 1.5rem; width: min(520px, calc(100vw - 2rem)); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(12, 24, 32, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin: 0 0 .5rem; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close { font: inherit; font-size: 1.4rem; line-height: 1; background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0 .25rem; }
.modal-close:hover { color: var(--text); }
.install-steps { border-top: 1px solid var(--line-soft); padding: .6rem 0; }
.install-steps summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.install-steps ol { margin: .5rem 0 .25rem; padding-left: 1.4rem; }
.install-steps li { margin: .3rem 0; }

/* The receipt scanner round an expense form's file input (FieldOps.Scan: receipt-scan-element.js) */
receipt-scan { display: block; }
.receipt-scan-preview { margin: .5rem 0 0; }

/* Receipt suggestions round the expense form (js/receipt-suggest.js; the hint is ReceiptHint) */
receipt-suggest { display: block; }
input.suggested { background: var(--warn-wash); border-color: var(--warn); }
.receipt-hint { margin: -.25rem 0 .75rem; font-size: .9rem; color: var(--warn-ink); }
.receipt-hint[hidden] { display: none; }
.btn-link {
    background: none; border: 0; padding: 0; margin-left: .35rem; min-height: 44px; width: auto;
    color: var(--primary); font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer;
}

/* Address suggestions (address-autocomplete.js) */
address-autocomplete { display: block; }
.suggest-anchor { position: relative; }
.suggest-list {
    position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
    margin: .2rem 0 0; padding: .25rem 0; list-style: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    font-weight: normal;
}
.suggest-list li[role="option"] { padding: .45rem .75rem; cursor: pointer; color: var(--ink); }
.suggest-list li[role="option"]:hover, .suggest-list li[aria-selected="true"] { background: var(--well); }
.suggest-credit { padding: .35rem .75rem 0; border-top: 1px solid var(--line-soft); margin-top: .25rem; font-size: var(--fs-fine); color: var(--ink-3); }
.suggest-credit a { color: inherit; }

/* Maps (js/map) */
.map-canvas { height: 340px; margin: .5rem 0 .75rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
/* MapLibre's control buttons stay white in both themes, so the toggle keeps light-theme colours
   rather than the theme tokens (which turn it white-on-white in dark mode). */
.map-layer-toggle { width: auto !important; padding: 0 .6rem !important; font-weight: 600; font-size: .8rem; line-height: 29px; font-family: inherit; color: #14212B; }
.map-layer-toggle[aria-pressed="true"] { background: #E9F0F5; }
@media (max-width: 600px) { .map-canvas { height: 280px; } }

/* ---- crew location notice ---- */
.notice-text h2 { margin-top: 0; }
.notice-text h3 { font-size: 1rem; margin: 1.25rem 0 .25rem; }
.notice-sign p { margin: 1.25rem 0; }

@media print {
    @page { margin: 12mm; }
    .sidebar, .appbar, .tabbar, .standalone-back, .no-print, #blazor-error-ui { display: none !important; }
    .shell { display: block; }
    .content { padding: 0; max-width: none; }
    .notice-sheet { border: 0; box-shadow: none; padding: 0; background: #fff; }
    body { background: #fff; color: #000; }

    /* Client pages print as the card alone, edge to edge. */
    .public-shell { padding: 0; min-height: 0; }
    .public-card { max-width: none; border: 0; box-shadow: none; padding: 0; background: #fff; }

    /* The client's job report on paper (the office page prints as it is): Photos start their own page,
       two to a row, short enough that six and a few notes share it on Letter or A4. */
    .public-card .job-report-photos-section { break-before: page; border-top: 0; }
    .public-card .job-report-section h3 { break-after: avoid; }
    .public-card .job-report-visits li, .public-card .job-report-notes li { break-inside: avoid; }
    .public-card .job-report-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4mm; }
    .public-card .job-report-photos li { break-inside: avoid; background: #fff; box-shadow: none; }
    .public-card .job-report-photos img { max-height: 42mm; }
    .public-card .job-report-photos figcaption { flex-direction: row; flex-wrap: wrap; column-gap: .5em; }
}

/* ---- crew map ---- */
.crew-map { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1rem; align-items: start; }
.crew-map-canvas { height: calc(100vh - 12rem); height: calc(100svh - 12rem); min-height: 24rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--well); }
.crew-map-list { display: grid; gap: 1rem; max-height: calc(100vh - 12rem); max-height: calc(100svh - 12rem); overflow-y: auto; }
.crew-map-list h2 { font-size: 1rem; margin: 0 0 .5rem; }
.crew-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.crew-row { display: grid; gap: .2rem; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; }
button.crew-row:not(:disabled) { cursor: pointer; }
button.crew-row:not(:disabled):hover { border-color: var(--brand-blue-light); }
.crew-row.is-selected { border-color: var(--brand-blue); box-shadow: 0 0 0 2px var(--info-wash); }
.crew-row.is-closed { opacity: .75; }
.crew-row .row-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.crew-map-stamp { font-size: var(--fs-smaller); }
.crew-map-notice { margin-top: 1rem; }
.crew-map-notice summary { cursor: pointer; font-weight: 600; }

/* Phone: the list is the page, the map sits under it. */
@media (max-width: 800px) {
    .crew-map { grid-template-columns: 1fr; }
    .crew-map-list { order: -1; max-height: none; overflow: visible; }
    .crew-map-canvas { height: 55vh; height: 55svh; min-height: 18rem; }
}

/* ---- founder signed in as someone ---- */
.founder-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.founder-banner form { margin: 0; }

/* Width switches: one of two views of the same list, picked at the 800 px phone breakpoint. */
@media (min-width: 801px) { .narrow-only { display: none; } }
@media (max-width: 800px) { .wide-only { display: none; } }

/* ---- Phone base: type, targets, controls ----
   Last in the file on purpose: these override the desktop rules above at equal specificity.
   The crew app's scale: 17 px body, 52 px controls, 44 px for anything else you tap, 14 px text floor.
   Screen only: Letter paper lays out about 740 px wide, and the printed notice keeps its desktop type. */
@media screen and (max-width: 800px) {
    :root { --fs-small: 14px; --fs-smaller: 14px; --fs-fine: 14px; }
    /* Nothing anyone typed (a company name, an email, a token) may run off a phone: a word too long
       for its line breaks inside rather than widening or cutting the page. */
    body { font-size: 17px; line-height: 1.45; overflow-wrap: anywhere; }
    /* ...but our own short words are never squeezed into breaking mid-word. A pill wraps only at a
       space; in a heading row the pill, or the card's action button, keeps its width and the name or
       title beside it wraps instead. Rows that wrap (page actions, row actions) move a button to the
       next line before they would shrink it, so a button breaks a word only if that word alone is
       wider than the screen. */
    .badge { overflow-wrap: normal; }
    :is(.card-head, h1) > .badge { flex-shrink: 0; white-space: nowrap; }
    .section-head > :not(h2) { flex-shrink: 0; }
    h1 { font-size: 26px; font-weight: 700; line-height: 1.15; }
    /* Section labels: page h2s only, so a dialog's title and the job report's title keep their
       case. The crew map's list headings are the same labels (named too, to outrank their desktop size). */
    main h2:not(.modal-head h2, .job-report-title), .crew-map-list h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }

    input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 17px; min-height: 52px; border-radius: 10px; }
    input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); }
    .btn { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; padding: .6rem 1rem; }
    /* Ghost actions are secondary, so they take the 44 px target rather than the 52 px button height. */
    .crumbs a, label.inline, .chip-toggle, .btn-ghost, .btn-danger-link { min-height: 44px; display: inline-flex; align-items: center; }
    /* A tick-box row's words are content, not a field caption: body size, like the client's add-ons on /q/. */
    label.inline { font-size: inherit; }
    /* A card's own action (Add visit, New quote) is secondary to the page's: the 44 px target, not 52. */
    .section-head .btn, .company-card .btn { min-height: 44px; padding: .4rem .9rem; }
    /* A heading's ghost action (Edit) keeps its 44 px target but not its height in the layout, so the
       heading row is as tall as the heading. */
    .section-head .btn-ghost { margin-block: -.6rem; }
    .company-card-name { display: inline-flex; align-items: center; min-height: 44px; }
    /* Stays a list-item so it keeps its disclosure triangle and its full-width tap area.
       MapLibre's attribution toggle is a summary too, sized by MapLibre: leave it alone. */
    summary:not(.maplibregl-map summary) { display: list-item; min-height: 44px; padding-block: .6rem; }
    /* A folded job card is one tappable row: tighter than a card with something in it. */
    .job-card { margin-bottom: .5rem; }
    .job-card:not([open]) { padding-block: 0; }

    /* Page actions fill the width in source order (reading order stays visual order), sharing a row
       while their words fit and wrapping onto the next when they do not. */
    .page-head .actions { width: 100%; align-items: stretch; gap: .4rem; }
    .page-head .actions > * { flex: 1 1 auto; margin: 0; }
    .page-head .actions > form { display: grid; }
    /* Slimmer sides than a lone button, so a status change, Report and Cancel project share one row
       at phone width; on a narrower screen the last one wraps at the normal gap. */
    .page-head .actions .btn { padding-inline: .8rem; }
    .page-head .actions .btn-danger-link { padding-inline: .35rem; }
    /* A quiet page action (Archive, Cancel project) keeps its own width beside the ones that fill. */
    .page-head .actions > :is(.btn-ghost, .btn-danger-link, form:has(> :is(.btn-ghost, .btn-danger-link))) { flex-grow: 0; }
    /* Ghost links leading the row (Team's "Company") line their text up with the title. */
    .page-head .actions > .btn-ghost:first-child { margin-left: -.8rem; }
    .grid-3 { gap: .75rem; }
    .segmented { display: flex; }
    .segmented a { flex: 1; min-height: 44px; }
    /* Stat tiles stay side by side: a figure needs far less width than a form field. */
    .grid-3.totals-row { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }

    /* table.stack: a list table whose rows become cards, so nothing scrolls sideways.
       The contract: the header row is kept for screen readers only; each tr is a card; the first
       cell, when it has no data-label, is the card's title; every td[data-label] shows that label
       over its value, two to a line, and an empty one drops out; td.wide (a note) and td.actions
       (a wrapping row of buttons) take the full width. Links inside take the 44 px target.
       Inside a .card the rows are ruled list rows instead, so a card never holds cards. */
    table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.stack, table.stack tbody { display: block; width: 100%; }
    table.stack.card-table { background: none; border: 0; }
    table.stack tr {
        --row-top: 14px; position: relative;
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1rem; min-height: 64px; margin-bottom: 8px;
        padding: var(--row-top) 16px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    }
    table.stack td:first-child:not([data-label]), table.stack td.wide, table.stack td.actions, table.stack td[colspan] { grid-column: 1 / -1; }
    :is(.card, .public-card) table.stack tr { --row-top: 12px; min-height: 0; margin: 0; padding: var(--row-top) 0 12px; background: none; border: 0; border-top: 1px solid var(--line-soft); border-radius: 0; }
    :is(.card, .public-card) table.stack tbody tr:first-child { --row-top: 0px; border-top: 0; }
    /* A footer row (a report's total) is one more row, its empty cells dropped. */
    table.stack tfoot { display: block; }
    table.stack tfoot th { display: block; padding: 0; border: 0; text-align: left; color: var(--ink); font-size: inherit; }
    table.stack tfoot th:empty { display: none; }
    /* .num and :first-child are named so the desktop .line-table and .card-table cell rules give way. */
    /* A cell is a grid item: min-width 0 lets a long email wrap inside its column. */
    table.stack td, table.stack td.num, table.stack td:first-child { display: block; min-width: 0; padding: 0; border: 0; text-align: left; white-space: normal; }
    table.stack td[data-label]:empty { display: none; }
    table.stack td:first-child:not([data-label]) { font-size: 17px; font-weight: 600; }
    table.stack td:first-child:not([data-label]) a { text-decoration: none; color: var(--ink); }
    /* An archived or past row stays quiet, its title too. */
    table.stack tr:is(.archived, .past) td:first-child a { color: var(--muted); }
    table.stack td a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; }
    table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-small); color: var(--muted); margin-bottom: .1rem; }
    table.stack td.actions { display: flex; flex-wrap: wrap; gap: 0 .25rem; justify-content: flex-start; }
    table.stack td.actions form { margin: 0; }
    /* Row actions are quiet and close together, and a ghost's text lines up with the text above it;
       its padding still widens the 44 px target. */
    table.stack td.actions .btn-ghost { padding-inline: .6rem; }
    table.stack td.actions > .btn-ghost:first-child, table.stack td.actions > form:first-child > .btn-ghost { margin-left: -.6rem; }
    /* A lone action (Edit) rides at the top right, level with the title, rather than taking a line of
       its own. Across, it is placed in the row's content box (its grid columns); down, in the padding
       box, from --row-top. A linked title is 44 px tall, a plain one a text line: two offsets. */
    table.stack td.actions:has(> :only-child) { position: absolute; top: calc(var(--row-top) - 10px); right: -.6rem; }
    table.stack tr:has(> td:first-child > a) > td.actions:has(> :only-child) { top: var(--row-top); }
    table.stack tr:has(> td.actions > :only-child) > td:first-child { padding-right: 6.5rem; }

    /* The signed-in-as strip stays one slim line under the app bar, its button at the 44 px target.
       A long name gives way (ellipsis), never the button. */
    .founder-banner { flex-wrap: nowrap; padding: .25rem .75rem; min-height: 44px; font-size: var(--fs-small); }
    .founder-banner > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .founder-banner .btn { min-height: 44px; white-space: nowrap; }
    /* The phone strip has room for who, not where: the company shows on More, under the account. */
    .founder-banner-company { display: none; }

    /* LineTable's lines go to the client: on a phone each reads like a receipt, the description over
       "1 × $1,850.00" (muted) and the amount at the right, with no per-field captions. */
    table.stack.receipt-lines tr { grid-template-columns: max-content max-content 1fr; gap: .2rem .35rem; align-items: baseline; }
    table.stack.receipt-lines td[data-label]::before { content: none; }
    table.stack.receipt-lines td.num { color: var(--muted); }
    table.stack.receipt-lines td.unit::before { content: "× "; display: inline; margin: 0; }
    table.stack.receipt-lines td.amount { justify-self: end; color: var(--ink); font-weight: 600; }

    /* The line editor extends .stack (named in the selector to outrank it): lines are ruled rows
       in a two-column grid, description full width. */
    table.stack.line-editor tr {
        grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .75rem; padding: .75rem 0; margin-bottom: 0;
        background: none; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
    }
    .line-editor td.desc { grid-column: 1 / -1; }
    .line-editor td input:not([type=checkbox]), .line-editor td select { width: 100%; min-width: 0; text-align: left; box-sizing: border-box; }
    .line-editor td.remove { align-self: end; justify-self: end; }

    /* Job report: two photos a row, and each visit stacks its day over its times. */
    .job-report-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
    .job-report-visits li { grid-template-columns: 1fr auto; }
    .job-report-visits li > :first-child, .job-report-visits li > :last-child { grid-column: 1 / -1; }
}

/* --- routes (recurring services) --- */
.sub-nav { display: flex; flex-wrap: wrap; gap: .25rem; margin: -.5rem 0 1rem; }
.day-pick { display: inline-flex; gap: .5rem; align-items: center; }
.day-pick input[type=date] { width: auto; }
.route-count { display: flex; align-items: center; min-height: 44px; font-size: var(--fs-small); }
.route-mark { font-size: .7rem; vertical-align: middle; }
.badge-stop { white-space: nowrap; }
.stop-panel { border-left: 4px solid var(--primary); }
.next-dates { list-style: none; padding: 0; margin: .25rem 0 .75rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.next-dates li { padding: .15rem .55rem; border-radius: .8em; background: var(--well); font-size: var(--fs-small); }
fieldset.rule { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; margin: 0 0 1rem; min-width: 0; }
fieldset.rule legend { font-weight: 600; padding: 0 .25rem; }
.balance-line { font-weight: 700; margin-top: .5rem !important; }
.balance-line.is-due { color: var(--warn-ink); }
.balance-line.is-paid { color: var(--ok-ink); }
.tab-headline { font-size: 1.1rem; font-weight: 600; }
.stop-checklist { list-style: none; padding: 0; margin: .25rem 0; }
.stop-checklist li { padding: .2rem 0; }
.stop-checklist .check-undone { color: var(--warn-ink); }
.job-report-stops a { display: inline-flex; align-items: center; min-height: 44px; }

/* --- the job's flow (FlowStrip): numbered circles joined by a line, then the one next action --- */
.flow-card { border-top: 3px solid var(--primary); }
.flow { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .25rem; }
.flow-step { position: relative; display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center; min-width: 0; }
/* The line into each step from the one before, behind the circles; solid blue once the step before is done. */
.flow-step + .flow-step::before {
    content: ""; position: absolute; top: 13px; right: 50%; width: calc(100% + .25rem); height: 2px; background: var(--line);
}
.flow-step.done + .flow-step::before { background: var(--primary); }
.flow-dot {
    position: relative; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none;
    border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--muted);
    font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.flow-step.done .flow-dot { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.flow-step.current .flow-dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 3px var(--info-wash); }
.flow-step.warn .flow-dot { border-color: var(--warn); background: var(--warn-wash); color: var(--warn-ink); }
.flow-step.skipped .flow-dot { border-style: dashed; }
.flow-label { font-weight: 600; font-size: var(--fs-small); line-height: 1.25; }
.flow-step:is(.todo, .skipped) .flow-label { color: var(--muted); font-weight: 500; }
.flow-detail { font-size: var(--fs-smaller); color: var(--muted); line-height: 1.25; }
.flow-step.warn .flow-detail { color: var(--warn-ink); }
.flow-now { display: none; }
.flow-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.flow-actions > * { margin: 0; }
.flow-actions summary.btn { list-style: none; display: inline-flex; align-items: center; }
.flow-actions summary.btn::-webkit-details-marker { display: none; }
.flow-actions details[open] { flex-basis: 100%; }
.flow-also summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.flow-form { display: grid; gap: .5rem; margin-top: .75rem; max-width: 36rem; }
.flow-form > .btn { justify-self: start; }
.addons-pick { border: 0; padding: 0; margin: 0; display: grid; gap: .25rem; min-width: 0; }
.addons-pick legend { font-weight: 600; padding: 0; margin-bottom: .25rem; }
.flow-sent { margin-top: 1rem; border-top: 1px solid var(--line-soft); padding-top: .75rem; }
.flow-sent p { margin: 0 0 .5rem; }
/* Extra work: the billed lines read as a note; an unbilled extra's offer on a draft invoice. */
.extra-billed { margin: .25rem 0; color: var(--muted); }
.extra-offer { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line-soft); }
.extra-offer p { margin: 0; }
.project-card-next { margin-top: .35rem; font-size: var(--fs-small); }

/* A phone shows the circles and, under them, the one step in hand; the button and its forms take the full width. */
@media (max-width: 480px) {
    .flow { margin-bottom: .5rem; }
    .flow-label, .flow-detail { display: none; }
    .flow-now { display: block; margin: 0 0 1rem; }
    .flow-actions > :is(form, details, p) { flex: 1 1 100%; }
    .flow-actions .btn-primary, .flow-form > .btn { width: 100%; justify-self: stretch; }
}

/* Time: a pay period's steps, a timesheet's days, and the lists of fixes and approvals. */
.period-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; margin-bottom: 1rem; }
.period-nav .period-label { flex-basis: 100%; font-variant-numeric: tabular-nums; }
.period-jump { display: flex; flex-wrap: wrap; gap: .25rem; margin-left: auto; }
.timesheet-day .section-head h3 { margin: 0; }
.badge-row { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.badge-row:empty { display: none; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.fix-list li { overflow-wrap: anywhere; }
