/* ============================================================================
   MIRACLE APP SHELL  ·  chrome (layered on mds.css)
   ----------------------------------------------------------------------------
   The app chrome that frames every view but is not content: the navy pillar
   rail, the mobile topbar + drawer/scrim, the cargo bar / cargo-selector
   overlay, the CargoHead, the group tab bar + sub-pills, the licence badge,
   the account menu and the footer. Content primitives (cards, tables, the
   .mds-field search chassis, the .mds-empty state) stay in mds.css core.
   Classes keep their mds- prefix; only the file boundary marks the layering.
   Linked in index.html after mds.css and before the feature files.
   ============================================================================ */

/* ============================================================================
   APP SHELL  ·  navy pillar rail (left) + white topbar + content column
   ----------------------------------------------------------------------------
   Concept B: the rail hosts the platform pillars; the topbar shows the active
   pillar. Desktop: slim 64px rail that hover-expands to show labels. Mobile
   (< md): the rail becomes an off-canvas drawer toggled by ☰ over a scrim.
   ============================================================================ */
:root { --mds-rail: 64px; --mds-rail-open: 264px; --mds-topbar: 56px; --mds-quickpane-w: 340px; }

/* ---- pillar rail ---- */
.mds-rail { position: fixed; left: 0; top: 0; bottom: 0; width: var(--mds-rail);
    background: var(--mds-chrome); color: #fff; z-index: var(--mds-z-rail);
    display: flex; flex-direction: column; overflow: hidden;
    transition: transform .2s ease, width .15s ease, box-shadow .15s ease; }
.mds-rail__brand { height: var(--mds-topbar); flex: none; position: relative;
    display: flex; align-items: center; padding: 0 var(--mds-space-4); }
/* Both logos live in the brand as an opacity crossfade (a display swap can't take the
   hover-intent delay below and would flicker on a quick mouse sweep, issue #20). */
.mds-rail__logo--mark { height: 28px; width: 28px; object-fit: contain; filter: brightness(0) invert(1);
    transition: opacity .12s ease; }
.mds-rail__logo--full { height: 30px; width: auto; opacity: 0; filter: brightness(0) invert(1);
    position: absolute; left: var(--mds-space-4); top: 50%; transform: translateY(-50%);
    transition: opacity .12s ease; }
.mds-rail__item { display: flex; align-items: center; gap: 14px; height: 46px; flex: none;
    padding: 0 20px; color: #cfe0e6; text-decoration: none; white-space: nowrap; cursor: pointer; }
.mds-rail__item i { min-width: 24px; text-align: center; font-size: 16px; }
.mds-rail__item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.mds-rail__item.is-active { background: rgba(255, 255, 255, .12); color: #fff;
    box-shadow: inset 3px 0 0 var(--mds-accent); }
.mds-rail__item--soon { cursor: default; color: rgba(255, 255, 255, .45); }
.mds-rail__item--soon:hover { background: none; color: rgba(255, 255, 255, .45); }
.mds-rail__label { flex: 1; }
.mds-rail__soon { font-size: 11px; background: rgba(255, 255, 255, .15); color: #cfe0e6;
    padding: 1px 6px; border-radius: var(--mds-radius-lg); }
.mds-rail__spacer { flex: 1; }
/* labels are hidden while the rail is the slim strip; revealed on hover-expand */
.mds-rail__label, .mds-rail__soon { opacity: 0; transition: opacity .12s ease; }
/* Rail states (issue #20, take 2): NO hover behavior at all — the rail is either slim
   (icons + tooltips) or expanded, switched ONLY by the chevron toggle at its foot and
   persisted. Two stable states, nothing opens or closes under the mouse. */
@media (min-width: 768px) {
    .mds-rail--expanded { width: var(--mds-rail-open); }
    .mds-rail--expanded .mds-rail__label, .mds-rail--expanded .mds-rail__soon { opacity: 1; }
    .mds-rail--expanded .mds-rail__logo--mark { opacity: 0; }
    .mds-rail--expanded .mds-rail__logo--full { opacity: 1; }
}
/* The expand toggle is a desktop affordance; the mobile drawer is always expanded. */
.mds-rail__toggle { background: none; border: 0; font: inherit; }
@media (max-width: 767px) {
    .mds-rail__toggle { display: none; }
}

/* ---- content column beside the rail ---- */
/* White, not canvas-gray: gray beside the capped panel read as "the page doesn't
   scale". The content edge is drawn by the panel's right hairline instead (mds.css). */
.mds-shell { margin-left: var(--mds-rail); min-height: 100vh;
    display: flex; flex-direction: column; background: var(--mds-surface);
    transition: margin-left .15s ease; }
/* Expanded rail (issue #20) reserves its width — AFTER the base rule so it wins. */
@media (min-width: 768px) {
    .mds-shell--railexpanded { margin-left: var(--mds-rail-open); }
}
/* left-align the page content against the rail (margin-left:0 beats Bootstrap's
   .container-fluid margin:auto; whitespace collects on the right) and cap the
   measure. This is the bridge that holds the legacy grid in the mds shell until
   the Bootstrap grid itself is retired; it replaces an inline style on the
   container. */
.mds-content { max-width: 1400px; margin-left: 0; margin-top: var(--mds-space-6); }

/* ---- topbar: MOBILE ONLY — ☰ (opens the rail drawer) + active pillar name.
   On desktop the rail is always visible and the account/badge live at its foot,
   so there is no topbar (shown only < md, below). ---- */
.mds-topbar { display: none; position: sticky; top: 0; z-index: var(--mds-z-topbar); flex: none;
    background: var(--mds-surface); border-bottom: 1px solid var(--mds-line);
    align-items: center; gap: var(--mds-space-4);
    height: var(--mds-topbar); padding: 0 var(--mds-space-4); }
.mds-topbar__burger { display: inline-flex; background: none; border: 0; cursor: pointer;
    font-size: 19px; color: var(--mds-title); padding: var(--mds-space-2); }
.mds-topbar__section { font-weight: 700; color: var(--mds-title); font-size: 15px; }
.mds-badge--basic { background: var(--mds-tint); color: var(--mds-accent-ink); }

/* ---- scrim behind the mobile drawer ---- */
.mds-scrim { display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, .4); z-index: var(--mds-z-scrim); }

