/*
  Staff workspace design system — approved "Current x MEH" direction (docs/ui-refresh).

  SCOPE: everything here is scoped to `.meh-app`, the root element of the two staff shells
  (installer MainLayout and MEH admin MehLayout). Customer pages (/s/*) and the PDF report
  are deliberately untouched: they have their own visual system and their own audience, and
  the brief defers the customer experience entirely. A token defined here must therefore
  never be defined on :root, or it would reach the wizard.

  DARK MODE: the mode lives on <html data-mode="dark">, written server-side from a cookie so
  the first paint is already correct, and flipped client-side by js/appearance.js. It is on
  <html> rather than <body> because only the document element is available before the body
  is parsed, and because `html:has(.meh-app)` below needs it to colour the overscroll gutter.

  Class names carry a `meh-` prefix because Bootstrap is still loaded application-wide and
  owns the unprefixed names (.btn, .table, .card). Section 9 restyles those Bootstrap
  primitives INSIDE the staff shell, so pages that have not yet been rewritten stay legible
  in both modes rather than rendering white-on-white.
*/

/* ---------------------------------------------------------------- 1. Fonts */
/* Local, so no third-party request and no CSP change. The SIL Open Font Licence for each
   family ships beside the binaries in wwwroot/fonts/ as the licence requires. */
@font-face {
    font-family: "MEH Inter";
    src: url("../fonts/Inter-Variable.ttf") format("truetype-variations");
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "MEH Poppins";
    src: url("../fonts/Poppins-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "MEH Poppins";
    src: url("../fonts/Poppins-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}

/* ---------------------------------------------------------------- 2. Tokens */
.meh-app {
    /* Surfaces */
    --meh-bg: #f4f6fa;
    --meh-panel: #ffffff;
    --meh-panel-raised: #f8fafd;
    --meh-side: #0c1a33;
    --meh-topbar: #ffffff;
    --meh-evidence: #eef1f7;

    /* Text */
    --meh-ink: #0c1a33;
    --meh-muted: #5e6b80;
    --meh-side-text: #bccce4;
    --meh-side-label: #9fb0ca;
    --meh-on-brand: #ffffff;

    /* Lines */
    --meh-line: #e0e5ee;
    --meh-line-strong: #c8d2e2;

    /* Brand */
    --meh-brand: #ac3bcc;
    --meh-brand-hover: #96289e;
    --meh-brand-text: #7d2996; /* purple that passes AA on --meh-panel at body size */
    --meh-brand-surface: #f3eaf7;
    --meh-brand-surface-strong: #f1e7f6;
    --meh-lilac: #dcc9e9;
    --meh-lilac-ink: #37214e;

    /* Status: text colour is always paired with a word, never colour alone */
    --meh-ok-surface: #e9f2ed;
    --meh-ok-ink: #1f5a3f;
    --meh-warn-surface: #f9e6b8;
    --meh-warn-ink: #6b4a12;
    --meh-info-surface: #e4e9f2;
    --meh-info-ink: #354f79;
    --meh-neutral-surface: #eceff4;
    --meh-neutral-ink: #55637a;
    --meh-danger-surface: #fae8e8;
    --meh-danger-ink: #8d2323;
    --meh-danger: #b3261e;

    /* Attention (gold) */
    --meh-gold: #f4b942;
    --meh-gold-surface: #fff9e9;
    --meh-gold-line: #ead29b;
    --meh-gold-ink: #6b4a12;

    /* Focus ring: 3:1 against --meh-bg, --meh-panel and the purple primary button */
    --meh-focus: #5b2d8c;

    /* Spacing scale (4pt). The prototype used 22 ad-hoc literals; this is the same rhythm
       with a system behind it. */
    --meh-1: 4px;
    --meh-2: 8px;
    --meh-3: 12px;
    --meh-4: 16px;
    --meh-5: 20px;
    --meh-6: 24px;
    --meh-8: 32px;
    --meh-10: 40px;

    /* Radius */
    --meh-radius: 10px;
    --meh-radius-sm: 6px;
    --meh-radius-lg: 14px;

    /* Elevation: panels use borders, not shadow. Only overlays lift. */
    --meh-shadow-pop: 0 5px 25px rgba(12, 26, 51, 0.16);
    --meh-shadow-dialog: 0 25px 90px rgba(12, 26, 51, 0.24);

    /* Type */
    --meh-font: "MEH Inter", "Segoe UI", system-ui, sans-serif;
    --meh-title-font: "MEH Poppins", "Segoe UI", system-ui, sans-serif;

    /* Control sizing: 44px is the touch target the brief requires. */
    --meh-control: 44px;
    --meh-control-sm: 36px;
    --meh-sidebar-w: 250px;
}

html[data-mode="dark"] .meh-app {
    color-scheme: dark;

    --meh-bg: #0b1424;
    --meh-panel: #142238;
    --meh-panel-raised: #101c2f;
    --meh-side: #0c1a33;
    --meh-topbar: #101c2f;
    --meh-evidence: #1b2a42;

    --meh-ink: #e4e9f2;
    --meh-muted: #acbbd1;
    --meh-side-text: #bccce4;
    --meh-side-label: #9fb0ca;

    --meh-line: #30415a;
    --meh-line-strong: #43567332;

    --meh-brand: #ac3bcc; /* the primary button stays the saturated brand purple */
    --meh-brand-hover: #bd57d8;
    --meh-brand-text: #dda0ed; /* lighter purple for text/links on dark surfaces */
    --meh-brand-surface: #322441;
    --meh-brand-surface-strong: #3a2a4c;
    --meh-lilac: #725084;
    --meh-lilac-ink: #f0e2f7;

    --meh-ok-surface: #193e35;
    --meh-ok-ink: #9fdfbf;
    --meh-warn-surface: #49391c;
    --meh-warn-ink: #f9d689;
    --meh-info-surface: #233b5c;
    --meh-info-ink: #bad2ff;
    --meh-neutral-surface: #2a3545;
    --meh-neutral-ink: #c4ccda;
    --meh-danger-surface: #4a2020;
    --meh-danger-ink: #ffb4ab;
    --meh-danger: #ef857c;

    --meh-gold-surface: #302a20;
    --meh-gold-line: #6a5430;
    --meh-gold-ink: #e4c994;

    --meh-focus: #f4b942;

    --meh-shadow-pop: 0 5px 25px rgba(0, 0, 0, 0.5);
    --meh-shadow-dialog: 0 25px 90px rgba(0, 0, 0, 0.6);
}

/* The document gutter behind a short page, and overscroll rubber-banding, would otherwise
   stay Bootstrap white in dark mode. Scoped with :has so customer pages keep their own
   background even while the staff cookie says dark. */
html:has(.meh-app) {
    background: #f4f6fa;
    /* Reserve the scrollbar's width even on a page too short to scroll. Without it, moving
       between a long list and a short one (e.g. the Disabled filter on Businesses) adds or
       removes the scrollbar and shifts every centred element sideways. */
    scrollbar-gutter: stable;
}

html[data-mode="dark"]:has(.meh-app) {
    background: #0b1424;
}

/* ---------------------------------------------------------------- 3. Base */
.meh-app {
    display: flex;
    min-height: 100dvh;
    background: var(--meh-bg);
    color: var(--meh-ink);
    font-family: var(--meh-font);
    font-size: 14px;
    line-height: 1.5;
    font-synthesis-weight: none;
}

.meh-app *,
.meh-app *::before,
.meh-app *::after {
    box-sizing: border-box;
}

.meh-app h1,
.meh-app h2,
.meh-app h3 {
    font-family: var(--meh-title-font);
    font-weight: 600;
    color: var(--meh-ink);
    margin: 0;
}

.meh-app h1 {
    font-size: 28px;
    line-height: 1.25;
    letter-spacing: -0.6px;
    /* A business name, a customer name or an address can be one long unbroken token, and a page
       title is where that first pushes the layout wider than the phone. `anywhere` only breaks a
       word that would otherwise overflow, so ordinary headings are unaffected. Deliberately NOT
       applied to table cells, where it breaks perfectly ordinary column headers mid-word. */
    overflow-wrap: anywhere;
}

.meh-app h2 {
    font-size: 16px;
    letter-spacing: -0.2px;
}

.meh-app h3 {
    font-size: 14px;
}

/*
  Zero-specificity scope via :where(), so any class rule beats it. As `.meh-app a` (0,1,1) it
  outranked `.meh-btn--primary` (0,1,0), and every primary action rendered as an <a> — Download
  report, New survey, Add a business — drew purple text on a purple button at 1.62:1. Measured on
  the rendered page in slice 5; the slice 1 contrast check had measured the TOKENS (white on brand,
  4.94) and so could not see a cascade defect. Check rendered elements, not the palette.
*/
:where(.meh-app) a {
    color: var(--meh-brand-text);
}

/*
  Focus indicator. Two rings, not one, and the reason is measurable: a single ring in either
  focus colour reaches only 1.9:1 (light) / 2.8:1 (dark) against the purple primary button it
  would sit on, under the 3:1 a focus indicator needs. The box-shadow fills the offset gap with
  the surface colour, so the outline is always separated from whatever it surrounds by a band
  that contrasts with both.
*/
.meh-app :focus-visible {
    outline: 3px solid var(--meh-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--meh-panel);
    border-radius: 2px;
}

/* On the navy sidebar the separating band has to be the navy, not the panel colour. */
.meh-sidebar :focus-visible {
    box-shadow: 0 0 0 2px var(--meh-side);
    outline-color: var(--meh-gold);
}

/* ---------------------------------------------------------------- 4. Shell */
.meh-sidebar {
    width: var(--meh-sidebar-w);
    flex: 0 0 var(--meh-sidebar-w);
    background: var(--meh-side);
    color: var(--meh-side-text);
    padding: var(--meh-6) var(--meh-4) var(--meh-5);
    display: flex;
    flex-direction: column;
    /* Pinned to the viewport while the page scrolls, so the signed-in identity and sign-out at
       its foot are always on screen. The document still scrolls (not an inner panel), which
       keeps browser find, anchor links and scroll restoration behaving normally. A sidebar
       taller than the viewport scrolls within itself rather than hiding its foot. */
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
    align-self: flex-start;
}

.meh-main {
    min-width: 0; /* load-bearing: without it a wide table stretches the flex row */
    flex: 1;
    display: flex;
    flex-direction: column;
}

.meh-topbar {
    min-height: 61px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--meh-4);
    padding: var(--meh-2) var(--meh-8);
    background: var(--meh-topbar);
    border-bottom: 1px solid var(--meh-line);
    font-size: 13px;
    color: var(--meh-muted);
}

.meh-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--meh-2);
    min-width: 0;
}

