/* Global theme layer: element defaults, the Bootstrap components we restyle and the shared page
   building blocks (DESIGN.md §8). Anything specific to one component belongs in that component's
   .razor.css instead. Element resets use :where() so they never outrank a component's own styles. */

:where(body) {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

/* Plain element selectors here: they must beat Bootstrap's element rules, and still sit
   below any component class. */
a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
    text-wrap: balance;
}

:where(:focus-visible) {
    outline: 2px solid var(--accent-fill);
    outline-offset: 2px;
}

/* Blazor moves focus to the page title after each navigation; the title isn't a control, so no ring. */
h1:focus {
    outline: none;
}

.muted {
    color: var(--muted);
}

.strong {
    font-weight: 600;
}

/* Order numbers, money, phone numbers, IMEIs: digits that line up (DESIGN.md §3). */
.num,
.mono {
    font-variant-numeric: tabular-nums;
}

.late {
    color: var(--status-problem);
    font-weight: 500;
}

/* ---------- Page furniture shared by every screen ---------- */

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 12px 16px;
    flex-wrap: wrap;
}

.page-head > div:first-child {
    flex: 1 1 320px;
    min-width: 0;
}

.page-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.page-head .head-actions,
.page-head .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.crumb a {
    color: var(--muted);
}

.crumb b {
    color: var(--text);
    font-weight: 500;
}

/* A save that failed: what went wrong and how to fix it (DESIGN.md §15). */
.form-alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--status-problem-soft);
    color: var(--status-problem);
    font-size: 14px;
    font-weight: 600;
    animation: shake 0.4s;
}

/* A friendly heads-up inside a card or dialog. */
.note-callout {
    padding: 10px 14px;
    border-left: 3px solid var(--accent-fill);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
    font-size: 13px;
}

/* ---------- Cards (DESIGN.md §8): hairline outline in both themes ---------- */

.card-surface {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    min-width: 0;
}

.card-surface.padded {
    padding: var(--pad);
}

.card-surface h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 30px;
}

.card-head h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-head .end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

a.card-surface,
.card-surface.hoverable {
    color: var(--text);
    text-decoration: none;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s, border-color 0.2s;
}

a.card-surface:hover,
.card-surface.hoverable:hover {
    transform: translateY(-2px);
    box-shadow: var(--lift-shadow);
    border-color: color-mix(in srgb, var(--accent-fill) 30%, var(--card-border));
}

/* Page layouts: cards side by side, stacking on narrow screens. */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
}

.cols-2,
.cols-3,
.cols-main-side,
.cols-side-main,
.cols-60-40 {
    display: grid;
    gap: var(--gap);
    align-items: start;
}

.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-main-side { grid-template-columns: minmax(0, 1fr) 340px; }
.cols-side-main { grid-template-columns: 320px minmax(0, 1fr); }
.cols-60-40 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }

@media (max-width: 1199px) {
    .cols-main-side,
    .cols-60-40 {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 899px) {
    .cols-2,
    .cols-3,
    .cols-side-main {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Icon tiles and KPI tiles (DESIGN.md §5, §8) ---------- */

.icon-tile {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    font-size: 19px;
    color: var(--tile-fg, var(--accent-soft-fg));
    background: var(--tile-bg, var(--accent-soft));
}

.icon-tile.round {
    border-radius: 50%;
}

.icon-tile.sm {
    width: 34px;
    height: 34px;
    font-size: 15px;
}

.tone-accent { --tile-fg: var(--accent-soft-fg); --tile-bg: var(--accent-soft); }
.tone-neutral { --tile-fg: var(--status-neutral); --tile-bg: var(--status-neutral-soft); }
.tone-waiting { --tile-fg: var(--status-waiting); --tile-bg: var(--status-waiting-soft); }
.tone-progress { --tile-fg: var(--status-progress); --tile-bg: var(--status-progress-soft); }
.tone-problem { --tile-fg: var(--status-problem); --tile-bg: var(--status-problem-soft); }
.tone-done { --tile-fg: var(--status-done); --tile-bg: var(--status-done-soft); }
.tone-teal { --tile-fg: var(--teal); --tile-bg: var(--teal-soft); }

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--gap);
}

.kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}

