/* ============================================================================
   MIRACLE DESIGN SYSTEM  ·  prefix: mds-
   ----------------------------------------------------------------------------
   Token-driven, mobile-first, BEM-named, low-specificity CSS kit. Modules
   restyle by COMPOSING these classes (write no new CSS). Namespaced 'mds-' so
   it coexists with Bootstrap / Kendo and depends on neither.

   Breakpoint contract (Tailwind defaults): sm 640 · md 768 · lg 1024.
   Tokens mirror a Tailwind theme so a later ASP.NET-Core + Tailwind move is a
   config copy. See prototypes/tailwind.config.preview.js. Full usage guide:
   docs/mds-design-system.md.
   ============================================================================ */

/* ---- 1. TOKENS ---------------------------------------------------------- */
:root {
    /* primitive palette */
    --mds-teal-50:    #EAF5F6;
    --mds-teal-500:   #47A3AF;   /* brand */
    --mds-teal-600:   #3A8A94;
    --mds-navy-700:   #1D425D;
    --mds-gray-100:   #F8F9FA;
    --mds-gray-200:   #E5E5E5;
    --mds-gray-500:   #68696A;
    --mds-gray-900:   #222222;
    --mds-green-700:  #2E7D32;
    --mds-amber-700:  #B9770E;
    --mds-red-600:    #B23B3B;
    --mds-orange-500: #E87722;
    --mds-gold-300:   #FFD700;
    --mds-gold-400:   #FFB347;

    /* semantic aliases (components reference ONLY these) */
    --mds-accent:      var(--mds-teal-500);
    --mds-accent-ink:  var(--mds-teal-600);
    --mds-title:       var(--mds-navy-700);
    --mds-on-accent:   #FFFFFF;
    --mds-text:        var(--mds-gray-900);
    --mds-muted:       var(--mds-gray-500);
    --mds-line:        var(--mds-gray-200);
    --mds-surface:     #FFFFFF;
    --mds-canvas:      var(--mds-gray-100);
    --mds-tint:        var(--mds-teal-50);
    --mds-success:     var(--mds-green-700);
    --mds-warning:     var(--mds-amber-700);
    --mds-danger:      var(--mds-red-600);

    /* spacing (Tailwind scale: 1=4px … 8=32px, 11=44px) */
    --mds-space-0-5: 2px;  --mds-space-1: 4px;   --mds-space-1-5: 6px;
    --mds-space-2: 8px;    --mds-space-2-5: 10px; --mds-space-3: 12px;
    --mds-space-4: 16px;   --mds-space-5: 20px;  --mds-space-6: 24px;
    --mds-space-7: 28px;   --mds-space-8: 32px;  --mds-space-11: 44px;

    /* radii (Tailwind: sm 2 · DEFAULT 4 · lg 8) */
    --mds-radius-sm: 2px; --mds-radius: 4px; --mds-radius-lg: 8px;

    /* z-index layers (low → high). One source of truth for the stacking order:
       combo < pane < topbar < menu < scrim < overlay < rail */
    --mds-z-combo: 10; --mds-z-pane: 40; --mds-z-topbar: 45; --mds-z-menu: 50;
    --mds-z-scrim: 55; --mds-z-overlay: 60; --mds-z-rail: 70;

    /* type — Inter is the UI font (self-hosted, see CSS/fonts/fonts.css).
       xs/sm bumped one step over the prototype baseline for data-dense legibility. */
    --mds-font:     'Inter', 'Segoe UI', Arial, sans-serif;
    --mds-text-xs:  12px;
    --mds-text-sm:  14px;
    --mds-text-lg:  16px;
    --mds-text-2xl: 22px;
}

/* ---- 2. SCAFFOLD: panel + title ---------------------------------------- */
.mds-panel {
    background: var(--mds-surface);
    padding: var(--mds-space-4);
    font-family: var(--mds-font);
    font-size: var(--mds-text-sm);
    line-height: 1.5;            /* Inter legibility (prototype-tuned) */
    letter-spacing: -0.005em;
    color: var(--mds-text);
}
@media (min-width: 768px) { .mds-panel { padding: var(--mds-space-11); } }