.meh-breadcrumb a {
    color: var(--meh-muted);
    text-decoration: none;
}

.meh-breadcrumb a:hover {
    color: var(--meh-brand-text);
    text-decoration: underline;
}

.meh-breadcrumb-current {
    color: var(--meh-ink);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meh-topbar-right {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    flex-shrink: 0;
}

.meh-content {
    padding: var(--meh-6) var(--meh-8) var(--meh-6);
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    min-width: 0;
    /* A wide table scrolls the CONTENT area, never the document. Measured on a 375px viewport:
       an un-migrated Bootstrap table pushed the document to 642px, which drags the fixed shell
       sideways and hides the navigation. Pages restyled in later slices use .meh-table-wrap for
       the same effect at panel level; this is the backstop for everything else. */
    overflow-x: auto;
}

.meh-footer {
    display: flex;
    justify-content: space-between;
    gap: var(--meh-4);
    padding: var(--meh-2) var(--meh-8) var(--meh-5);
    font-size: 12px;
    color: var(--meh-muted);
}

/* ---------------------------------------------------------------- 5. Sidebar contents */
.meh-brand {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    margin-bottom: var(--meh-6);
    text-decoration: none;
    color: #ffffff;
}

/* No background in EITHER mode: the mark's circle is the artwork's own edge, and any box
   behind it reappears as the white rim the design review asked to remove. */
.meh-brand-logo {
    display: block;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: transparent;
}

.meh-wordmark {
    display: block;
    font-family: var(--meh-title-font);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.4px;
    color: #ffffff;
}

.meh-wordmark small {
    display: block;
    margin-top: 5px;
    font-family: var(--meh-font);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 2.6px;
    color: var(--meh-side-text);
}

.meh-workspace {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    padding: var(--meh-3);
    margin-bottom: var(--meh-5);
    background: #182840;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--meh-radius-sm);
}

.meh-workspace-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: grid;
    place-content: center;
    border-radius: 50%;
    background: var(--meh-lilac);
    color: #0c1a33;
    font-weight: 600;
    font-size: 13px;
}