.kpi .figure {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    animation: count-in 0.6s var(--ease-out);
}

.kpi .label {
    font-size: 14px;
}

.kpi .delta {
    font-size: 12px;
    color: var(--muted);
}

.kpi:hover .icon-tile {
    animation: bounce 0.5s var(--ease-spring);
}

/* ---------- Buttons: white text on the accent fill in both themes (DESIGN.md §2.2) ---------- */

.btn {
    --bs-btn-font-size: 14px;
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: var(--radius);
    --bs-btn-padding-y: 0;
    --bs-btn-padding-x: 14px;
    --bs-btn-focus-box-shadow: var(--focus-ring);
    min-height: var(--control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    text-decoration: none;
    transition: transform 0.12s var(--ease-spring), background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: scale(0.96);
}

.btn-sm {
    --bs-btn-font-size: 13px;
    --bs-btn-padding-x: 10px;
    min-height: 30px;
}

.btn-lg {
    --bs-btn-font-size: 15px;
    --bs-btn-padding-x: 20px;
    min-height: var(--action-h);
}

.btn-primary {
    --bs-btn-color: var(--on-accent);
    --bs-btn-bg: var(--accent-fill);
    --bs-btn-border-color: var(--accent-fill);
    --bs-btn-hover-color: var(--on-accent);
    --bs-btn-hover-bg: color-mix(in srgb, var(--accent-fill) 88%, #000000);
    --bs-btn-hover-border-color: var(--bs-btn-hover-bg);
    --bs-btn-active-color: var(--on-accent);
    --bs-btn-active-bg: color-mix(in srgb, var(--accent-fill) 80%, #000000);
    --bs-btn-active-border-color: var(--bs-btn-active-bg);
    --bs-btn-disabled-color: var(--on-accent);
    --bs-btn-disabled-bg: var(--accent-fill);
    --bs-btn-disabled-border-color: var(--accent-fill);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* The "+" on a primary button turns when you point at it. */
.btn-primary:hover .fa-plus {
    transform: rotate(90deg);
}

.btn .fa-plus {
    transition: transform 0.3s var(--ease-spring);
}

/* Soft: in-card actions such as "Add device" (DESIGN.md §8). */
.btn-soft {
    --bs-btn-color: var(--accent-soft-fg);
    --bs-btn-bg: var(--accent-soft);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--accent-soft-fg);
    --bs-btn-hover-bg: color-mix(in srgb, var(--accent-soft) 82%, var(--accent-fill));
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--accent-soft-fg);
    --bs-btn-active-bg: color-mix(in srgb, var(--accent-soft) 75%, var(--accent-fill));
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--accent-soft-fg);
    --bs-btn-disabled-bg: var(--accent-soft);
    --bs-btn-disabled-border-color: transparent;
}

/* Default: surface with a hairline. */
.btn-outline-secondary {
    --bs-btn-color: var(--text);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-active-color: var(--text);
    --bs-btn-active-bg: var(--surface-2);
    --bs-btn-active-border-color: var(--field-border);
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-bg: var(--surface);
    --bs-btn-disabled-border-color: var(--border);
}

.btn-ghost {
    --bs-btn-color: var(--muted);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--text);
    --bs-btn-active-bg: var(--surface-2);
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: transparent;
    --bs-btn-padding-x: 10px;
}

/* Confirms a removal. Soft, so it reads as a warning in both themes. */
.btn-danger-soft {
    --bs-btn-color: var(--status-problem);
    --bs-btn-bg: var(--status-problem-soft);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--status-problem);
    --bs-btn-hover-bg: color-mix(in srgb, var(--status-problem-soft) 80%, var(--status-problem));
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--status-problem);
    --bs-btn-active-bg: color-mix(in srgb, var(--status-problem-soft) 70%, var(--status-problem));
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--status-problem);
    --bs-btn-disabled-bg: var(--status-problem-soft);
    --bs-btn-disabled-border-color: transparent;
}