@media (max-width: 767px) {
    .mds-topbar { display: flex; }
    .mds-rail { transform: translateX(-100%); width: var(--mds-rail-open); }
    .mds-rail.mds-rail--open { transform: none; }
    .mds-rail__label, .mds-rail__soon { opacity: 1; }
    .mds-rail__logo--mark { opacity: 0; }
    .mds-rail__logo--full { opacity: 1; }
    .mds-shell { margin-left: 0; }
    .mds-scrim.is-open { display: block; }
}

/* ============================================================================
   CARGO SELECTOR  ·  inline search field → full-screen overlay
   ----------------------------------------------------------------------------
   ONE reusable selector. A slim search-field anchor (.mds-cargobar) sits in the
   workspace; clicking it (or Enter/Space on it — it is a role="button", never a
   focus handler) opens a full-screen overlay (.mds-cargosel)
   carrying Search · Favorites · Recent. The same overlay is reused inline for
   the 2nd / adjacent cargo — the anchor's data-mode tells it what to do with
   the pick. Results render INSIDE the overlay (AJAX SearchResult fragment).
   The search-field chassis (.mds-field) is a core primitive in mds.css; the
   anchor and overlay field compose it.
   ============================================================================ */
.mds-detail { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- the inline anchor: a .mds-field that looks like a search box and opens
   the overlay (it carries a label span, not a real input) ----------------- */
.mds-cargobar { width: 100%; max-width: 480px;
    margin: var(--mds-space-4) auto var(--mds-space-4) var(--mds-space-5);
    cursor: text; color: var(--mds-muted); font-size: var(--mds-text-sm); }
.mds-cargobar:hover { border-color: var(--mds-accent); }
.mds-cargobar__nm { flex: 1; }
.mds-cargobar__ar { margin-left: auto; color: var(--mds-muted); }

/* ---- wide-screen quick-switch pane: docked Recent + Favorites + a search
   field that opens the overlay. Hidden by default; only shown when there is
   room for it AND the content (breakpoint below), where it replaces the inline
   top field. Dock at 1500px (custom, above the lg 1024 contract): fits the
   340px pane + 3 card columns (1500 − 64 rail − 340 pane ≈ 1096). Kept this
   low because 150%-scaled displays (DPR 1.5) cap the CSS viewport near 1554px,
   so a higher threshold would almost never trigger. ----------------------- */
.mds-quickpane { display: none; }
/* width:auto so the field fills the pane minus its margins (the base .mds-cargobar
   is width:100%, which would overflow the pane to the right once margins apply) */
.mds-cargobar--pane { margin: var(--mds-space-4); max-width: none; width: auto; }
.mds-quickpane__scroll { flex: 1; overflow: auto; }

@media (min-width: 1500px) {
    .mds-quickpane { display: flex; flex-direction: column;
        position: fixed; top: 0; bottom: 0; left: var(--mds-rail); width: var(--mds-quickpane-w);
        background: var(--mds-surface); border-right: 1px solid var(--mds-line); z-index: var(--mds-z-pane); }
    .mds-shell--cargo { margin-left: calc(var(--mds-rail) + var(--mds-quickpane-w)); }
    .mds-detail > .mds-cargobar { display: none; }   /* the pane carries the field now */
    /* expanded rail (issue #20): pane and content shift by the expanded rail width */
    .mds-rail--expanded ~ .mds-quickpane { left: var(--mds-rail-open); }
    .mds-shell--cargo.mds-shell--railexpanded { margin-left: calc(var(--mds-rail-open) + var(--mds-quickpane-w)); }
}

/* ---- the overlay: covers the workspace, the search field stays exactly
   where the anchor was (same top-left offset), the content underneath is
   hidden. The field is anchored; only the body fills with results. -------- */
.mds-cargosel { display: none; position: fixed; top: 0; left: var(--mds-rail); right: 0; bottom: 0;
    z-index: var(--mds-z-overlay); background: var(--mds-canvas); flex-direction: column; }
.mds-rail--expanded ~ .mds-cargosel { left: var(--mds-rail-open); }   /* expanded rail, issue #20 */
body.mds-cargo-open .mds-cargosel { display: flex; }
/* lock the page behind the overlay so only the result list scrolls (otherwise
   the page's own scrollbar sits next to the overlay's). Quirk: on classic
   (space-taking) scrollbars this can shift the page by one scrollbar width on
   open/close; add `scrollbar-gutter: stable` to the scroller if that bites. */
body.mds-cargo-open { overflow: hidden; }
/* the panel fills the overlay as a flex column so the result list can scroll */
.mds-cargosel__panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mds-cargosel__head { display: flex; align-items: center; gap: var(--mds-space-3); flex: none;
    padding: var(--mds-space-4) var(--mds-space-5) var(--mds-space-3); }
/* Ad-hoc pick-mode banner: the selector is answering a module's question, not switching cargo. */
.mds-cargosel__mode { flex: none; padding: var(--mds-space-2) var(--mds-space-5) 0;
    font-size: var(--mds-text-sm); font-weight: 600; color: var(--mds-accent-ink); }

/* Module-side second-cargo field (issue #2): label + search input, or the picked
   cargo with remove/change. Empty, it is a text field (issue #41) — the pill keeps the
   old button's look, the text input inside it carries the prompt as its placeholder. */
.mds-secondfield { display: flex; align-items: center; flex-wrap: wrap; gap: var(--mds-space-2); }
.mds-secondfield__label { font-weight: 600; color: var(--mds-title); font-size: var(--mds-text-sm); }
.mds-secondfield__search { display: inline-flex; align-items: center; gap: var(--mds-space-1-5);
    border: 1px solid var(--mds-line); border-radius: var(--mds-radius-lg); background: var(--mds-surface);
    padding: 6px 12px; font-family: inherit; font-size: var(--mds-text-sm); color: var(--mds-muted);
    cursor: text; }
.mds-secondfield__search:hover, .mds-secondfield__search:focus-within { border-color: var(--mds-accent);
    color: var(--mds-accent-ink); }
/* the input drops its own outline (it is borderless inside the pill), so the pill has to carry
   the focus ring — an accent border alone is what hover already does, and a keyboard user must
   be able to tell "my focus is here" from "the mouse is over it". */
.mds-secondfield__search:focus-within { outline: 2px solid var(--mds-accent); outline-offset: 2px; }
.mds-secondfield__input { width: 260px; max-width: 100%; border: 0; outline: 0; background: none;
    padding: 0; font-family: inherit; font-size: var(--mds-text-sm); color: var(--mds-title); }
.mds-secondfield__input::placeholder { color: var(--mds-muted); opacity: 1; }
.mds-secondfield__value { font-weight: 600; color: var(--mds-title); font-size: var(--mds-text-sm); }
.mds-secondfield__clear { border: none; background: none; cursor: pointer; color: var(--mds-muted);
    font-size: var(--mds-text-lg); line-height: 1; padding: 0 var(--mds-space-1); }
.mds-secondfield__clear:hover { color: var(--mds-danger); }
.mds-secondfield__change { border: none; background: none; cursor: pointer; padding: 0;
    color: var(--mds-accent-ink); font-family: inherit; font-size: var(--mds-text-xs);
    text-decoration: underline; }
/* the field mirrors .mds-cargobar 1:1 (both are .mds-field) so it sits in the
   same spot when opened; accent border marks the active/focused state */
.mds-cargosel__field { position: relative; width: 100%; max-width: 480px;
    border-color: var(--mds-accent); }

/* suggestions combobox (Alpine) — floats under the field */
.mds-combo { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: var(--mds-z-combo);
    background: var(--mds-surface); border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius-lg); box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
    padding: var(--mds-space-1) 0; max-height: 320px; overflow: auto; }