.meh-workspace-text {
    min-width: 0;
}

.meh-workspace-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #f1f5fb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meh-workspace-text small {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--meh-side-text);
}

.meh-nav-label {
    font-size: 12px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--meh-side-label);
    margin: 0 var(--meh-3) var(--meh-2);
}

/* A second grouping label inside the nav (e.g. "Business settings"), which needs air above it
   but not the margin the first one gets from the workspace block. */
.meh-nav-label--section {
    margin-top: var(--meh-4);
    padding: 0;
}

.meh-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Anchors, not buttons: middle-click and open-in-new-tab are real expectations in an
   operational tool. */
.meh-nav-item {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    min-height: var(--meh-control);
    padding: 10px var(--meh-3);
    border-radius: 7px;
    color: var(--meh-side-text);
    text-decoration: none;
    font-size: 14px;
}

.meh-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.meh-nav-item.active {
    background: var(--meh-brand);
    color: #ffffff;
    font-weight: 500;
}

.meh-nav-item .meh-icon {
    flex-shrink: 0;
}

.meh-nav-count {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.14);
    border-radius: var(--meh-1);
    font-size: 12px;
    padding: 2px 6px;
}

.meh-sidebar-spacer {
    flex: 1;
    min-height: var(--meh-6);
}

.meh-profile {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: var(--meh-4);
}

.meh-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: grid;
    place-content: center;
    border-radius: 50%;
    background: var(--meh-lilac);
    color: var(--meh-lilac-ink);
    font-size: 12px;
    font-weight: 600;
}

.meh-profile-text {
    min-width: 0;
}

.meh-profile-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #f1f5fb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meh-profile-text small {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--meh-side-text);
}

.meh-profile-actions {
    margin-left: auto;
    display: flex;
    gap: var(--meh-1);
}

.meh-sidebar-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--meh-control-sm);
    min-height: var(--meh-control-sm);
    border: 0;
    background: none;
    border-radius: var(--meh-radius-sm);
    color: var(--meh-side-text);
    text-decoration: none;
    cursor: pointer;
}

.meh-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.meh-admin-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--meh-2);
    font-size: 12px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid var(--meh-lilac);
    background: var(--meh-brand-surface-strong);
    color: var(--meh-brand-text);
    border-radius: var(--meh-1);
    padding: 6px 9px;
}

/* ---------------------------------------------------------------- 6. Appearance toggle */
.meh-appearance {
    display: inline-flex;
    align-items: center;
    gap: var(--meh-2);
    min-height: var(--meh-control-sm);
    padding: 6px 10px;
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel);
    color: var(--meh-ink);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.meh-appearance:hover {
    border-color: var(--meh-line-strong);
    background: var(--meh-panel-raised);
}

.meh-appearance .meh-icon {
    color: var(--meh-brand-text);
}

/* Only one of the two labels is ever shown; both exist so the control can be operated
   without a round trip and still announce its new state. */
.meh-appearance[aria-pressed="true"] .meh-appearance-to-dark,
.meh-appearance[aria-pressed="false"] .meh-appearance-to-light {
    display: none;
}

/* ---------------------------------------------------------------- 7. Page furniture */
.meh-page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--meh-5);
    margin-bottom: var(--meh-6);
    flex-wrap: wrap;
}

/* Without min-width:0 a flex item refuses to shrink below its longest word, so one long
   business name widens the whole page rather than wrapping inside its own column. */
.meh-page-head > * {
    min-width: 0;
}

.meh-eyebrow {
    font-size: 12px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--meh-brand-text);
    margin: 0 0 var(--meh-2);
    overflow-wrap: anywhere;
}

.meh-lead {
    color: var(--meh-muted);
    font-size: 14px;
    line-height: 1.6;
    margin: var(--meh-2) 0 0;
    max-width: 70ch;
}

.meh-actions {
    display: flex;
    gap: var(--meh-2);
    align-items: center;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------------- 8. Components */

/* 8.1 Panel */
.meh-panel {
    background: var(--meh-panel);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius);
    overflow: hidden;
    margin-bottom: var(--meh-5);
}

.meh-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--meh-3);
    padding: var(--meh-4) var(--meh-5);
    border-bottom: 1px solid var(--meh-line);
    flex-wrap: wrap;
}

.meh-panel-head small {
    font-size: 12px;
    color: var(--meh-muted);
}

.meh-panel-body {
    padding: var(--meh-5);
}

.meh-panel--narrow {
    max-width: 680px;
}

/* 8.2 Stat cards. The accent is a named modifier, not :nth-child: a row can hold two, three
   or five cards without the meaning of a colour moving to a different measure. */
.meh-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--meh-3);
    margin-bottom: var(--meh-6);
}

.meh-stat {
    background: var(--meh-panel);
    border: 1px solid var(--meh-line);
    border-top: 3px solid #bccce4;
    border-radius: 9px;
    padding: var(--meh-4);
}

.meh-stat--brand { border-top-color: var(--meh-brand); }
.meh-stat--lilac { border-top-color: var(--meh-lilac); }
.meh-stat--gold { border-top-color: var(--meh-gold); }

.meh-stat-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--meh-2);
    font-size: 13px;
    color: var(--meh-muted);
}

.meh-stat-value {
    font-family: var(--meh-title-font);
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -1px;
    line-height: 1.1;
    margin: var(--meh-3) 0 var(--meh-2);
}

.meh-stat small {
    font-size: 12px;
    color: var(--meh-muted);
    line-height: 1.5;
}

.meh-stat small b {
    color: var(--meh-brand-text);
    font-weight: 600;
}

/* 8.3 Status pill. Colour never carries the meaning alone — the word does. */
.meh-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    line-height: 1.4;
    padding: 4px 8px;
    border-radius: var(--meh-1);
    background: var(--meh-neutral-surface);
    color: var(--meh-neutral-ink);
    border: 1px solid transparent;
}

.meh-tag--dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.meh-tag--ok { background: var(--meh-ok-surface); color: var(--meh-ok-ink); }
.meh-tag--warn { background: var(--meh-warn-surface); color: var(--meh-warn-ink); }
.meh-tag--info { background: var(--meh-info-surface); color: var(--meh-info-ink); }
.meh-tag--neutral { background: var(--meh-neutral-surface); color: var(--meh-neutral-ink); }
.meh-tag--danger { background: var(--meh-danger-surface); color: var(--meh-danger-ink); }
.meh-tag--outline {
    background: transparent;
    border-color: var(--meh-line-strong);
    color: var(--meh-muted);
}