/* A finished action: the button says what happened for a moment ("Paid"). */
.btn-success {
    --bs-btn-color: #ffffff;
    --bs-btn-bg: var(--status-done);
    --bs-btn-border-color: var(--status-done);
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: var(--status-done);
    --bs-btn-hover-border-color: var(--status-done);
    --bs-btn-disabled-color: #ffffff;
    --bs-btn-disabled-bg: var(--status-done);
    --bs-btn-disabled-border-color: var(--status-done);
}

[data-bs-theme="dark"] .btn-success {
    --bs-btn-color: #0b1f14;
    --bs-btn-hover-color: #0b1f14;
    --bs-btn-disabled-color: #0b1f14;
}

/* Work in progress on a button: a spinner beside the button's own words ("Charging $84.00…"). */
.btn .fa-spinner,
.spin {
    animation: spin 0.8s linear infinite;
}

/* Icon-only row actions such as edit and remove. Always visible, so they work on touch screens. */
.icon-button {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, transform 0.2s var(--ease-spring);
}

.icon-button:hover,
.icon-button:focus-visible {
    background: var(--surface-2);
    color: var(--text);
}

.icon-button:active {
    transform: scale(0.9);
}

.icon-button.on {
    color: var(--accent);
}

.icon-button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* "View all ›" and other accent text actions. */
.link-button,
.link-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    padding: 0;
    background: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.link-button:hover,
.link-more:hover {
    text-decoration: underline;
}

.link-more i {
    font-size: 11px;
    transition: transform 0.2s var(--ease-spring);
}

.link-more:hover i {
    transform: translateX(3px);
}

/* ---------- Count badges (DESIGN.md §8) ---------- */

.badge-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: var(--status-neutral-soft);
    color: var(--status-neutral);
}

.badge-count.accent {
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}

.badge-count.solid {
    background: var(--status-problem-solid);
    color: #ffffff;
}

.badge-count.waiting {
    background: var(--status-waiting-soft);
    color: var(--status-waiting);
}

/* ---------- Avatars ---------- */

.avatar {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text);
}

.avatar.mini {
    width: 20px;
    height: 20px;
    font-size: 9px;
}

.avatar.lg {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.avatar.navy {
    border: 0;
    background: var(--navy);
    color: #ffffff;
}

/* ---------- Tabs and segmented choices (DESIGN.md §8) ---------- */

.tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
    max-width: 100%;
}

.tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 12px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.tab:hover {
    color: var(--text);
    text-decoration: none;
}

.tab::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent-fill);
    transform: scaleX(0);
    transition: transform 0.3s var(--ease-out);
}

.tab.active {
    color: var(--text);
    font-weight: 600;
}

.tab.active::after {
    transform: scaleX(1);
}

.tab.active .badge-count:not(.solid):not(.waiting) {
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}

.tab-panel {
    animation: fade-up 0.3s var(--ease-out);
    min-width: 0;
}

.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.seg button,
.seg a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.seg button:hover,
.seg a:hover {
    color: var(--text);
}

.seg .active {
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}

/* ---------- List page pattern (DESIGN.md §10): toolbar, filter chips, filter box, data table, pager ---------- */

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 16px 0;
}

.toolbar > .spacer {
    flex: 1;
}

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover {
    border-color: var(--field-border);
    text-decoration: none;
}

.chip.on,
.chip.active {
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
    border-color: transparent;
}