.mds-combo__item { padding: 8px 14px; cursor: pointer;
    font-size: var(--mds-text-sm); color: var(--mds-title); }
.mds-combo__item.is-active { background: var(--mds-tint); }
.mds-cargosel__close { margin-left: auto; border: 0; background: none; font-size: 26px; line-height: 1;
    cursor: pointer; color: var(--mds-muted); }
.mds-cargosel__close:hover { color: var(--mds-title); }
/* the result panel sits in the body, indented to line up with the field */
.mds-cargosel .mds-pscroll { padding: 0 var(--mds-space-5) var(--mds-space-5); }
/* the result row's real link (synonym cell): row look stays, keyboard focus shows */
.mds-results__link { color: inherit; text-decoration: none; }
.mds-results__link:focus-visible { outline: 2px solid var(--mds-accent); outline-offset: 1px; }

/* tabs + scroll body (reused by the overlay) */
.mds-ptabs { display: flex; border-bottom: 1px solid var(--mds-line); flex: none;
    padding: 0 var(--mds-space-5); }
/* compact, left-aligned under the field — not spread across the full width */
.mds-ptab { flex: none; padding: 11px 16px; border: 0; background: none; cursor: pointer;
    font-size: var(--mds-text-xs); color: var(--mds-muted);
    border-bottom: 2px solid transparent; font-family: inherit; }
