/*
    The website's look: the Windows app's design system (docs/DESIGN_SYSTEM.md, "The website"), as CSS.
    The tokens are Foundation.xaml's; the two palettes are Palette.Light.xaml and Palette.Dark.xaml, value for value.
    A colour literal belongs in the palette blocks below and nowhere else (DesignTests checks both).
*/

/* ================= Foundation: sizes, type, weights, faces. No colour. ================= */
:root {
    /* Spacing: a 4px base unit */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius scales with the surface: controls md, panels lg */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    /* Type: body 14, the steps below it a pixel apart */
    --fs-micro: 11px;
    --fs-tiny: 12px;
    --fs-small: 13px;
    --fs-body: 14px;
    --fs-lead: 16px;
    --fs-title: 18px;
    --fs-figure: 22px;
    --fs-display-sm: 26px;
    --fs-display: 30px;
    --fs-page-title: 32px;
    --fs-stat: 30px;

    /* Weights: five, and no more */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* Windows' own faces, as in the app; elsewhere the phone's own */
    --ui-font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --display-font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Controls and targets */
    --control-sm: 32px;
    --control-md: 40px;
    --control-lg: 48px;
    --tap-min: 44px;
    --border-accent: 3px;

    /* Motion: only where it helps, never over 300ms, easing out (Foundation.xaml's) */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --motion-fast: 150ms;
    --motion-base: 200ms;

    /* Layout */
    --sidebar-width: 244px;
    --content-max: 1480px;
}

/* ================= Palettes ================= */
/* Light: Palette.Light.xaml. The default when the phone or PC isn't set to dark. */
:root,
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #F1F5F7;
    --panel: #FFFFFF;
    --panel-2: #F6F9FA;
    --line: #DAE3E7;
    --line-strong: #C3D0D6;
    --text: #15212A;
    --muted: #53616A;
    --faint: #5F6D76;
    --sidebar: #EAF2F5;
    --sidebar-text: #1B2C33;
    --sidebar-muted: #5A6D76;
    --sidebar-nav: #38535E;
    --sidebar-hover: #DDEAEF;
    --sidebar-active: #C9E6EF;
    --sidebar-active-text: #0B3A47;
    --sidebar-line: #19394A24;
    --primary: #0B7189;
    --primary-strong: #095E72;
    --primary-soft: #DDF1F6;
    --success: #24784D;
    --success-soft: #E1F4E9;
    --warning: #95630D;
    --warning-soft: #FFF2D8;
    --danger: #B54235;
    --danger-soft: #FEE9E6;
    --info: #3F5FB0;
    --info-soft: #E8EEFB;
    --violet: #6656A8;
    --on-primary: #FFFFFF;
    --paper: #FFFFFF;
    --on-accent: #FFFFFF;
    --danger-line: #CBA3A0;
    --danger-hover: #F1CBC6;
    --row-hover: #F2FAFC;
    --scrim: #0F151880;
    --focus-ring: #0B71898C;
    --brand-tile: #7AD3E6;
    --brand-tile-ink: #06323C;
}

/* Dark: Palette.Dark.xaml. When the phone or PC is set to dark, unless the moon/sun button picked light. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0F1518;
        --panel: #161E22;
        --panel-2: #1B252A;
        --line: #2A373D;
        --line-strong: #3D4D54;
        --text: #E6EEF1;
        --muted: #9DADB4;
        --faint: #84939A;
        --sidebar: #0A0F12;
        --sidebar-text: #D3E0E5;
        --sidebar-muted: #84979F;
        --sidebar-nav: #98AAB2;
        --sidebar-hover: #FFFFFF0D;
        --sidebar-active: #173B48;
        --sidebar-active-text: #FFFFFF;
        --sidebar-line: #FFFFFF17;
        --primary: #4CC2DA;
        --primary-strong: #7AD3E6;
        --primary-soft: #12343F;
        --success: #62D18E;
        --success-soft: #1A3928;
        --warning: #F0BB58;
        --warning-soft: #3D301B;
        --danger: #FF8174;
        --danger-soft: #422520;
        --info: #8AA8F5;
        --info-soft: #1E2A4A;
        --violet: #AA9BEF;
        --on-primary: #06262E;
        --paper: #FFFFFF;
        --on-accent: #FFFFFF;
        --danger-line: #7F5553;
        --danger-hover: #64362F;
        --row-hover: #152629;
        --scrim: #050A0CA6;
        --focus-ring: #4CC2DA8C;
        --brand-tile: #7AD3E6;
        --brand-tile-ink: #06323C;
    }
}

/* Dark, picked with the moon/sun button (remembered in a cookie). */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0F1518;
    --panel: #161E22;
    --panel-2: #1B252A;
    --line: #2A373D;
    --line-strong: #3D4D54;
    --text: #E6EEF1;
    --muted: #9DADB4;
    --faint: #84939A;
    --sidebar: #0A0F12;
    --sidebar-text: #D3E0E5;
    --sidebar-muted: #84979F;
    --sidebar-nav: #98AAB2;
    --sidebar-hover: #FFFFFF0D;
    --sidebar-active: #173B48;
    --sidebar-active-text: #FFFFFF;
    --sidebar-line: #FFFFFF17;
    --primary: #4CC2DA;
    --primary-strong: #7AD3E6;
    --primary-soft: #12343F;
    --success: #62D18E;
    --success-soft: #1A3928;
    --warning: #F0BB58;
    --warning-soft: #3D301B;
    --danger: #FF8174;
    --danger-soft: #422520;
    --info: #8AA8F5;
    --info-soft: #1E2A4A;
    --violet: #AA9BEF;
    --on-primary: #06262E;
    --paper: #FFFFFF;
    --on-accent: #FFFFFF;
    --danger-line: #7F5553;
    --danger-hover: #64362F;
    --row-hover: #152629;
    --scrim: #050A0CA6;
    --focus-ring: #4CC2DA8C;
    --brand-tile: #7AD3E6;
    --brand-tile-ink: #06323C;
}

/* ================= Base ================= */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--ui-font);
    font-size: var(--fs-body);
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p {
    margin: 0;
}

h1:focus {
    outline: none;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-strong);
    text-decoration: underline;
}

/* One ring for every focusable thing: 3px, 2px outside, keyboard focus only */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

svg.icon {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.center {
    text-align: center;
}

.muted {
    color: var(--muted);
}

/* Money or gallons at risk, and the good kind of different */
.bad { color: var(--danger); }
.good { color: var(--success); }
.warn { color: var(--warning); }

.blazor-error-boundary {
    background: var(--danger-soft);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
}

    .blazor-error-boundary::after {
        content: "Something went wrong.";
    }

/* ================= The shell: sidebar and page ================= */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.side {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    padding: 0 var(--space-3) var(--space-5);
    overflow-y: auto;
}

.side-top {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 72px;
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--sidebar-line);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    flex: 1;
    color: var(--sidebar-text);
}

    .brand:hover {
        color: var(--sidebar-text);
        text-decoration: none;
    }

.brand-tile {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: var(--radius-lg);
    background: var(--brand-tile);
    color: var(--brand-tile-ink);
    font-family: var(--display-font);
    font-size: var(--fs-title);
    font-weight: var(--weight-extrabold);
    display: grid;
    place-items: center;
}