.chip-count {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.chip.on .chip-count,
.chip.active .chip-count {
    color: inherit;
}

.filter {
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--control-h);
    width: min(300px, 100%);
    padding: 0 11px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter:focus-within {
    border-color: var(--accent-fill);
    box-shadow: var(--focus-ring);
}

.filter input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

.table-wrap {
    position: relative;
    overflow-x: auto;
}

.card-surface > .table-wrap {
    padding: 8px;
}

/* Data table (DESIGN.md §8): a surface-2 header band, sentence-case muted headers, hairline rows. */
table.grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.grid th {
    text-align: left;
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    padding: 9px 14px;
    background: var(--surface-2);
    white-space: nowrap;
}

.grid th:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.grid th:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.grid td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.grid tbody tr:last-child td {
    border-bottom: 0;
}

.grid .r {
    text-align: right;
}

.grid .nowrap {
    white-space: nowrap;
}

.grid tbody tr {
    cursor: pointer;
    transition: background-color 0.6s ease-out;
}

.grid tbody tr:hover td {
    background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

.grid tbody tr.flash td {
    background: var(--accent-soft);
}

.grid small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

/* Record numbers in tables: accent and underlined (DESIGN.md §3). */
.grid .record {
    color: var(--accent);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--muted);
}

.pager .spacer {
    flex: 1;
}

/* The Columns button over a table that has no toolbar of its own. */
.list-tools {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 8px 6px;
}

/* Columns that give way on narrower screens, whichever component draws the heading. */
@media (max-width: 899px) {
    .grid .wide-only {
        display: none;
    }
}

/* ---------- Empty states: friendly, never blank (DESIGN.md §15) ---------- */

.empty {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 28px 16px;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}

.empty b {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.empty .art {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 4px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--accent);
    font-size: 24px;
    animation: float 3s ease-in-out infinite;
}

.empty.card-surface,
.card-surface .empty {
    justify-items: center;
}

/* ---------- Record page pattern (DESIGN.md §10): cards of facts beside the work ---------- */

.panel {
    display: grid;
    gap: 12px;
    align-content: start;
    padding: 18px var(--pad) var(--pad);
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
}

.panel-head h2 {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pad-x {
    padding-left: var(--pad);
    padding-right: var(--pad);
}

.facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px 14px;
    margin: 0;
    font-size: 14px;
}

.facts dt {
    color: var(--muted);
    font-weight: 400;
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* A small heading inside a card, in sentence case (DESIGN.md §3). */
.sub-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.sub-head .hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* A clickable row in a card's list: it slides open a little on hover and points the way. */
.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 4px;
    border-bottom: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.12s, padding 0.2s var(--ease-out);
}

.list-row:last-child {
    border-bottom: 0;
}

a.list-row:hover,
button.list-row:hover {
    background: var(--surface-2);
    padding-inline: 10px;
    text-decoration: none;
}

button.list-row {
    width: 100%;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}

.list-row .chev {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    transition: transform 0.2s var(--ease-spring), color 0.15s;
}

.list-row:hover .chev {
    transform: translateX(3px);
    color: var(--text);
}

.list-row.selected {
    background: var(--accent-soft);
    padding-inline: 10px;
}

/* ---------- The repair's four steps (DESIGN.md §8) ---------- */

.stepper {
    display: flex;
    align-items: flex-start;
}

.stepper .step {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.stepper .step::before {
    content: "";
    position: absolute;
    top: 10px;
    left: calc(-50% + 12px);
    right: calc(50% + 12px);
    height: 2px;
    background: var(--border);
}

.stepper .step:first-child::before {
    display: none;
}

.stepper .step.done::before,
.stepper .step.current::before {
    background: var(--status-done);
}

.stepper .node {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    font-size: 10px;
}

.stepper .step.done .node {
    border-color: var(--status-done);
    background: var(--status-done);
    color: #ffffff;
}

.stepper .step.current .node {
    border-color: var(--accent-fill);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-fill) 18%, transparent);
}

.stepper .step.current .node::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-fill);
    animation: pulse-dot 1.8s infinite;
}

.stepper .step.done,
.stepper .step.current {
    color: var(--text);
    font-weight: 500;
}

.stepper .when {
    font-size: 11px;
    font-weight: 400;
    color: var(--muted);
}

/* ---------- Device thumbnails: a little device drawn in CSS (DESIGN.md §8) ---------- */