.mds-ptab.is-active { color: var(--mds-title); font-weight: 700; border-bottom-color: var(--mds-text); }

.mds-pscroll { flex: 1; min-height: 0; overflow: auto; }
.mds-ppanel { display: none; }
.mds-ppanel.is-active { display: block; }

/* Real links since the a11y pass — keep the row look, not the browser's link look. */
.mds-crow { text-decoration: none; color: inherit; }
.mds-crow { display: flex; align-items: center; gap: var(--mds-space-2);
    padding: 9px 14px; border-bottom: 1px solid var(--mds-gray-100); cursor: pointer;
    color: var(--mds-title); text-decoration: none; }
.mds-crow:hover { background: var(--mds-tint); }
.mds-crow.is-active { background: var(--mds-tint); box-shadow: inset 3px 0 0 var(--mds-text); }
.mds-crow__nm { flex: 1; font-weight: 500; font-size: var(--mds-text-xs); line-height: 1.35;
    letter-spacing: .02em; }
.mds-crow__nm small { display: block; color: var(--mds-muted); font-weight: 400; }

.mds-pane-group { padding: 10px 14px var(--mds-space-1);
    font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--mds-muted); }
.mds-pane-empty { padding: var(--mds-space-6) var(--mds-space-4); color: var(--mds-muted);
    font-size: var(--mds-text-sm); text-align: center; line-height: 1.5; }

/* ---- favorites pane: group filter + empty state (issue #44) -------------- */
/* The group filter IS the shell's sub-pill row (.mds-subpills/.mds-pill), only tightened
   to the pane's 14px row inset. Drawn as buttons because it filters rather than navigates,
   so it needs the form-control resets the anchor version gets for free. */
