/*
 * Motor Trade - the whole-page shell: navy left sidebar, white top bar, content
 * slot. Styles lib/ui-motor-shell.js and nothing else.
 *
 * Every value here was measured off design/reference/01-market-neutral.png and
 * 02-warehouse-preview.png (sidebar navy #102a3a, ~249px wide; active nav block
 * #00858f spanning the full sidebar width; top bar 66px over a #ebedf0 hairline;
 * content #f8f8f6; slate avatar fill; bright teal strapline rule).
 *
 * Every selector sits under `.msh-shell` and every class is prefixed `msh-`,
 * every custom property `--msh-`, so this file cannot reach the content styled
 * by styles/motor-sales-ops.css (`mui-`) or styles/motor-ceo-finance.css
 * (`mceo-`), and neither of those can reach the frame.
 *
 * ONE accent (teal). Monochrome line icons drawn in currentColor. No emoji, no
 * gradients, no animation, no second accent.
 */

.motor-ui.msh-shell {
  --msh-navy: #102a3a;
  --msh-navy-soft: #16344a;
  --msh-navy-line: rgba(255, 255, 255, 0.12);
  --msh-on-navy: #ffffff;
  --msh-on-navy-soft: #c9d5e6;
  --msh-on-navy-muted: #7d8fa4;

  --msh-accent: #00858f;
  --msh-accent-strong: #006e78;
  --msh-accent-bright: #22e8e3;

  --msh-bg: #f8f8f6;
  --msh-surface: #ffffff;
  --msh-line: #ebedf0;
  --msh-ink: #0c141d;
  --msh-ink-soft: #68758a;

  --msh-slate: #7d8b9e;

  --msh-sidebar-width: 249px;
  --msh-topbar-height: 66px;
  --msh-font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  margin: 0;
  background: var(--msh-bg);
  color: var(--msh-ink);
  font-family: var(--msh-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.msh-shell *,
.msh-shell *::before,
.msh-shell *::after { box-sizing: inherit; }

.msh-shell p,
.msh-shell ul,
.msh-shell li { margin: 0; }

.msh-shell ul { list-style: none; padding: 0; }

.msh-shell .msh-icon { flex: 0 0 auto; }

.msh-shell .msh-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- sidebar ------------------------------------------------------- */

.msh-shell .msh-sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: 0 0 var(--msh-sidebar-width);
  width: var(--msh-sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 0 26px;
  background: var(--msh-navy);
  color: var(--msh-on-navy);
  overflow-y: auto;
}

/* ---------- wordmark ---------- */

.msh-shell .msh-brand {
  padding: 0 24px 18px;
  border-bottom: 1px solid var(--msh-navy-line);
}

.msh-shell .msh-brand-the {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.15;
  color: var(--msh-on-navy);
}

/* One line at the measured 249px sidebar width, whatever font actually loads. */
.msh-shell .msh-brand-name {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
  white-space: nowrap;
  color: var(--msh-on-navy);
}

.msh-shell .msh-brand-sub {
  margin-top: 5px;
  font-size: 13px;
  color: var(--msh-on-navy-muted);
}

/* ---------- identity ---------- */

.msh-shell .msh-identity {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 20px 24px 22px;
}

.msh-shell .msh-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: var(--msh-slate);
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.msh-shell .msh-avatar-empty {
  background: transparent;
  border: 1px dashed var(--msh-on-navy-muted);
}

.msh-shell .msh-identity-text { min-width: 0; }

.msh-shell .msh-identity-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--msh-on-navy);
  overflow-wrap: anywhere;
}

.msh-shell .msh-identity-meta {
  font-size: 13px;
  line-height: 1.35;
  color: var(--msh-on-navy-muted);
  overflow-wrap: anywhere;
}

/* ---------- nav ---------- */

.msh-shell .msh-nav {
  flex: 1 1 auto;
  padding-top: 14px;
}

.msh-shell .msh-nav-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* The active item is a solid teal block spanning the whole sidebar width, so
   rows are full-bleed and carry their own horizontal padding. */
.msh-shell .msh-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 8px 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--msh-on-navy-soft);
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.msh-shell button.msh-nav-item:hover { background: rgba(255, 255, 255, 0.06); }

.msh-shell button.msh-nav-item:focus-visible {
  outline: 2px solid var(--msh-accent-bright);
  outline-offset: -3px;
}