.mds-title {
    display: flex; align-items: baseline; justify-content: space-between;
    flex-wrap: wrap; gap: var(--mds-space-1) var(--mds-space-3);
    margin: 0 0 var(--mds-space-3); padding-bottom: var(--mds-space-1);
    border-bottom: 2px solid var(--mds-accent);
}
.mds-title__name { margin: 0; font-size: var(--mds-text-lg); font-weight: 400; color: var(--mds-title); }
.mds-title__meta { font-size: var(--mds-text-sm); color: var(--mds-muted); }
@media (min-width: 768px) { .mds-title__name { font-size: var(--mds-text-2xl); } }

/* ---- 3. CARD LAYOUT: mobile-first masonry (1 → 2 → 3 columns) ----------- */
.mds-cards { column-gap: var(--mds-space-7); }
@media (min-width: 768px)  { .mds-cards { column-count: 2; } }
@media (min-width: 1024px) { .mds-cards { column-count: 3; } }
.mds-card { break-inside: avoid; margin-bottom: var(--mds-space-4); }

/* ---- 4. CARD HEADER: icon badge + title + optional info link ----------- */
.mds-card__head {
    display: flex; align-items: center; gap: var(--mds-space-2);
    margin-bottom: var(--mds-space-1); padding-bottom: var(--mds-space-1);
    border-bottom: 2px solid var(--mds-accent);
    color: var(--mds-title); font-size: var(--mds-text-sm); font-weight: 700; line-height: 20px;
}
.mds-card__icon {
    flex: none; width: 20px; height: 20px; border-radius: var(--mds-radius);
    background: var(--mds-accent);
    display: inline-flex; align-items: center; justify-content: center;
}
.mds-card__icon img { width: 13px; height: 13px; object-fit: contain;
    filter: brightness(0) invert(1); }                 /* render glyph white on accent */
.mds-card__info { margin-left: auto; font-weight: 400; color: var(--mds-muted);
    font-size: var(--mds-text-xs); text-decoration: none; }
.mds-card__info:hover { color: var(--mds-accent-ink); }

/* ---- 5. DATA LIST: label · value · unit  (replaces border-table) -------- */
.mds-data { width: 100%; border-collapse: collapse; }
.mds-data tr { line-height: 19px; }
.mds-data td { padding-top: var(--mds-space-0-5); padding-bottom: var(--mds-space-0-5);
    border-bottom: 1px solid var(--mds-line); vertical-align: top; }
.mds-data tr:last-child td { border-bottom: none; }
/* Only rows that actually link somewhere react to hover (never hover a
   non-clickable row). The whole row is the click target; its "ⓘ" reveals on hover. */
.mds-data__row--link { cursor: pointer; }
.mds-data__row--link:hover td { background: var(--mds-tint); }
.mds-data__row--link .mds-info { visibility: hidden; }
.mds-data__row--link:hover .mds-info { visibility: visible; }
@media (hover: none) { .mds-data__row--link .mds-info { visibility: visible; } }
/* Milbros-style: label column shrinks to the widest label, value sits left
   right after it; unit is an inline muted span inside the value cell. The gap
   lives on the value cell (padding-left) so it shows even for the widest label. */
.mds-data__k { width: 1%; white-space: nowrap; color: var(--mds-text); }
.mds-data__v { text-align: left; font-weight: 600; padding-left: var(--mds-space-4); }
.mds-data__u { margin-left: var(--mds-space-1); font-weight: 400; color: var(--mds-muted); }

/* ---- 6. DATA TABLE: multi-column with header row ----------------------- */
.mds-table { width: 100%; border-collapse: collapse; }
.mds-table th { text-align: left; padding: var(--mds-space-1) var(--mds-space-2);
    color: var(--mds-muted); font-size: var(--mds-text-xs); font-weight: 700;
    text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--mds-line); }
.mds-table td { padding: var(--mds-space-1) var(--mds-space-2); border-bottom: 1px solid var(--mds-line);
    vertical-align: top; }
.mds-table tr.mds-table__row--link { cursor: pointer; }
.mds-table tr.mds-table__row--link:hover td { background: var(--mds-tint); }