.mds-favgroups { gap: var(--mds-space-1); padding: var(--mds-space-3) 14px var(--mds-space-1); }
button.mds-pill { font-family: inherit; font-size: var(--mds-text-xs); cursor: pointer; }
/* the big centred empty state, brought down to a pane column (the quick-pane is ~300px) */
.mds-favempty { margin: var(--mds-space-8) auto; padding: 0 var(--mds-space-4); }
.mds-favempty .mds-empty__icon { font-size: 28px; }
.mds-favempty .mds-empty__title { margin: var(--mds-space-3) 0 var(--mds-space-1);
    font-size: var(--mds-text-lg); }
.mds-favempty .mds-empty__text { font-size: var(--mds-text-sm); }

/* ---- the search-result table: cards on phones, the 6-column table from 768px
   (issue #35). On a 390px screen the six columns overflow horizontally and hide
   exactly the identity values a vetting officer confirms a product with (CAS,
   UN, Miracle ID) behind a scrollbar nobody sees. So mobile-first the rows
   become cards; markup is untouched, which is why the cells are addressed by
   COLUMN POSITION -- CargoResultsColumnContractTests pins that order down.
   The whole row stays the tap target, as on the wide layout. ------------- */
.mds-results, .mds-results tbody { display: block; }
.mds-results thead { display: none; }             /* the ::before labels replace it */
.mds-results tbody tr { display: block; min-height: 44px; padding: var(--mds-space-2);
    border: 1px solid var(--mds-line); border-radius: var(--mds-radius); }
.mds-results tbody tr + tr { margin-top: var(--mds-space-2); }
.mds-results td { display: block; padding: 0; border-bottom: 0; }
/* the card is the surface now, so the pick highlight belongs on the row -- the core
   rule tints the cells, which in card layout only paints behind the text lines.
   Undoing the core cell tint is CARD-ONLY (see the max-width block below): on the wide
   table the core rule keeps doing the tinting, exactly as before this feature. */
.mds-results tbody tr.mds-table__row--link:hover { background: var(--mds-tint); }
.mds-results td:nth-child(1) { color: var(--mds-title); font-weight: 700; }   /* synonyms = the title */
/* CAS / UN / Miracle ID share one quiet identity line under the names */
.mds-results td:nth-child(n+4) { display: inline-block; margin: var(--mds-space-1) var(--mds-space-2) 0 0;
    color: var(--mds-muted); font-size: var(--mds-text-sm); }
.mds-results td:nth-child(4)::before { content: "CAS "; }
.mds-results td:nth-child(5)::before { content: "UN "; }
.mds-results td:nth-child(6)::before { content: "ID "; }
/* a value the product has not got leaves no blank line -- and no orphaned label.
   Last in the block on purpose: it has to beat the identity rule above. */
.mds-results td:empty { display: none; }

@media (min-width: 768px) {
    /* room for all six columns again -- back to the plain table, visually unchanged.
       The cell rule has to undo per-column card rules, so it carries a :nth-child()
       of its own (matching every cell): without it the card selectors outrank it. */
    .mds-results { display: table; }
    .mds-results thead { display: table-header-group; }
    .mds-results tbody { display: table-row-group; }
    .mds-results tbody tr, .mds-results tbody tr + tr { display: table-row; min-height: 0;
        padding: 0; margin-top: 0; border: 0; border-radius: 0; }
    .mds-results tbody tr td:nth-child(n) { display: table-cell; margin: 0;
        padding: var(--mds-space-1) var(--mds-space-2); border-bottom: 1px solid var(--mds-line);
        color: inherit; font-size: inherit; font-weight: inherit; }
    .mds-results tbody tr td:nth-child(n)::before { content: none; }
    /* the legacy grid printed "-" for a value the product has not got. That is grid
       formatting, so it is drawn here instead of travelling in the DTO (the cards drop
       the whole line instead, which needs a truly empty cell). One pseudo-class more
       (0,3,4) than the cell rule above (0,2,3), so the display reset cannot swallow it. */
    .mds-results tbody tr td:nth-child(n):empty::after { content: "-"; }
}

@media (max-width: 767px) {
    /* card layout only: the row carries the pick highlight, so the core cell tint has to go */
    .mds-results tbody tr.mds-table__row--link:hover td { background: none; }
    .mds-cargobar { max-width: none; margin: var(--mds-space-3) var(--mds-space-4); }
    .mds-cargosel { left: 0; }
    .mds-cargosel__head { padding: var(--mds-space-3) var(--mds-space-4); }
    .mds-cargosel__field { max-width: none; }
    .mds-cargosel .mds-ptabs { padding: 0 var(--mds-space-4); }
    .mds-cargosel .mds-pscroll { padding: 0 var(--mds-space-4) var(--mds-space-4); }
}