/* 8.4 Buttons */
.meh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--meh-2);
    min-height: var(--meh-control);
    padding: 10px var(--meh-4);
    border: 1px solid var(--meh-line-strong);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel);
    color: var(--meh-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.meh-btn:hover {
    background: var(--meh-panel-raised);
    border-color: var(--meh-muted);
    color: var(--meh-ink);
}

.meh-btn--primary {
    background: var(--meh-brand);
    border-color: var(--meh-brand);
    color: var(--meh-on-brand);
}

.meh-btn--primary:hover {
    background: var(--meh-brand-hover);
    border-color: var(--meh-brand-hover);
    color: var(--meh-on-brand);
}

.meh-btn--danger {
    background: var(--meh-panel);
    border-color: var(--meh-danger);
    color: var(--meh-danger);
}

.meh-btn--danger:hover {
    background: var(--meh-danger-surface);
    border-color: var(--meh-danger);
    color: var(--meh-danger-ink);
}

.meh-btn--quiet {
    border-color: transparent;
    background: transparent;
    color: var(--meh-brand-text);
}

.meh-btn--quiet:hover {
    background: var(--meh-brand-surface);
    border-color: transparent;
}

.meh-btn--sm {
    min-height: var(--meh-control-sm);
    padding: 6px 10px;
    font-size: 13px;
}

/*
  On a touch device every button gets the full 44px target, including the small variant.
  Keyed on the POINTER rather than the width: a small button is fine under a mouse at any window
  size, and a phone held on a roof is the case the brief is actually about. Measured on the
  inspection editor at 375px, where "Add to changes" — the primary action of every field — was
  36px tall.
*/
@media (pointer: coarse) {
    .meh-app .meh-btn,
    .meh-app .meh-btn--sm,
    .meh-app .meh-page-link,
    .meh-app .meh-sidebar-link {
        min-height: var(--meh-control);
    }
}

.meh-btn:disabled,
.meh-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: default;
}

.meh-btn:disabled:hover,
.meh-btn[aria-disabled="true"]:hover {
    background: var(--meh-panel);
    border-color: var(--meh-line-strong);
}

/* 8.5 Forms */
.meh-field {
    display: block;
    margin-bottom: var(--meh-4);
}

.meh-field-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: var(--meh-2);
}

.meh-required {
    color: var(--meh-danger);
    margin-left: 2px;
}

.meh-input,
.meh-app select.meh-input,
.meh-app textarea.meh-input {
    display: block;
    width: 100%;
    min-height: var(--meh-control);
    padding: 10px var(--meh-3);
    border: 1px solid var(--meh-line-strong);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel);
    color: var(--meh-ink);
    font: inherit;
    font-size: 15px;
}

.meh-app textarea.meh-input {
    min-height: 92px;
    resize: vertical;
}

.meh-input::placeholder {
    color: var(--meh-muted);
    opacity: 1;
}

.meh-input:hover {
    border-color: var(--meh-muted);
}

.meh-input:disabled {
    background: var(--meh-panel-raised);
    color: var(--meh-muted);
    cursor: default;
}

.meh-input[aria-invalid="true"],
.meh-input.invalid {
    border-color: var(--meh-danger);
    border-width: 2px;
}

.meh-field-hint {
    display: block;
    margin-top: var(--meh-2);
    font-size: 13px;
    line-height: 1.5;
    color: var(--meh-muted);
}

.meh-field-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: var(--meh-2);
    font-size: 13px;
    color: var(--meh-danger);
}

.meh-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--meh-4);
}

/* Optional is marked on the field that is optional, rather than every other field carrying a
   required asterisk — the shorter list is the one worth reading. */
.meh-optional {
    font-weight: 400;
    font-size: 13px;
    color: var(--meh-muted);
}

/* A form column wide enough to read but not so wide the eye loses the label-to-input pairing. */
.meh-form-column {
    max-width: 760px;
}

/* Several small forms sharing one table cell. Each action is its own POST with its own
   FormName, so they cannot be one form; this lays them out as though they were. */
.meh-row-actions {
    display: flex;
    gap: var(--meh-2);
    flex-wrap: wrap;
    align-items: center;
}

.meh-swatch-row {
    display: flex;
    align-items: center;
    gap: var(--meh-2);
}

/* A separator that does not need a bullet character in the markup. */
.meh-dot-sep::before {
    content: "·";
    margin: 0 var(--meh-2);
    color: var(--meh-line-strong);
}

.meh-app hr {
    border: 0;
    border-top: 1px solid var(--meh-line);
    margin: var(--meh-5) 0;
}

.meh-search {
    display: flex;
    align-items: center;
    gap: var(--meh-2);
    min-height: var(--meh-control-sm);
    padding: 4px var(--meh-3);
    border: 1px solid var(--meh-line-strong);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel);
    color: var(--meh-muted);
}

.meh-search input {
    border: 0;
    background: none;
    outline: none;
    color: var(--meh-ink);
    font: inherit;
    font-size: 14px;
    min-width: 0;
    width: 190px;
}

/* 8.5b Filter tabs and search. Both are ANCHORS and a GET form, never script: a filtered,
   searched, paged view is then a URL someone can share, bookmark and reload, and it works
   with no circuit on a server-rendered page. */
.meh-tabs {
    display: flex;
    align-items: center;
    gap: var(--meh-4);
    flex-wrap: wrap;
}

.meh-tab {
    display: inline-flex;
    align-items: center;
    min-height: var(--meh-control-sm);
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    color: var(--meh-muted);
    text-decoration: none;
    font-size: 14px;
}

.meh-tab:hover {
    color: var(--meh-ink);
}

/* Emphasis by text-shadow, not font-weight: a heavier weight widens the label, so switching
   tab slid every later tab (and anything laid out after the row) sideways. */
.meh-tab.active {
    color: var(--meh-brand-text);
    border-bottom-color: var(--meh-brand);
    text-shadow: 0 0 0.6px currentColor, 0 0 0.6px currentColor;
}

.meh-search-form {
    display: flex;
    align-items: center;
    gap: var(--meh-2);
    flex-wrap: wrap;
}

/* A row of filter selects with one Apply button, aligned on their controls rather than their
   labels so the button sits level with the inputs and not with the text above them. */