.brand-name {
    display: block;
    font-weight: var(--weight-bold);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.brand-role {
    display: block;
    font-size: var(--fs-tiny);
    color: var(--sidebar-muted);
    margin-top: 2px;
}

/* The menu button is only on a phone */
.icon-btn.menu-button {
    display: none;
}

.side-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.nav {
    margin: var(--space-4) 0 var(--space-2);
    flex: 1;
}

.nav-group + .nav-group {
    border-top: 1px solid var(--sidebar-line);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
}

.nav-label {
    font-size: var(--fs-micro);
    font-weight: var(--weight-extrabold);
    color: var(--sidebar-muted);
    text-transform: uppercase;
    margin: 0 var(--space-3) var(--space-2);
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--control-md);
    padding: 0 var(--space-3);
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    color: var(--sidebar-nav);
    font-weight: var(--weight-bold);
}

    .nav a .icon {
        width: 20px;
        height: 20px;
    }

    /* How many wait on a page (Needs a look), at the item's far end */
    .nav a .badge {
        margin-left: auto;
    }

    .nav a:hover {
        background: var(--sidebar-hover);
        color: var(--sidebar-text);
        text-decoration: none;
    }

    /* The selected page's bar is the item's own left edge, so it bends with the rounded corners */
    .nav a.active {
        background: var(--sidebar-active);
        color: var(--sidebar-active-text);
        box-shadow: inset var(--border-accent) 0 0 var(--primary);
    }

.side-foot {
    padding: 0 0 0 var(--space-3);
}

.side-foot .badge {
    margin-bottom: var(--space-2);
}

.look-only {
    font-size: var(--fs-tiny);
    color: var(--sidebar-muted);
    margin: 0 0 var(--space-3);
}

.me {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.me-text {
    flex: 1;
    min-width: 0;
}

.me-name {
    font-weight: var(--weight-bold);
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.me-day {
    font-size: var(--fs-tiny);
    color: var(--sidebar-muted);
}

.me form {
    margin: 0;
    display: contents;
}

/* The moon shows on the light screen, the sun on the dark one */
.theme-switch .sun { display: none; }
:root[data-theme="dark"] .theme-switch .sun { display: block; }
:root[data-theme="dark"] .theme-switch .moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-switch .sun { display: block; }
    :root:not([data-theme="light"]) .theme-switch .moon { display: none; }
}

/* The page, centred so a wide screen doesn't leave all its space on the right */
.page {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-8) var(--space-8) var(--space-6);
}

/* ================= Page heading ================= */
.head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4) var(--space-6);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}

.head-text {
    min-width: 0;
    flex: 1 1 420px;
}

.overline-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--control-sm);
}

.overline {
    font-size: var(--fs-small);
    font-weight: var(--weight-extrabold);
    color: var(--primary);
    text-transform: uppercase;
}

.title {
    font-family: var(--display-font);
    font-size: var(--fs-page-title);
    font-weight: var(--weight-bold);
    line-height: 1.2;
    margin: var(--space-2) 0 var(--space-1);
    overflow-wrap: anywhere;
}

.lead {
    color: var(--muted);
    max-width: 720px;
}

.lead .badge {
    margin-left: var(--space-1);
}

.head-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ================= Buttons ================= */
/* The bare button is the secondary. Exactly one primary on a page. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-md);
    padding: 0 var(--space-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-weight: var(--weight-bold);
    white-space: nowrap;
    cursor: pointer;
}

    .btn:hover {
        border-color: var(--primary);
        background: var(--panel-2);
        color: var(--text);
        text-decoration: none;
    }

    .btn:active {
        transform: translateY(1px);
    }

    .btn.primary {
        background: var(--primary-strong);
        border-color: var(--primary-strong);
        color: var(--on-primary);
    }

        .btn.primary:hover {
            background: var(--primary);
            border-color: var(--primary);
        }

    /* Destructive: the danger soft fill, beside "Keep it" */
    .btn.danger {
        background: var(--danger-soft);
        border-color: var(--danger-line);
        color: var(--danger);
    }

        .btn.danger:hover {
            background: var(--danger-hover);
            border-color: var(--danger);
        }

    .btn.small {
        min-height: var(--control-sm);
        padding: 0 var(--space-3);
        font-size: var(--fs-small);
    }

    .btn.wide {
        width: 100%;
    }

/* Square, ghost, one icon */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: var(--control-sm);
    height: var(--control-sm);
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--sidebar-nav);
    cursor: pointer;
}

    .icon-btn:hover {
        background: var(--sidebar-hover);
        border-color: var(--sidebar-line);
        color: var(--sidebar-text);
    }

/* A day or a month, with arrows on each side */
.stepper {
    display: inline-flex;
    align-items: stretch;
    min-height: var(--tap-min);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel);
    overflow: hidden;
}

    .stepper a, .stepper .off {
        display: grid;
        place-items: center;
        width: var(--tap-min);
        color: var(--text);
    }

    .stepper a:hover {
        background: var(--panel-2);
        color: var(--primary);
    }

    .stepper .off {
        color: var(--line-strong);
    }

    .stepper strong {
        display: grid;
        place-items: center;
        min-width: 150px;
        padding: 0 var(--space-3);
        border-left: 1px solid var(--line);
        border-right: 1px solid var(--line);
        white-space: nowrap;
    }

/* ================= Fields ================= */
.form {
    display: grid;
    gap: var(--space-4);
}

.field {
    display: grid;
    gap: var(--space-2);
}

    /* Hidden till its choice is picked (data-show-when, site.js) */
    .field[hidden] {
        display: none;
    }

.field-label {
    font-size: var(--fs-small);
    font-weight: var(--weight-bold);
    color: var(--muted);
}

input, select {
    font: inherit;
    font-size: var(--fs-body);
    min-height: var(--tap-min);
    width: 100%;
    padding: 0 var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel-2);
    color: var(--text);
}

    input:hover, select:hover {
        border-color: var(--muted);
    }

    input:focus, select:focus {
        outline: 3px solid var(--focus-ring);
        outline-offset: 2px;
        border-color: var(--primary);
    }

    input::placeholder {
        color: var(--faint);
    }

select {
    cursor: pointer;
    appearance: none;
    padding-right: 36px;
}

/* A list to pick from: the arrow on the right, as in the Windows app */
.select-box {
    position: relative;
    display: block;
}

    .select-box .icon {
        position: absolute;
        right: var(--space-3);
        top: 50%;
        transform: translateY(-50%);
        color: var(--muted);
        pointer-events: none;
    }

/* A pick list whose choices can hold more choices, as in the Windows app (PayDayPicker: Every week opens Monday to
   Sunday beside it). The box looks like a field; the menu opens under it, and a choice with more opens to the right, or
   to the left with no room there */
.choice-menu {
    position: relative;
}

.choice-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    min-height: var(--tap-min);
    padding: 0 var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-body);
    text-align: left;
    cursor: pointer;
}

    .choice-box:hover {
        border-color: var(--muted);
    }

    .choice-box:focus-visible {
        outline: 3px solid var(--focus-ring);
        outline-offset: 2px;
        border-color: var(--primary);
    }

    .choice-box .icon {
        color: var(--muted);
    }