/* ---- cargo workspace: header (cargo name + Jump-to) --------------------- */
/* position: relative so the favorite popover can anchor to the whole header on phones */
.mds-cargohead { position: relative; display: flex; align-items: center; gap: var(--mds-space-3);
    flex-wrap: wrap; background: var(--mds-surface); padding: var(--mds-space-4) var(--mds-space-5) 0; }
.mds-cargohead__name { margin: 0; color: var(--mds-title); font-weight: 600;
    font-size: var(--mds-text-2xl); line-height: 1.2; }

/* ---- favorite star: explicit toggle + the group popover (issue #43) ------ */
.mds-favstar { position: relative; display: inline-flex; align-items: center; }
.mds-favstar__btn { background: none; border: 0; padding: var(--mds-space-1); cursor: pointer;
    color: var(--mds-muted); font-size: var(--mds-text-lg); line-height: 1; }
.mds-favstar__btn:hover { color: var(--mds-warning); }
.mds-favstar__btn[aria-pressed="true"] { color: var(--mds-warning); }
/* Not a favorite = an OUTLINED star. The FA subset ships the solid style only (no regular),
   so the outline is drawn as a text stroke; where that is unsupported the rules above stand
   and the state reads as a muted vs. amber solid star. */
@supports (-webkit-text-stroke: 1px currentColor) {
    .mds-favstar__btn[aria-pressed="false"] .fa-star { color: transparent;
        -webkit-text-stroke: 1.5px var(--mds-muted); }
    .mds-favstar__btn[aria-pressed="false"]:hover .fa-star { -webkit-text-stroke-color: var(--mds-warning); }
}
/* State UNKNOWN: the list never loaded, so neither star may be shown - the button carries no
   aria-pressed at all and neither rule above matches. Faded so it reads as "not answered yet"
   rather than as either answer; it stays clickable, because the click is the retry. */
.mds-favstar__btn.is-unknown { opacity: .4; }
.mds-favstar__btn.is-unknown:hover { opacity: 1; color: var(--mds-muted); }

.mds-favstar__pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--mds-z-menu);
    min-width: 240px; display: grid; gap: var(--mds-space-2);
    background: var(--mds-surface); border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius-lg); box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    padding: var(--mds-space-3); }
.mds-favstar__label { font-size: var(--mds-text-xs); color: var(--mds-muted); }
.mds-favstar__select,
.mds-favstar__newname { width: 100%; padding: 6px 8px; font: inherit; font-size: var(--mds-text-sm);
    color: var(--mds-text); background: var(--mds-surface); border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius); }
.mds-favstar__actions { display: flex; justify-content: flex-end; gap: var(--mds-space-2); }
.mds-favstar__error { margin: 0; font-size: var(--mds-text-xs); color: var(--mds-danger); }
/* the failed-un-star message has no popover to sit in: float it under the star */
.mds-favstar__error--loose { position: absolute; top: calc(100% + 2px); left: 0; white-space: nowrap;
    z-index: var(--mds-z-menu); }
/* same outside-click catcher as the Jump-to menu */
.mds-favstar__backdrop { position: fixed; inset: 0; z-index: calc(var(--mds-z-menu) - 1); }

@media (max-width: 767px) {
    /* A popover hung under the star runs off the right edge as soon as the cargo name is long.
       Static positioning hands the anchor to .mds-cargohead, so it spans the header instead. */
    .mds-favstar { position: static; }
    .mds-favstar__pop { left: var(--mds-space-4); right: var(--mds-space-4); min-width: 0; }
    .mds-favstar__error--loose { left: var(--mds-space-4); right: var(--mds-space-4);
        white-space: normal; }
}

.mds-jumpto { position: relative; }
.mds-jumpto__btn { display: inline-flex; align-items: center; gap: var(--mds-space-1);
    border: 1px solid var(--mds-line); background: var(--mds-surface); border-radius: var(--mds-radius-lg);
    padding: 7px 12px; font-size: var(--mds-text-sm); cursor: pointer; color: var(--mds-title); font-family: inherit; }