.msh-shell .msh-nav-item .msh-nav-icon {
  width: 22px;
  height: 22px;
  color: inherit;
}

.msh-shell .msh-nav-label { min-width: 0; }

.msh-shell .msh-nav-active {
  background: var(--msh-accent);
  color: #ffffff;
  font-weight: 700;
}

.msh-shell button.msh-nav-active:hover { background: var(--msh-accent); }

/* A page this role owns that has not opened yet: blurred face, crisp reason.
   Another role's pages are not in the markup at all. */
.msh-shell .msh-nav-locked {
  position: relative;
  flex-wrap: wrap;
  gap: 0 10px;
  cursor: default;
  color: var(--msh-on-navy-muted);
}

.msh-shell .msh-nav-face {
  display: flex;
  align-items: center;
  gap: 14px;
  filter: blur(1.2px);
  opacity: 0.58;
}

.msh-shell .msh-nav-lock-icon {
  width: 17px;
  height: 17px;
  margin-left: auto;
  color: var(--msh-on-navy-muted);
}

.msh-shell .msh-nav-when {
  flex: 1 0 100%;
  padding-left: 36px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--msh-on-navy-muted);
}

/* ---------- strapline ---------- */

.msh-shell .msh-strapline { padding: 24px 24px 0; }

.msh-shell .msh-strapline-rule {
  display: block;
  width: 46px;
  height: 3px;
  margin-bottom: 14px;
  border-radius: 2px;
  background: var(--msh-accent-bright);
}

.msh-shell .msh-strapline-line {
  font-size: 15px;
  line-height: 1.45;
  color: var(--msh-on-navy-muted);
}

/* ---------- main column --------------------------------------------------- */

.msh-shell .msh-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  background: var(--msh-bg);
}

/* ---------- top bar ---------- */

.msh-shell .msh-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  min-height: var(--msh-topbar-height);
  padding: 12px 30px;
  background: var(--msh-surface);
  border-bottom: 1px solid var(--msh-line);
}

.msh-shell .msh-topbar-firm {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--msh-ink);
}

.msh-shell .msh-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.msh-shell .msh-stat {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 2px 20px;
  white-space: nowrap;
  color: var(--msh-ink-soft);
}

.msh-shell .msh-stat + .msh-stat { border-left: 1px solid var(--msh-line); }
.msh-shell .msh-stat:last-child { padding-right: 0; }

.msh-shell .msh-stat-icon {
  width: 20px;
  height: 20px;
  color: var(--msh-accent);
}

.msh-shell .msh-stat-label {
  font-size: 15px;
  color: var(--msh-ink-soft);
}

.msh-shell .msh-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--msh-ink);
}

/* ---------- content slot ---------- */

.msh-shell .msh-content {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--msh-bg);
}

/* The page renderers bring their own padding; the slot only supplies the
   surface. A page that sets its own background keeps it. */
.msh-shell .msh-content > .motor-ui { background: transparent; }

.msh-shell .msh-footer-note {
  padding: 0 34px 26px;
  color: var(--msh-ink-soft);
  font-size: 13px;
  text-align: right;
}

/* ---------- round banner --------------------------------------------------
   The round and the time still left in it. One line, above the sheet, in the
   place the shipped app puts #phase-timer-banner. Urgency is carried by ink
   weight and a warm border, never by a second accent colour or animation. */

.msh-shell .msh-round {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 34px 0;
  padding: 10px 14px;
  border: 1px solid var(--msh-line);
  border-left: 3px solid var(--msh-accent);
  border-radius: 8px;
  background: var(--msh-surface);
  color: var(--msh-ink);
  font-size: 13px;
}

.msh-shell .msh-round-icon { color: var(--msh-accent); }

.msh-shell .msh-round-label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.msh-shell .msh-round-time {
  color: var(--msh-ink-soft);
  font-variant-numeric: tabular-nums;
}

.msh-shell .msh-round-note {
  margin-left: auto;
  color: var(--msh-ink-soft);
  font-size: 12px;
}

.msh-shell .msh-round-danger {
  border-left-color: #b4471f;
  background: #fdf5f1;
}

.msh-shell .msh-round-danger .msh-round-icon { color: #b4471f; }

.msh-shell .msh-round-danger .msh-round-time {
  color: #8f3716;
  font-weight: 700;
}

.msh-shell .msh-round-paused {
  border-left-color: var(--msh-slate);
  background: #f3f5f7;
}

.msh-shell .msh-round-paused .msh-round-icon { color: var(--msh-slate); }

/* ---------- whole-class notices -------------------------------------------
   The class crisis and its clock, a wholesale window about to open: events
   that belong to no one sheet. They sit under the round banner so a student
   meets them on whatever page they are on. */

.msh-shell .msh-notices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 34px 0;
}