.meh-filter-form {
    display: flex;
    gap: var(--meh-3);
    flex-wrap: wrap;
    align-items: flex-end;
    width: 100%;
}

.meh-filter-form .meh-field {
    margin-bottom: 0;
    min-width: 180px;
    flex: 1 1 180px;
}

.meh-filter-form .meh-field--action {
    flex: 0 0 auto;
    min-width: 0;
}

/* Key/value pairs inside a table cell, for audit metadata. */
.meh-kv {
    font-size: 13px;
}

.meh-kv span {
    color: var(--meh-muted);
}

.meh-kv span::after {
    content: ":";
}

.meh-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--meh-ink);
    background: var(--meh-panel-raised);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-1);
    padding: 1px 5px;
}

/* A secret shown once: selectable in a single gesture, wrapping rather than scrolling so the
   whole value is visible at a glance, and focusable so it can be reached and copied by keyboard. */
.meh-secret {
    display: block;
    margin: var(--meh-3) 0;
    padding: var(--meh-3);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    color: var(--meh-ink);
    background: var(--meh-panel);
    border: 1px solid var(--meh-line-strong);
    border-radius: var(--meh-radius-sm);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    user-select: all;
}

/* A select sitting inline with a button in a table row, rather than filling the cell. */
.meh-input--inline {
    display: inline-block;
    width: auto;
    max-width: 210px;
    min-height: var(--meh-control-sm);
    padding: 6px 10px;
    font-size: 14px;
}

/* The quiet second line under a status: what is happening, or what happens next. */
.meh-next-step {
    display: block;
    margin-top: var(--meh-1);
    font-size: 12px;
    color: var(--meh-muted);
}

/* Doubled class, because .meh-definition is declared later in this file and would otherwise win
   the two-column template at equal specificity. The role key reads as a stacked list: its
   descriptions are sentences, not values, and they wrap to nothing in a side column. */
.meh-definition.meh-role-key {
    margin: var(--meh-4) 0;
    padding: var(--meh-3);
    background: var(--meh-panel-raised);
    border-radius: var(--meh-radius-sm);
    font-size: 13px;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--meh-1);
}

.meh-role-key dt {
    font-weight: 600;
    color: var(--meh-ink);
}

.meh-role-key dd + dt {
    margin-top: var(--meh-2);
}

/* A logo on an unknown background needs a neutral surface behind it — a white logo on a white
   panel would look like nothing was uploaded. */
.meh-logo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--meh-4);
    margin-bottom: var(--meh-4);
    background: var(--meh-panel-raised);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius-sm);
}

.meh-logo-preview img {
    max-height: 80px;
    max-width: 100%;
}

.meh-stacked-form {
    margin-top: var(--meh-3);
}

/* Checkboxes as a real fieldset. The whole row is the label, so the hit target is the full
   width rather than a 16px box — the difference between easy and fiddly on a phone. */
.meh-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.meh-fieldset legend {
    padding: 0;
    margin-bottom: var(--meh-2);
}

.meh-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--meh-1);
}

.meh-checkbox {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    min-height: var(--meh-control);
    padding: 0 var(--meh-3);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel);
    cursor: pointer;
}

.meh-checkbox:hover {
    border-color: var(--meh-line-strong);
    background: var(--meh-panel-raised);
}

.meh-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--meh-brand);
    flex-shrink: 0;
}

.meh-checkbox:has(input:checked) {
    border-color: var(--meh-brand);
    background: var(--meh-brand-surface);
}

/* :has is recent enough to be worth a fallback for the focus ring, since the input itself is
   what receives focus but the border a reader sees belongs to the label. */
.meh-checkbox:has(input:focus-visible) {
    outline: 3px solid var(--meh-focus);
    outline-offset: 2px;
}

/* The unauthenticated landing copy: a readable measure, centred in the content area. */
.meh-marketing {
    max-width: 640px;
    padding: var(--meh-8) 0;
}

.meh-marketing h1 {
    margin-bottom: var(--meh-3);
}

/* 8.6 Tables */
.meh-table-wrap {
    overflow-x: auto; /* scrolls inside the panel; the document never scrolls sideways */
}

.meh-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.meh-table th {
    background: var(--meh-panel-raised);
    color: var(--meh-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: var(--meh-3) var(--meh-4);
    border-bottom: 1px solid var(--meh-line);
    white-space: nowrap;
}

.meh-table td {
    padding: var(--meh-3) var(--meh-4);
    border-bottom: 1px solid var(--meh-line);
    vertical-align: top;
}

.meh-table tbody tr:last-child td {
    border-bottom: 0;
}

.meh-table tbody tr:hover {
    background: var(--meh-brand-surface);
}

.meh-table td strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
}

.meh-table td small {
    color: var(--meh-muted);
    font-size: 13px;
}

/* The whole identity cell is the link, so the target is a comfortable size on a phone and
   the name and its slug cannot drift apart. */
.meh-table-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.meh-table-link:hover strong {
    color: var(--meh-brand-text);
    text-decoration: underline;
}

.meh-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.meh-muted-cell {
    color: var(--meh-muted);
    white-space: nowrap;
}

.meh-table-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--meh-3);
    flex-wrap: wrap;
    padding: var(--meh-3) var(--meh-4);
    border-top: 1px solid var(--meh-line);
    font-size: 13px;
    color: var(--meh-muted);
}

.meh-pagination {
    display: flex;
    align-items: center;
    gap: var(--meh-1);
}

.meh-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--meh-control-sm);
    min-height: var(--meh-control-sm);
    padding: 0 10px;
    border: 1px solid var(--meh-line-strong);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel);
    color: var(--meh-ink);
    text-decoration: none;
    font-size: 13px;
}

.meh-page-link:hover {
    background: var(--meh-panel-raised);
    color: var(--meh-ink);
}

.meh-page-link[aria-current="page"] {
    background: var(--meh-brand);
    border-color: var(--meh-brand);
    color: var(--meh-on-brand);
    font-weight: 600;
}

.meh-page-link[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}

/* 8.7 Empty, loading, error */
.meh-empty {
    text-align: center;
    padding: var(--meh-10) var(--meh-5);
    color: var(--meh-muted);
}

.meh-empty h3 {
    margin-bottom: var(--meh-2);
}

.meh-skeleton {
    background: linear-gradient(90deg, var(--meh-brand-surface) 25%, var(--meh-panel-raised) 37%, var(--meh-brand-surface) 63%);
    background-size: 400% 100%;
    animation: meh-shimmer 1.4s ease infinite;
    border-radius: var(--meh-radius-sm);
    min-height: 16px;
}