.mds-jumpto__btn:hover { background: var(--mds-canvas); }
.mds-jumpto__menu { display: none; position: absolute; top: calc(100% + 6px); right: 0; min-width: 240px;
    background: var(--mds-surface); border: 1px solid var(--mds-line); border-radius: var(--mds-radius-lg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18); padding: var(--mds-space-1) 0; z-index: var(--mds-z-menu);
    max-height: 70vh; overflow: auto; }
.mds-jumpto.is-open .mds-jumpto__menu { display: block; }
.mds-jumpto__menu a { display: block; padding: var(--mds-space-2) var(--mds-space-3); color: var(--mds-text);
    text-decoration: none; font-size: var(--mds-text-sm); white-space: nowrap; }
.mds-jumpto__menu a:hover { background: var(--mds-raised); color: var(--mds-text); }
.mds-jumpto__sep { height: 1px; background: var(--mds-line); margin: var(--mds-space-1) 0; }
/* Invisible outside-click catcher, just below the menu (Blazor has no document-level
   click handler; the prototype used mds.js for this). */
.mds-jumpto__backdrop { position: fixed; inset: 0; z-index: calc(var(--mds-z-menu) - 1); }

/* ---- cargo workspace: group tab bar + sub-pills -------------------------- */
/* The tab-bar chassis itself (.mds-tabs/.mds-tab) is a core content primitive (mds.css) —
   this file keeps only the chrome wrapper + the group-tab-bar's own responsive label swap. */
.mds-tabsbar { background: var(--mds-surface); }
.mds-tabstrip { position: relative; }
.mds-tab__short { display: none; }

.mds-subpills { display: flex; gap: var(--mds-space-1-5); flex-wrap: wrap;
    padding: var(--mds-space-3) var(--mds-space-5); }
.mds-pill { border: 1px solid var(--mds-line); background: var(--mds-surface); color: var(--mds-muted);
    border-radius: 14px; padding: 5px 12px; font-size: var(--mds-text-xs); text-decoration: none; }
.mds-pill:hover { color: var(--mds-title); }
.mds-pill.is-active { background: var(--mds-text); color: var(--mds-surface); border-color: var(--mds-text); }

@media (max-width: 767px) {
    .mds-tabstrip::after { content: ""; position: absolute; top: 0; right: 0; bottom: 1px; width: 32px;
        pointer-events: none; background: linear-gradient(to right, transparent, var(--mds-surface)); }
    .mds-tab__full { display: none; }
    .mds-tab__short { display: inline; }
    .mds-subpills { padding: var(--mds-space-2) var(--mds-space-4); }
}

/* ---- licence badge: top of the rail, directly under the logo ---- */
.mds-rail__plan { flex: none; padding: var(--mds-space-1) var(--mds-space-4) var(--mds-space-3); }
/* nowrap so the label never wraps to two lines while the rail is mid-expand (it
   is just revealed sideways by the rail's overflow, keeping the badge height fixed) */
.mds-rail__plan .mds-badge { white-space: nowrap; }
.mds-rail__planlabel { display: none; }   /* shown only when the rail is expanded */
.mds-rail--expanded .mds-rail__planlabel { display: inline; }
@media (max-width: 767px)  { .mds-rail__planlabel { display: inline; } }

/* ---- ACCOUNT MENU — lives at the FOOT of the rail ---- */
.mds-acct { position: relative; }
.mds-acct__btn { display: inline-flex; align-items: center; gap: var(--mds-space-2);
    background: none; border: 0; color: var(--mds-title); cursor: pointer; font: inherit;
    padding: var(--mds-space-1) var(--mds-space-2); border-radius: var(--mds-radius); }
.mds-acct__btn:hover { background: var(--mds-canvas); }
.mds-acct__avatar { width: 26px; height: 26px; flex: none; border-radius: 50%;
    background: var(--mds-accent-ink); color: var(--mds-on-accent); display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: var(--mds-text-xs); }
    /* accent-ink, not accent: the initials are text — white on teal-500 was 2.9:1 */
.mds-acct__name { white-space: nowrap; }
.mds-acct__caret { opacity: .7; font-size: 10px; }
.mds-acct__menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 210px;
    background: var(--mds-surface); color: var(--mds-text); border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius-lg); box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    padding: var(--mds-space-1) 0; display: none; }
.mds-acct.is-open .mds-acct__menu { display: block; }
.mds-acct__item { display: flex; align-items: center; gap: var(--mds-space-2);
    padding: var(--mds-space-2) var(--mds-space-3); color: var(--mds-text);
    font-size: var(--mds-text-sm); text-decoration: none; cursor: pointer; white-space: nowrap; }