.thumb {
    flex: none;
    position: relative;
    border-radius: 7px;
    background: linear-gradient(160deg, #3b3f4a, #15171c);
    box-shadow: inset 0 0 0 1.5px #5b606c, 0 2px 6px rgba(16, 24, 40, 0.15);
}

.thumb::before {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 5px;
    background: var(--screen, linear-gradient(150deg, #6a5acd, #1e90ff 55%, #20c997));
}

.thumb.phone { width: 30px; height: 52px; }
.thumb.phone::after { content: ""; position: absolute; top: 5px; left: 50%; width: 8px; height: 3px; border-radius: 3px; background: #0b0c0f; transform: translateX(-50%); }
.thumb.tablet { width: 44px; height: 56px; border-radius: 8px; }
.thumb.laptop { width: 56px; height: 36px; margin: 0 6px 6px; border-radius: 5px 5px 2px 2px; }
.thumb.laptop::after { content: ""; position: absolute; left: -6px; right: -6px; bottom: -6px; height: 6px; border-radius: 0 0 6px 6px; background: linear-gradient(#c9ccd3, #9aa0aa); }
.thumb.desktop { width: 56px; height: 40px; margin-bottom: 8px; border-radius: 5px; }
.thumb.desktop::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 18px; height: 8px; transform: translateX(-50%); background: linear-gradient(#c9ccd3, #9aa0aa); clip-path: polygon(25% 0, 75% 0, 100% 100%, 0 100%); }
.thumb.watch { width: 32px; height: 40px; border-radius: 11px; }
.thumb.console { width: 56px; height: 28px; border-radius: 13px; }
.thumb.home { width: 36px; height: 36px; border-radius: 50%; }
.thumb.sm { transform: scale(0.75); transform-origin: left center; margin-right: -8px; }
.thumb.s-sunset { --screen: linear-gradient(150deg, #ff7e5f, #feb47b); }
.thumb.s-ocean { --screen: linear-gradient(150deg, #2193b0, #6dd5ed); }
.thumb.s-forest { --screen: linear-gradient(150deg, #11998e, #38ef7d); }
.thumb.s-night { --screen: linear-gradient(150deg, #232526, #414345); }
.thumb.s-grape { --screen: linear-gradient(150deg, #8e2de2, #4a00e0); }
.thumb.s-sky { --screen: linear-gradient(150deg, #6a5acd, #1e90ff 55%, #20c997); }

/* ---------- Forms: outlines meet 3:1 contrast; focus shows the accent border and a soft ring ---------- */

.form-control,
.form-select {
    min-height: var(--control-h);
    font-size: 14px;
    border-color: var(--field-border);
    background-color: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-fill);
    box-shadow: var(--focus-ring);
    background-color: var(--surface);
    color: var(--text);
}

.form-control::placeholder {
    color: var(--muted);
}

.form-label,
label.field-label,
legend.field-label {
    font-size: 13px;
    font-weight: 500;
}

/* A group of ticks labelled like a field, not a big Bootstrap legend. */
legend.field-label {
    float: none;
    width: auto;
    margin: 0 0 2px;
    padding: 0;
    line-height: inherit;
}

.form-check-input {
    border-color: var(--field-border);
    background-color: var(--surface);
}

.form-check-input:checked {
    background-color: var(--accent-fill);
    border-color: var(--accent-fill);
}

/* Switches spring across (DESIGN.md §8 Toggle). */
.form-switch .form-check-input {
    width: 2.4em;
    height: 1.35em;
    transition: background-position 0.25s var(--ease-spring), background-color 0.2s;
}

.field-error,
.validation-message {
    color: var(--status-problem);
    font-size: 13px;
    font-weight: 600;
}

/* Phones: 16px text in fields so iOS never zooms in on focus (DESIGN.md §3). */
@media (max-width: 599px) {
    .form-control,
    .form-select,
    .filter input {
        font-size: 16px;
    }
}

/* A form inside a card: fields stacked, buttons at the end. */
.card-form {
    display: grid;
    gap: 14px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.form-alert .form-actions {
    margin-top: 8px;
}

/* Blazor's reconnect and error UI, in OnSite's colours. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--status-problem-soft);
    color: var(--status-problem);
    font-weight: 600;
    box-shadow: var(--overlay-shadow);
}

#blazor-error-ui .reload {
    margin-left: 12px;
    color: inherit;
}

/* ---------- Settings sections: one card per group of settings ---------- */

.settings-card {
    display: grid;
    gap: 14px;
    align-content: start;
    padding: var(--pad);
}

.settings-card + .settings-card,
.settings-card + .settings-pair,
.settings-pair + .settings-card {
    margin-top: var(--gap);
}

.settings-card p {
    margin: 4px 0 0;
}

.settings-card .small {
    font-size: 13px;
}

.settings-card .block {
    display: block;
}

.settings-card .two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
}

.settings-card .short {
    max-width: 140px;
}

.settings-card .divider {
    height: 1px;
    margin: 4px 0;
    background: var(--border);
}

.settings-card .rows {
    display: grid;
    gap: 8px;
}

/* An editable row of a list, such as a tax: fields side by side, remove at the end. */
.settings-card .row-edit {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: end;
}

.settings-card .row-edit.preset {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr) auto;
}

.settings-card .row-edit .icon-button {
    margin-bottom: 2px;
}

.settings-card .row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
}

.settings-card .inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.settings-card .inline-form .form-control {
    flex: 1 1 160px;
    min-width: 0;
}

/* A switch with a bold title and a one-line explanation under it (DESIGN.md §8 Toggle). */
.settings-card .switch-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 4px 0;
    cursor: pointer;
}

.settings-card .switch-row > span {
    display: grid;
    gap: 2px;
}

.settings-card .switch-row .form-check-input {
    margin-top: 2px;
}

.settings-card .retired {
    opacity: 0.6;
}

.settings-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--gap);
    align-items: start;
}

.settings-pair > .settings-card {
    margin-top: 0;
}

@media (max-width: 899px) {
    .settings-pair {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 599px) {
    .settings-card .two,
    .settings-card .row-edit,
    .settings-card .row-edit.preset {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-card .row-edit .icon-button {
        justify-self: start;
    }
}

/* ---------- Work lists on Overview and My workday ---------- */

.work-list {
    display: grid;
    align-content: start;
    gap: 6px;
    padding: 16px var(--pad) 12px;
}

/* Inside a tab: the card above already has the title. */
.work-list.bare {
    padding: 4px 0 0;
}

.work-list.bare ul > li:first-child a {
    border-top: 0;
}

.work-list .list-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.work-list .list-head h2 {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.work-list .list-head h2 i {
    color: var(--muted);
    font-size: 14px;
}

.work-list .badge-count.zero {
    background: var(--status-neutral-soft);
    color: var(--status-neutral);
}

.work-list .hint,
.work-list .nothing {
    margin: 0;
    font-size: 13px;
}

.work-list ul {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

.work-list li a {
    display: grid;
    gap: 3px;
    padding: 10px 4px;
    border-top: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.12s, padding 0.2s var(--ease-out);
}

.work-list li a:hover {
    background: var(--surface-2);
    padding-inline: 10px;
}

.work-list .line-one {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 14px;
}

.work-list .number {
    flex: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.work-list .device {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.work-list .line-two {
    font-size: 13px;
}

.work-list .late {
    color: var(--status-problem);
    font-weight: 600;
}

.work-list .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.work-list .unread-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-fill);
}

.work-list .more {
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

/* ---------- Motion (DESIGN.md §18): quick, springy, and off for anyone who asks ---------- */

/* A changed row or card glows soft accent for a moment (DESIGN.md §9). */
.flash {
    animation: flash 2.6s ease;
}

.skeleton {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s infinite;
}

@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes count-in { from { opacity: 0; transform: translateY(6px) scale(0.92); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 50% { transform: scale(0.6); } }
@keyframes bounce { 40% { transform: translateY(-5px) scale(1.06); } }
@keyframes float { 50% { transform: translateY(-5px); } }
@keyframes flash { 0%, 30% { background-color: var(--accent-soft); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes land { 0% { transform: scale(0.9); box-shadow: 0 0 0 3px var(--accent-fill); } 100% { transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Phones: two KPI tiles a row, compact (DESIGN.md §10). */
@media (max-width: 599px) {
    .kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .kpi {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 14px;
    }

    h1 {
        font-size: 22px;
    }
}

/* ---------- Camera scanning (DESIGN.md §11, §18.4) ----------
   The full-screen viewfinder wwwroot/js/scanning.js opens on phones and tablets. It sits over the
   page, outside any component, so its styles live here. A viewfinder is dark in both themes, so it
   names its own few colours once, here. */
.scan-viewer {
    --viewfinder: #0b0d12;
    --on-viewfinder: #ffffff;
    --viewfinder-muted: rgba(255, 255, 255, 0.78);
    --viewfinder-hit: #5ccb8d;
    --viewfinder-line: #93b8ff;
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    grid-template-rows: auto 1fr auto;
    justify-items: center;
    gap: 16px;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--viewfinder);
    color: var(--on-viewfinder);
    animation: fade-up 0.2s var(--ease-out);
}

html.scan-open {
    overflow: hidden;
}

.scan-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
}

.scan-viewer.live .scan-video {
    opacity: 1;
}

.scan-top,
.scan-frame,
.scan-bottom {
    position: relative;
}

/* Above the frame's shade, which darkens everything around the frame. */
.scan-top {
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: min(560px, 100%);
}

.scan-prompt {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.scan-top .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.35);
    color: var(--on-viewfinder);
}

.scan-top .btn:hover,
.scan-top .btn:focus-visible,
.scan-top .btn.on {
    background: var(--on-viewfinder);
    color: var(--viewfinder);
}

.scan-top .btn[hidden] {
    display: none;
}

/* The frame: four corners and a sweeping line; the corners snap green on a hit. */
.scan-frame {
    align-self: center;
    width: min(320px, 80vw);
    aspect-ratio: 1;
    border-radius: 14px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}

.scan-viewer.failed .scan-frame {
    opacity: 0.35;
}

.scan-frame > span {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 4px solid var(--on-viewfinder);
    transition: border-color 0.25s, transform 0.3s var(--ease-spring);
}

.scan-frame > span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.scan-frame > span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.scan-frame > span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.scan-frame > span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }

.scan-frame.hit > span {
    border-color: var(--viewfinder-hit);
    transform: scale(0.92);
}

.scan-line {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 10%;
    height: 2px;
    border-radius: 2px;
    background: var(--viewfinder-line);
    box-shadow: 0 0 12px var(--viewfinder-line);
    animation: scan-sweep 2s ease-in-out infinite alternate;
}

.scan-frame.hit .scan-line,
.scan-viewer:not(.live) .scan-line {
    display: none;
}

@keyframes scan-sweep { to { top: 90%; } }

.scan-bottom {
    display: grid;
    justify-items: center;
    gap: 10px;
    width: min(480px, 100%);
    text-align: center;
}

.scan-message {
    margin: 0;
    color: var(--viewfinder-muted);
    font-size: 15px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.scan-message:empty {
    display: none;
}

.scan-viewer.failed .scan-message {
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.55);
    color: var(--on-viewfinder);
    text-shadow: none;
}

.scan-type {
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--on-viewfinder);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* A shop's logo in place of its initials (ShopMark): the mark's box steps back so the logo shows as it is. */
.mark:has(> .shop-logo) {
    background: transparent !important;
    box-shadow: none !important;
}

.shop-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---------- Address suggestions (js/addresses.js) ----------
   The list sits on the page's body, under the street box it belongs to, above dialogs. */
.address-suggestions {
    position: fixed;
    z-index: 1100;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--overlay-shadow);
    max-height: 320px;
    overflow-y: auto;
}

.address-suggestion {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
}

.address-suggestion .secondary {
    font-size: 12.5px;
    color: var(--muted);
}

.address-suggestion mark {
    background: none;
    padding: 0;
    color: var(--accent);
    font-weight: 700;
}

.address-suggestion.highlighted,
.address-suggestion:hover {
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}

.address-suggestion.highlighted mark,
.address-suggestion.highlighted .secondary {
    color: var(--accent-soft-fg);
}

.address-credit {
    margin-top: 2px;
    padding: 6px 10px 2px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
    text-align: right;
}