.choice-list {
    position: absolute;
    z-index: 70;
    top: calc(100% + var(--space-1));
    left: 0;
    min-width: 100%;
    display: grid;
    padding: var(--space-1);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px var(--scrim);
}

    .choice-list[hidden] {
        display: none;
    }

    .choice-list button {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-4);
        width: 100%;
        min-height: var(--control-sm);
        padding: 0 var(--space-3);
        border: 0;
        border-radius: var(--radius-sm);
        background: none;
        color: var(--text);
        font: inherit;
        font-size: var(--fs-body);
        text-align: left;
        white-space: nowrap;
        cursor: pointer;
    }

        .choice-list button:hover, .choice-list button:focus-visible, .choice-list button[aria-expanded="true"] {
            background: var(--row-hover);
            outline: none;
        }

        .choice-list button.picked {
            color: var(--primary);
            font-weight: var(--weight-semibold);
        }

.choice-hint {
    color: var(--muted);
    font-size: var(--fs-small);
}

.choice-more {
    position: relative;
}

    .choice-list.sub {
        top: calc(-1 * var(--space-1));
        left: calc(100% + var(--space-1));
        min-width: 160px;
    }

        .choice-list.sub.left {
            left: auto;
            right: calc(100% + var(--space-1));
        }

/* A button beside fields is as tall as they are */
.tools form .btn {
    min-height: var(--tap-min);
}

/* A search field: room on the left for the magnifier */
.search-box {
    position: relative;
}

    .search-box .icon {
        position: absolute;
        left: var(--space-3);
        top: 50%;
        transform: translateY(-50%);
        color: var(--faint);
        pointer-events: none;
    }

    .search-box input {
        padding-left: 36px;
    }

.validation-message {
    color: var(--danger);
    font-size: var(--fs-tiny);
}

/* What a form or page says back, inside it */
.message {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
}

    .message.warn {
        background: var(--warning-soft);
        color: var(--warning);
        margin-bottom: var(--space-6);
    }

/* A form's fields, two or three across, each with its label above and a short line under it */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    align-items: start;
}

    .form-grid.three {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

.helper {
    font-size: var(--fs-tiny);
    color: var(--muted);
}

/* The code that connects a tablet: big, spaced out, easy to copy by eye */
/* The owner's setup steps (Setup.razor): numbered steps along the top, those done ticked, the one shown filled; on a
   phone only the numbers */
.setup-steps {
    display: flex;
    gap: var(--space-2);
    margin: 0 0 var(--space-5);
    padding: 0;
    list-style: none;
    overflow-x: auto;
}

    .setup-steps li {
        flex: 1 1 0;
        min-width: 0;
    }

.setup-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

    /* Each step's name under its number, so seven fit beside the menu without cutting their names short */
    .setup-steps a, .setup-steps .setup-step {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-2) var(--space-1);
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        background: var(--panel);
        color: var(--muted);
        font-size: var(--fs-small);
        font-weight: var(--weight-bold);
        text-decoration: none;
        white-space: nowrap;
    }

        .setup-steps a:hover {
            border-color: var(--primary);
            color: var(--text);
        }

    .setup-steps li.on a, .setup-steps li.on .setup-step {
        border-color: var(--primary);
        background: var(--primary-soft);
        color: var(--text);
    }

    .setup-steps li.done a {
        color: var(--text);
    }

.setup-num {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    font-variant-numeric: tabular-nums;
}

    .setup-steps li.on .setup-num {
        border-color: var(--primary);
        background: var(--primary);
        color: var(--on-primary);
    }

    .setup-steps li.done .setup-num {
        border-color: var(--success);
        background: var(--success);
        color: var(--on-primary);
    }

.setup-panel .panel-title {
    margin-bottom: var(--space-2);
}

.setup-panel > .muted {
    margin-bottom: var(--space-4);
}

/* What setup still needs, on its last step: each a link to the step that asks for it */
.setup-missing {
    margin: var(--space-2) 0 0;
    padding-left: var(--space-5);
}

    .setup-missing li + li {
        margin-top: var(--space-1);
    }

/* A station not set up yet: the setup steps alone, under a bar with its name and Sign out, no menu */
.setup-shell {
    min-height: 100vh;
}

.setup-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-6);
    background: var(--sidebar);
    color: var(--sidebar-text);
    border-bottom: 1px solid var(--sidebar-line);
}

    .setup-bar .brand-name {
        font-weight: var(--weight-bold);
    }

    /* The name gives way first (two lines at most, then cut short), so the bar never runs past a phone's screen */
    .setup-bar .brand {
        flex: 0 1 auto;
    }

    .setup-bar .me {
        flex: none;
    }

.panel-subtitle {
    font-size: var(--fs-body);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-3);
}

.setup-add {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
}

/* Short numbers, one to a line: the label and its ?, then a small box, the boxes lined up (Setup's gallons and days) */
.setup-rows {
    display: grid;
    grid-template-columns: max-content 8rem;
    justify-content: start;
    gap: var(--space-3) var(--space-5);
}

    .setup-row {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        align-items: center;
    }

        .setup-row label {
            font-weight: var(--weight-bold);
        }

/* Who's on the staff so far: a short list, each name with its job right beside it */
.table.setup-people {
    width: auto;
    margin-bottom: var(--space-2);
}

    .setup-people th:first-child, .setup-people td:first-child {
        min-width: 12rem;
    }

    .setup-people td:first-child {
        font-weight: var(--weight-bold);
    }

/* Remove a row: a quiet x that turns red when pointed at */
.row-remove {
    color: var(--muted);
}

    .row-remove:hover {
        color: var(--danger);
        background: var(--danger-soft);
        border-color: var(--danger-line);
    }

/* Not on screen: words for a screen reader, and a form's first button, there so Enter saves */
.visually-hidden, .default-submit {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* A line on its own under a grid of fields */
.form-grid + .helper {
    display: block;
    margin-top: var(--space-4);
}

/* A small circled ? beside a label (Help.razor). Its line shows above the field, from its left edge, when the ? is
   pointed at, tapped or tabbed to. */
.help {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    margin-left: var(--space-1);
    border: 1.5px solid currentColor;
    border-radius: 50%;
    color: var(--muted);
    font-size: var(--fs-micro);
    font-weight: var(--weight-extrabold);
    line-height: 1;
    vertical-align: 1px;
    text-transform: none;
    cursor: help;
}

    .help:hover, .help:focus-visible {
        color: var(--primary);
    }

    .help:focus {
        outline: none;
    }

    .help:focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }

:where(.field, .setup-row, .check-field, th):has(> .help, > * > .help) {
    position: relative;
}

.help-tip {
    position: absolute;
    left: 0;
    bottom: calc(100% + var(--space-2));
    z-index: 30;
    width: max-content;
    max-width: min(320px, calc(100vw - 2 * var(--space-5)));
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel);
    box-shadow: 0 8px 24px var(--scrim);
    color: var(--text);
    font-size: var(--fs-small);
    font-weight: var(--weight-regular);
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transform: translateY(2px);
    transition: opacity 120ms ease-out, transform 120ms ease-out, visibility 0s 120ms;
    pointer-events: none;
}

    .help:hover .help-tip, .help:focus .help-tip {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: opacity 120ms ease-out, transform 120ms ease-out;
    }

@media (prefers-reduced-motion: reduce) {
    .help-tip {
        transform: none;
    }
}