.mds-acct__item:hover { background: var(--mds-raised); color: var(--mds-text); }
/* Logoff is a <button> among <a> siblings — re-base the UA button chrome (issue #22).
   font-family only: the font shorthand would out-specify .mds-acct__item's text-sm size. */
button.mds-acct__item { background: none; border: 0; font-family: inherit; width: 100%; text-align: left; }
.mds-acct__sep { height: 1px; background: var(--mds-line); margin: var(--mds-space-1) 0; }
.mds-acct__toggle { justify-content: space-between; }   /* Show Tips: label left, checkbox right */

/* account button as a rail item (light on navy); its menu must escape the rail's
   overflow:hidden, so it is position:fixed and pops up from the bottom-left. */
.mds-acct--rail { position: static; }
.mds-acct--rail .mds-acct__btn { display: flex; width: 100%; align-items: center; gap: 14px;
    color: #cfe0e6; padding: 0 20px; height: 52px; border-radius: 0; }
.mds-acct--rail .mds-acct__btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.mds-acct--rail .mds-acct__menu { position: fixed; left: var(--mds-space-2); bottom: 56px;
    top: auto; right: auto; }

/* ============================================================================
   FOOTER  ·  navy, multi-column: brand + tagline, link columns, copy bar
   ============================================================================ */
.mds-footer { background: var(--mds-chrome); color: #fff; }
.mds-footer__inner {
    max-width: 1400px; margin: 0 auto;
    padding: var(--mds-space-6) var(--mds-space-5) var(--mds-space-5);
    display: flex; flex-wrap: wrap; gap: var(--mds-space-6) var(--mds-space-8);
}
.mds-footer__brand { flex: 1 1 240px; min-width: 220px;
    display: flex; flex-direction: column; gap: var(--mds-space-3); }
.mds-footer__logo { height: 30px; width: auto; display: block;
    filter: brightness(0) invert(1); }                 /* dark logo -> white on navy */
.mds-footer__tagline { margin: 0; max-width: 34ch;
    color: rgba(255, 255, 255, .75); font-size: var(--mds-text-sm); line-height: 1.5; }
.mds-footer__col { display: flex; flex-direction: column; align-items: flex-start;
    gap: var(--mds-space-2); min-width: 130px; }
.mds-footer__head { margin: 0 0 var(--mds-space-1); color: #fff; font-weight: 700;
    font-size: var(--mds-text-xs); text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.mds-footer__col a,
#missive-footer-restore { color: rgba(255, 255, 255, .85);
    font-size: var(--mds-text-sm); text-decoration: none; }
.mds-footer__col a:hover,
#missive-footer-restore:hover { color: #fff; text-decoration: underline; }
/* Live-chat restore: _MissiveChat injects this button into #missive-footer-slot
   when the chat is hidden. Looks like a footer link; JS toggles display. */
#missive-footer-restore { display: none; background: none; border: 0;
    padding: 0; cursor: pointer; font-family: var(--mds-font); }
.mds-footer__bar { max-width: 1400px; margin: 0 auto;
    padding: var(--mds-space-3) var(--mds-space-5);
    border-top: 1px solid rgba(255, 255, 255, .12); }
.mds-footer__copy { color: rgba(255, 255, 255, .6); font-size: var(--mds-text-xs); }

/* Day / night palette switch in the account menu (#114): a segmented control, explicit and
   stored; the active segment is ink, not teal (teal means "act on"). */
.mds-theme { display: flex; gap: 2px; margin: var(--mds-space-1) var(--mds-space-2); padding: 2px;
    background: var(--mds-raised); border-radius: var(--mds-radius-lg); }
.mds-theme__opt { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 32px; padding: 0 var(--mds-space-2); border: 0; border-radius: 6px; background: none;
    color: var(--mds-muted); font: inherit; font-size: var(--mds-text-xs); cursor: pointer; }
.mds-theme__opt:hover { color: var(--mds-text); }
.mds-theme__opt.is-active { background: var(--mds-surface); color: var(--mds-text); font-weight: 650;
    box-shadow: 0 0 0 1px var(--mds-line); }
.mds-theme__opt:focus-visible { outline: 2px solid var(--mds-accent); outline-offset: 1px; }
