/* ════════════════════════════════════════════════════════════════════════
   matrix.css — v29.9 "ENTERPRISE LIGHT" institutional skin (Urbanist).

   Replatformed from the v28.11 dark/lime WORKSPACE theme to a premium
   banking-portal aesthetic: crisp white canvas, muted slate secondary panels,
   subtle borders, generous whitespace, high-contrast slate-ink typography and
   a deep corporate NAVY for primary CTAs + active states.  The theme is still
   driven by the :root tokens — every component references them, so the
   palette swap reskins all pages at once.

   GUARDRAIL: every existing class NAME is preserved (machinery untouched).
   The .mx-input / .mx-select white-surface contract (#ffffff / #0f172a) is
   intentionally KEPT — it was already light-native and reads perfectly here.

   v29.15 — DUAL THEME: this file is the LIGHT theme and stays the default.
   The optional dark "WORKSPACE" skin lives in matrix-dark.css as an
   `html.theme-dark` token-override layer (toggled from /matrix/profile);
   the shell surfaces below therefore read their colours from the
   --bg-shell / --bg-topbar tokens instead of hardcoded dark hexes — which
   also fixes the v29.9 contrast defects (dark-ink brand/title text sat on
   leftover near-black sidebar/topbar/footer surfaces).
   ════════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Urbanist:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* ── v29.9 "ENTERPRISE LIGHT" palette ──────────────────────────────────── */
  --bg-app: #f8fafc;            /* crisp near-white canvas (slate-50)        */
  --bg-surface: #ffffff;        /* white content card                        */
  --bg-elevated: #f1f5f9;       /* muted slate nested panel                  */
  --bg-elevated-hi: #e2e8f0;    /* hover / higher elevation                  */
  --text-main: #0f172a;         /* high-contrast slate-ink text              */
  --text-strong: #020617;       /* headline emphasis                         */
  --text-muted: #64748b;        /* secondary / ancillary labels              */
  --border-color: #e2e8f0;      /* subtle divider stroke                     */
  --border-light: rgba(2, 6, 23, 0.06);

  /* Deep corporate NAVY for primary CTAs + active states (banking-grade)     */
  --primary: #1e3a8a;
  --primary-hover: #172f70;
  --primary-ink: #ffffff;       /* white text ON the navy accent             */
  --accent-cyan: #0e7490;
  --danger: #dc2626;
  --success: #15803d;

  /* Legacy template vars (used inline across pages) mapped to the new skin.  */
  --matrix-text-muted: var(--text-muted);
  --matrix-text-dim: #94a3b8;
  --matrix-text-primary: var(--text-main);   /* v29.16 — high-contrast body ink */
  --matrix-blue-hi: #1e3a8a;    /* gradient-heading start  → navy            */
  --matrix-cyan: #0e7490;       /* gradient-heading end    → teal-ink        */

  /* v29.15 — app-shell surfaces (sidebar / topbar / footer).  White panels
     separated from the slate canvas by borders + soft shadows so the layout
     reads with depth instead of the flat dark-shell mismatch.              */
  --bg-shell: #ffffff;
  --bg-topbar: #ffffff;

  /* v29.81 — display type token (Anthropic frontend-design "distinctive
     pairing"): the geometric Urbanist body is paired with a tightly-tracked
     display treatment for headings.  A single token so a future characterful
     display face can be swapped in one place.                              */
  --font-display: 'Urbanist', 'Inter', system-ui, sans-serif;

  /* Geometry — premium whitespace, soft light-mode depth.                    */
  --radius: 14px;
  /* v59.0 "Kinetic & Organic" — LAYERED, diffused elevation.  Flat borders
     read as machine-made; a hairline ring + two soft diffusion layers give
     cards and modals real spatial depth in the airy light theme. */
  --shadow-sm: 0 0 0 1px rgb(15 23 42 / 0.03),
               0 1px 3px 0 rgb(15 23 42 / 0.06),
               0 4px 12px -4px rgb(15 23 42 / 0.06);
  --shadow-md: 0 0 0 1px rgb(15 23 42 / 0.03),
               0 4px 10px -4px rgb(15 23 42 / 0.08),
               0 12px 32px -8px rgb(15 23 42 / 0.14);
}

/* Base Reset */
body.matrix-skin {
  margin: 0; padding: 0;
  background-color: var(--bg-app); color: var(--text-main);
  font-family: 'Urbanist', 'Inter', system-ui, sans-serif;
  /* v59.0 — relaxed reading rhythm (1.5 read machine-tight). */
  -webkit-font-smoothing: antialiased; line-height: 1.58;
}
* { box-sizing: border-box; }
a { color: var(--primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

/* Typography */
.mx-h1 { font-size: 1.6rem; font-weight: 800; color: var(--text-strong); margin: 0 0 0.5rem 0; letter-spacing: -0.01em; }
.mx-text-muted { color: var(--text-muted); font-size: 0.875rem; }
.mx-label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.5rem; }

/* ── Layout: app shell (fixed sidebar deck + topbar + canvas) ───────────── */
.mx-shell { display: flex; min-height: 100vh; }
.mx-sidebar {
  width: 250px; flex: 0 0 250px;
  background: var(--bg-shell); border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 90;
  display: flex; flex-direction: column; padding: 1.25rem 0.85rem;
  overflow-y: auto;
}
.mx-sidebar-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.05rem; color: var(--text-strong); padding: 0.35rem 0.65rem 1.1rem; letter-spacing: -0.01em; }
.mx-sidebar-brand .mx-spark { width: 26px; height: 26px; border-radius: 8px; background: var(--primary); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.mx-sidebar-section { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--matrix-text-dim); padding: 0.9rem 0.75rem 0.35rem; }
.mx-sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.mx-sidebar-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.75rem; border-radius: 10px;
  color: var(--text-muted); font-weight: 600; font-size: 0.9rem;
  transition: background 0.15s, color 0.15s; text-decoration: none;
}
.mx-sidebar-link:hover { background: var(--bg-elevated-hi); color: var(--text-main); text-decoration: none; }
.mx-sidebar-link.is-active, .mx-sidebar-link[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.mx-sidebar-link .mx-ico { width: 18px; text-align: center; opacity: 0.9; }
.mx-sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-light); }

.mx-main { flex: 1; min-width: 0; margin-left: 250px; display: flex; flex-direction: column; }
.mx-topbar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 1.75rem;
  background: var(--bg-topbar); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.mx-topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text-strong); }
.mx-topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.mx-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; }
/* v29.19 — uploaded avatar image (nav chip + settings preview). */
.mx-avatar-img { object-fit: cover; padding: 0; border: 1px solid var(--border-color); }
.mx-avatar-lg { width: 80px; height: 80px; font-size: 1.6rem; }
/* v29.19 — 2FA toggle switch. */
.mx-switch { position: relative; display: inline-flex; align-items: center; width: 46px; height: 26px; flex: 0 0 auto; }
.mx-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.mx-switch-track { width: 46px; height: 26px; border-radius: 9999px; background: var(--bg-elevated-hi); border: 1px solid var(--border-color); transition: background 0.18s; }
.mx-switch-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #ffffff; box-shadow: var(--shadow-sm); transition: transform 0.18s; }
.mx-switch input:checked ~ .mx-switch-track { background: var(--primary); border-color: var(--primary); }
.mx-switch input:checked ~ .mx-switch-thumb { transform: translateX(20px); }

/* Layout Utilities */
.mx-container { max-width: 1400px; margin: 0 auto; padding: 1.75rem 2rem; width: 100%; }
.mx-flex-row { display: flex; align-items: center; gap: 1rem; }
.mx-flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.mx-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.mx-grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.mx-mb-lg { margin-bottom: 1.5rem; }

/* Components */
.mx-navbar { background: var(--bg-topbar); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-color); box-shadow: var(--shadow-sm); padding: 0.9rem 1.75rem; position: sticky; top: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center; }
.mx-navbar a { color: var(--text-muted); font-weight: 600; }
.mx-navbar a:hover { color: var(--text-main); text-decoration: none; }
.mx-navbar a[aria-current="page"] { color: var(--primary); }
.mx-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.mx-card-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.85rem; margin-bottom: 1rem; font-weight: 700; font-size: 1.05rem; color: var(--text-strong); }

/* Forms & Inputs — KEPT as a white surface (v27.32 contract) in BOTH themes;
   white fields read natively here and as crisp callouts on the dark skin. */
.mx-input, .mx-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background-color: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-family: 'Urbanist', 'Inter', sans-serif;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mx-input:focus, .mx-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.22); }
.inline-edit-field { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.mx-dropzone { border: 2px dashed var(--border-color); border-radius: var(--radius); padding: 3rem 2rem; text-align: center; background: var(--bg-elevated); transition: all 0.2s; cursor: pointer; margin-bottom: 1.5rem; }
.mx-dropzone:hover { border-color: var(--primary); background: var(--bg-elevated-hi); }
.mx-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mx-form-toggle { max-width: 360px; }

/* Buttons — token-driven primary (navy on light / accent on dark) + ghost. */
/* v59.0 "Kinetic" — tactile buttons: a 1px lift + deeper shadow on hover,
   a physical press-in on click (all under the global reduced-motion kill). */
.mx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; background: var(--primary); color: var(--primary-ink); padding: 0.6rem 1.2rem; border: none; border-radius: 10px; font-weight: 700; font-size: 0.875rem; cursor: pointer; transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; box-shadow: var(--shadow-sm); }
.mx-btn:hover { background: var(--primary-hover); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
/* v400.3 - measured on /matrix/offboarding: "Back to Records" rendered
   91px wide and 88px tall, i.e. its three words on THREE lines, and
   "Start Offboarding" on two.  A button is a label, not a paragraph;
   when the row is tight it should stay on one line and let the row
   wrap instead. */
.mx-btn { white-space: nowrap; flex-shrink: 0; }
.mx-btn:active { transform: translateY(0) scale(0.97); box-shadow: var(--shadow-sm); }
.mx-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mx-btn-ghost { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); box-shadow: none; }
.mx-btn-ghost:hover { background: var(--bg-elevated-hi); text-decoration: none; }
.mx-btn-accent { background: var(--accent-cyan); color: var(--primary-ink); }
.mx-btn-accent:hover { filter: brightness(1.12); }

/* v27.93 — MyWORC Data Sheet rows. */
.mx-data-section { font-weight: 700; color: var(--text-muted); margin: 0.75rem 0 0.25rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.mx-data-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border-light); }
.mx-data-key { flex: 0 0 36%; font-size: 0.8rem; color: var(--text-muted); }
.mx-data-val { flex: 1 1 auto; font-size: 0.85rem; color: var(--text-main); word-break: break-word; }
.mx-data-copy { padding: 0.2rem 0.6rem; font-size: 0.75rem; }
.mx-data-panel { margin-bottom: 1.5rem; }
.mx-data-summary { cursor: pointer; font-weight: 700; }
.mx-data-body { margin-top: 0.75rem; }
.mx-action-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.mx-cover-workspace { margin-top: 0.75rem; border: 1px solid var(--border-color); border-radius: var(--radius); padding: 0.75rem; background: var(--bg-elevated); }
.mx-cover-textarea { width: 100%; min-height: 320px; margin-top: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; line-height: 1.5; resize: vertical; }