.tablet-code {
    margin: var(--space-2) 0 var(--space-3);
    font-size: var(--fs-display-sm);
    font-weight: var(--weight-extrabold);
    letter-spacing: 0.12em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* A field, or what the form says, on its own row after a grid of fields */
.form-grid + .field, .form-grid + .message {
    margin-top: var(--space-4);
}

input.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

/* The bottom of a form: what it said back on the left, its buttons on the right, the save last */
.form-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-5);
}

    .form-foot .message, .form-foot .saved, .form-foot .helper {
        order: -2;
        margin: 0 auto 0 0;
    }

    /* A button that comes before the save on screen, though after it in the form (so Enter saves) */
    .form-foot .before {
        order: -1;
    }

.table-panel > .form-foot {
    margin: 0;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--line);
}

/* ================= Popup ================= */
/* Something new, over the page, as in the Windows app: the page dims and the card fades in at the middle, growing from
   96% (MotionPanel). Its top stays put, so a card that grows (a problem under its buttons) grows downward. */
.popup-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    justify-items: center;
    align-items: start;
    padding: max(6vh, var(--space-6)) var(--space-4) var(--space-6);
    background: var(--scrim);
    overflow-y: auto;
    animation: popup-dim var(--motion-base) var(--ease-out);
}

.popup {
    width: min(600px, 100%);
    padding: var(--space-5) var(--space-6) var(--space-6);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 48px var(--scrim);
    transform-origin: top center;
    animation: popup-in 240ms var(--ease-out);
}

    .popup.wide {
        width: min(820px, 100%);
    }

.popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.popup-title {
    font-size: var(--fs-title);
    font-weight: var(--weight-bold);
}

.popup-lead {
    margin-top: var(--space-1);
    font-size: var(--fs-small);
    color: var(--muted);
}

/* The page under a popup stays where it is */
body:has(.popup-backdrop) {
    overflow: hidden;
}

@keyframes popup-dim {
    from { opacity: 0; }
}

@keyframes popup-in {
    from { opacity: 0; transform: scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
    .popup-backdrop, .popup {
        animation: popup-dim 100ms linear;
    }
}

/* Who a payment is from, at the top of its popup, with Change */
.pay-who {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--panel-2, var(--bg));
}

    .pay-who strong {
        display: block;
        font-size: var(--fs-lead);
    }

/* "Full balance" under the amount, filling it in */
.fill-btn {
    justify-self: start;
    margin-top: var(--space-1);
}

.pays-what {
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}

/* What a payment will pay, oldest delivery first, inside its popup */
.pays-list {
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line);
}

    .pays-list li {
        display: flex;
        justify-content: space-between;
        gap: var(--space-3);
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--line);
        font-size: var(--fs-small);
    }

.pays-note {
    margin-top: var(--space-3);
    font-weight: var(--weight-semibold);
}

/* A tick box with its words beside it, on its own row in a form */
.check-field {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
    font-weight: var(--weight-medium);
    cursor: pointer;
}

.popup form > .field {
    margin-top: var(--space-4);
}

.popup .message.warn {
    margin-top: var(--space-4);
}

    .popup .message.warn a {
        color: inherit;
        text-decoration: underline;
    }

/* A second row of fields under the first, in a popup */
.form-grid.spaced {
    margin-top: var(--space-4);
}

/* The station's logo in its tile: the picture fills it, on a plain background so any logo reads */
.brand-tile.has-logo {
    background: var(--paper);
    padding: 2px;
    overflow: hidden;
}

    .brand-tile img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: calc(var(--radius-lg) - 2px);
    }

.logo-field {
    display: grid;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.logo-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.check-field.inline {
    margin-top: 0;
}

/* Tick boxes side by side under one label (the payment methods the station takes) */
.check-group {
    border: 0;
    padding: 0;
    margin: var(--space-5) 0 0;
    min-width: 0;
}

    .check-group legend {
        padding: 0;
        margin-bottom: var(--space-2);
    }

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
}

/* Buttons under an empty list, to start it */
.empty-action {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    padding: 0 var(--space-5) var(--space-6);
}

/* A popup's sale: who and how, then its items and payments */
.sale-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-4);
}

.table.compact td, .table.compact th {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
}

.table tr.total td {
    font-weight: var(--weight-bold);
    border-top: 1px solid var(--line-strong);
}

.paid-line {
    display: block;
}

.pre-line {
    white-space: pre-line;
}

.edit-table.spaced, .popup .table {
    margin-top: var(--space-4);
}

.void-form {
    margin-top: var(--space-4);
}

/* A picture or file to pick, as a button */
.file-pick {
    margin-top: var(--space-2);
    cursor: pointer;
}

.popup textarea {
    width: 100%;
    font-family: ui-monospace, Consolas, monospace;
    font-size: var(--fs-small);
}

.import-preview {
    max-height: 320px;
    overflow: auto;
    margin-top: var(--space-2);
}

/* Reports: the downloads a line each */
.downloads {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
}

/* Sales a day as bars */
.bar-chart {
    margin: 0;
}

    .bar-chart svg {
        display: block;
        width: 100%;
        height: 140px;
    }

    .bar-chart rect {
        fill: var(--primary);
        opacity: 0.85;
    }

        .bar-chart rect.today {
            fill: var(--accent-strong, var(--primary-strong));
            opacity: 1;
        }


.bar-chart-top, .bar-chart-axis {
    display: flex;
    justify-content: space-between;
    font-size: var(--fs-tiny);
    color: var(--muted);
}

.bar-chart-top {
    margin-bottom: var(--space-2);
}

.bar-chart-axis {
    margin-top: var(--space-1);
}

/* A chart answers a pointer at once (site.js, data-chart): the column or part pointed at stays, the rest dim, and its
   tip shows beside the pointer. Instant, like any hover. The unseen .hit columns are what the pointer finds. */
[data-chart] {
    border-radius: var(--radius-md);
}

[data-chart] rect.hit {
    opacity: 0;
}

[data-chart][data-on] rect:not(.on):not(.hit) {
    opacity: 0.35;
}

[data-chart] rect.on:not(.hit) {
    opacity: 1;
}

[data-chart][data-on] .donut-part:not(.on) {
    opacity: 0.3;
}

[data-chart][data-on] .donut-key li:not(.on) > * {
    opacity: 0.45;
}

.donut-key li {
    cursor: default;
}

.column-labels span.on {
    color: var(--text);
    font-weight: var(--weight-bold);
}

.chart-tip {
    position: fixed;
    z-index: 90;
    max-width: 280px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--panel);
    color: var(--text);
    font-size: var(--fs-small);
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 8px 24px var(--scrim);
    pointer-events: none;
}

    .chart-tip strong {
        font-weight: var(--weight-bold);
    }

/* Bars with a name under each (ColumnChart): two side by side are sales (primary) and expenses (violet) */
.column-chart rect.a {
    fill: var(--primary);
}

.column-chart rect.b {
    fill: var(--violet);
}

.column-chart rect.now, .column-chart rect.today {
    opacity: 1;
}

.column-labels {
    display: grid;
    grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
    margin-top: var(--space-1);
    font-size: var(--fs-tiny);
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
}