@keyframes meh-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.meh-callout {
    display: flex;
    gap: var(--meh-3);
    padding: var(--meh-4);
    border: 1px solid var(--meh-gold-line);
    border-left: 4px solid var(--meh-gold);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-gold-surface);
    color: var(--meh-gold-ink);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: var(--meh-5);
}

.meh-callout h2,
.meh-callout h3 {
    color: inherit;
    margin-bottom: var(--meh-1);
}

.meh-callout--danger {
    border-color: var(--meh-danger);
    border-left-color: var(--meh-danger);
    background: var(--meh-danger-surface);
    color: var(--meh-danger-ink);
}

.meh-callout--info {
    border-color: var(--meh-line-strong);
    border-left-color: var(--meh-brand);
    background: var(--meh-brand-surface);
    color: var(--meh-ink);
}

/* 8.8 Two-column page body: main column plus a narrower rail. Collapses to one column
   before the sidebar does, because the rail is supporting detail, not navigation. */
.meh-two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--meh-5);
    align-items: start;
}

@media (max-width: 1250px) {
    .meh-two-column {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 8.8b Settings layout: a section sub-navigation beside the page body (Account/Manage).
   The sub-nav is a light-surface list, not a second copy of the navy sidebar, so the two
   levels of navigation never look like the same control. */
.meh-settings {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--meh-5);
    align-items: start;
}

.meh-subnav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--meh-2);
    background: var(--meh-panel);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius);
}

.meh-subnav-item {
    display: flex;
    align-items: center;
    min-height: var(--meh-control-sm);
    padding: 6px var(--meh-3);
    border-radius: var(--meh-radius-sm);
    border-left: 3px solid transparent;
    color: var(--meh-muted);
    text-decoration: none;
    font-size: 14px;
}

.meh-subnav-item:hover {
    background: var(--meh-brand-surface);
    color: var(--meh-ink);
}

.meh-subnav-item.active {
    background: var(--meh-brand-surface);
    border-left-color: var(--meh-brand);
    color: var(--meh-brand-text);
    font-weight: 600;
}

@media (max-width: 900px) {
    .meh-settings {
        grid-template-columns: minmax(0, 1fr);
    }

    /* A scrolling strip on a narrow screen, so the settings body is not pushed below a
       seven-item list. */
    .meh-subnav {
        flex-direction: row;
        overflow-x: auto;
    }

    .meh-subnav-item {
        white-space: nowrap;
        border-left: 0;
        border-bottom: 3px solid transparent;
    }

    .meh-subnav-item.active {
        border-bottom-color: var(--meh-brand);
    }
}

/* The same structure as .meh-two-column for pages whose content needs the full width: the
   markup stays identical, so a page can move between the two by changing one class. */
.meh-single-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--meh-5);
    align-items: start;
}

.meh-callout-list {
    margin: var(--meh-2) 0 0;
    padding-left: var(--meh-4);
}

.meh-callout-list li + li {
    margin-top: var(--meh-1);
}

.meh-callout a {
    color: inherit;
    font-weight: 600;
}

/* 8.9 Activity list */
.meh-activity {
    list-style: none;
    margin: 0;
    padding: 0;
}

.meh-activity-item {
    display: flex;
    gap: var(--meh-3);
    padding: var(--meh-4) var(--meh-5);
    border-bottom: 1px solid var(--meh-line);
}

.meh-activity-item:last-child {
    border-bottom: 0;
}

.meh-activity-icon {
    display: grid;
    place-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 7px;
    background: var(--meh-brand-surface);
    color: var(--meh-brand-text);
}

.meh-activity-item strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.meh-activity-item p {
    margin: var(--meh-1) 0 0;
    font-size: 13px;
    color: var(--meh-muted);
}

.meh-activity-item time {
    display: block;
    margin-top: var(--meh-1);
    font-size: 12px;
    color: var(--meh-muted);
}

/* 8.9b Evidence: the customer's own photographs, grouped by what they show.
   Never recoloured, dimmed or inverted for dark mode — an installer is reading a real photograph
   of a real switchboard, and adjusting it to suit the theme would change what they see. */
.meh-evidence-group + .meh-evidence-group {
    margin-top: var(--meh-5);
}

.meh-evidence-group h3 {
    margin-bottom: var(--meh-3);
}

.meh-evidence-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--meh-3);
}

.meh-evidence {
    margin: 0;
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius-sm);
    overflow: hidden;
    background: var(--meh-evidence);
}

.meh-evidence img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.meh-evidence-placeholder {
    display: grid;
    place-content: center;
    aspect-ratio: 1;
    color: var(--meh-muted);
    font-size: 13px;
}

.meh-evidence figcaption {
    padding: var(--meh-2);
    background: var(--meh-panel);
}

/* Survey detail: every photograph in ONE grid, each captioned with what it shows. A heading
   and a grid per photo type left one lonely tile per row on a typical survey (most types have
   a single photo), so the panel ran to several screens of mostly empty space. Landscape tiles
   because nearly every customer photo is landscape, and a square crop cut off the parts of a
   switchboard an installer is looking for. */
.meh-evidence-grid--flat {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.meh-evidence-grid--flat .meh-evidence img,
.meh-evidence-grid--flat .meh-evidence-placeholder {
    aspect-ratio: 4 / 3;
}

.meh-evidence-grid--flat figcaption {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--meh-1);
}

.meh-evidence-label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--meh-ink);
}

.meh-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--meh-2);
}

/* 8.9c The site inspection editor. Used on a phone, on site, often one-handed. */
.meh-inspection {
    max-width: 900px;
}

/* Always visible, because on site the save state has to be true at a glance. It sticks to the
   top of the CONTENT area, not the window, so it never covers the navigation. */
.meh-savebar {
    position: sticky;
    top: 0;
    z-index: 5;
    margin-bottom: var(--meh-4);
    padding: var(--meh-3) 0;
    background: var(--meh-bg);
    border-bottom: 1px solid var(--meh-line);
}

.meh-savebar-row {
    display: flex;
    align-items: center;
    gap: var(--meh-3);
    flex-wrap: wrap;
}

.meh-savebar-time {
    font-size: 13px;
    color: var(--meh-muted);
}

.meh-savebar-action {
    margin-left: auto;
}