/* ---- 6b. DEFINITION LIST: term + body, stack on mobile (notes/glossary) - */
.mds-deflist__row { padding: var(--mds-space-2) var(--mds-space-1); border-bottom: 1px solid var(--mds-line); }
.mds-deflist__term { margin-bottom: var(--mds-space-0-5); font-weight: 700; color: var(--mds-title); }
@media (min-width: 640px) {
    .mds-deflist__row { display: grid; grid-template-columns: 160px 1fr;
        gap: var(--mds-space-3); align-items: start; }
    .mds-deflist__term { margin-bottom: 0; }
}

/* ---- 7. STATUS VALUE --------------------------------------------------- */
.mds-status { font-weight: 700; }
.mds-status--ok   { color: var(--mds-success); }
.mds-status--no   { color: var(--mds-danger); }
.mds-status--warn { color: var(--mds-warning); }

/* ---- 8. CHIP ----------------------------------------------------------- */
.mds-chip { display: inline-block; margin: 0 var(--mds-space-1) var(--mds-space-1) 0;
    padding: var(--mds-space-0-5) var(--mds-space-2); border-radius: var(--mds-radius);
    background: var(--mds-tint); color: var(--mds-accent-ink); font-size: var(--mds-text-xs); }

/* ---- 9. BADGE ---------------------------------------------------------- */
.mds-badge { display: inline-flex; align-items: center; gap: var(--mds-space-1);
    padding: 5px var(--mds-space-2-5); border-radius: var(--mds-radius);
    background: var(--mds-accent); color: var(--mds-on-accent);
    font-size: var(--mds-text-xs); font-weight: 700; }