.chart-keys {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

/* A colour in a chart's key: a small rounded square */
.chart-key {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--primary);
}

    .chart-key.b { background: var(--violet); }
    .chart-key.s0 { background: var(--primary); }
    .chart-key.s1 { background: var(--info); }
    .chart-key.s2 { background: var(--violet); }
    .chart-key.s3 { background: var(--success); }
    .chart-key.s4 { background: var(--warning); }
    .chart-key.s5 { background: var(--danger-line); }
    .chart-key.other { background: var(--line-strong); }

/* Two charts side by side, one under the other on a phone */
.chart-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.chart-title {
    font-size: var(--fs-body);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-3);
}

.chart-section {
    margin-bottom: var(--space-4);
}

.chart-foot {
    margin-top: var(--space-3);
    font-size: var(--fs-small);
    color: var(--muted);
}

/* A chart at the top of a table's panel, over its rows */
.chart-panel {
    padding: var(--space-5);
    border-bottom: 1px solid var(--line);
}

/* Parts of a whole (DonutChart): the ring with the total in its middle, the key beside it */
.donut {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    flex-wrap: wrap;
    margin: 0;
}

.donut-ring {
    position: relative;
    width: 168px;
    height: 168px;
    flex: none;
}

    .donut-ring svg {
        display: block;
        width: 100%;
        height: 100%;
    }

.donut-track {
    fill: none;
    stroke: var(--panel-2);
    stroke-width: 6;
}

.donut-part {
    fill: none;
    stroke-width: 6;
}

    .donut-part.s0 { stroke: var(--primary); }
    .donut-part.s1 { stroke: var(--info); }
    .donut-part.s2 { stroke: var(--violet); }
    .donut-part.s3 { stroke: var(--success); }
    .donut-part.s4 { stroke: var(--warning); }
    .donut-part.s5 { stroke: var(--danger-line); }
    .donut-part.other { stroke: var(--line-strong); }

/* Over the ring but not in the pointer's way: the parts under it are what it points at */
.donut-middle {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    pointer-events: none;
}

    .donut-middle strong {
        font-family: var(--display-font);
        font-size: var(--fs-lead);
        font-variant-numeric: tabular-nums;
    }

    .donut-middle span {
        font-size: var(--fs-tiny);
        color: var(--muted);
    }

.donut-key {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 240px;
}

    .donut-key li {
        display: contents;
    }