.meh-savebar-message {
    margin-top: var(--meh-2);
    padding: var(--meh-2) var(--meh-3);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-info-surface);
    color: var(--meh-info-ink);
    font-size: 14px;
}

.meh-savebar-message.is-error {
    background: var(--meh-warn-surface);
    color: var(--meh-warn-ink);
}

/* Collapsible section. A <details> so it works without script and keeps its state on the page. */
.meh-section {
    background: var(--meh-panel);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius);
    margin-bottom: var(--meh-4);
    overflow: hidden;
}

.meh-section > summary {
    display: flex;
    align-items: center;
    gap: var(--meh-2);
    min-height: var(--meh-control);
    padding: var(--meh-3) var(--meh-5);
    cursor: pointer;
    font-family: var(--meh-title-font);
    font-weight: 600;
    font-size: 16px;
    list-style: none;
}

.meh-section > summary::-webkit-details-marker {
    display: none;
}

/* A rotating caret drawn in CSS: one less SVG in a list that repeats per section. */
.meh-section > summary::before {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--meh-muted);
    border-bottom: 2px solid var(--meh-muted);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.meh-section[open] > summary::before {
    transform: rotate(45deg);
}

.meh-section > summary:hover {
    background: var(--meh-panel-raised);
}

.meh-section-body {
    padding: 0 var(--meh-5) var(--meh-5);
    border-top: 1px solid var(--meh-line);
    padding-top: var(--meh-4);
}

.meh-subpanel {
    margin-top: var(--meh-4);
    padding: var(--meh-4);
    border: 1px solid var(--meh-line);
    border-radius: var(--meh-radius-sm);
    background: var(--meh-panel-raised);
}

.meh-subpanel h3 {
    margin-bottom: var(--meh-3);
}

.meh-inspection-field {
    padding: var(--meh-4) 0;
    border-bottom: 1px solid var(--meh-line);
}

.meh-inspection-field:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

/* One column on a phone, so a gloved thumb never has to hit a half-width control. */
.meh-inspection-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--meh-2);
    margin-top: var(--meh-2);
}

@media (min-width: 720px) {
    .meh-inspection-row {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
    }

    .meh-inspection-note,
    .meh-inspection-row .meh-row-actions {
        grid-column: 1 / -1;
    }
}

.meh-input-group {
    display: flex;
    align-items: center;
    gap: var(--meh-2);
}

.meh-input-unit {
    font-size: 14px;
    color: var(--meh-muted);
    flex-shrink: 0;
}

.meh-saved-value {
    display: block;
    margin-top: var(--meh-1);
    font-size: 13px;
    color: var(--meh-muted);
}

.meh-evidence.is-superseded {
    opacity: 0.6;
}

.meh-evidence figcaption strong {
    display: block;
    font-size: 13px;
}

.meh-evidence-source,
.meh-evidence-note {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--meh-muted);
}

.meh-evidence figcaption .meh-row-actions {
    margin-top: var(--meh-2);
}

.meh-review-list {
    margin: var(--meh-2) 0 var(--meh-4);
    padding-left: var(--meh-5);
    font-size: 14px;
}

.meh-review-list li + li {
    margin-top: var(--meh-1);
}

.meh-publish-actions {
    margin-top: var(--meh-4);
}

.meh-btn--block {
    width: 100%;
}

/* Blazor's @bind on a checkbox needs the input itself, so this variant carries the sizing the
   .meh-checkbox descendant selector would otherwise apply. */
.meh-checkbox-input {
    width: 18px;
    height: 18px;
    accent-color: var(--meh-brand);
    flex-shrink: 0;
}

/* 8.10 Definition list */
.meh-definition {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: var(--meh-2) var(--meh-4);
    font-size: 14px;
    margin: 0;
}

.meh-definition dt {
    color: var(--meh-muted);
}

.meh-definition dd {
    margin: 0;
    font-weight: 500;
    /* An email address or a blob reference is one long token, and in a side panel it would
       otherwise run past the panel's edge. Values are data, not prose, so breaking one is
       right where breaking a table header was not. */
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- 9. Bootstrap bridge */
/*
  Staff pages still carry Bootstrap markup until their slice lands. Without this, dark mode
  would render white cards and dark text on a dark page. These rules are scoped INSIDE
  .meh-app, so Bootstrap itself is unchanged for the customer wizard and Identity pages.
*/
.meh-app .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--meh-ink);
    --bs-table-border-color: var(--meh-line);
    --bs-table-hover-bg: var(--meh-brand-surface);
    --bs-table-hover-color: var(--meh-ink);
    --bs-table-striped-color: var(--meh-ink);
    --bs-table-striped-bg: var(--meh-panel-raised);
    color: var(--meh-ink);
}

.meh-app .table > thead {
    color: var(--meh-muted);
}

/* Deliberately NOT `overflow-wrap: anywhere` on cells. It does stop a long customer email
   setting the table's width, but it also breaks ordinary headers mid-word ("Pro duct s"),
   which is worse than a table the reader scrolls. The scroll container on .meh-content is
   what keeps the document from moving. */

.meh-app .card {
    background: var(--meh-panel);
    border-color: var(--meh-line);
    color: var(--meh-ink);
    border-radius: var(--meh-radius);
}

.meh-app .card-header,
.meh-app .card-footer {
    background: var(--meh-panel-raised);
    border-color: var(--meh-line);
    color: var(--meh-ink);
}

.meh-app .list-group-item {
    background: var(--meh-panel);
    border-color: var(--meh-line);
    color: var(--meh-ink);
}

.meh-app .form-control,
.meh-app .form-select {
    min-height: var(--meh-control);
    background: var(--meh-panel);
    border-color: var(--meh-line-strong);
    color: var(--meh-ink);
    font-size: 15px;
}

.meh-app .form-control:focus,
.meh-app .form-select:focus {
    background: var(--meh-panel);
    color: var(--meh-ink);
    border-color: var(--meh-brand);
    box-shadow: none;
}

.meh-app .form-control::placeholder {
    color: var(--meh-muted);
    opacity: 1;
}

.meh-app .form-text,
.meh-app .text-muted {
    color: var(--meh-muted) !important;
}

/* Floating labels. Bootstrap leaves a select's label at its own near-black, which on a dark
   panel is all but invisible, and paints a white chip behind a raised label via ::after.
   Both are fixed here rather than page by page, because every staff form uses the pattern. */
.meh-app .form-floating > label {
    color: var(--meh-muted);
}