.mds-badge--premium { background: linear-gradient(var(--mds-gold-300), var(--mds-gold-400)); color: #5A4500; }

/* ---- 10. BUTTON -------------------------------------------------------- */
.mds-btn { display: inline-flex; align-items: center; gap: var(--mds-space-2);
    padding: var(--mds-space-1-5) var(--mds-space-4); border: 1px solid transparent;
    border-radius: var(--mds-radius); font-size: var(--mds-text-sm); font-family: var(--mds-font);
    cursor: pointer; background: var(--mds-canvas); color: var(--mds-text); text-decoration: none; }
.mds-btn:hover { filter: brightness(.97); }
.mds-btn--primary { background: var(--mds-accent); color: var(--mds-on-accent); }
.mds-btn--outline { background: transparent; border-color: var(--mds-accent); color: var(--mds-accent-ink); }
.mds-btn--ghost   { background: var(--mds-canvas); border-color: var(--mds-line); color: var(--mds-text); }
.mds-btn--sm { padding: var(--mds-space-1) var(--mds-space-2-5); font-size: var(--mds-text-xs); }

/* ---- 11. ALERT --------------------------------------------------------- */
.mds-alert { padding: var(--mds-space-2) var(--mds-space-3); border-left: 3px solid var(--mds-accent);
    background: var(--mds-canvas); color: var(--mds-text); }
.mds-alert--success { border-left-color: var(--mds-success); }
.mds-alert--warning { border-left-color: var(--mds-warning); }
.mds-alert--danger  { border-left-color: var(--mds-danger); }

/* ---- 12. ICON ROW: pictograms (PPE, GHS) ------------------------------- */
.mds-icons { display: flex; flex-wrap: wrap; gap: var(--mds-space-2); margin: var(--mds-space-2) 0; }
.mds-icons img { width: 38px; height: 38px; object-fit: contain; }

/* ----------------------------------------------------------------------------
   13. PROSE  ·  long-form reading mode (Knowledgebase articles)
   ----------------------------------------------------------------------------
   The app is a dense data cockpit (14px, tight rhythm). An article is a reading
   surface: bigger type, generous line-height, a capped measure. These tokens
   live in the .mds-prose scope ONLY, so the cockpit views stay untouched.
   Consumes raw semantic HTML (h2/ul/table/figure...) — WordPress block classes
   are stripped upstream; we style the bare elements.
   ---------------------------------------------------------------------------- */
.mds-prose {
    --mds-prose-text: 16px; --mds-prose-lh: 1.65;
    --mds-prose-h1: 28px; --mds-prose-h2: 22px; --mds-prose-h3: 18px;
    --mds-prose-gap: var(--mds-space-4);
    max-width: 68ch;        /* ~65–75 char measure */
    font-size: var(--mds-prose-text); line-height: var(--mds-prose-lh);
    color: var(--mds-text);
}
.mds-prose p { margin: 0 0 var(--mds-prose-gap); }
.mds-prose h1, .mds-prose h2, .mds-prose h3 { color: var(--mds-title); line-height: 1.25; }
.mds-prose h1 { font-size: var(--mds-prose-h1); font-weight: 400;
    margin: 0 0 var(--mds-space-5); padding-bottom: var(--mds-space-1);
    border-bottom: 2px solid var(--mds-accent); }
.mds-prose h2 { font-size: var(--mds-prose-h2); font-weight: 700; margin: var(--mds-space-8) 0 var(--mds-space-3); }
.mds-prose h3 { font-size: var(--mds-prose-h3); font-weight: 700; margin: var(--mds-space-6) 0 var(--mds-space-2); }
.mds-prose a { color: var(--mds-accent-ink); text-decoration: underline; }
.mds-prose strong { font-weight: 700; }
.mds-prose em { font-style: italic; }
.mds-prose ul, .mds-prose ol { margin: 0 0 var(--mds-prose-gap); padding-left: var(--mds-space-6); }
/* restore list markers — the app resets ul/ol to list-style:none for menus */
.mds-prose ul { list-style: disc; }
.mds-prose ul ul { list-style: circle; }
.mds-prose ol { list-style: decimal; }
.mds-prose li { margin-bottom: var(--mds-space-2); }
.mds-prose blockquote { margin: var(--mds-prose-gap) 0; padding-left: var(--mds-space-4);
    border-left: 3px solid var(--mds-line); color: var(--mds-muted); font-style: italic; }
.mds-prose code { padding: 1px var(--mds-space-1); border-radius: var(--mds-radius-sm);
    background: var(--mds-tint); font-family: 'Consolas', monospace; font-size: .9em; }
/* tables: a light cell grid (readable for data, and makes empty cells — e.g.
   the Yes/No tick columns on permit checklists — visible), NOT the compact
   borderless .mds-table of the cockpit */
.mds-prose table { width: auto; max-width: 100%; border-collapse: collapse;
    margin: var(--mds-prose-gap) 0; font-size: var(--mds-text-sm); }
.mds-prose th, .mds-prose td { border: 1px solid var(--mds-line);
    padding: var(--mds-space-1-5) var(--mds-space-3); text-align: left; vertical-align: top; }
.mds-prose th { background: var(--mds-tint); color: var(--mds-title); font-weight: 700; }
/* figures + images: the source floats standalone images (align=*), which the
   normaliser strips — so render them as clean centred blocks with breathing
   room. Thumbnails inside tables / links stay inline at their natural size. */
.mds-prose figure { margin: var(--mds-prose-gap) 0; }
.mds-prose img { max-width: 100%; height: auto; border-radius: var(--mds-radius); }
/* author-floated images: text flows around them (as authored via align=*) */
.mds-prose img[align="right"] { float: right; margin: 4px 0 var(--mds-space-3) var(--mds-space-5); }
.mds-prose img[align="left"]  { float: left;  margin: 4px var(--mds-space-5) var(--mds-space-3) 0; }
/* centred + standalone images -> own centred line, clearing any prior float
   (stops e.g. an align=right diagram bleeding into the next image/section) */
.mds-prose img[align="center"],
.mds-prose > p > img:only-child,
.mds-prose figure > img { display: block; margin: var(--mds-prose-gap) auto; clear: both; float: none; }
/* thumbnails inside tables / links stay inline at natural size */
.mds-prose td img, .mds-prose a img { display: inline-block; margin: 0; float: none; clear: none; }
/* headings clear floats so a floated image never bleeds into the next section */
.mds-prose h2, .mds-prose h3 { clear: both; }
.mds-prose figcaption { margin-top: var(--mds-space-1); text-align: center;
    color: var(--mds-muted); font-size: var(--mds-text-sm); }
/* video embeds: responsive 16:9, never the theme's fixed pixel size */
.mds-prose iframe { display: block; width: 100%; max-width: 720px; aspect-ratio: 16 / 9;
    height: auto; margin: var(--mds-prose-gap) 0; border: 0; border-radius: var(--mds-radius); }
/* disclosures (rebuilt from theme accordions): scan the titles, expand on click */
.mds-prose details { border-bottom: 1px solid var(--mds-line); clear: both; }
.mds-prose summary { cursor: pointer; list-style: none; display: flex; align-items: center;
    gap: var(--mds-space-2); padding: var(--mds-space-3) 0; font-weight: 700; color: var(--mds-title); }
.mds-prose summary::-webkit-details-marker { display: none; }
.mds-prose summary::before { content: "\f054"; font-family: "Font Awesome 5 Free"; font-weight: 900;
    font-size: 11px; color: var(--mds-accent); transition: transform .15s ease; }
.mds-prose details[open] > summary::before { transform: rotate(90deg); }
.mds-prose summary:hover { color: var(--mds-accent-ink); }
.mds-prose details > div { padding: 0 0 var(--mds-space-4) var(--mds-space-6); }
.mds-prose details > div > :first-child { margin-top: 0; }

/* callouts: boxed note (info=teal) / warning (amber) — tint + left bar + icon */
.mds-callout { margin: var(--mds-prose-gap) 0; padding: var(--mds-space-3) var(--mds-space-4);
    border-left: 4px solid var(--mds-accent); border-radius: var(--mds-radius); background: var(--mds-tint); }
.mds-callout__label { display: flex; align-items: center; gap: var(--mds-space-2);
    margin-bottom: var(--mds-space-1); font-weight: 700; color: var(--mds-accent-ink); }
.mds-callout > :last-child { margin-bottom: 0; }
.mds-callout--warning { border-left-color: var(--mds-warning); background: #FDF6E9; }
.mds-callout--warning .mds-callout__label { color: var(--mds-warning); }

/* ---- 13b. PROSE HELPERS ------------------------------------------------- */
.mds-muted   { color: var(--mds-muted); font-size: var(--mds-text-xs); line-height: 14px; }
.mds-accent  { color: var(--mds-accent-ink); font-weight: 700; }
.mds-link    { color: var(--mds-accent-ink); text-decoration: none; }
.mds-link:hover { text-decoration: underline; }
/* inline help link: the small "ⓘ" after a field label -> seminar article */
.mds-info { margin-left: var(--mds-space-1); color: var(--mds-muted);
    font-size: 10px; line-height: 1; text-decoration: none; cursor: pointer; }
.mds-info:hover { color: var(--mds-accent-ink); }

/* ---- 13c. CARD TEXT: short prose inside a cockpit card — 14px and tight, the
   cockpit counterpart to the 16px reading-mode .mds-prose. Keeps text cards
   (description, hazards, cleaning, PPE) at the same size as the data cards. --- */
.mds-cardtext { font-size: var(--mds-text-sm); line-height: 1.5; }
.mds-cardtext p { margin: 0 0 var(--mds-space-2); }
.mds-cardtext > :last-child { margin-bottom: 0; }
.mds-cardtext a { color: var(--mds-accent-ink); text-decoration: none; }
.mds-cardtext a:hover { text-decoration: underline; }
.mds-cardtext ul { margin: 0; padding-left: var(--mds-space-5); list-style: disc; }
.mds-cardtext li { margin-bottom: var(--mds-space-1); list-style: inherit; }
.mds-cardtext li:last-child { margin-bottom: 0; }

/* ---- 14. CHIP GROUP: collapse a long set to ~2 rows + show-all toggle --- */
.mds-chips--collapsed { max-height: 24px; overflow: hidden; }   /* exactly one row of mds-chip (26px pitch) */
.mds-chips-toggle { margin-top: var(--mds-space-1); }   /* behaviour hook; styled by .mds-toggle */

/* ---- 14b. TOGGLE: the one "reveal more" control — a subtle accent text button
   with an optional chevron. Used by every Show all / Update history / Show more,
   and by <summary>. Contrast with .mds-btn, which is for real actions. -------- */
.mds-toggle { display: inline-flex; align-items: center; gap: var(--mds-space-1);
    background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
    color: var(--mds-accent-ink); font-family: var(--mds-font); font-size: var(--mds-text-xs);
    text-decoration: none; }
.mds-toggle:hover { text-decoration: underline; }
.mds-toggle__chev { font-size: 9px; transition: transform .15s ease; }
summary.mds-toggle { list-style: none; width: fit-content; }
summary.mds-toggle::-webkit-details-marker { display: none; }
details[open] > summary.mds-toggle .mds-toggle__chev { transform: rotate(180deg); }
/* a native <details> disclosure block (e.g. the update history) */
.mds-disclosure { margin-top: var(--mds-space-4); }
.mds-disclosure__body { margin-top: var(--mds-space-2); }

/* ----------------------------------------------------------------------------
   15. NOTES  ·  small helpers on top of the deflist (importance, meta, edit)
   ---------------------------------------------------------------------------- */
.mds-notes__icon { margin-right: var(--mds-space-1); }
.mds-notes__icon--red   { color: var(--mds-danger); }
.mds-notes__icon--amber { color: var(--mds-warning); }
.mds-notes__row--user .mds-deflist__term { color: var(--mds-accent-ink); }
.mds-notes .mds-deflist__row { position: relative; }
.mds-notes__meta { margin-top: var(--mds-space-1); font-size: var(--mds-text-xs); }
/* edit: hover-revealed pencil at the row's top-right — adds no row height */
.mds-notes__edit { position: absolute; top: var(--mds-space-2); right: var(--mds-space-1);
    font-size: var(--mds-text-xs); visibility: hidden; }
.mds-notes .mds-deflist__row:hover .mds-notes__edit { visibility: visible; }
@media (hover: none) { .mds-notes__edit { visibility: visible; } }

/* ============================================================================
   16. 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-navy-700); color: #fff; z-index: var(--mds-z-rail);
    display: flex; flex-direction: column; overflow: hidden;
    transition: transform .2s ease, width .15s ease; }
.mds-rail__brand { height: var(--mds-topbar); flex: none;
    display: flex; align-items: center; padding: 0 var(--mds-space-4); }
.mds-rail__logo--mark { height: 28px; width: 28px; object-fit: contain; filter: brightness(0) invert(1); }
.mds-rail__logo--full { height: 30px; width: auto; display: none; filter: brightness(0) invert(1); }
.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: 9px; 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; }
@media (min-width: 768px) {
    .mds-rail:hover { width: var(--mds-rail-open); box-shadow: 4px 0 18px rgba(0, 0, 0, .18); }
    .mds-rail:hover .mds-rail__label, .mds-rail:hover .mds-rail__soon { opacity: 1; }
    .mds-rail:hover .mds-rail__logo--mark { display: none; }
    .mds-rail:hover .mds-rail__logo--full { display: inline; }
}

/* ---- content column beside the rail ---- */
.mds-shell { margin-left: var(--mds-rail); min-height: 100vh;
    display: flex; flex-direction: column; background: var(--mds-canvas); }
/* 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-navy-700); padding: var(--mds-space-2); }
.mds-topbar__section { font-weight: 700; color: var(--mds-navy-700); 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); }
    body.mds-nav-open .mds-rail { transform: none; }
    .mds-rail__label, .mds-rail__soon { opacity: 1; }
    .mds-rail__logo--mark { display: none; }
    .mds-rail__logo--full { display: inline; }
    .mds-shell { margin-left: 0; }
    body.mds-nav-open .mds-scrim { display: block; }
}

/* ============================================================================
   17. CARGO SELECTOR  ·  inline search field → full-screen overlay
   ----------------------------------------------------------------------------
   ONE reusable selector. A slim search-field anchor (.mds-cargobar) sits in the
   workspace; focusing/clicking it 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).
   ============================================================================ */
.mds-detail { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- reusable field chassis: one search/input look, composed by the anchor
   (.mds-cargobar) and the overlay field (.mds-cargosel__field). The KB prototype
   fields (.mds-kbnav__search / .mds-kbhero) should migrate onto this too. ---- */
.mds-field { display: flex; align-items: center; gap: var(--mds-space-2);
    padding: 9px 14px; background: var(--mds-surface);
    border: 1px solid var(--mds-line); border-radius: var(--mds-radius-lg); }
.mds-field i { color: var(--mds-muted); }
.mds-field__input { flex: 1; border: 0; outline: 0; background: none; font-family: inherit;
    font-size: var(--mds-text-sm); color: var(--mds-navy-700); }

/* ---- 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 */
}

/* ---- 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; }
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); }
/* 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-navy-700); }
.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-navy-700); }
/* 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); }

/* 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-navy-700); font-weight: 700; border-bottom-color: var(--mds-accent); }

.mds-pscroll { flex: 1; min-height: 0; overflow: auto; }
.mds-ppanel { display: none; }
.mds-ppanel.is-active { display: block; }

.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-navy-700); 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-accent); }
.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; }

@media (max-width: 767px) {
    .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) --------------------- */
.mds-cargohead { 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-navy-700); font-weight: 600;
    font-size: var(--mds-text-2xl); line-height: 1.2; }

.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-navy-700); 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-accent); color: #fff; }
.mds-jumpto__sep { height: 1px; background: var(--mds-line); margin: var(--mds-space-1) 0; }