.donut-amount, .donut-share {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.donut-amount {
    font-weight: var(--weight-bold);
}

.donut-share {
    color: var(--muted);
    font-size: var(--fs-small);
}

/* A month, week or day to show, in a page heading: as tall as the buttons beside it and dressed like one, no label */
.head-pick {
    display: flex;
    align-items: center;
}

    .head-pick select, .head-pick input {
        width: auto;
        min-height: var(--control-md);
        background: var(--panel);
        font-weight: var(--weight-bold);
    }

    .head-pick select:hover, .head-pick input:hover {
        border-color: var(--primary);
        background: var(--panel-2);
    }

/* Utang by age: four figures, each opening its list */
.ageing {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

    .ageing .age {
        display: grid;
        gap: 2px;
        padding: var(--space-3) var(--space-4);
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        background: var(--panel);
        color: var(--text);
        text-decoration: none;
    }

        .ageing .age:hover {
            background: var(--row-hover);
        }

        .ageing .age.on {
            box-shadow: inset 0 0 0 2px var(--primary);
        }

        .ageing .age.bad strong {
            color: var(--danger);
        }

.age-label {
    font-size: var(--fs-tiny);
    color: var(--muted);
}

@media (max-width: 720px) {
    .chart-pair {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The setup steps on a phone: numbers only (the step's own title says which it is) */
    .setup-steps .setup-name {
        display: none;
    }

    .setup-steps a {
        justify-content: center;
    }

    /* The setup's bar on a phone: the station, the theme and Sign out (who's signed in is on the Dashboard later) */
    .setup-bar {
        padding-inline: var(--space-4);
    }

        .setup-bar .me-text {
            display: none;
        }

    /* The gallons and days: a label that wraps, and the box beside it */
    .setup-rows {
        grid-template-columns: minmax(0, 1fr) 6rem;
        justify-content: stretch;
    }

    .ageing {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* A heading that sorts its column */
.table th a.sort {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

    .table th a.sort:hover, .table th a.sort.on {
        color: var(--text);
    }

.sort-mark {
    font-size: var(--fs-micro);
}

/* ================= Rows that open ================= */
/* A row with a name to open opens from anywhere on it (site.js), so it shows it can be clicked */
.table tbody tr:has(a.cell-title), [data-row]:has(a[data-row-link]) {
    cursor: pointer;
}

.todo li[data-row]:hover {
    background: var(--row-hover);
}

.todo li[data-row] {
    margin: 0 calc(-1 * var(--space-3));
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    border-radius: var(--radius-sm);
}

/* A date to pick beside a list's other filters (Sales, End of day's day, Expenses' month) */
.date-pick input {
    min-width: 150px;
}

/* While the next page comes: a thin bar along the top that runs most of the way, then fills and fades (site.js) */
.loading-bar {
    position: fixed;
    inset: 0 auto auto 0;
    z-index: 100;
    width: 0;
    height: 3px;
    background: var(--primary);
    pointer-events: none;
}

.loading-bar.going {
    animation: loading-go 2.5s cubic-bezier(0.1, 0.6, 0.2, 1) 60ms forwards;
}

.loading-bar.done {
    width: 100%;
    opacity: 0;
    animation: none;
    transition: width var(--motion-fast) var(--ease-out), opacity 250ms var(--ease-out) 100ms;
}

@keyframes loading-go {
    from { width: 0; }
    to { width: 85%; }
}

@media (prefers-reduced-motion: reduce) {
    .loading-bar.going {
        animation: none;
        width: 100%;
        opacity: 0.6;
    }
}

/* Saved: rises in, stays six seconds, fades out (NoticeHost in the Windows app) */
.saved {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--success-soft);
    color: var(--success);
    font-weight: var(--weight-bold);
    animation: saved-in var(--motion-base) var(--ease-out), saved-out var(--motion-fast) var(--ease-out) 6s forwards;
}

@keyframes saved-in {
    from { opacity: 0; transform: translateY(4px); }
}

@keyframes saved-out {
    to { opacity: 0; transform: translateY(4px); visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .saved {
        animation: saved-out 100ms linear 6s forwards;
    }
}

/* A table whose cells are fields (the price list): rows keep one height, the fields are compact */
.edit-table td {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
}

.edit-table input, .edit-table select {
    min-height: var(--control-sm);
    padding: 0 var(--space-2);
    font-size: var(--fs-small);
}

.edit-table select {
    padding-right: var(--space-8);
}

/* Prices take the room a price needs; the name takes the rest */
.edit-table td.num {
    width: 120px;
}

.edit-table td.center {
    width: 96px;
}

.edit-table .select-box .icon {
    right: var(--space-2);
}

/* ================= Stat cards ================= */
/* Four across, like the Windows app; three when a page has three or six */
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

    .stats:has(> :nth-child(3):last-child),
    .stats:has(> :nth-child(5):last-child),
    .stats:has(> :nth-child(6):last-child) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats:has(> :nth-child(2):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

/* A number, its label, a one-line note. The rail (the card's own left edge) is a claim about the number. */
.stat {
    position: relative;
    display: block;
    min-height: 124px;
    padding: var(--space-5);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: inset var(--border-accent) 0 0 var(--rail, var(--primary));
    color: var(--text);
}

    .stat.neutral { --rail: var(--info); }
    .stat.good { --rail: var(--success); }
    .stat.warn { --rail: var(--warning); }
    .stat.bad { --rail: var(--danger); }

    /* A card that opens its list: a small arrow in the corner, the border primary under the mouse */
    a.stat:hover {
        border-color: var(--primary);
        color: var(--text);
        text-decoration: none;
    }

    a.stat:active {
        background: var(--panel-2);
    }

.stat-go {
    position: absolute;
    top: 22px;
    right: var(--space-5);
    width: 12px;
    height: 12px;
    color: var(--faint);
}

a.stat:hover .stat-go {
    color: var(--primary);
}

.stat-label {
    font-size: var(--fs-tiny);
    font-weight: var(--weight-extrabold);
    color: var(--muted);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.stat .stat-label {
    padding-right: var(--space-5);
}

.stat-value {
    font-family: var(--display-font);
    font-size: var(--fs-stat);
    font-weight: var(--weight-bold);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    margin: var(--space-3) 0 var(--space-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    /* Words in the number's place ("Not counted") are a little smaller */
    .stat-value.words {
        font-size: var(--fs-display-sm);
    }

.stat-note {
    font-size: var(--fs-tiny);
    color: var(--muted);
}

/* ================= Tabs ================= */
/* The sections of a page, one at a time. The same weight picked or not, so the names never shift. */
.tabs {
    display: flex;
    gap: var(--space-6);
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--space-5);
    overflow-x: auto;
    scrollbar-width: none;
}

    .tabs a {
        flex: none;
        display: flex;
        align-items: center;
        gap: var(--space-2);
        min-height: var(--tap-min);
        color: var(--muted);
        font-weight: var(--weight-semibold);
        box-shadow: inset 0 calc(-1 * var(--border-accent)) 0 transparent;
        white-space: nowrap;
    }

        .tabs a:hover {
            color: var(--text);
            text-decoration: none;
        }

        .tabs a.on {
            color: var(--text);
            box-shadow: inset 0 calc(-1 * var(--border-accent)) 0 var(--primary);
        }

.tab-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 var(--space-1);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    color: var(--muted);
    font-size: var(--fs-micro);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
}

.tabs a.on .tab-count {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ================= Panels ================= */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

/* A panel of facts or fields, kept to a width the eye can follow across */
.panel.readable {
    max-width: 720px;
}

.panel + .panel, .panel + .table-panel, .table-panel + .panel, .table-panel + .table-panel {
    margin-top: var(--space-3);
}

/* A smaller heading inside a setup step (who signs in on the device just added) */
.setup-sub {
    font-size: var(--fs-lead);
    font-weight: var(--weight-bold);
    margin: var(--space-5) 0 var(--space-3);
}

/* A heading over a group of panels, with its action (POS devices on Users, each device its own panel) */
.section-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin: var(--space-6) 0 var(--space-3);
}

.section-title {
    font-size: var(--fs-title);
    font-weight: var(--weight-bold);
}

/* A form under a panel's line of text (the owner PIN on Users): room between them */
.panel > .muted + form {
    margin-top: var(--space-4);
}

/* Several buttons in a panel's tools bar, after its count */
.tools-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

    .tools-buttons form.tools-action {
        flex: none;
    }

/* A form that's only a small button (Get a code) is the size of the small links beside it, not of a field */
.tools form.tools-action .btn.small {
    min-height: var(--control-sm);
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.panel-title {
    font-size: var(--fs-title);
    font-weight: var(--weight-bold);
}

.panel-meta {
    font-size: var(--fs-tiny);
    color: var(--muted);
}

/* Two panels side by side (End of day's count) */
.columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    align-items: start;
}

    .columns > .panel + .panel {
        margin-top: 0;
    }

/* A handful of facts, label left and value right, with a rule between them */
.facts {
    margin: 0;
}

    .facts > div {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: var(--space-4);
        padding: var(--space-3) 0;
        border-bottom: 1px solid var(--line);
    }

        .facts > div:last-child {
            border-bottom: 0;
        }

    .facts dt {
        color: var(--muted);
    }

    /* A short line under a fact's label: what the setting does */
    .facts .fact-help {
        display: block;
        font-size: var(--fs-tiny);
        color: var(--muted);
        margin-top: 2px;
    }

    .facts dd {
        margin: 0;
        font-weight: var(--weight-bold);
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .facts .total {
        border-top: 1px solid var(--line-strong);
    }

        .facts .total dt {
            color: var(--text);
            font-weight: var(--weight-bold);
        }

        .facts .total dd {
            font-family: var(--display-font);
            font-size: var(--fs-figure);
        }

    .facts .count {
        font-size: var(--fs-tiny);
        color: var(--muted);
        margin-left: var(--space-2);
    }

/* ================= Tables ================= */
/* A panel with no padding, so the tools bar and the table meet its edges */
/* A table wider than its panel (a narrow window) scrolls sideways rather than losing its last columns */
.table-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    padding-bottom: var(--space-1);
}

.tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-4) var(--space-5);
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
}

.tools form {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin: 0;
    flex: 1 1 480px;
}

    /* A form that's only a button (Add a tablet): its own size, after the count */
    .tools form.tools-action {
        flex: none;
    }

    .tools form .field {
        flex: 0 1 200px;
    }

        .tools form .field.grow {
            flex: 1 1 260px;
            max-width: 360px;
        }

.tools-title {
    font-size: var(--fs-title);
    font-weight: var(--weight-bold);
}

.tools-sum {
    text-align: right;
    margin-left: auto;
}

    .tools-sum strong {
        display: block;
    }

    .tools-sum span {
        font-size: var(--fs-tiny);
        color: var(--muted);
    }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-small);
}

    /* Column headers: uppercase micro text on the second surface */
    .table th {
        padding: var(--space-3) var(--space-4);
        background: var(--panel-2);
        border-bottom: 1px solid var(--line-strong);
        color: var(--muted);
        font-size: var(--fs-micro);
        font-weight: var(--weight-bold);
        text-transform: uppercase;
        text-align: left;
        white-space: nowrap;
    }

    .table td {
        padding: var(--space-3) var(--space-4);
        border-bottom: 1px solid var(--line);
        vertical-align: middle;
    }

    .table tbody tr:last-child td {
        border-bottom: 0;
    }

    .table tbody tr:hover {
        background: var(--row-hover);
    }

    .table th.num, .table td.num {
        text-align: right;
    }

    .table th.center, .table td.center {
        text-align: center;
    }

    .table tr.cancelled td {
        opacity: 0.55;
    }

    /* A total row, and a row that starts a group (Cost per gallon) */
    .table tr.total td {
        font-weight: var(--weight-bold);
        border-top: 1px solid var(--line-strong);
    }

    .table tr.group td {
        padding-top: var(--space-5);
        background: var(--panel);
        color: var(--muted);
        font-size: var(--fs-micro);
        font-weight: var(--weight-bold);
        text-transform: uppercase;
    }

    .table td.indent {
        padding-left: var(--space-8);
        color: var(--muted);
    }

    .table tr.big td {
        font-size: var(--fs-body);
    }

/* A cell with a name on top and a line under it */
.cell-title {
    display: block;
    font-weight: var(--weight-bold);
    color: var(--text);
}

a.cell-title {
    color: var(--primary);
}

.cell-title.bad { color: var(--danger); }
.cell-sub.warn { color: var(--warning); }
.cell-sub.bad { color: var(--danger); }

.cell-sub {
    display: block;
    font-size: var(--fs-tiny);
    color: var(--muted);
    margin-top: 2px;
}

/* Initials in a soft circle: the identity cell of a customer row */
.who {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.avatar {
    width: var(--control-sm);
    height: var(--control-sm);
    flex: none;
    border-radius: var(--radius-pill);
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: var(--fs-micro);
    font-weight: var(--weight-extrabold);
}

/* ================= Badges ================= */
/* States a status, never acts. A rounded square, not a pill. */
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    color: var(--muted);
    font-size: var(--fs-micro);
    font-weight: var(--weight-bold);
    white-space: nowrap;
    vertical-align: middle;
}

    .badge.accent { background: var(--primary-soft); color: var(--primary); }
    .badge.good { background: var(--success-soft); color: var(--success); }
    .badge.warn { background: var(--warning-soft); color: var(--warning); }
    .badge.bad { background: var(--danger-soft); color: var(--danger); }
    .badge.info { background: var(--info-soft); color: var(--info); }

    /* A count in front of a sentence ("17 sukis are due") */
    .badge.count {
        justify-content: center;
        min-width: var(--space-10);
        min-height: 28px;
        font-size: var(--fs-small);
        font-weight: var(--weight-extrabold);
        font-variant-numeric: tabular-nums;
    }

/* ================= To do ================= */
/* What needs the owner, a line each: how many, what, and a button to the page that shows them */
.todo {
    list-style: none;
    margin: calc(-1 * var(--space-2)) 0;
    padding: 0;
}

    .todo li {
        display: flex;
        align-items: center;
        gap: var(--space-4);
        padding: var(--space-3) 0;
        border-bottom: 1px solid var(--line);
    }

        .todo li:last-child {
            border-bottom: 0;
        }

.todo-text {
    flex: 1;
    min-width: 0;
    font-weight: var(--weight-medium);
}

/* Ask first: a warning block in the page, with "Keep it" and the danger button last */
/* A question before something that can't be taken back (Disable, Remove, Undo): over the page, in the middle of the
   screen wherever it's scrolled to, the page dimmed behind it, like a popup; Cancel or Esc goes back to the page */
.confirm {
    position: fixed;
    z-index: 60;
    top: max(20vh, var(--space-8));
    left: 0;
    right: 0;
    margin: 0 auto;
    width: min(520px, calc(100vw - 2 * var(--space-4)));
    display: grid;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6);
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 0 100vmax var(--scrim), 0 18px 48px var(--scrim);
    font-weight: var(--weight-semibold);
    animation: popup-in 240ms var(--ease-out);
}

body:has(.confirm) {
    overflow: hidden;
}

.confirm-buttons {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* What the page says back after an action, under its tabs */
.page-result {
    margin-bottom: var(--space-4);
}

.pay-card {
    margin-bottom: var(--space-4);
}

.table td.actions {
    white-space: nowrap;
}

    .table td.actions .btn + .btn {
        margin-left: var(--space-2);
    }

/* ================= Days worked ================= */
/* A week a row each: a filled day was worked, a soft one was half a day, a paler one is already paid for */
/* Fixed columns: a day's mark or a total changing doesn't move them */
.table.week {
    table-layout: fixed;
}

    .table.week col.week-name {
        width: 200px;
    }

    .table.week col.week-total {
        width: 112px;
    }

.week th.today {
    color: var(--primary);
}

.week td.day {
    padding: var(--space-1);
}

.day-cell {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: var(--tap-min);
    padding: 2px var(--space-1);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
    color: var(--muted);
    font-weight: var(--weight-bold);
    line-height: 1.2;
}

    button.day-cell {
        width: 100%;
        font: inherit;
        font-weight: var(--weight-bold);
        cursor: pointer;
    }

        button.day-cell:hover {
            border-color: var(--primary);
        }

    .day-cell small {
        font-size: var(--fs-micro);
        font-weight: var(--weight-regular);
    }

    .day-cell.worked {
        background: var(--primary-strong);
        border-color: var(--primary-strong);
        color: var(--on-primary);
    }

    .day-cell.half {
        background: var(--primary-soft);
        border-color: var(--primary);
        color: var(--primary);
    }

    .day-cell.paid {
        opacity: 0.6;
    }

    .day-cell.future {
        background: transparent;
        border-style: dashed;
    }

/* ================= A statement of account: paper ================= */
.paper {
    max-width: 880px;
    padding: var(--space-8);
}

.paper-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-6);
    flex-wrap: wrap;
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--line);
}

    .paper-head .alone-brand {
        margin: 0;
    }

.paper-station {
    display: block;
    font-size: var(--fs-lead);
    font-weight: var(--weight-bold);
}

.paper-title {
    text-align: right;
}

    .paper-title h2 {
        font-size: var(--fs-title);
        font-weight: var(--weight-bold);
    }

.paper-parties {
    display: flex;
    justify-content: space-between;
    gap: var(--space-6);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}

    .paper-parties .field-label {
        display: block;
        margin-bottom: var(--space-1);
    }

.paper-due {
    text-align: right;
}

.paper-amount {
    display: block;
    font-family: var(--display-font);
    font-size: var(--fs-display);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
}

.paper-section {
    font-size: var(--fs-lead);
    font-weight: var(--weight-bold);
    margin: var(--space-6) 0 var(--space-2);
}

.paper .table {
    border: 1px solid var(--line);
}

.paper-note {
    margin-top: var(--space-4);
    font-size: var(--fs-small);
}

/* On paper: A4, only the statement, no sidebar or heading */
@page {
    size: A4;
    margin: 14mm;
}

@media print {
    .side, .head, .page-result {
        display: none;
    }

    html, body {
        background: var(--panel);
    }

    .shell {
        display: block;
    }

    .page {
        padding: 0;
        max-width: none;
    }

    .paper {
        border: 0;
        padding: 0;
        max-width: none;
    }

    .table tbody tr:hover {
        background: none;
    }
}

/* ================= Empty state ================= */
.empty {
    padding: var(--space-10) var(--space-5);
    text-align: center;
}

.empty-title {
    font-weight: var(--weight-bold);
}

.empty-text {
    font-size: var(--fs-tiny);
    color: var(--muted);
    margin: var(--space-2) auto 0;
    max-width: 420px;
}

.more {
    padding: var(--space-3) var(--space-4) var(--space-2);
    font-weight: var(--weight-bold);
}

/* ================= Signing in, and pages for someone not signed in ================= */
.alone {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-6) var(--space-4);
}

.alone-card {
    width: 100%;
    max-width: 480px;
    padding: var(--space-8);
}

    /* The same card, for someone signed in (a page that isn't there): in the middle of the page */
    .page > .alone-card {
        margin: var(--space-12) auto;
    }

.alone-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-6);
}

    .alone-brand .brand-tile {
        width: 48px;
        height: 48px;
        font-size: var(--fs-figure);
    }

