/* suite/shell/shell.css — the suite shell: Level-1 rail, Level-2 menu, workspace, dialogs.
 *
 * GEOMETRY is the approved frame (pdm-demo-dashboard styles/shell.css + responsive.css @ 59be624):
 * rail 96px (16px 8px padding, --sidebar surface, hairline right edge), icon-only 56px at ≤1180px;
 * Level-2 236px / 200px (≤1440) / 190px (≤1280) / 210px (≤1180). Colours, radii and surfaces come
 * ONLY from the approved tokens (../vendor/tokens.css). Module frames get none of this: every rule
 * below is scoped to .sx, and modules render in their own documents.
 *
 * TYPOGRAPHY is the approved scale (brief §4; Route Manager rtm.css): Barlow Semi Condensed
 * titles 30/600 · section & dialog titles 22/600 · body/inputs 16/400 · navigation/buttons 16/500 ·
 * labels & support 14/400–500; IBM Plex Mono for tags 14/400. Rail labels are 14/500 (support size):
 * the approved rail is 96px wide and 16px labels do not fit it — recorded as an owner question. */

@font-face { font-family: "Barlow Semi Condensed"; font-weight: 400; font-display: swap; src: url("../fonts/BarlowSemiCondensed-Regular.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url("../fonts/BarlowSemiCondensed-Medium.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/BarlowSemiCondensed-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("../fonts/IBMPlexMono-Medium.woff2") format("woff2"); }

html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
.sx {
  --font-ui: "Barlow Semi Condensed", "Segoe UI", -apple-system, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Selected-state TEXT on --accent-soft: the approved accent is 2.96:1 (light) / 3.64:1 (dark) there,
     under WCAG AA 4.5:1. Same hue, deeper in light and lighter in dark — measured by tools/contrast.py. */
  --sx-accent-text: color-mix(in srgb, var(--accent) 62%, #000);
  --rail-w: 96px;
  --nav2-w: 236px;
  position: relative; display: flex; height: 100vh; overflow: hidden; background: var(--bg);
  font-family: var(--font-ui); font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.sx button, .sx input, .sx select, .sx textarea { font-family: var(--font-ui); }
.sx :focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sx-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sx { --sx-accent-text: color-mix(in srgb, var(--accent) 55%, #fff); } }
:root[data-theme="dark"] .sx { --sx-accent-text: color-mix(in srgb, var(--accent) 55%, #fff); }

/* ---- Level 1: the rail ---- */
.sx-rail {
  width: var(--rail-w); flex: 0 0 auto; height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 16px 8px; background: var(--sidebar); border-right: var(--hair);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  position: relative; z-index: 20;
}
.sx-brand {
  appearance: none; -webkit-appearance: none; border: 0; background: none; margin: 0; cursor: pointer;
  display: flex; justify-content: center; padding: 2px 0 14px;
}
.sx-brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.sx-brand-mark span { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--on-accent, #fff); box-sizing: content-box; }
.sx-rail-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.sx-rail-item, .sx-rail-tool {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; margin: 0; box-shadow: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%;
  padding: 9px 4px; border-radius: var(--radius-chip);
  font-size: 14px; font-weight: 500; line-height: 1.15; color: var(--text2); cursor: pointer; text-align: center;
  text-decoration: none;
}
.sx-rail-item svg, .sx-rail-tool svg { width: 20px; height: 20px; flex: 0 0 auto; }
.sx-rail-item:hover, .sx-rail-tool:hover { color: var(--text); background: var(--card2); }
.sx-rail-item[aria-current="page"], .sx-rail-item[aria-expanded="true"], .sx-rail-item[data-current="true"] { background: var(--accent-soft); color: var(--sx-accent-text); }
.sx-rail-short { display: none; }
.sx-rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.sx-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--sx-accent-text);
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}
.sx-theme-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.sx-avatar svg { width: 18px; height: 18px; }
.sx-rail-tool .sx-rail-sub { font-size: 14px; font-weight: 400; color: var(--text2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Level 2: the second menu ---- */
.sx-nav2 {
  width: var(--nav2-w); flex: 0 0 auto; height: 100%; box-sizing: border-box; overflow-y: auto;
  padding: 18px 12px; border-right: var(--hair);
  /* The --sidebar tint composited onto --bg: the colour it shows over a plain page, made opaque so the
     flyout never shows a module frame through it (a backdrop blur cannot sample another document). */
  background: linear-gradient(var(--sidebar), var(--sidebar)), var(--bg);
}
.sx-nav2[hidden] { display: none; }
/* Over a module, the module's own navigation holds this place; the host menu opens as the approved
   dismissible flyout over it (click-away scrim, Escape, close control). */
.sx.is-module .sx-nav2 {
  position: absolute; z-index: 15; top: 0; bottom: 0; left: var(--rail-w);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  /* Closed = visibility:hidden, not only off-screen: a closed flyout's links must not be tabbable or
     announced. Visibility flips after the slide-out, and immediately on open. */
  transform: translateX(-112%); opacity: 0; pointer-events: none; visibility: hidden;
  transition: transform .16s ease, opacity .16s ease, visibility 0s linear .16s;
}
.sx.is-module.nav2-open .sx-nav2 { transform: none; opacity: 1; pointer-events: auto; visibility: visible; transition-delay: 0s; }
.sx-scrim { display: none; }
.sx.is-module.nav2-open .sx-scrim { display: block; position: absolute; inset: 0 0 0 var(--rail-w); z-index: 14; background: rgba(0,0,0,0.14); }
@media (prefers-reduced-motion: reduce) { .sx.is-module .sx-nav2 { transition: none; } }

.sx-nav2-head {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px 10px;
  font-size: 16px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text2);   /* Route: 16/600 */
}
.sx-nav2-head span { flex: 1; min-width: 0; }
.sx-icon-btn {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 30px; height: 30px; border-radius: 7px; color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.sx-icon-btn:hover { color: var(--text); background: var(--card2); }
.sx-icon-btn svg { width: 16px; height: 16px; }
.sx-nav2-group { margin: 16px 0 6px; padding: 0 10px; font-size: 14px; font-weight: 500; color: var(--text2); }
.sx-nav2-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
/* One row: icon + label on one line, selected state, and the open-in-separate-window action at the
   far right of the same row (the approved Route Manager secondary-navigation pattern). */
.sx-nav2-row { display: flex; align-items: center; border-radius: var(--radius-chip); }
.sx-nav2-row:hover { background: var(--card2); }
/* Route Manager's menu: the selected row has no pill — accent text only (AA-deepened, see --sx-accent-text). */
.sx-nav2-row[aria-current="page"] { background: transparent; }
.sx-nav2-item {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 7px 6px 7px 12px; border-radius: var(--radius-chip);
  font-size: 16px; font-weight: 500; line-height: 1.4; color: var(--text2); text-decoration: none;
}
.sx-nav2-item svg { width: 17px; height: 17px; flex: 0 0 auto; }
.sx-nav2-row:hover .sx-nav2-item { color: var(--text); }
.sx-nav2-row[aria-current="page"] .sx-nav2-item { color: var(--sx-accent-text); }
.sx-nav2-item span { flex: 1; min-width: 0; }      /* wraps rather than truncating a module name */
.sx-nav2-pop { opacity: .75; margin-right: 4px; }
.sx-nav2-row:hover .sx-nav2-pop, .sx-nav2-pop:focus-visible { opacity: 1; }

/* ---- a module is open: its standalone frame spans the WINDOW, as on its own page ----
   The approved standalone page reserves an empty Level-1 rail surface of exactly the rail's width
   (96px, 56px at ≤1180px). Keeping that frame intact and laying the shell rail over the reserved
   surface means the module's media queries see the same width they see standalone — at 1366px an
   iframe beside the rail would be 1270px wide and cross the module's own ≤1280px rung. The shell rail
   drops its own surface there: the module's reserved rail already paints the identical one. */
.sx.is-module .sx-main { position: absolute; inset: 0; z-index: 0; }
/* Over a module the rail paints its own surface OPAQUE (the --sidebar tint composited onto --bg — the colour a
   reserved module rail shows): whatever a module draws in its reserved rail stays underneath, for every module. */
.sx.is-module .sx-rail { background: linear-gradient(var(--sidebar), var(--sidebar)), var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
.sx.is-module .sx-page { margin-left: var(--rail-w); }

/* ---- workspace ---- */
.sx-main { flex: 1; min-width: 0; height: 100%; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.sx-page { flex: 1; overflow-y: auto; padding: 34px 38px 70px; box-sizing: border-box; }
/* No width cap on working content: pages fill the workspace; prose keeps a readable measure (.sx-empty > *). */
.sx-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.sx-page-head .sx-eyebrow { margin: 0; }
/* The section-menu button: only where the menu is a flyout (<=900px). Wider, the menu is a column. */
.sx-menu-btn {
  display: none; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 12px; border-radius: 8px; border: var(--hair); background: var(--card); color: var(--text);
  font-size: 16px; font-weight: 500; line-height: 1.3;
}
.sx-menu-btn:hover { background: var(--card2); }
.sx-menu-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--sx-accent-text); }
.sx-menu-glyph { width: 16px; height: 12px; flex: 0 0 auto;
  background: linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
              linear-gradient(currentColor, currentColor) 0 50% / 100% 2px no-repeat,
              linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat; }
@media (max-width: 900px) { .sx-menu-btn { display: inline-flex; } }
.sx-framebar { display: none; }
@media (max-width: 900px) { .sx-framebar { display: flex; align-items: center; padding: 10px 16px; border-bottom: var(--hair); background: var(--bg); flex: 0 0 auto; } }
.sx-eyebrow { font-size: 14px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text2); margin: 0 0 12px; }
.sx-title { font-size: 30px; font-weight: 600; line-height: 1.25; margin: 0 0 20px; }
.sx-card { background: var(--card); border: var(--hair); border-radius: var(--radius-card, 14px); box-shadow: var(--shadow-card, none); padding: 36px 32px; }
.sx-empty { text-align: center; }
.sx-empty > * { max-width: 620px; margin-left: auto; margin-right: auto; }
.sx-empty h2 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 0 0 8px; }
.sx-empty p { margin: 0 0 16px; color: var(--text2); }
.sx-empty .sx-support { font-size: 14px; }
.sx-frame { flex: 1; width: 100%; border: 0; display: block; background: var(--bg); }
.sx-frame[hidden] { display: none; }
.sx-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text2); font-size: 16px; background: var(--bg); }
.sx-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: sx-spin .8s linear infinite; }
@keyframes sx-spin { to { transform: rotate(360deg); } }
.sx-mono { font-family: var(--font-mono); font-size: 14px; font-weight: 400; }

/* ---- notice (host-owned; sits above module frames, below modal dialogs) ---- */
.sx-notice {
  position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px));
  padding: 12px 16px; border-radius: 10px; background: var(--card); color: var(--text); border: var(--hair);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18); font-family: "Barlow Semi Condensed", "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.5; transition: opacity .3s ease;
}
.sx-notice.is-error { border-left: 4px solid var(--vesselalarm, #ff3b30); }
.sx-notice.is-out { opacity: 0; }

/* ---- buttons (approved accent / ghost look) ---- */
.sx-btn {
  appearance: none; -webkit-appearance: none; cursor: pointer; border-radius: 8px;
  padding: 8px 16px; font-size: 16px; font-weight: 500; line-height: 1.3;
  /* White on the approved accent is 3.65:1 (WCAG AA needs 4.5:1 at 16px): the same hue, deepened. */
  border: 1px solid transparent; background: color-mix(in srgb, var(--accent) 80%, #000); color: var(--on-accent, #fff);
}
.sx-btn:hover { filter: brightness(1.06); }
.sx-btn[disabled] { opacity: .55; cursor: default; }
.sx-btn.is-ghost { background: var(--card); color: var(--text); border: var(--hair); }

/* ---- dialogs: the native top layer — nothing in the page can paint over it, the background is
   inert, focus is contained, Escape cancels (fixes the rejected in-stacking-context modal) ---- */
.sx-dialog {
  border: var(--hair); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  font-family: "Barlow Semi Condensed", "Segoe UI", -apple-system, system-ui, sans-serif; font-size: 16px; line-height: 1.5;
}
.sx-dialog button, .sx-dialog input { font-family: inherit; }
.sx-dialog::backdrop { background: rgba(0,0,0,0.32); }
.sx-dialog form { padding: 24px 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.sx-dialog h2 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 0; }
.sx-dialog p { margin: 0; color: var(--text2); font-size: 14px; }
.sx-field { display: flex; flex-direction: column; gap: 6px; }
.sx-field label { font-size: 14px; font-weight: 500; color: var(--text); }
.sx-field input {
  font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 8px; border: var(--hair);
  background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--divider, transparent);
}
.sx-field input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
/* Show / Hide password: the toggle sits inside the field's right edge; the input keeps room for it. */
.sx-pw { position: relative; display: flex; }
.sx-pw input { flex: 1; min-width: 0; padding-right: 48px; }
.sx-pw .sx-pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text2); }
.sx-pw .sx-pw-toggle:hover { color: var(--text); }
.sx-pw .sx-pw-toggle svg { width: 18px; height: 18px; }
.sx-error { color: var(--vesselalarm, #ff3b30); font-size: 14px; min-height: 21px; }
.sx-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---- responsive: the approved rungs ---- */
/* The second menu keeps 236px down to 1181px: it is the same column the module's own navigation
   occupies (DMS measured 235px at 1440), so switching between them does not shift the content edge. */
@media (max-width: 1280px) { .sx-page { padding-left: 32px; padding-right: 32px; } }
@media (max-width: 1180px) {
  .sx { --rail-w: 56px; --nav2-w: 210px; }
  /* Narrow rail keeps READABLE short labels at the agreed 14px (not icon-only): the 56px width is the
     approved rung (module frames reserve the same), so only horizontal padding gives way. */
  .sx-rail { padding: 14px 2px; }
  .sx-rail-item, .sx-rail-tool { padding: 8px 2px; }
  .sx-rail-label { display: none; }
  .sx-rail-short { display: block; white-space: nowrap; }
  .sx-brand { padding-bottom: 10px; }
  .sx-nav2 { padding: 16px 8px; }
  .sx-page { padding: 26px 26px 60px; }
}
/* Narrow (~800px): the permanent second menu becomes the flyout everywhere so content keeps its width. */
@media (max-width: 900px) {
  .sx .sx-nav2 {
    position: absolute; z-index: 15; top: 0; bottom: 0; left: var(--rail-w);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10); transform: translateX(-112%); opacity: 0; pointer-events: none;
    visibility: hidden; transition: transform .16s ease, opacity .16s ease, visibility 0s linear .16s;
  }
  .sx.nav2-open .sx-nav2 { transform: none; opacity: 1; pointer-events: auto; visibility: visible; transition-delay: 0s; }
  .sx.nav2-open .sx-scrim { display: block; position: absolute; inset: 0 0 0 var(--rail-w); z-index: 14; background: rgba(0,0,0,0.14); }
}

/* ---- first-time account setup (account-setup.js): the suite's own card and fields, without the navigation ---- */
.sx.is-setup .sx-rail, .sx.is-setup .sx-nav2, .sx.is-setup .sx-scrim { display: none; }
.sx.is-setup .sx-main { overflow-y: auto; }
.sx-setup { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 48px 16px 64px; box-sizing: border-box; gap: 20px; }
.sx-setup-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; color: var(--text); }
.sx-setup-card { width: min(460px, 100%); box-sizing: border-box; padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.sx-setup-title { font-size: 24px; font-weight: 600; line-height: 1.25; margin: 0; }
.sx-setup-title:focus { outline: none; }
.sx-setup-lead { margin: 0; color: var(--text2); font-size: 15px; line-height: 1.5; }
.sx-setup-form { display: flex; flex-direction: column; gap: 14px; }
.sx-setup-form input[readonly] { color: var(--text2); background: var(--card2, var(--bg)); }
.sx-field-err { color: var(--vesselalarm, #ff3b30); font-size: 13.5px; min-height: 0; }
.sx-field-err:empty { display: none; }
.sx-setup-rule-text { margin: -6px 0 0; font-size: 13.5px; color: var(--text2); }
.sx-setup-rule { list-style: none; margin: -6px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 13.5px; color: var(--text3); }
.sx-setup-rule:empty { display: none; }
.sx-setup-rule li.is-met { color: var(--healthy, #2e9e5b); }
.sx-setup-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.sx-setup-foot { margin: 0; font-size: 13px; color: var(--text3); }
@media (max-width: 480px) { .sx-setup { padding-top: 24px; } .sx-setup-card { padding: 22px 18px; } .sx-setup-rule { grid-template-columns: 1fr; } .sx-setup-actions .sx-btn { flex: 1; } }