/* ---- cargo workspace: group tab bar + sub-pills -------------------------- */
.mds-tabsbar { background: var(--mds-surface); }
.mds-tabstrip { position: relative; }
.mds-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--mds-line);
    overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--mds-space-5); }
.mds-tabs::-webkit-scrollbar { height: 0; }
.mds-tab { flex: none; padding: 12px 14px; color: var(--mds-muted); cursor: pointer;
    font-size: var(--mds-text-sm); white-space: nowrap; text-decoration: none;
    border-bottom: 2px solid transparent; }
.mds-tab:hover { color: var(--mds-navy-700); }
.mds-tab.is-active { color: var(--mds-navy-700); font-weight: 700; border-bottom-color: var(--mds-accent); }
.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-navy-700); }
.mds-pill.is-active { background: var(--mds-accent); color: #fff; border-color: var(--mds-accent); }

@media (max-width: 767px) {
    .mds-tabs { padding: 0 var(--mds-space-4); }
    .mds-tabstrip::after { content: ""; position: absolute; top: 0; right: 0; bottom: 1px; width: 32px;
        pointer-events: none; background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff); }
    .mds-tab__full { display: none; }
    .mds-tab__short { display: inline; }
    .mds-subpills { padding: var(--mds-space-2) var(--mds-space-4); }
}