.meh-app .form-floating > .form-control:focus ~ label::after,
.meh-app .form-floating > .form-control:not(:placeholder-shown) ~ label::after,
.meh-app .form-floating > .form-control-plaintext ~ label::after,
.meh-app .form-floating > .form-select ~ label::after {
    background-color: var(--meh-panel);
}

/* The literal `.btn-primary { background-color: #1b6ec2 }` in app.css is a plain declaration,
   so Bootstrap's own `background-color: var(--bs-btn-bg)` never wins and setting the variable
   alone leaves the button scaffold-blue. These declare the colours outright at a higher
   specificity, and the variables below still carry the hover and active states. */
.meh-app .btn-primary {
    background-color: var(--meh-brand);
    border-color: var(--meh-brand);
    color: #ffffff;
}

.meh-app .btn-primary:hover,
.meh-app .btn-primary:active,
.meh-app .btn-primary:focus-visible {
    background-color: var(--meh-brand-hover);
    border-color: var(--meh-brand-hover);
    color: #ffffff;
}

.meh-app .btn-primary {
    --bs-btn-bg: var(--meh-brand);
    --bs-btn-border-color: var(--meh-brand);
    --bs-btn-hover-bg: var(--meh-brand-hover);
    --bs-btn-hover-border-color: var(--meh-brand-hover);
    --bs-btn-active-bg: var(--meh-brand-hover);
    --bs-btn-active-border-color: var(--meh-brand-hover);
    --bs-btn-color: #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-disabled-bg: var(--meh-brand);
    --bs-btn-disabled-border-color: var(--meh-brand);
}

.meh-app .btn-outline-secondary,
.meh-app .btn-secondary {
    --bs-btn-color: var(--meh-ink);
    --bs-btn-border-color: var(--meh-line-strong);
    --bs-btn-bg: var(--meh-panel);
    --bs-btn-hover-bg: var(--meh-panel-raised);
    --bs-btn-hover-color: var(--meh-ink);
    --bs-btn-hover-border-color: var(--meh-muted);
}

.meh-app .btn {
    min-height: var(--meh-control-sm);
}

.meh-app .alert-success {
    background: var(--meh-ok-surface);
    border-color: transparent;
    color: var(--meh-ok-ink);
}

.meh-app .alert-danger {
    background: var(--meh-danger-surface);
    border-color: transparent;
    color: var(--meh-danger-ink);
}

.meh-app .alert-warning {
    background: var(--meh-warn-surface);
    border-color: transparent;
    color: var(--meh-warn-ink);
}

.meh-app .alert-info {
    background: var(--meh-info-surface);
    border-color: transparent;
    color: var(--meh-info-ink);
}

.meh-app .badge.bg-secondary {
    background: var(--meh-neutral-surface) !important;
    color: var(--meh-neutral-ink);
}

.meh-app .modal-content,
.meh-app .dropdown-menu {
    background: var(--meh-panel);
    border-color: var(--meh-line);
    color: var(--meh-ink);
}

.meh-app hr {
    border-color: var(--meh-line);
    opacity: 1;
}

/* Radzen overlays render in a portal at the end of <body>, outside .meh-app, so they are
   themed from the document attribute instead — but ONLY on a document that contains the
   staff shell. The appearance cookie is site-wide (path=/), so data-mode="dark" also lands
   on customer pages; keyed on the attribute alone, a staffer who once chose dark would get a
   dark dropdown panel in an otherwise light customer wizard. StaffStylesheetScopeTests pins
   that every selector here is anchored to .meh-app. */
html[data-mode="dark"]:has(.meh-app) .rz-dialog,
html[data-mode="dark"]:has(.meh-app) .rz-popup,
html[data-mode="dark"]:has(.meh-app) .rz-dropdown-panel {
    background: #142238;
    color: #e4e9f2;
    border-color: #30415a;
}

/* ---------------------------------------------------------------- 10. Responsive */
@media (max-width: 1100px) {
    .meh-app {
        --meh-sidebar-w: 224px;
    }

    .meh-content,
    .meh-topbar,
    .meh-footer {
        padding-left: var(--meh-5);
        padding-right: var(--meh-5);
    }
}

/* Phone: the sidebar becomes a banner with a horizontally scrolling nav strip. Identity and
   sign-out move into the top bar, because on a phone the sidebar's profile block is gone. */
@media (max-width: 760px) {
    .meh-app {
        display: block;
    }

    .meh-sidebar {
        width: 100%;
        flex: none;
        padding: var(--meh-4);
        position: static;
        height: auto;
        overflow-y: visible;
    }

    .meh-brand {
        margin-bottom: var(--meh-3);
    }

    .meh-workspace {
        margin-bottom: var(--meh-3);
    }

    .meh-nav-label,
    .meh-sidebar-spacer,
    .meh-profile {
        display: none;
    }

    .meh-nav {
        flex-direction: row;
        gap: var(--meh-1);
        overflow-x: auto;
        padding-bottom: var(--meh-1);
    }

    .meh-nav-item {
        white-space: nowrap;
    }

    .meh-nav-item .meh-nav-count {
        display: none;
    }

    .meh-topbar {
        flex-wrap: wrap;
        padding: var(--meh-3) var(--meh-4);
    }

    .meh-topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .meh-content {
        padding: var(--meh-5) var(--meh-4);
    }

    .meh-footer {
        padding: var(--meh-2) var(--meh-4) var(--meh-4);
        flex-direction: column;
        gap: var(--meh-1);
    }

    .meh-app h1 {
        font-size: 24px;
    }

    .meh-page-head {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ---------------------------------------------------------------- 11. Motion */
@media (prefers-reduced-motion: reduce) {
    .meh-app *,
    .meh-app *::before,
    .meh-app *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/*
  Screen-reader-only text that still gets announced.

  `clip-path: inset(50%)` rather than the deprecated `clip: rect(0,0,0,0)`, which is the current
  recipe. I first changed this believing it fixed a horizontal-overflow bug on the business detail
  page; re-measured properly, it did not — `document.body.scrollWidth` was 375 either way. The
  change stands on its own merits, but it fixed nothing.

  Measuring note for anyone chasing overflow in the preview pane: `documentElement.scrollWidth`
  reports the OUTER window width under viewport emulation (it read 791 on a 375px viewport), so it
  will invent overflow that does not exist. Compare `document.body.scrollWidth` against
  `document.body.clientWidth` instead.
*/
.meh-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
}