.msh-shell .msh-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 15px;
  border: 1px solid var(--msh-line);
  border-radius: 10px;
  background: var(--msh-surface);
  font-size: 13px;
}

.msh-shell .msh-notice-icon {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--msh-slate);
}

.msh-shell .msh-notice-body {
  flex: 1 1 auto;
  min-width: 0;
}

.msh-shell .msh-notice-title { font-weight: 700; }

.msh-shell .msh-notice-text {
  margin-top: 2px;
  color: var(--msh-ink-soft);
}

.msh-shell .msh-notice-time {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}

.msh-shell .msh-notice-time span {
  color: var(--msh-ink-soft);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.msh-shell .msh-notice-time strong { font-variant-numeric: tabular-nums; }

.msh-shell .msh-notice-urgent {
  border-color: #e3c4b6;
  background: #fdf5f1;
}

.msh-shell .msh-notice-urgent .msh-notice-icon { color: #b4471f; }

/* ---------- firm facts ----------------------------------------------------
   Cash, this role's budget, Stock at cost, Debt and VAT, Net position and
   Staff this round: the strip the shipped app builds as #motor-sheet-facts.
   It wraps rather than scrolls, so no figure is ever pushed out of sight. */

.msh-shell .msh-facts {
  display: flex;
  /* One row on a laptop, always. The five cells share the width by flex-grow,
     so wrap must not fire on the sub-pixel a scrollbar or grow-rounding can
     add; the ≤560px block below turns wrapping back on where the cells are
     meant to stack two-up. */
  flex-wrap: nowrap;
  gap: 1px;
  margin: 12px 34px 0;
  overflow: hidden;
  border: 1px solid var(--msh-line);
  border-radius: 10px;
  background: var(--msh-line);
}

.msh-shell .msh-fact {
  display: flex;
  flex: 1 1 150px;
  /* Without this a cell cannot shrink below its own text, so the five-cell
     strip wraps to two rows the moment a scrollbar (a busy sheet, a full
     forecourt) takes ~15px off the row. min-width:0 lets the cells give up a
     few pixels each and stay on one line, which is what the strip is for. */
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px;
  background: var(--msh-surface);
}

.msh-shell .msh-fact-label {
  color: var(--msh-ink-soft);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.msh-shell .msh-fact-value {
  color: var(--msh-ink);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Net position is the figure the whole lesson is measured on. */
.msh-shell .msh-fact-net .msh-fact-value { color: var(--msh-accent-strong); }

.msh-shell .msh-facts-note {
  flex: 1 1 100%;
  padding: 8px 14px;
  background: var(--msh-surface);
  color: var(--msh-ink-soft);
  font-size: 12px;
}

/* ---------- secondary shared functions ------------------------------------
   Live Chart and the firm/team chat. SECONDARY: each is a closed control the
   student opens, never a panel every work screen carries beneath itself. Built
   on <details>/<summary>, so opening one needs no JavaScript at all. */

.msh-shell .msh-secondary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 30px 34px 30px;
  padding-top: 22px;
  border-top: 1px solid var(--msh-line);
}

.msh-shell .msh-secondary-block {
  border: 1px solid var(--msh-line);
  border-radius: 12px;
  background: var(--msh-surface);
}

.msh-shell .msh-secondary-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  color: var(--msh-ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

/* The marker is drawn by the caret rule below, in both engines. */
.msh-shell .msh-secondary-summary::-webkit-details-marker { display: none; }
.msh-shell .msh-secondary-summary::marker { content: ""; }

.msh-shell .msh-secondary-summary:hover { background: #f4f6f7; }

.msh-shell .msh-secondary-summary:focus-visible {
  outline: 2px solid var(--msh-accent);
  outline-offset: -2px;
}

.msh-shell .msh-secondary-icon { color: var(--msh-ink-soft); }

.msh-shell .msh-secondary-title { flex: 0 0 auto; }

.msh-shell .msh-secondary-hint {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--msh-ink-soft);
  font-size: 13px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A plain chevron, so it is obvious the row opens. */
.msh-shell .msh-secondary-summary::after {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 1.6px solid var(--msh-ink-soft);
  border-bottom: 1.6px solid var(--msh-ink-soft);
  transform: rotate(45deg) translate(-2px, -2px);
}

.msh-shell .msh-secondary-block[open] .msh-secondary-summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.msh-shell .msh-secondary-block[open] .msh-secondary-summary {
  border-bottom: 1px solid var(--msh-line);
  border-radius: 12px 12px 0 0;
}

.msh-shell .msh-secondary-body { padding: 16px 20px 18px; }

/* Every firm's Net position, in rank order, inside the Live Chart disclosure.
   The bar is proportional width only; the accent marks your own firm. */

.msh-shell .msh-standings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  counter-reset: none;
}

.msh-shell .msh-standing {
  display: grid;
  grid-template-columns: 22px minmax(90px, 1.2fr) minmax(60px, 2fr) auto;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.msh-shell .msh-standing-rank {
  color: var(--msh-ink-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.msh-shell .msh-standing-name {
  overflow: hidden;
  color: var(--msh-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msh-shell .msh-standing-you { color: var(--msh-ink-soft); }

.msh-shell .msh-standing-bar {
  display: block;
  overflow: hidden;
  height: 8px;
  border-radius: 4px;
  background: #eef0f2;
}

.msh-shell .msh-standing-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: #c7cdd3;
}

.msh-shell .msh-standing-value {
  color: var(--msh-ink);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.msh-shell .msh-standing-own .msh-standing-name,
.msh-shell .msh-standing-own .msh-standing-rank,
.msh-shell .msh-standing-own .msh-standing-value { color: var(--msh-accent-strong); }

.msh-shell .msh-standing-own .msh-standing-name { font-weight: 700; }

.msh-shell .msh-standing-own .msh-standing-fill { background: var(--msh-accent); }

.msh-shell .msh-standings-note {
  margin-top: 13px;
  color: var(--msh-ink-soft);
  font-size: 12px;
}

/* ---------- narrow screens ------------------------------------------------ */

@media (max-width: 960px) {
  .motor-ui.msh-shell { flex-direction: column; min-height: 100%; }

  .msh-shell .msh-sidebar {
    position: static;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    padding: 18px 0 16px;
  }

  .msh-shell .msh-brand,
  .msh-shell .msh-identity,
  .msh-shell .msh-strapline { padding-left: 20px; padding-right: 20px; }

  .msh-shell .msh-nav { padding-top: 12px; }

  .msh-shell .msh-nav-list {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding: 0 20px;
  }

  .msh-shell .msh-nav-row { flex: 0 0 auto; }

  .msh-shell .msh-nav-item {
    width: auto;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 15px;
  }

  .msh-shell .msh-nav-locked { flex-wrap: nowrap; }
  .msh-shell .msh-nav-lock-icon { margin-left: 4px; }

  .msh-shell .msh-nav-when {
    flex: 0 0 auto;
    padding-left: 6px;
    font-size: 11px;
  }

  .msh-shell .msh-strapline { padding-top: 18px; }

  .msh-shell .msh-topbar { padding: 12px 20px; }
  .msh-shell .msh-topbar-firm { font-size: 19px; }
  .msh-shell .msh-stat { padding: 2px 12px; }
  .msh-shell .msh-footer-note { padding: 0 20px 20px; }

  .msh-shell .msh-round { margin: 18px 20px 0; }
  .msh-shell .msh-notices { margin: 8px 20px 0; }
  .msh-shell .msh-facts { margin: 10px 20px 0; }
  .msh-shell .msh-secondary { margin: 24px 20px 24px; }
}

@media (max-width: 560px) {
  .msh-shell .msh-topbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .msh-shell .msh-stats { margin-left: -12px; }

  .msh-shell .msh-round { flex-wrap: wrap; }
  .msh-shell .msh-round-note { margin-left: 0; flex-basis: 100%; }
  .msh-shell .msh-facts { flex-wrap: wrap; }
  .msh-shell .msh-fact { flex-basis: 45%; }
  .msh-shell .msh-notice { flex-wrap: wrap; }
  .msh-shell .msh-notice-time { text-align: left; }

  /* The bar is decoration; the rank, the firm and the figure are the data. */
  .msh-shell .msh-standing { grid-template-columns: 20px 1fr auto; }
  .msh-shell .msh-standing-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .msh-shell * { transition: none !important; animation: none !important; }
}