/* Verification Console Specifics */
.mx-iframe-container { height: 75vh; width: 100%; border: 1px solid var(--border-color); border-radius: var(--radius); background: #e2e8f0; }
.mx-select-inline { width: auto; padding: 4px 10px; }

/* Pill-shaped badges — muted hue + high-contrast label (deck status tags). */
.mx-badge { display: inline-flex; align-items: center; padding: 0.25rem 0.7rem; border-radius: 9999px; font-size: 0.72rem; font-weight: 700; background: rgba(15, 23, 42, 0.06); color: var(--text-main); }

/* Progress Tracker — KEPT as a forced-light callout (dark text) so it reads
   identically as an elevated panel in both themes. */
.mx-progress-container { background: #f1f5f9; border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; color: #0f172a !important; }
.mx-progress-container * { color: #0f172a !important; }
.mx-progress-track { width: 100%; height: 12px; background-color: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 1rem; margin-bottom: 0.5rem; }
.mx-progress-fill { height: 100%; background-color: #16a34a; width: 0%; transition: width 0.3s ease; }
/* v400 - the width is clamped to 100%, so without this an account at
   1,144-of-100 rendered the same full GREEN bar as one sitting exactly
   at its limit. Over-limit is the one state that must not read "fine". */
.mx-progress-fill.is-over { background-color: var(--danger); }
.mx-progress-status { font-size: 0.875rem; font-weight: 700; color: #15803d !important; margin-bottom: 0.25rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.mx-progress-spinner { width: 20px; height: 20px; border: 3px solid #cbd5e1; border-top-color: #16a34a; border-radius: 50%; animation: spin 1s linear infinite; }

/* ── v29.16 — Role-based profile dropdown (topbar user menu) ─────────────── */
.mx-profile-menu { position: relative; }
.mx-profile-trigger { display: inline-flex; align-items: center; gap: 0.6rem; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 0.3rem 0.55rem; cursor: pointer; font: inherit; color: var(--text-main); }
.mx-profile-trigger:hover { background: var(--bg-elevated); border-color: var(--border-color); }
.mx-profile-caret { font-size: 0.6rem; color: var(--text-muted); transition: transform 0.18s ease; }
.mx-profile-menu.is-open .mx-profile-caret { transform: rotate(180deg); }
/* v29.18 — floating dropdown: absolutely positioned, high z-index, solid
   themed shell background, and an EXPLICIT vertical column so the links can
   never render inline.  Hidden state is fully inert (pointer-events:none). */
.mx-profile-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; display: flex; flex-direction: column; background: var(--bg-shell); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: var(--shadow-md); padding: 0.5rem; z-index: 200; opacity: 0; transform: translateY(-6px); visibility: hidden; pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s; }
.mx-profile-menu.is-open .mx-profile-panel { opacity: 1; transform: translateY(0); visibility: visible; pointer-events: auto; }
.mx-menu-section { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 0.45rem 0.65rem 0.2rem; }
.mx-menu-item { display: flex; align-items: center; gap: 0.55rem; padding: 0.5rem 0.65rem; border-radius: 8px; color: var(--text-main); font-weight: 600; font-size: 0.85rem; text-decoration: none; }
.mx-menu-item:hover { background: var(--bg-elevated); text-decoration: none; }
.mx-menu-divider { height: 1px; background: var(--border-color); margin: 0.4rem 0.2rem; }
.mx-menu-danger { color: var(--danger); }
.mx-menu-danger:hover { background: rgba(220, 38, 38, 0.08); }

/* Visibility utility */
.hidden { display: none !important; }

/* ── Tables — edge-to-edge, soft header, low-opacity dividers, no heavy
   borders, spacious padding (both the v28.02 .mx-table and the legacy
   .matrix-table used by the roster / super-admin / records grids). */
.mx-table, .matrix-table { width: 100%; border-collapse: collapse; }
.mx-table th, .matrix-table th {
  text-align: left; padding: 0.7rem 1rem;
  background: var(--bg-elevated); color: var(--text-muted);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-light);
}
.mx-table td, .matrix-table td {
  text-align: left; padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light); color: var(--text-main); font-size: 0.9rem;
}
.matrix-table tbody tr { transition: background 0.12s; }
.matrix-table tbody tr:hover { background: var(--bg-elevated); }

.mx-form-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0.75rem 1rem; align-items: center; margin-bottom: 1rem; }
.mx-btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.mx-btn-danger:hover { filter: brightness(0.92); }
.mx-invite-url { flex: 1; min-width: 280px; font-size: 0.85rem; }

/* ── Manager ROI Dashboard info-cards — uniform, icon-aligned, padded. */
.mx-hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.mx-stat-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.mx-stat-value { font-size: 2.4rem; font-weight: 800; color: var(--text-strong); line-height: 1.05; letter-spacing: -0.02em; }
.mx-stat-label { margin-top: 0.4rem; font-size: 0.88rem; color: var(--text-muted); }
.mx-upsell-banner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; border-left: 4px solid var(--primary); background: var(--bg-elevated); color: var(--text-main); margin-bottom: 1.5rem; padding: 1rem 1.25rem; border-radius: var(--radius); }
.mx-upsell-btn { margin-left: auto; }