.alone-card h1 {
    font-size: var(--fs-figure);
    font-weight: var(--weight-bold);
}

.alone-card .lead {
    margin: var(--space-1) 0 var(--space-6);
}

.alone-card .message {
    margin-bottom: var(--space-4);
}

.alone-card .btn {
    min-height: var(--control-lg);
    margin-top: var(--space-2);
}

/* ================= Smaller screens ================= */
@media (max-width: 1180px) {
    .stats,
    .stats:has(> :nth-child(3):last-child),
    .stats:has(> :nth-child(5):last-child),
    .stats:has(> :nth-child(6):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats:has(> :nth-child(3):last-child) > :last-child,
    .stats:has(> :nth-child(5):last-child) > :last-child {
        grid-column: 1 / -1;
    }
}

/* A phone, or a narrow window: the sidebar becomes a bar at the top with a Menu button */
@media (max-width: 900px) {
    .shell {
        display: block;
    }

    .side {
        position: sticky;
        top: 0;
        z-index: 10;
        height: auto;
        max-height: 100vh;
        padding: 0 var(--space-2);
        border-bottom: 1px solid var(--sidebar-line);
    }

    .side-top {
        min-height: 56px;
        padding: 0 var(--space-2);
        border-bottom: 0;
    }

    .brand-tile {
        width: 36px;
        height: 36px;
    }

    .brand-name {
        -webkit-line-clamp: 1;
    }

    .icon-btn.menu-button {
        display: inline-flex;
        color: var(--sidebar-text);
    }

        .menu-button .close { display: none; }
        .side.open .menu-button .close { display: block; }
        .side.open .menu-button .open { display: none; }

    .side-body {
        display: none;
        padding-bottom: var(--space-4);
    }

    .side.open .side-body {
        display: flex;
        border-top: 1px solid var(--sidebar-line);
    }

    .nav {
        margin-top: var(--space-3);
    }

    .nav a {
        min-height: var(--tap-min);
    }

    .side-foot {
        padding: var(--space-3) var(--space-2) 0;
        border-top: 1px solid var(--sidebar-line);
    }

    .icon-btn {
        width: var(--tap-min);
        height: var(--tap-min);
    }

    .page {
        padding: var(--space-5) var(--space-4) var(--space-8);
    }

    .columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media screen and (max-width: 720px) {
    .title {
        font-size: var(--fs-display-sm);
    }

    .head {
        margin-bottom: var(--space-5);
    }

    .head-actions {
        width: 100%;
    }

    .stepper {
        flex: 1;
    }

        .stepper strong {
            flex: 1;
            min-width: 0;
        }

    .stats {
        gap: var(--space-2);
        margin-bottom: var(--space-5);
    }

    .stat {
        min-height: 0;
        padding: var(--space-4);
    }

    .stat-go {
        top: 18px;
        right: var(--space-4);
    }

    .stat-value {
        font-size: var(--fs-display-sm);
        margin: var(--space-2) 0 var(--space-1);
    }

    .stat-label {
        white-space: normal;
    }

    .todo li {
        gap: var(--space-3);
    }

        .stat-value.words {
            font-size: var(--fs-title);
            line-height: 31px;
        }

    .tools {
        padding: var(--space-3) var(--space-4);
    }

    .tools-sum {
        text-align: left;
        margin-left: 0;
    }

    /* Lists to pick from share a row; the search and its button take the next */
    .tools form .field {
        flex: 1 1 140px;
        max-width: none;
    }

        .tools form .field.grow {
            flex: 1 1 100%;
            max-width: none;
        }

    /* A table becomes a list: words down the left, numbers and badges down the right */
    .table thead {
        display: none;
    }

    .table, .table tbody {
        display: block;
    }

        .table tr {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            grid-auto-flow: row dense;
            column-gap: var(--space-3);
            row-gap: 2px;
            padding: var(--space-3) var(--space-4);
            border-bottom: 1px solid var(--line);
        }

        .table tbody tr:last-child {
            border-bottom: 0;
        }

        .table td {
            display: block;
            grid-column: 1;
            padding: 0;
            border: 0;
            text-align: left;
        }

            .table td.num, .table td.center {
                grid-column: 2;
                text-align: right;
            }

            /* The cell that answers "how much" goes top right */
            .table td.key {
                order: -1;
            }

            .table td.first {
                order: -2;
            }

            .table td:empty, .table td.wide {
                display: none;
            }

            .table td[data-label]::before {
                content: attr(data-label) " ";
                color: var(--muted);
                font-size: var(--fs-tiny);
            }

        .table tr.total {
            border-top: 1px solid var(--line-strong);
        }

            .table tr.total td {
                border-top: 0;
            }

        .table tr.group td {
            grid-column: 1 / -1;
            padding-top: var(--space-2);
        }

        .table td.indent {
            padding-left: 0;
        }

    .form-grid, .form-grid.three {
        grid-template-columns: minmax(0, 1fr);
    }

    .paper {
        padding: var(--space-5);
    }

    .paper-title, .paper-due {
        text-align: left;
    }

    .edit-table tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: row;
        row-gap: var(--space-2);
    }

        .edit-table td, .edit-table td.num, .edit-table td.center {
            grid-column: auto;
            width: auto;
            text-align: left;
        }

            .edit-table td.whole {
                grid-column: 1 / -1;
            }

            .edit-table td[data-label]::before {
                display: block;
                margin-bottom: var(--space-1);
                font-weight: var(--weight-bold);
            }

            .edit-table td.check {
                display: flex;
                align-items: center;
                gap: var(--space-2);
            }

                .edit-table td.check::before {
                    display: inline;
                    order: 2;
                    margin: 0;
                }

            /* An item and its x on the first line, its prices under them (Setup's prices) */
            .edit-table td.row-name {
                grid-column: 1;
                grid-row: 1;
                align-self: center;
            }

            .edit-table td.row-end {
                grid-column: 2;
                grid-row: 1;
                text-align: right;
            }

    /* Comparison tables keep their columns and scroll sideways */
    .scroll-x {
        overflow-x: auto;
    }

        .scroll-x .table {
            display: table;
        }

            .scroll-x .table.week {
                min-width: 600px;
            }

            .scroll-x .table thead {
                display: table-header-group;
            }

            .scroll-x .table tbody {
                display: table-row-group;
            }

            .scroll-x .table tr {
                display: table-row;
                padding: 0;
            }

            .scroll-x .table td, .scroll-x .table th {
                display: table-cell;
                padding: var(--space-3) var(--space-2);
                border-bottom: 1px solid var(--line);
            }

                .scroll-x .table td:first-child, .scroll-x .table th:first-child {
                    padding-left: var(--space-4);
                }

                .scroll-x .table th {
                    white-space: normal;
                    vertical-align: bottom;
                }

                .scroll-x .table td:last-child, .scroll-x .table th:last-child {
                    padding-right: var(--space-4);
                }

                .scroll-x .table td.num {
                    text-align: right;
                }

                .scroll-x .table td.indent {
                    padding-left: var(--space-6);
                }

            .scroll-x .table tr.group td {
                padding-top: var(--space-5);
            }

    .alone-card {
        padding: var(--space-6) var(--space-5);
    }
}