/* ---- empty state: shown until a cargo is selected ---------------------- */
.mds-empty { max-width: 420px; margin: var(--mds-space-11) auto; text-align: center; }
.mds-empty__icon { font-size: 40px; color: var(--mds-accent); opacity: .5; }
.mds-empty__title { margin: var(--mds-space-4) 0 var(--mds-space-2);
    font-size: var(--mds-text-2xl); font-weight: 600; color: var(--mds-title); }
.mds-empty__text { margin: 0; color: var(--mds-muted); line-height: 1.5; }

/* ---- 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 */
@media (min-width: 768px) { .mds-rail:hover .mds-rail__planlabel { display: inline; } }
@media (max-width: 767px)  { .mds-rail__planlabel { display: inline; } }

/* ---- 18. 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-navy-700); 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); color: #fff; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: var(--mds-text-xs); }
.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-accent); color: #fff; }
.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; }

/* ----------------------------------------------------------------------------
   19. FOOTER  ·  navy, multi-column: brand + tagline, link columns, copy bar
   ---------------------------------------------------------------------------- */
.mds-footer { background: var(--mds-navy-700); 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); }

/* ----------------------------------------------------------------------------
   20. FRAMEWORK INTEGRATION  ·  the two spots where mds- meets Bootstrap / Alpine.
   ----------------------------------------------------------------------------
   Focus ring: Bootstrap (B3 bootstrap.css + B5 frontpage/main.css) draws an
   outline / box-shadow on :focus that lingers after a mouse click. Suppress it
   for pointer focus, keep it for :focus-visible (keyboard) — the modern, a11y-
   correct default.
   x-cloak: Alpine convention — keep [x-cloak] elements hidden until Alpine
   initialises (it then strips the attribute) so templated markup never flashes.
   ---------------------------------------------------------------------------- */
:focus:not(:focus-visible) { outline: none !important; box-shadow: none !important; }
[x-cloak] { display: none !important; }