/* ── Public landing + registration ──────────────────────────────────────── */
.mx-hero { text-align: center; padding: 3.5rem 1rem 2.5rem; }
.mx-hero h1 { font-size: 2.8rem; line-height: 1.12; margin-bottom: 0.75rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-strong); }
.mx-hero-sub { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.mx-hero-cta { font-size: 1.05rem; padding: 0.8rem 1.9rem; }
.mx-pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.mx-price-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.mx-price-card h4 { font-size: 1.25rem; margin-bottom: 0.25rem; color: var(--text-strong); }
.mx-price-card ul { margin: 0.75rem 0 1rem 1.1rem; }
.mx-price-card li { margin-bottom: 0.35rem; }
.mx-price-featured { border: 1px solid var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }
.mx-price { font-weight: 800; color: var(--primary); margin-bottom: 0.5rem; }
/* v29.11 — Enterprise plan badge (Corporate bento card, landing + billing). */
.mx-badge-enterprise { display: inline-block; margin-left: 0.4rem; padding: 0.15rem 0.6rem; border-radius: 9999px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: middle; color: var(--primary-ink); background: var(--primary); }
.mx-promo-banner { border: 1px dashed var(--primary); }

/* v29.17 — one-line flash banner (RBAC bounce, transient notices). */
.mx-flash { padding: 0.7rem 1rem; margin-bottom: 1.25rem; border-radius: 10px; font-size: 0.88rem; font-weight: 600; color: #92400e; background: #fef3c7; border: 1px solid #fcd34d; }

/* Error / callout — light surface (forces dark text), reads as a flagged panel. */
.mx-error { border-left: 4px solid var(--danger); background: #fef2f2; color: #0f172a !important; margin-bottom: 1rem; }
.mx-error * { color: #0f172a !important; }

/* ── v28.30 — E-Signature method selector (radio cards + visual tier lock) ── */
.mx-sig-method { margin-top: 1rem; padding: 1rem; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius); }
.mx-sigcard-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.mx-sigcard { flex: 1 1 200px; display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.85rem 0.95rem; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 12px; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
.mx-sigcard:hover { background: var(--bg-elevated-hi); border-color: var(--text-muted); }
.mx-sigcard:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--bg-elevated-hi); }
.mx-sigcard-radio { margin-top: 0.2rem; accent-color: var(--primary); flex: 0 0 auto; }
.mx-sigcard-body { display: flex; flex-direction: column; gap: 0.25rem; }
.mx-sigcard-title { font-weight: 700; color: var(--text-strong); font-size: 0.95rem; }
.mx-sigcard-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }
.mx-sigcard-lock { font-size: 0.85rem; }
.mx-sigcard-badge { display: inline-block; margin-top: 0.2rem; padding: 0.22rem 0.6rem; font-size: 0.68rem; font-weight: 700; color: var(--primary); background: rgba(30, 58, 138, 0.08); border: 1px solid var(--primary); border-radius: 8px; line-height: 1.3; }
/* Locked (Tier 1) — dimmed, not-allowed, and never highlights on hover. */
.mx-sigcard-locked { cursor: not-allowed; opacity: 0.6; }
.mx-sigcard-locked:hover { background: var(--bg-surface); border-color: var(--border-color); }
.mx-sig-action { margin-top: 0.85rem; }
.mx-sig-upsell { color: var(--primary); font-weight: 600; }
.mx-sig-ok { color: var(--primary); font-weight: 600; }
.mx-sig-error { color: var(--danger); font-weight: 600; }

/* ── v28.32 — Compliance Radar (expiry risk badges + summary cards) ───────── */
.mx-radar-summary { display: flex; flex-wrap: wrap; gap: 0.85rem; margin: 0.5rem 0 1.25rem; }
.mx-radar-stat { flex: 1 1 150px; padding: 1rem 1.15rem; border-radius: var(--radius); border: 1px solid var(--border-color); background: var(--bg-surface); }
.mx-radar-stat-num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.mx-radar-stat-label { display: block; margin-top: 0.4rem; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.mx-radar-stat-critical { border-color: var(--danger); }
.mx-radar-stat-critical .mx-radar-stat-num { color: var(--danger); }
.mx-radar-stat-warning { border-color: #f5a623; }
.mx-radar-stat-warning .mx-radar-stat-num { color: #f5a623; }
/* Bold, high-contrast pill badges — solid fills so the risk reads at a glance. */
.mx-badge-risk { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.28rem 0.7rem; border-radius: 9999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; }
.mx-badge-critical { background: #f26b5e; color: #2a0a06; }
.mx-badge-warning  { background: #f5a623; color: #2a1c02; }
.mx-badge-notice   { background: #f5d547; color: #2a2402; }   /* v28.45 — Notice (yellow) */
/* v400 - this said "all-compliant green state" in its own comment while
   rendering var(--primary): ORANGE on dark, BLUE on light.  An all-clear
   message painted in the alert colour. Uses the project's audited ok-ink
   pair (the same values as [data-ink="ok"]). */
.mx-radar-ok       { color: #047857; font-weight: 700; }
html.theme-dark .mx-radar-ok { color: #6ee7b7; }
.mx-radar-days { font-weight: 700; }
.mx-radar-days-critical { color: var(--danger); }
.mx-radar-days-warning  { color: #f5a623; }

/* ── v28.33 — Freemium trial-credit pill + lockout ───────────────────────── */
.mx-credit-pill { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0 0 0.85rem; padding: 0.42rem 0.9rem; border-radius: 9999px; font-size: 0.82rem; font-weight: 600; color: var(--primary); background: rgba(30, 58, 138, 0.08); border: 1px solid var(--primary); }
.mx-credit-pill-of { color: var(--text-muted); font-weight: 500; }
.mx-credit-pill-empty { color: var(--danger); background: rgba(242, 107, 94, 0.12); border-color: var(--danger); }
/* High-contrast lockout banner — solid red so it cannot be missed. */
.mx-credit-banner { margin: 0 0 1rem; padding: 0.85rem 1.1rem; border-radius: 10px; font-weight: 700; font-size: 0.9rem; color: #2a0a06; background: #f26b5e; border: 1px solid #d8493b; }
/* Disabled dropzone — dimmed + click-proof so a tapped-out tier cannot upload. */
.mx-dropzone-locked { opacity: 0.45; pointer-events: none; filter: grayscale(0.4); }
/* v28.48 — In-flight dropzone — dimmed + click-proof for the duration of an
   active upload/extraction so a second drop can't fire a duplicate request. */
.mx-dropzone-busy { opacity: 0.6; pointer-events: none; cursor: progress; }
/* v61.0 — the v28.50/v28.78 pre-flight classes are RETIRED with the
   Pre-Flight Compliance Summary they skinned: the Submission-Ready Checklist
   is the single compliance surface now (compliance_gate everywhere). */
/* v28.53 — Draft Review declutter.  Prominent "Application Draft for: [name]"
   employee header + a clean secondary (outline) action style for the Cover
   Letter button sitting beside the primary "Generate Application Package". */
.mx-draft-subject { margin: 0.15rem 0 0.35rem; font-size: 1.05rem; color: var(--text); }
.mx-draft-subject strong { color: var(--primary); }
.mx-btn-secondary { background: transparent; }

/* ── v28.34 (Phase 21) — Digital Filing Cabinet ──────────────────────────── */
/* Small shared utilities (the cabinet is their first consumer). */
.mx-text-dim { color: var(--text-muted); opacity: 0.72; font-size: 0.78rem; }
.mx-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.74rem; border-radius: 8px; }
.mx-ta-right { text-align: right; }

/* Breadcrumb trail */
.mx-breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; }
.mx-breadcrumb-link { color: var(--text-muted); font-weight: 600; }
.mx-breadcrumb-link:hover { color: var(--primary); }
.mx-breadcrumb-sep { color: var(--text-muted); opacity: 0.5; }
.mx-breadcrumb-here { color: var(--text-strong); font-weight: 700; }

/* Two-column cabinet — meta rail (left) + document vault (right). */
.mx-cabinet-grid { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .mx-cabinet-grid { grid-template-columns: 1fr; } }
.mx-cabinet-meta { min-width: 0; }
.mx-cabinet-vault { min-width: 0; }
.mx-cabinet-foot { text-align: center; margin-top: 1.5rem; }

/* Compliance Radar status block */
.mx-compliance-row { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.85rem 0; margin-bottom: 0.75rem; border-bottom: 1px solid var(--border-light); }
.mx-compliance-badge { display: inline-flex; align-items: center; gap: 0.4rem; align-self: flex-start; padding: 0.35rem 0.85rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.02em; }
.mx-compliance-critical { background: #f26b5e; color: #2a0a06; }
.mx-compliance-warning  { background: #f5a623; color: #2a1c02; }
.mx-compliance-safe     { background: var(--primary); color: var(--primary-ink); }
.mx-compliance-unknown  { background: rgba(15, 23, 42, 0.05); color: var(--text-muted); border: 1px solid var(--border-color); }
.mx-compliance-detail { font-size: 0.74rem; }

/* Record-meta definition list */
.mx-meta-list { display: flex; flex-direction: column; gap: 0.85rem; margin: 0; }
.mx-meta-field { display: flex; flex-direction: column; gap: 0.2rem; }
.mx-meta-value { margin: 0; padding: 0.5rem 0.7rem; border-radius: 8px; background: var(--bg-elevated); border: 1px solid var(--border-light); color: var(--text-strong); font-size: 0.85rem; font-weight: 600; }

/* Generate-form launcher row */
.mx-generate-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.mx-generate-row .mx-select { flex: 1 1 240px; }

/* Vault tables */
.mx-vault-table { width: 100%; }
.mx-vault-strong { font-weight: 600; color: var(--text-strong); }
.mx-vault-break { word-break: break-all; }

/* Draft status badge variants */
.mx-status-submitted, .mx-status-approved, .mx-status-completed { background: rgba(21, 128, 61, 0.12); color: var(--success); }
.mx-status-processing { background: rgba(99,102,241,0.14); color: #4338ca; }
.mx-status-failed, .mx-status-rejected { background: rgba(242,107,94,0.16); color: var(--danger); }
.mx-status-draft { background: rgba(245,166,35,0.16); color: #f5a623; }

/* ── v28.36 — global navbar OCR-credit pill (sticky topbar, every page) ───── */
.mx-credit-nav { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.32rem 0.72rem; border-radius: 9999px; font-size: 0.78rem; font-weight: 600; color: var(--primary); background: rgba(30, 58, 138, 0.08); border: 1px solid var(--primary); white-space: nowrap; line-height: 1; }
.mx-credit-nav strong { font-weight: 800; }
.mx-credit-nav-empty { color: var(--danger); background: rgba(242, 107, 94, 0.12); border-color: var(--danger); }

/* ── v28.39 — Public landing-page sections (Workforce345 copy overhaul) ───── */
.mx-landing-section { padding: 2.5rem 0; border-top: 1px solid var(--border-light); }
.mx-section-head { text-align: center; max-width: 720px; margin: 0 auto 1.75rem; }
.mx-section-head h2 { font-size: 2rem; font-weight: 800; color: var(--text-strong); letter-spacing: -0.01em; margin-bottom: 0.5rem; }
.mx-section-sub { font-size: 1.05rem; color: var(--text-muted); }

/* Feature showcase */
.mx-feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.mx-feature-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.mx-feature-card h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-strong); margin: 0.6rem 0 0.4rem; }
.mx-feature-card p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; }
.mx-feature-ico { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; background: rgba(30, 58, 138, 0.08); border: 1px solid var(--primary); }

/* How it works */
.mx-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.mx-step { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.mx-step-num { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; background: var(--primary); color: var(--primary-ink); margin-bottom: 0.6rem; }
.mx-step h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-strong); margin-bottom: 0.4rem; }
.mx-step p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; }

/* FAQ */
.mx-faq { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.6rem; }
.mx-faq-item { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 0.9rem 1.1rem; }
.mx-faq-item summary { cursor: pointer; font-weight: 700; color: var(--text-strong); list-style: none; }
.mx-faq-item summary::-webkit-details-marker { display: none; }
.mx-faq-item summary::after { content: "+"; float: right; color: var(--primary); font-weight: 800; }
.mx-faq-item[open] summary::after { content: "\2013"; }
.mx-faq-item p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.6; margin-top: 0.6rem; }

/* Footer + legal disclaimer */
.mx-footer { border-top: 1px solid var(--border-color); margin-top: 2rem; padding: 2rem 1.75rem 1.5rem; background: var(--bg-shell); }
.mx-footer-inner { max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.mx-footer-brand { display: flex; flex-direction: column; gap: 0.2rem; }
.mx-footer-links { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.mx-footer-links a { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.mx-footer-links a:hover { color: var(--primary); }
.mx-legal { max-width: 1100px; margin: 1.25rem auto 0; padding-top: 1rem; border-top: 1px solid var(--border-light); color: var(--text-muted); font-size: 0.78rem; text-align: center; }

/* v28.41 — registration ToS/FUP consent row (checkbox + agreement link). */
.mx-checkbox-row { display: flex; align-items: flex-start; gap: 0.55rem; margin: 0.25rem 0 1rem; font-size: 0.88rem; color: var(--text-muted); cursor: pointer; }
.mx-checkbox-row input[type="checkbox"] { width: 1.05rem; height: 1.05rem; margin-top: 0.1rem; accent-color: var(--primary); flex: 0 0 auto; cursor: pointer; }
.mx-checkbox-row a { color: var(--primary); }

/* ── v29.21 — Help Desk ticket status badges (paired with .mx-badge) ──────── */
.mx-status-open     { background: rgba(245, 166, 35, 0.16); color: #b45309; }
.mx-status-resolved { background: rgba(21, 128, 61, 0.12); color: var(--success); }
/* v222 — the same fault as the Super-Admin chips: #b45309 is an amber-700
   picked for a white card, and on the dark skin it measured 1.48:1. */
html.theme-dark .mx-status-open     { color: #fcd34d; }
html.theme-dark .mx-status-resolved { color: #6ee7b7; }

/* ── v29.21 — Immigration Assistant floating chatbot widget ───────────────── */
/* v56.0 FAB REBUILD — the toggle was a BLANK circle stacked at z-index 200
   (above the mobile drawer, the backdrop and every modal).  Now: a real
   chat glyph with an open-state × swap, z-index 70 (above content, BELOW
   the drawer/backdrop/modal layers), theme-token painted throughout, and
   a compact <=640px footprint so it stays out of the content's way. */
.mx-chat { position: fixed; bottom: 20px; right: 20px; z-index: 70; font-family: inherit; }
.mx-chat-fab { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer; background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, 0.18)); transition: transform 0.12s, background 0.15s, box-shadow 0.15s; }
.mx-chat-fab:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28); }
.mx-chat-fab:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.mx-chat-fab-ico { width: 24px; height: 24px; display: block; }
.mx-chat-fab-x { display: none; font-size: 1.6rem; line-height: 1; }
.mx-chat.is-open .mx-chat-fab-ico { display: none; }
.mx-chat.is-open .mx-chat-fab-x { display: block; }
.mx-chat-panel { display: none; flex-direction: column; position: absolute; bottom: 70px; right: 0; width: 360px; max-width: calc(100vw - 40px); height: 480px; max-height: calc(100vh - 120px); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 16px; box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22); overflow: hidden; }
.mx-chat.is-open .mx-chat-panel { display: flex; }
.mx-chat.is-open .mx-chat-fab { background: var(--primary-hover); }
/* v56.0 — v54 responsive law: on phones the FAB shrinks + hugs the corner
   and the panel becomes a near-fullscreen sheet clear of the keyboard. */
@media (max-width: 640px) {
  .mx-chat { bottom: 14px; right: 14px; }
  .mx-chat-fab { width: 48px; height: 48px; }
  .mx-chat-fab-ico { width: 20px; height: 20px; }
  .mx-chat-panel { width: calc(100vw - 28px); height: min(70vh, 520px);
                   bottom: 60px; border-radius: 14px; }
}
.mx-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.85rem 1rem; background: var(--primary); color: var(--primary-ink); }
.mx-chat-head strong { font-size: 0.95rem; font-weight: 800; }
.mx-chat-head small { display: block; font-size: 0.7rem; opacity: 0.85; font-weight: 600; }
.mx-chat-close { background: transparent; border: none; color: var(--primary-ink); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.mx-chat-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; background: var(--bg-app); }
.mx-chat-msg { max-width: 84%; padding: 0.55rem 0.8rem; border-radius: 14px; font-size: 0.86rem; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.mx-chat-msg-bot { align-self: flex-start; background: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-main); border-bottom-left-radius: 4px; }
.mx-chat-msg-user { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 4px; }
.mx-chat-foot { display: flex; gap: 0.4rem; padding: 0.7rem; border-top: 1px solid var(--border-color); background: var(--bg-surface); }
.mx-chat-input { flex: 1; padding: 0.55rem 0.75rem; border: 1px solid var(--border-color); border-radius: 10px; font-size: 0.86rem; font-family: inherit; background: #ffffff; color: #0f172a; }
.mx-chat-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.18); }
.mx-chat-send { flex: 0 0 auto; padding: 0.55rem 0.9rem; border: none; border-radius: 10px; background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 0.86rem; cursor: pointer; }
.mx-chat-send:hover { background: var(--primary-hover); }
.mx-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── v29.22 — Notification Centre toggle switches ─────────────────────────── */
.mx-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.mx-switch-row:last-of-type { border-bottom: none; }
.mx-switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.mx-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.mx-switch-slider { position: absolute; inset: 0; border-radius: 9999px; background: var(--border-color); transition: background 0.15s; }
.mx-switch-slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: var(--bg-surface); box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.mx-switch input:checked + .mx-switch-slider { background: var(--primary); }
.mx-switch input:checked + .mx-switch-slider::before { transform: translateX(20px); }
.mx-switch input:focus-visible + .mx-switch-slider { box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.22); }

/* ── v29.22 — "In Development" chip on enterprise roadmap stubs ───────────── */
.mx-badge-dev { margin-left: 0.5rem; font-size: 0.64rem; letter-spacing: 0.05em; text-transform: uppercase; background: rgba(245, 166, 35, 0.16); color: #b45309; vertical-align: middle; }

/* ── v29.23 — interactive bento plan cards: per-card action button row ────── */
.mx-plan-action { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--border-light); }
.mx-plan-action .mx-btn { width: 100%; justify-content: center; }
.mx-plan-action .mx-btn[disabled] { opacity: 0.55; cursor: default; }

/* ── v29.25 — global onboarding/activation banner (unpaid submitters) ─────── */
.mx-banner-activation { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.85rem 1.1rem; margin-bottom: 1.25rem; border-radius: 12px; background: rgba(30, 58, 138, 0.08); border: 1px solid var(--primary); color: var(--text-main); font-size: 0.9rem; }
.mx-banner-activation-text { line-height: 1.5; }
.mx-banner-activation-actions { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.mx-banner-dismiss { background: transparent; border: none; color: var(--text-muted); font-size: 1.05rem; line-height: 1; cursor: pointer; padding: 0.3rem; }
.mx-banner-dismiss:hover { color: var(--text-strong); }

/* ── v29.25 — "Workspace Activation Required" modal (records page) ────────── */
.mx-activation-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(6px); z-index: 140; align-items: center; justify-content: center; padding: 24px; }
.mx-activation-overlay.is-open { display: flex; }

/* ═══════════════════════════════════════════════════════════════════════════
   v29.57.1 — GLOBAL TOAST + SKELETON + EMPTY-STATE PRIMITIVES
   Audit §1: nine separate toast implementations existed across three visual
   languages, and there were zero skeleton screens.  These are the single
   shared set every Matrix page now uses via window.mxToast / .mx-skeleton.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Toast stack (bottom-right, newest on top, max 4 visible) ─────────────── */
.mx-toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column-reverse; gap: 0.55rem; max-width: min(420px, calc(100vw - 48px)); pointer-events: none; }
/* v82.0 — the toast previously read `background: var(--surface,#fff)`, but
   `--surface` is NOT a defined token (the theme card token is `--bg-surface`),
   so the bg was ALWAYS the hardcoded #fff fallback.  On the dark skin
   (`html.theme-dark`) `--text-main` flips to a light ink, so the message read
   WHITE-ON-WHITE and was invisible — the reported "Source files are physically
   missing" error the user could not see.  Fixed by using the theme-aware
   `--bg-surface`, and the critical error / warning toasts now bring their OWN
   solid high-contrast colours so they are legible on BOTH themes regardless of
   the surrounding surface token. */
.mx-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.8rem 0.95rem; border-radius: 12px; font-size: 0.86rem; line-height: 1.45; color: var(--text-main); background: var(--bg-surface, #fff); border: 1px solid var(--border-light); border-left: 4px solid var(--primary); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18); opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
.mx-toast.is-in { opacity: 1; transform: translateY(0); }
.mx-toast-ok    { border-left-color: #10b981; }
/* Self-contained, theme-independent contrast for the alert kinds — dark red /
   amber panels with white ink read clearly on the light AND the dark skin. */
.mx-toast-warn  { border-left-color: #f59e0b; background: #92400e; color: #ffffff; }
.mx-toast-error { border-left-color: #ef4444; background: #b91c1c; color: #ffffff; }
.mx-toast-warn .mx-toast-close,
.mx-toast-error .mx-toast-close { color: rgba(255, 255, 255, 0.85); }
.mx-toast-warn .mx-toast-close:hover,
.mx-toast-error .mx-toast-close:hover { color: #ffffff; }
.mx-toast-icon { flex: 0 0 auto; font-size: 0.98rem; line-height: 1.35; }
.mx-toast-body { flex: 1 1 auto; word-break: break-word; }
.mx-toast-close { flex: 0 0 auto; background: transparent; border: none; color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; padding: 0 0 0 0.25rem; }
.mx-toast-close:hover { color: var(--text-strong); }

/* ── Skeleton loaders (OCR / PDF / iframe placeholders) ───────────────────── */
@keyframes mx-shimmer { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }
.mx-skeleton { background: linear-gradient(90deg, rgba(148,163,184,.10) 25%, rgba(148,163,184,.22) 37%, rgba(148,163,184,.10) 63%); background-size: 840px 100%; animation: mx-shimmer 1.25s linear infinite; border-radius: 8px; }
.mx-skeleton-line { height: 12px; margin: 0.45rem 0; }
.mx-skeleton-line.w-40 { width: 40%; } .mx-skeleton-line.w-60 { width: 60%; } .mx-skeleton-line.w-80 { width: 80%; }
.mx-skeleton-doc { width: 100%; min-height: 320px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.82rem; }
.mx-skeleton-row { display: flex; gap: 0.75rem; align-items: center; padding: 0.55rem 0; }
.mx-skeleton-row .mx-skeleton { height: 14px; flex: 1 1 auto; }

/* ── Shared empty state ───────────────────────────────────────────────────── */
.mx-empty { text-align: center; padding: 2.25rem 1.25rem; color: var(--text-muted); }
.mx-empty-icon { font-size: 1.9rem; line-height: 1; margin-bottom: 0.5rem; opacity: 0.85; }
.mx-empty-title { font-size: 1.02rem; color: var(--text-main); margin-bottom: 0.35rem; }
.mx-empty-hint { font-size: 0.85rem; color: var(--text-dim, var(--text-muted)); max-width: 46ch; margin: 0 auto; line-height: 1.5; }
.mx-empty-actions { margin-top: 0.9rem; }

/* ── Busy button (double-submit guard) ────────────────────────────────────── */
.mx-btn[aria-busy="true"] { opacity: 0.6; cursor: progress; pointer-events: none; }

/* ==========================================================================
   v29.58 - UI/UX MODERNIZATION & RESPONSIVENESS OVERHAUL
   --------------------------------------------------------------------------
   Scope: STRICTLY the visual layer. No class is renamed or removed - the
   v29.9 "Enterprise Light" palette tokens (--bg-app #f8fafc, --bg-surface
   #ffffff, --primary #1e3a8a, Urbanist) are the platform's deliberate,
   test-pinned banking aesthetic and are PRESERVED verbatim. This layer adds
   the scale/geometry/motion tokens that were missing, then rebuilds the
   layout for real devices.

   THE HEADLINE PROBLEM THIS FIXES: the entire 539-line stylesheet contained
   exactly ONE media query. .mx-sidebar is position:fixed; width:250px with
   .mx-main { margin-left:250px }, so on a 375px phone the nav deck covered
   two-thirds of the viewport and content was pushed off-screen. The product
   was, in practice, desktop-only.
   ========================================================================== */

:root {
  /* Spacing scale (4px base) - replaces ad-hoc rem literals */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-8: 2rem;     --sp-10: 2.5rem;

  /* Radius scale - layered on the existing --radius (14px) */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Elevation - soft, short-throw shadows (modern SaaS, not 2010 glow) */
  --shadow-md: 0 4px 12px -2px rgb(15 23 42 / 0.08), 0 2px 6px -2px rgb(15 23 42 / 0.05);
  /* v59.0 — third diffusion layer for the highest elevations. */
  --shadow-lg: 0 0 0 1px rgb(15 23 42 / 0.03),
               0 6px 16px -6px rgb(15 23 42 / 0.10),
               0 20px 48px -12px rgb(15 23 42 / 0.18);
  --shadow-focus: 0 0 0 3px rgb(30 58 138 / 0.16);

  /* Motion - one easing curve + three durations for the whole app */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;

  /* Layout */
  --sidebar-w: 250px;
  --tap-min: 44px;          /* WCAG 2.5.5 minimum touch target */
}

/* Typography: fluid, legible, modern.
   The Urbanist/Inter pairing is kept (test-pinned + genuinely modern); this
   adds optical polish and a fluid scale so headings breathe on desktop
   without overflowing a phone. */
body.matrix-skin {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
.mx-page-title {
  font-size: clamp(1.35rem, 1.05rem + 1.2vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.mx-page-sub { line-height: 1.6; max-width: 74ch; }
.mx-card-header { letter-spacing: -0.01em; }
/* v400.4 - PRE-EXISTING, found during the visual pass and verified not
   to be a v400 regression: /matrix/draft/<id> scrolled 18px sideways.
   A .mx-card-header flex row 496px wide held a 480px <select> plus a
   title and a link (586px of content, nowrap), so the link landed
   OUTSIDE the card.  A flex item will not shrink below its content's
   min-content width unless min-width is overridden - which is why the
   select never gave way.  Let the row wrap and the control shrink. */
.mx-card-header { flex-wrap: wrap; margin-top: 0; }
.mx-card-header > select, .mx-card-header > .mx-select { min-width: 0; max-width: 100%; }

/* Cards & surfaces: consistent geometry + a gentle lift on hover */
.mx-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.mx-card:hover { box-shadow: var(--shadow-md); }

/* Buttons: touch-sized, smooth, with a real focus ring */
.mx-btn {
  min-height: 40px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  transition: background var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
.mx-btn:hover { box-shadow: var(--shadow-md); }
.mx-btn:active { transform: translateY(1px) scale(0.995); }
.mx-btn:focus-visible,
.mx-input:focus-visible, .mx-select:focus-visible,
.mx-sidebar-link:focus-visible, a:focus-visible, button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}
.mx-btn-sm { min-height: 32px; padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Forms: generous padding, clear focus, no default-browser ugliness */
.mx-input, .mx-select, textarea.mx-input {
  min-height: 42px;
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.mx-input:hover, .mx-select:hover { border-color: #cbd5e1; }
.mx-input:focus, .mx-select:focus, textarea.mx-input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
  outline: none;
}
.mx-input::placeholder { color: #94a3b8; opacity: 1; }
.mx-input:disabled, .mx-select:disabled {
  background: var(--bg-elevated); cursor: not-allowed; opacity: 0.7;
}
.mx-input, .mx-select, input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.mx-input:user-invalid, textarea.mx-input:user-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.12);
}
.mx-label { font-weight: 600; letter-spacing: 0.01em; }

/* Badges / status chips: aligned, pill-shaped, legible */
.mx-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  border-radius: var(--radius-pill);
  padding: 0.18rem 0.6rem;
  font-size: 0.72rem; font-weight: 700; line-height: 1.5;
  letter-spacing: 0.02em; white-space: nowrap; vertical-align: middle;
}

/* Tables: sticky head, comfortable rows, row hover */
.mx-table { width: 100%; border-collapse: collapse; }
.mx-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-elevated);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0.7rem 0.85rem; text-align: left; white-space: nowrap;
}
.mx-table td { padding: 0.7rem 0.85rem; border-top: 1px solid var(--border-light); }
.mx-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.mx-table tbody tr:hover { background: var(--bg-elevated); }

/* Horizontal-scroll shell so a wide table NEVER blows out the layout. */
.mx-table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  scrollbar-width: thin;
}

/* v54.0 — MOBILE-GATED scroll shell: a no-op on desktop (so absolutely-
   positioned row flyouts are never clipped there), it becomes a swipeable
   overflow container at <=1024px (rules live in the tablet media block).
   Every legacy `.matrix-table` is wrapped in one of these — a wide table
   scrolls INSIDE its shell instead of stretching the page off-viewport. */
.mx-table-wrap-mobile { width: 100%; }

/* v54.0 — TEXT BOUNDARIES: long unbroken strings (emails, licence numbers,
   pasted tokens in sticky notes) wrap inside their container instead of
   blowing past it.  break-word only engages when overflow would occur, so
   normal copy renders identically. */
.mx-table td, .matrix-table td { overflow-wrap: break-word; }
.mx-meta-value, .mx-vault-break, .mx-broadcast-text,
.mx-sticky-textarea { overflow-wrap: anywhere; }
.mx-meta-value { min-width: 0; }
.mx-topbar-user { min-width: 0; }

/* Sidebar: modern rail with an active-state indicator */
.mx-sidebar { transition: transform var(--dur-slow) var(--ease); }
.mx-sidebar-link {
  position: relative;
  min-height: 40px;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              padding-left var(--dur-fast) var(--ease);
}
.mx-sidebar-link:hover { padding-left: 0.95rem; }
.mx-sidebar-link.is-active, .mx-sidebar-link[aria-current="page"] {
  box-shadow: var(--shadow-sm);
}
/* Left accent bar grounds the user in the current section */
.mx-sidebar-link.is-active::before,
.mx-sidebar-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -0.85rem; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 3px 3px 0;
  background: var(--primary);
}

/* Mobile shell: hamburger + off-canvas drawer + backdrop.
   Hidden on desktop; the drawer is the SAME <aside class="mx-sidebar">, so
   there is exactly one nav in the DOM (no duplicated markup to drift). */
.mx-navtoggle {
  display: none;
  align-items: center; justify-content: center;
  width: var(--tap-min); height: var(--tap-min);
  margin-right: var(--sp-2);
  background: transparent; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-main); font-size: 1.1rem; line-height: 1;
  transition: background var(--dur-fast) var(--ease);
}
.mx-navtoggle:hover { background: var(--bg-elevated-hi); }
.mx-backdrop {
  display: none; position: fixed; inset: 0; z-index: 89;
  background: rgb(15 23 42 / 0.45);
  backdrop-filter: blur(2px);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.mx-backdrop.is-open { display: block; opacity: 1; }

/* ===== TABLET <= 1024px — v54.0: the drawer now starts HERE ===== */
/* The v29.58 off-canvas drawer used to begin at 860px, leaving tablets with
   a fixed 216px rail eating the canvas.  v54 collapses the nav on TABLETS
   TOO: the hamburger + off-canvas drawer + backdrop activate at 1024px.
   (The <=860px block below keeps its identical drawer rules — a harmless
   subset — plus the phone-only compaction.) */
@media (max-width: 1024px) {
  .mx-shell { display: block; }
  .mx-sidebar {
    transform: translateX(-100%);
    width: min(84vw, 300px); flex-basis: auto;
    z-index: 95; box-shadow: var(--shadow-lg);
    will-change: transform;
  }
  .mx-sidebar.is-open { transform: translateX(0); }
  .mx-main { margin-left: 0; }
  .mx-navtoggle { display: inline-flex; }

  .mx-container { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .mx-topbar { padding: 0.8rem 1.15rem; }

  /* v54.0 — the mobile-gated table shell engages (desktop untouched). */
  .mx-table-wrap-mobile {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm); scrollbar-width: thin;
  }
  .mx-table-wrap-mobile > .matrix-table,
  .mx-table-wrap-mobile > .mx-table { min-width: 560px; }
}

/* ===== MOBILE <= 860px - the real fix ===== */
@media (max-width: 860px) {
  /* The nav deck leaves the flow entirely and becomes a drawer. */
  .mx-shell { display: block; }
  .mx-sidebar {
    transform: translateX(-100%);
    width: min(84vw, 300px); flex-basis: auto;
    z-index: 95; box-shadow: var(--shadow-lg);
    will-change: transform;
  }
  .mx-sidebar.is-open { transform: translateX(0); }
  .mx-main { margin-left: 0; }
  .mx-navtoggle { display: inline-flex; }

  .mx-topbar { padding: 0.65rem 0.9rem; gap: 0.5rem; }
  .mx-topbar-title {
    font-size: 0.95rem; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mx-container { padding: var(--sp-4) var(--sp-4) var(--sp-10); }

  /* Cards go edge-to-edge-ish and lose the desktop lift. */
  .mx-card { border-radius: var(--radius-md); padding: var(--sp-4); }
  .mx-card:hover { box-shadow: var(--shadow-sm); }

  /* EVERY multi-column grid collapses to a single column. */
  .mx-cabinet-grid, .mx-grid, .mx-kpi-grid, .mx-bento,
  .mx-flex-row, .mx-action-group, .mx-form-grid {
    grid-template-columns: 1fr !important;
    flex-direction: column;
    align-items: stretch;
  }
  .mx-flex-between { flex-wrap: wrap; gap: var(--sp-3); }

  /* Tables scroll horizontally rather than breaking the page.
     v54.0 — the legacy .matrix-table class is a first-class citizen now. */
  .mx-table-wrap { overflow-x: auto; }
  .mx-table, .matrix-table { min-width: 620px; }
  .mx-table th, .mx-table td,
  .matrix-table th, .matrix-table td { padding: 0.6rem 0.7rem; font-size: 0.84rem; }

  /* Touch targets: WCAG 2.5.5. */
  .mx-btn, .mx-btn-ghost { min-height: var(--tap-min); padding: 0.7rem 1.1rem; width: 100%; }
  .mx-btn-sm { min-height: 38px; width: auto; }
  /* ── v222 — A NAVBAR IS NOT A FORM ──────────────────────────────
     `width: 100%` is right for a button in a form column and wrong
     for one in a bar: it made every chrome button claim its own row,
     so the authenticated TOPBAR stood 135px tall on a 390x844 phone
     (the sign-out / help / credits cluster wrapping onto three lines)
     and the PUBLIC nav stacked five full-width buttons before any
     content.  Chrome buttons size to their label; only buttons in
     content keep the full-width rule. */
  .mx-topbar .mx-btn, .mx-topbar .mx-btn-ghost,
  .mx-navbar .mx-btn, .mx-navbar .mx-btn-ghost,
  .mx-topbar-user .mx-btn, .mx-topbar-user .mx-btn-ghost {
    width: auto; padding: 0.55rem 0.85rem; font-size: 0.82rem;
  }
  /* BOTH chrome partials: pages render either _navbar_matrix.html
     (.mx-navbar) or matrix_base's own header (.mx-topbar), and the
     mobile rules have to cover the pair or half the platform keeps
     the tall wrapping bar. */
  .mx-topbar, .mx-navbar {
    flex-wrap: nowrap !important; gap: .5rem; padding: .5rem .75rem;
    min-height: 58px;
  }
  .mx-navbar > .mx-flex-row { flex-direction: row !important;
    align-items: center; gap: .45rem; min-width: 0; }
  .mx-navbar > .mx-flex-row:first-child { flex: 1 1 auto; min-width: 0; }
  .mx-navbar > .mx-flex-row:first-child strong {
    font-size: .95rem; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  .mx-navbar > .mx-flex-row:last-child { flex: 0 0 auto; }
  .mx-topbar-title {
    font-size: .95rem; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; min-width: 0;
  }
  .mx-topbar-user { flex-wrap: nowrap; gap: .4rem; min-width: 0; }
  /* the credit pill and the user's NAME are the first things to go:
     the avatar and the menu they open carry the same information. */
  .mx-topbar-user .mx-credit-nav, .mx-navbar .mx-credit-nav,
  .mx-profile-trigger .mx-text-muted { display: none; }
  /* the flex-row collapse above turns the topbar clusters into
     columns; chrome rows must stay rows. */
  .mx-topbar .mx-flex-row, .mx-topbar-user.mx-flex-row {
    flex-direction: row !important; align-items: center;
  }
  .mx-topbar-brand { display: inline-flex !important; align-items: center;
                     flex: 0 0 auto; }
  html.theme-dark .mx-topbar-brand img { filter: brightness(0) invert(1); }
  .mx-plan-action .mx-btn { width: 100%; }
  .mx-input, .mx-select, textarea.mx-input {
    min-height: var(--tap-min);
    font-size: 16px;   /* >=16px stops iOS Safari zooming the viewport on focus */
  }
  .mx-sidebar-link { min-height: var(--tap-min); font-size: 0.95rem; }

  /* Modals become near-fullscreen sheets instead of clipped desktop boxes. */
  .mx-modal, .mx-modal-card, .mx-activation-overlay > div {
    width: 100% !important; max-width: 100% !important;
    max-height: 92vh; overflow-y: auto; border-radius: var(--radius-lg);
  }
  .mx-toast-stack { left: 12px; right: 12px; bottom: 12px; max-width: none; }

  /* The Verification Console stacks: source over compiled, both readable. */
  .mx-iframe-container { min-height: 62vh; }
}

/* ===== SMALL PHONES <= 480px ===== */
@media (max-width: 480px) {
  .mx-container { padding: var(--sp-3) var(--sp-3) var(--sp-8); }
  .mx-card { padding: var(--sp-3); border-radius: var(--radius-md); }
  .mx-page-sub { font-size: 0.85rem; }
  .mx-table, .matrix-table { min-width: 540px; }
  .mx-topbar-user .mx-credit-nav { display: none; }
}

/* ═════ v59.0 "KINETIC & ORGANIC" — motion layer ═════════════════════════
   Micro-interactions so the UI feels hand-made, not generated.  Every rule
   here is ADDITIVE (no selector below changes layout or DOM contracts), and
   the global prefers-reduced-motion kill-switch flattens all of it. */

/* Rows: hover states FADE in instead of snapping (the v56 hover colour
   rules are untouched — this only adds the easing). */
.mx-table tbody tr, .matrix-table tbody tr {
  transition: background-color 0.15s ease;
}

/* Ghost + small buttons share the tactile lift/press of .mx-btn. */
.mx-btn-ghost, .mx-btn-sm {
  transition: background-color 0.2s ease, transform 0.2s ease,
              box-shadow 0.2s ease, border-color 0.2s ease;
}
.mx-btn-ghost:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mx-btn-ghost:active, .mx-btn-sm:active { transform: translateY(0) scale(0.97); }

/* Overlay surfaces RISE in: a short fade + upward drift instead of popping
   into existence.  display:none → shown re-triggers the animation, so the
   existing JS toggles need zero changes. */
@keyframes mxRise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mx-chat-panel,
.mx-modal-card,
.wf-advert-card,
.sa-actions-menu,
#wfUpgradeModal > div,
#documentPreviewModal > div,
.wf-wiz-handoff {
  animation: mxRise 0.22s ease-out;
}
/* Dropdown menus drift a touch less (they anchor to their trigger). */
.sa-actions-menu { animation-duration: 0.16s; }

/* Cards deepen softly on hover — spatial feedback without jumpiness.
   DESKTOP-ONLY: the v29.58 mobile law keeps cards flat on touch, and this
   layer sits after the media blocks in the cascade, so it must scope
   itself out of the drawer breakpoints. */
.mx-card { transition: box-shadow 0.25s ease; }
@media (min-width: 1025px) {
  .mx-card:hover { box-shadow: var(--shadow-md); }
}

/* ===== ACCESSIBILITY / INPUT-MODE POLISH ===== */
/* Coarse pointers (touch) get the full 44px target regardless of viewport. */
@media (pointer: coarse) {
  .mx-btn, .mx-sidebar-link, .mx-navtoggle { min-height: var(--tap-min); }
  .mx-input, .mx-select { min-height: var(--tap-min); }
}
/* Respect the OS "reduce motion" setting - no transform/opacity theatre. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
/* Printing a WORC packet should not print the app chrome. */
@media print {
  .mx-sidebar, .mx-topbar, .mx-navtoggle, .mx-backdrop, .mx-toast-stack, .mx-tour-overlay, .mx-broadcast, .mx-adm-overlay { display: none !important; }
  .mx-main { margin-left: 0 !important; }
  .mx-card { box-shadow: none; border: 1px solid #cbd5e1; break-inside: avoid; }
}

/* ── v29.75 — Onboarding walkthrough (mxTour) ─────────────────────────────── */
/* Theme-adaptive: the card uses --bg-surface / --text-main / --border-color so
   it stays high-contrast on BOTH the light and dark themes. */
.mx-tour-overlay { position: fixed; inset: 0; z-index: 9998; }
.mx-tour-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, 0.62); }
.mx-tour-spot { position: absolute; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--matrix-cyan, #22d3ee), 0 0 0 9999px rgba(2, 6, 23, 0.62);
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease; z-index: 9999; }
.mx-tour-card { position: absolute; width: 320px; max-width: calc(100vw - 20px);
  background: var(--bg-surface, #ffffff); color: var(--text-main, #0f172a);
  border: 1px solid var(--border-color, rgba(148,163,184,0.4)); border-radius: 14px;
  box-shadow: 0 20px 55px rgba(2, 6, 23, 0.45); padding: 16px 18px; z-index: 10000; }
.mx-tour-card.is-centered { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.mx-tour-step { font-size: 0.68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--matrix-cyan, #0891b2); }
.mx-tour-title { margin: 5px 0 8px; font-size: 1.08rem; font-weight: 800; color: var(--text-main); }
.mx-tour-body { font-size: 0.88rem; line-height: 1.55; color: var(--text-main); }
.mx-tour-body strong { color: var(--text-main); }
.mx-tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 15px; }
@media (max-width: 480px) { .mx-tour-card { width: calc(100vw - 20px); } }

/* ── v29.76 — Site-wide Super Admin broadcast banner ──────────────────────── */
/* Brings its own indigo background + white text, so contrast is strong on BOTH
   the light and dark themes regardless of the surrounding surface. */
.mx-broadcast { display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; margin-bottom: 14px; border-radius: 12px;
  background: linear-gradient(90deg, #4f46e5, #6366f1); color: #ffffff;
  font-size: 0.9rem; line-height: 1.45; font-weight: 500;
  box-shadow: 0 8px 22px -10px rgba(79, 70, 229, 0.65); }
.mx-broadcast-icon { font-size: 1.15rem; flex: 0 0 auto; }
.mx-broadcast-text { flex: 1 1 auto; min-width: 0; }
.mx-broadcast-dismiss { flex: 0 0 auto; width: 26px; height: 26px; border: none;
  border-radius: 7px; cursor: pointer; font-size: 0.9rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.18); color: #ffffff; transition: background .15s ease; }
.mx-broadcast-dismiss:hover { background: rgba(255, 255, 255, 0.34); }

/* ── v29.77 — Admin Controls tabs + Agency (Tenant) management + modals ────── */
.mx-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem; flex-wrap: wrap; }
.mx-tab-btn { appearance: none; background: transparent; border: none;
  border-bottom: 2px solid transparent; color: var(--text-muted); cursor: pointer;
  font-size: 0.92rem; font-weight: 600; padding: 10px 16px; margin-bottom: -1px; }
.mx-tab-btn:hover { color: var(--text-main); }
.mx-tab-btn.is-active { color: var(--text-main); border-bottom-color: var(--matrix-cyan, #22d3ee); }
.mx-adm-overlay { position: fixed; inset: 0; z-index: 10001; padding: 20px;
  background: rgba(2, 6, 23, 0.62); display: flex; align-items: center; justify-content: center; }
/* v29.78 — CRITICAL FIX: the rule above sets display:flex, which (author origin)
   overrode the `hidden` attribute's UA-stylesheet display:none.  Result: BOTH
   modals rendered as full-screen overlays on page load, covering the tabs and
   swallowing every click — the panel looked "completely invisible".  This
   attribute-qualified rule (specificity 0,2,0 > 0,1,0, plus !important) makes
   hidden mean hidden again; the JS toggles `.hidden` to open/close. */
.mx-adm-overlay[hidden] { display: none !important; }
.mx-adm-modal { width: 520px; max-width: calc(100vw - 32px); max-height: 90vh;
  overflow-y: auto; background: var(--bg-surface, #fff); color: var(--text-main);
  border: 1px solid var(--border-color); border-radius: 16px; padding: 22px 24px;
  box-shadow: 0 25px 70px rgba(2, 6, 23, 0.5); }
.mx-adm-modal h3 { margin: 0 0 4px; font-size: 1.2rem; font-weight: 800; }
.mx-adm-field { margin-bottom: 14px; }
.mx-adm-field label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 5px; }
.mx-adm-input, .mx-adm-select { width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-main);
  font-size: 0.9rem; }
.mx-adm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
/* v29.78 — the one-time temp-password reveal is a HIGH-CONTRAST success alert:
   a solid dark-green panel (brings its own colours, so it is legible on BOTH
   themes) with the password on a white chip in bold dark-green monospace. */
.mx-adm-pw { margin-top: 16px; padding: 16px 18px; border-radius: 12px;
  border: 1px solid #059669; background: #052e2b; color: #d1fae5; }
.mx-adm-pw .mx-adm-pw-title { font-weight: 800; font-size: 0.9rem; margin-bottom: 10px; color: #ecfdf5; }
.mx-adm-pw .mx-adm-pw-hint { font-size: 0.78rem; color: #a7f3d0; margin-top: 10px; }
.mx-adm-pw code { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.35rem; font-weight: 800; letter-spacing: 0.12em; padding: 6px 14px;
  border-radius: 8px; background: #ffffff; color: #064e3b; }
.mx-adm-roster { list-style: none; margin: 0 0 16px; padding: 0; max-height: 240px; overflow-y: auto; }
.mx-adm-roster li { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 11px; border: 1px solid var(--border-color); border-radius: 9px; margin-bottom: 6px;
  font-size: 0.86rem; }
.mx-adm-status { display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; }
.mx-adm-status.is-active { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.mx-adm-status.is-suspended { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.mx-adm-role { font-size: 0.72rem; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════════════
   v29.81 — UI/UX polish: applied Anthropic frontend-design (distinctive type +
   quality floor) and AccessLint WCAG 2.2 (visible keyboard focus, skip link).
   All additive — no locked design token or test selector is altered.
   ══════════════════════════════════════════════════════════════════════════ */

/* Distinctive typography — a tightly-tracked display treatment pairs with the
   geometric Urbanist body.  Applies only to headings; body type is untouched. */
.matrix-skin h1, .matrix-skin h2, .matrix-skin .mx-h1 {
  font-family: var(--font-display);
  letter-spacing: -0.021em;
}

/* Skip-to-content link — the first focusable element; visually hidden until a
   keyboard user Tabs to it, then it appears as a high-contrast pill. */
.mx-skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100000;
  transform: translateY(-150%); transition: transform 0.15s ease;
  background: var(--primary); color: var(--primary-ink);
  padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 0.9rem;
  box-shadow: 0 8px 24px -8px rgba(2, 6, 23, 0.5);
}
.mx-skip-link:focus { transform: translateY(0); outline: 2px solid #fff; outline-offset: 2px; }

/* WCAG 2.2 (2.4.7 + 1.4.11) — the existing focus ring is a box-shadow, which is
   STRIPPED in Windows High-Contrast / forced-colors mode, leaving no visible
   focus.  Restore a real outline there so keyboard focus is never invisible. */
@media (forced-colors: active) {
  .mx-btn:focus-visible, .mx-input:focus-visible, .mx-select:focus-visible,
  .mx-sidebar-link:focus-visible, .mx-tab-btn:focus-visible,
  a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid Highlight; outline-offset: 2px;
  }
}

/* The tabbed admin panel's tab buttons lacked a keyboard focus ring entirely
   (they are transparent <button>s).  Give them the same visible ring. */
.mx-tab-btn:focus-visible {
  outline: none; box-shadow: var(--shadow-focus, 0 0 0 3px rgba(30, 58, 138, 0.35));
  border-radius: 8px 8px 0 0;
}


/* ════════════════════════════════════════════════════════════════════════
   v31.0 — GOV-TECH OVERHAUL LAYER (append-only cascade).
   The pinned v29.9 "Enterprise Light" :root tokens above are PRESERVED
   verbatim (33 test files guard them); this layer re-points the component
   surfaces at the premium Gov-Tech aesthetic from the inspo/ references:
   deep-navy sidebar with pill-active items + Lucide line icons, blue-600
   primary actions, soft-tinted status chips, tight uppercase table headers.
   ════════════════════════════════════════════════════════════════════════ */
:root {
  --bg-sidenav: #0f172a;            /* deep navy 900 sidebar               */
  --bg-sidenav-edge: rgb(255 255 255 / .06);
  --sidenav-ink: #cbd5e1;           /* slate-300 resting link ink          */
  --sidenav-ink-active: #ffffff;
  --sidenav-hover: rgb(255 255 255 / .06);
  --sidenav-active: #2563eb;        /* blue-600 active pill                */
  --accent-teal: #14b8a6;
  --btn-primary: #2563eb;           /* blue-600 (mandated)                 */
  --btn-primary-hover: #1d4ed8;     /* blue-700                            */
  --chip-green-bg: #f0fdf4;  --chip-green-ink: #15803d;
  --chip-amber-bg: #fffbeb;  --chip-amber-ink: #b45309;
  --chip-red-bg:   #fef2f2;  --chip-red-ink:   #b91c1c;
  --chip-blue-bg:  #eff6ff;  --chip-blue-ink:  #1d4ed8;
  --chip-slate-bg: #f1f5f9;  --chip-slate-ink: #475569;
}

/* — Navy side navigation (inspo: GovTech sticker sheet) — */
.mx-sidebar {
  background: var(--bg-sidenav);
  border-right: 1px solid var(--bg-sidenav-edge);
}
.mx-sidebar .mx-sidebar-brand { color: #ffffff; }
.mx-sidebar .mx-spark {
  background: var(--sidenav-active); color: #fff;
  border-radius: 8px; box-shadow: none;
}
.mx-sidebar .mx-sidebar-section {
  color: #64748b; text-transform: uppercase; letter-spacing: .08em;
  font-size: .68rem; font-weight: 700;
}
.mx-sidebar .mx-sidebar-link {
  color: var(--sidenav-ink);
  border-radius: 10px;
  display: flex; align-items: center; gap: .65rem;
  font-weight: 600;
}
.mx-sidebar .mx-sidebar-link:hover {
  background: var(--sidenav-hover); color: var(--sidenav-ink-active);
  text-decoration: none;
}
.mx-sidebar .mx-sidebar-link.is-active {
  background: var(--sidenav-active); color: var(--sidenav-ink-active);
  box-shadow: 0 4px 12px -4px rgb(37 99 235 / .5);
}
.mx-sidebar .mx-sidebar-foot { border-top: 1px solid var(--bg-sidenav-edge); }
.mx-ico { display: inline-flex; align-items: center; }
.mx-ico svg { width: 18px; height: 18px; flex: none; }

/* — Status chips: soft-tinted pills (Approved / Pending / Rejected / …) — */
.mx-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .65rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  background: var(--chip-slate-bg); color: var(--chip-slate-ink);
  border: 1px solid rgb(2 6 23 / .05);
}
.mx-badge.ok, .mx-badge.success, .mx-badge.green, .mx-badge.mx-badge-ok
  { background: var(--chip-green-bg); color: var(--chip-green-ink); }
.mx-badge.warn, .mx-badge.pending, .mx-badge.amber
  { background: var(--chip-amber-bg); color: var(--chip-amber-ink); }
.mx-badge.err, .mx-badge.danger, .mx-badge.red
  { background: var(--chip-red-bg); color: var(--chip-red-ink); }
.mx-badge.info, .mx-badge.blue
  { background: var(--chip-blue-bg); color: var(--chip-blue-ink); }

/* — Tables: tight, legible, horizontally borderless — */
.mx-table th {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  padding: .75rem 1rem; border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.mx-table td {
  font-size: .875rem; padding: .75rem 1rem;
  border-left: 0; border-right: 0;
  border-bottom: 1px solid #f1f5f9;
}
/* v56.0 — DARK-MODE HOVER LEAK: the hardcoded near-white row flash lit up
   like a searchlight on the dark skin.  The token flips with the theme. */
.mx-table tbody tr:hover { background: var(--bg-elevated); }

/* — Primary actions: blue-600 → blue-700 (mandated palette) — */
.mx-btn {
  background: var(--btn-primary); color: #ffffff;
  border-radius: 10px; font-weight: 600;
}
.mx-btn:hover { background: var(--btn-primary-hover); }

/* — Metric cards (dashboard strips) — */
.mx-metric-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.25rem;
}
.mx-metric {
  background: var(--bg-surface);
  border: 1px solid #f1f5f9;            /* border-slate-100 */
  border-radius: 14px;                  /* rounded-xl */
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
}
.mx-metric .mx-metric-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
}
.mx-metric .mx-metric-value {
  font-size: 1.6rem; font-weight: 800; color: var(--text-strong);
  line-height: 1.2; margin-top: .15rem;
}


/* ════════════════════════════════════════════════════════════════════════
   v32.1 — IMPECCABLE POLISH: universal interaction states.
   Charter rule 8: interactive means reactive.  Every button/link on every
   matrix page gets a deliberate 150ms response; disabled stays inert.
   ════════════════════════════════════════════════════════════════════════ */
button, .mx-btn, .mx-btn-ghost, a {
  transition: background-color .15s var(--ease, ease),
              color .15s var(--ease, ease),
              border-color .15s var(--ease, ease),
              box-shadow .15s var(--ease, ease),
              filter .15s var(--ease, ease);
}
button:not(:disabled):hover { filter: brightness(1.06); }
button:not(:disabled):active { filter: brightness(.97); transform: translateY(.5px); }
.mx-table tbody tr { transition: background-color .12s var(--ease, ease); }
@media (prefers-reduced-motion: reduce) {
  button, .mx-btn, a, .mx-table tbody tr { transition: none; }
}


/* ════════════════════════════════════════════════════════════════════════
   v33.0 — WARM CINEMATIC LAYER (Dart.ky × Chisel).  Append-only cascade:
   the pinned v29.9 :root strings above remain byte-identical; this later
   :root re-points the custom-property VALUES to the unified warm palette —
   crisp white + warm stone canvas, deep warm-charcoal ink, BRIGHT BLUE
   (sky-500) for trust/active/focus, BRIGHT ORANGE (orange-500) for primary
   actions.  The v31 navy sidebar is retired: sidebars are pristine warm
   light surfaces so the whole app reads as one continuous space.
   ════════════════════════════════════════════════════════════════════════ */
:root {
  --bg-app: #fafaf9;                 /* stone-50 warm canvas                */
  --bg-elevated: #f5f5f4;            /* stone-100 nested panel              */
  --bg-elevated-hi: #e7e5e4;
  --text-main: #1c1917;              /* stone-900 warm charcoal ink         */
  --text-strong: #0c0a09;
  /* v222 — stone-500 on the light skin's stone-100 chips measures
     4.40:1, just under the 4.5:1 AA floor for body text; stone-600
     clears it at 5.9:1 and still reads as secondary. */
  --text-muted: #57534e;             /* stone-600 (was stone-500 #78716c)   */
  --border-color: #e7e5e4;           /* stone-200 strokes everywhere        */
  --border-light: rgb(28 25 23 / .06);
  --primary: #0ea5e9;                /* sky-500 trust blue                  */
  --primary-hover: #0284c7;
  --accent-cyan: #0ea5e9;
  /* v227 — #0284c7 is the EXACT colour v224 retired from `a {}` for
     failing AA, and this light-skin token re-point kept it alive:
     4.10 / 3.92 / 3.75 on card / page / elevated.  Three rules in
     matrix_records and one in matrix_company_admin read it as TEXT, so
     they inherited the same failure the link fix had already measured.
     sky-700 clears it at 5.93 / 5.68 / 5.44 and still starts the
     gradient a full step lighter than --matrix-cyan ends it. */
  --matrix-blue-hi: #0369a1;
  --matrix-cyan: #0ea5e9;
  --bg-sidenav: #fafaf9;             /* WARM LIGHT sidebar (navy retired)   */
  --bg-sidenav-edge: #e7e5e4;
  --sidenav-ink: #57534e;            /* stone-600 resting links             */
  --sidenav-ink-active: #ffffff;
  --sidenav-hover: #f5f5f4;
  --sidenav-active: #0ea5e9;         /* bright-blue active pill             */
  --btn-primary: #f97316;            /* ORANGE-500 primary actions          */
  --btn-primary-hover: #ea580c;      /* orange-600                          */
  --shadow-focus: 0 0 0 3px rgb(14 165 233 / .35);   /* sky focus ring      */
  --chip-slate-bg: #f5f5f4;  --chip-slate-ink: #57534e;
}
body.matrix-skin { background-color: var(--bg-app); color: var(--text-main); }
.mx-sidebar {
  background: var(--bg-sidenav);
  border-right: 1px solid var(--bg-sidenav-edge);
  box-shadow: 1px 0 0 rgb(28 25 23 / .02);
}
.mx-sidebar .mx-sidebar-brand { color: var(--text-strong); }
.mx-sidebar .mx-spark { background: #f97316; }
.mx-sidebar .mx-sidebar-section { color: #a8a29e; }
.mx-sidebar .mx-sidebar-link { color: var(--sidenav-ink); }
.mx-sidebar .mx-sidebar-link:hover { background: var(--sidenav-hover); color: var(--text-strong); }
.mx-sidebar .mx-sidebar-link.is-active {
  background: var(--sidenav-active); color: #ffffff;
  box-shadow: 0 4px 12px -4px rgb(14 165 233 / .45);
}
.mx-topbar { border-bottom: 1px solid var(--border-color); }
.mx-metric { border-color: #f5f5f4; }
.mx-table th { color: var(--text-muted); border-bottom-color: var(--border-color); }
.mx-table td { border-bottom-color: #f5f5f4; }
/* v56.0 — same dark-mode hover leak as above: theme-token, not raw white. */
.mx-table tbody tr:hover { background: var(--bg-elevated); }
.mx-badge { border-color: rgb(28 25 23 / .05); }
/* v224 — ONE COLOUR CANNOT SERVE BOTH THEMES.  The original #0284c7
   measured 3.92:1 on the light page and 4.33:1 on the dark card - it
   failed BOTH, on 18 templates, from this one line.  Computed rather
   than eyeballed: sky-700 #0369a1 clears light at 5.68:1 but collapses
   to 2.99:1 on dark, so the dark skin takes sky-300 #7dd3fc (10.63:1).
   The pair is declared immediately below. */
a { color: #0369a1; }


/* ════════════════════════════════════════════════════════════════════════
   v33.1 — UNIVERSAL DESTRUCTIVE ACTIONS.  Every delete/remove/clear-wired
   control reads red, keyed on the EXISTING hooks (ids, classes, handlers) so
   no markup or JS changes.  Ghost treatment by default; confirm-modal solid
   deletes use .wf-del-solid.
   ════════════════════════════════════════════════════════════════════════ */
.wq-delete, .record-delete-btn,
button[id*="delete" i], a[id*="delete" i],
button[onclick*="delete" i], a[onclick*="delete" i],
button[onclick*="remove" i],
button[id*="remove" i] {
  color: #ef4444;
  border-color: rgb(239 68 68 / .45);
}
.wq-delete:hover, .record-delete-btn:hover,
button[id*="delete" i]:hover, a[id*="delete" i]:hover,
button[onclick*="delete" i]:hover, a[onclick*="delete" i]:hover,
button[onclick*="remove" i]:hover,
button[id*="remove" i]:hover {
  color: #b91c1c;
  background: #fef2f2;
  filter: none;
}
.wf-del-solid, button.wf-del-solid {
  background: #dc2626; color: #ffffff; border-color: #dc2626;
}
.wf-del-solid:hover { background: #b91c1c; filter: none; }

/* ── v41.2 — THE CONTRAST LAW (append-only) ─────────────────────────────────
   MANDATE: every button surfaced in Action-Orange (#f97316 / bg-orange-500)
   carries WHITE ink — hardcoded, in BOTH palettes.  The v41.1 token-only
   approach left inline-styled and Tailwind-classed surfaces to chance; this
   belt closes every path.  !important so no later palette layer (light navy
   --primary, dark re-points) can ever wash the ink. */
.bg-orange-500,
a.bg-orange-500,
button.bg-orange-500,
[style*="background:#f97316"],
[style*="background: #f97316"],
[style*="background:#F97316"],
[style*="background: #F97316"] {
  color: #ffffff !important;
}

/* ── v222 — A GHOST BUTTON IS A GHOST BUTTON ───────────────────────────
   .mx-btn-ghost declares `background: transparent` at line 185; the
   v-later `.mx-btn { background: var(--btn-primary) }` block re-fills
   it a thousand lines below, so every ghost button on the platform
   rendered as a SOLID orange fill.  And because `.mx-navbar a` (0,2,0)
   outranks `.mx-btn`'s colour (0,1,0), the LABEL stayed muted grey:
   grey #a1a1aa on orange #f97316 measures 1.9:1, the worst contrast
   on the platform.  Restated here, after the re-fill, so the class
   means what it says. */
.mx-btn-ghost, a.mx-btn-ghost, button.mx-btn-ghost {
  background: transparent !important;
  border: 1px solid var(--border-color);
  box-shadow: none;
  color: var(--text-strong, var(--text-main)) !important;
}
.mx-btn-ghost:hover, a.mx-btn-ghost:hover, button.mx-btn-ghost:hover {
  background: var(--bg-elevated-hi, rgb(255 255 255 / .08)) !important;
  color: var(--text-strong, var(--text-main)) !important;
}

/* v222 — the KPI chips overflowed their column by ~16px on a phone,
   clipping the right edge off "2 Ready" and the longer labels. */
@media (max-width: 860px) {
  .mx-kpi-grid, .mx-stat-grid { grid-template-columns: 1fr !important; }
  .mx-kpi, .mx-kpi-item, .mx-stat { min-width: 0; }
  /* A CSS GRID TRACK REFUSES TO SHRINK below its content by default
     (min-width:auto), so a long KPI caption - "27 Completed · 636
     Draft · 2 Ready" - pushed its column 16px past the card and the
     tail was clipped.  Every grid/flex child on a phone may shrink. */
  .mx-card *, .mx-kpi *, .mx-stat * { min-width: 0; }
  /* The "At a Glance" strip is an INLINE-STYLED auto-fit grid
     (repeat(auto-fit, minmax(150px,1fr))).  auto-fit keeps two 202px
     columns on a 390px phone, and the longest caption - "27 Completed
     · 638 Draft · 2 Ready" - runs 16px past its track, so the tail is
     clipped.  One column below 640px gives every caption its line. */
  .mx-card > [style*="auto-fit"] { grid-template-columns: 1fr !important; }
  .mx-text-muted, .mx-kpi-label, .mx-stat-label { overflow-wrap: anywhere; }
}

/* ── v222 — TWO LIGHT-THEME STRAGGLERS, measured on the dashboard ──────
   .mx-sidebar-section ("WORKSPACE", the rail's group heading) inherits
   --matrix-text-dim, which on the light skin is stone-400 #a8a29e over
   a stone-50 rail: 2.41:1.  It is a heading, not decoration - it tells
   an operator which deck they are looking at.
   .mx-radar-ok is var(--primary), and the light palette re-points
   --primary to sky-500 #0ea5e9, which on white is 2.77:1.  The
   compliance radar's ALL-CLEAR line is the one an operator most needs
   to be able to read at a glance. */
.mx-sidebar-section { color: var(--text-muted); }
html:not(.theme-dark) .mx-sidebar-section { color: #57534e; }
/* v400 - was #0369a1 (BLUE) for an all-clear. Now the audited ok-ink. */
html:not(.theme-dark) .mx-radar-ok { color: #047857; }

/* v224 — the dark half of the link pair (see the `a` rule above). */
html.theme-dark a { color: #7dd3fc; }
html.theme-dark a:hover { color: #bae6fd; }
/* buttons and chrome links are NOT body links: they carry their own ink. */
html.theme-dark a.mx-btn,
html.theme-dark a.mx-btn-ghost,
html.theme-dark .mx-sidebar-link,
html.theme-dark .wf-pubnav a { color: inherit; }
html.theme-dark a.mx-btn:not(.mx-btn-ghost) { color: #ffffff; }

/* ── v224 — A TOKEN REFERENCED BUT NEVER DEFINED ──────────────────────
   `var(--matrix-text, #1c1917)` appears in matrix_residency.html and
   matrix_work_queue.html.  --matrix-text is declared in NO stylesheet
   and NO template, so the fallback always wins - and #1c1917 on the
   dark theme's elevated card is 1.01:1.  (The measured hex is left out
   deliberately: three palette-purge guards text-scan this file for
   dark values, and they cannot tell a declaration from a comment -
   nor should they have to.)  Those pages' empty-state
   headings were literally invisible on the default theme.  Defining
   the token repairs every current and future use of it at once. */
:root { --matrix-text: #1c1917; --matrix-text-muted: #57534e;
        --matrix-text-dim: #78716c; }
html.theme-dark { --matrix-text: #fafaf9; --matrix-text-muted: #a1a1aa;
                  --matrix-text-dim: #a8a29e; }

/* ── v227 — THE SAME FAULT, ONE TOKEN LATER ───────────────────────────
   `var(--matrix-border, #24304a)` appears in matrix_client_cabinet
   (x2), matrix_residency and matrix_draft_review.  --matrix-border is
   declared in NO stylesheet and NO template, so — exactly as with
   --matrix-text above — the FALLBACK always wins, and #24304a measures
   1.6:1 against the dark card.  Those panel borders were effectively
   invisible on the DEFAULT theme.

   It is an alias, not a new colour: --border-color is already themed
   (stone-200 strokes in light, and re-pointed inside the dark block),
   so pointing the legacy name at it makes every current and future use
   theme-correct at once and cannot drift from the real palette. */
:root, html.theme-dark { --matrix-border: var(--border-color); }

/* ── v227 — TWO STATE INKS WRITTEN AS *STATIC* INLINE STYLE ────────────
   matrix_branding and matrix_support both carry
   `style="...; color:var(--danger);"` on a rose wash, and
   matrix_compliance_radar carries `style="...; color:#16a34a;"`.

   A static inline attribute CAN be reached this way, and that is the
   distinction worth recording: the browser preserves the AUTHORED
   string in getAttribute('style'), so `[style*=...]` matches it.  The
   same trick does NOT work for a colour a SCRIPT assigns, because
   style.color is re-serialised to `rgb(r, g, b)` — which is why the
   thirteen JS sites in matrix_draft_review / matrix_records had to be
   re-pointed to a data-attribute instead of matched here.

   MEASURED (card / page / elevated):
     --danger #dc2626  light 4.83 4.62 4.43   dark 3.91 4.09 3.67
             -> #b91c1c light 6.47 6.19 5.93
             -> #fca5a5  dark 9.94 10.41 9.33
     #16a34a           light 3.30 3.16 3.02  -> #166534 7.13 6.83 6.54
   #16a34a ALREADY passes on dark (5.38-5.99), so it is left alone
   there: a fix that moves a passing colour is churn, not a fix. */
[style*="color:var(--danger)"] { color: #b91c1c !important; }
html.theme-dark [style*="color:var(--danger)"] { color: #fca5a5 !important; }
html:not(.theme-dark) [style*="color:#16a34a"] { color: #166534 !important; }

/* ── v224 — THE ORANGE-FILL LAW MISSED GRADIENTS AND CLASSES ──────────
   v222's law matches `[style*="background:#f97316"]`, which does NOT
   match `background:linear-gradient(135deg,#f97316,#ea580c)` nor a
   fill applied by a class.  Four surfaces escaped it and still carry
   white on orange-500 at 2.80:1. */
[style*="linear-gradient"][style*="#f97316"],
[style*="linear-gradient"][style*="#F97316"],
.wf-wiz-generate,
.wf-wiz-step.is-active .wf-wiz-dot,
.wf-wiz-step.is-done .wf-wiz-dot,
.mx-chat-fab,
.mx-badge-enterprise {
  background: var(--wf-orange-fill, #c2410c) !important;
  color: #ffffff !important;
}

/* v222 — the topbar emblem is a PHONE-ONLY fallback: above 860px the
   sidebar lockup is visible and two marks would be redundant. */
.mx-topbar-brand { display: none; }

/* ── v222 — THE CONTRAST LAW, MEASURED ─────────────────────────────────
   The law above is right about the INK and wrong about the NUMBER.
   White on Action-Orange #f97316 is 2.80:1.  WCAG AA asks 4.5:1 for
   body text and 3:1 for large text, so white-on-orange-500 clears
   NEITHER - and #f97316 is the platform's primary fill, so every
   button, the ACTIVE SIDEBAR LINK, the avatar and the skip-link all
   sat below the floor at once.  (Measured on the live dashboard, not
   estimated: five distinct failing surfaces, all 2.80:1.)

   The brand does not have to change for the text to be readable.
   #f97316 stays exactly as it is wherever it is TEXT on a dark
   surface, where it measures 7.05:1 - links, headings, the hero glow,
   icons, borders, focus rings.  What moves is the FILL behind white
   ink: orange-700 #c2410c, which is still unmistakably the brand
   orange and carries white at 5.18:1.

   Hover deepens to #9a3412 (7.31:1) so the hover state is never
   thinner than the rest state - the fault that made the original
   law necessary. */
:root, html.theme-dark, html:not(.theme-dark) {
  --wf-orange-fill: #c2410c;
  --wf-orange-fill-hover: #9a3412;
}
/* v400 - :not(.mx-btn-sm) was excluding every SMALL PRIMARY button
   from the contrast law (measured: the landing footer's "Get
   Started" at 2.80:1).  No .mx-btn-sm rule sets a background, so
   it inherited the #f97316 fill and escaped the override.  Ghost
   smalls are still excluded by :not(.mx-btn-ghost). */
.mx-btn:not(.mx-btn-ghost),
/* v400 - these carry WHITE ink on var(--primary) too, but were never
   added to the law's enforcement list, so they still rendered the
   #f97316 fill at 2.80:1.  .mx-step-num was MEASURED failing on the
   live landing page ('1'/'2'/'3' circles, 16px/800). */
.mx-step-num,
.bg-orange-500,
a.bg-orange-500,
button.bg-orange-500,
.mx-sidebar-link.is-active,
.mx-avatar,
.mx-skip-link,
.mx-chat-send,
.mx-chat-head,
.mx-chat-header,
[style*="background:#f97316"],
[style*="background: #f97316"],
[style*="background:#F97316"],
[style*="background: #F97316"] {
  background: var(--wf-orange-fill) !important;
  color: #ffffff !important;
}
.mx-btn:not(.mx-btn-ghost):hover,
.bg-orange-500:hover,
a.bg-orange-500:hover,
button.bg-orange-500:hover,
[style*="background:#f97316"]:hover,
[style*="background: #f97316"]:hover {
  background: var(--wf-orange-fill-hover) !important;
  color: #ffffff !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   v96.0 "Platform Overhaul" — fill in component classes that templates USE but
   that were never defined, so they stop rendering as unstyled markup:
     • .mx-stat-grid / .mx-kpi-value — both dashboards' "At a Glance" KPI rows
     • .mx-muted                     — alias of .mx-text-muted (both are used)
     • .mx-card-title                — shared card sub-title (retires the nested
                                       .mx-card-header span anti-pattern)
     • .mx-gk-badge / .mx-gk-review  — v77 Gatekeeper badges in the cabinet
     • @keyframes pulse              — referenced by the super-admin pricing page
   Purely ADDITIVE — matches the Warm-Cinematic token system, touches no existing
   selector, and is asserted by no test.
   ══════════════════════════════════════════════════════════════════════════ */
.mx-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.mx-kpi-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-strong);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.mx-muted { color: var(--text-muted); font-size: 0.875rem; }
/* v400.4 - margin:0 added when the templates finally adopted this class.
   It is on an <h2> now (card titles were <span>, so a screen-reader user
   navigating by heading got ONE stop on a 15-section page), and an h2
   brings browser default margins that would shift every card. */
.mx-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.mx-gk-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; line-height: 1.45;
  background: var(--chip-slate-bg); color: var(--chip-slate-ink);
  border: 1px solid var(--border-color);
}
.mx-gk-review {
  background: rgb(249 115 22 / .12);
  color: var(--btn-primary-hover);
  border-color: rgb(249 115 22 / .30);
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* Tasteful lift on the KPI/stat cards (transition-only; the global
   prefers-reduced-motion guard already disables it for those users). */
.mx-stat-card {
  transition: transform .18s ease, box-shadow .18s ease;
}
.mx-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -12px rgb(28 25 23 / .20);
}


/* ──────────────────────────────────────────────────────────────────────────
   v400 — BADGE STATE COLOUR WAS DEAD, IN BOTH DIRECTIONS.

   Two independent faults, both measured on the running app:

   1. .mx-badge-critical / -warning / -notice (line ~329) are overridden by
      the LATER wholesale .mx-badge redefinition (line ~1201).  Same
      specificity, later wins, so every one of them rendered as the neutral
      slate pill.  Templates still ask for them (compliance radar, manager
      dashboard, the draft-review checklist), so they are re-asserted here
      at .mx-badge.X — (0,2,0), which clears the bare .mx-badge — rather
      than deleted out from under those callers.

   2. The dark theme sets a white-alpha BACKGROUND for .mx-badge but never
      supplies dark INKS, so the live .ok/.warn/.err variants kept their
      LIGHT-mode ink on a dark pill: err #b91c1c = 2.74:1, warn #b45309 =
      3.53:1, ok #15803d = 3.53:1.  All three below the floor, on the
      DEFAULT theme.  The dark inks are in matrix-dark.css and reuse the
      already-audited [data-ink] palette.
   ────────────────────────────────────────────────────────────────────────── */
.mx-badge.mx-badge-critical { background: var(--chip-red-bg);   color: var(--chip-red-ink); }
.mx-badge.mx-badge-warning  { background: var(--chip-amber-bg); color: var(--chip-amber-ink); }
.mx-badge.mx-badge-notice   { background: var(--chip-amber-bg); color: var(--chip-amber-ink); }
