/*
 * The one product's frame: the sidebar (six items), the top bar and the open item's tabs. One file, served by Snappy at /shell/shell.css
 * and linked by both apps: Snappy's pages (app/Shell.tsx) and the SOP pages under /procedures (their embedded mode), so
 * the two draw the same frame from the same rules. The markup is built from the same model (web/src/shell/navModel.ts,
 * GET /api/shell/nav). Tokens are its own (--shx-*), copied from .claude/skills/snappy-ui/tokens.css (Paper and Graphite), so
 * neither app's own variables can change how it looks. Neutral; purple only on count badges and the logo mark.
 */
:where(.shx-side, .shx-top, .shx-scrim, .shx-tabs-row, .shx-tabs-wrap) {
  --shx-ground: #f6f6f4;
  --shx-surface: #ffffff;
  --shx-sunken: #efefec;
  --shx-line: #e4e4e0;
  --shx-line-strong: #cfcfca;
  --shx-ink: #16161a;
  --shx-ink-2: #3a3a40;
  --shx-ink-3: #66666d;
  --shx-mark: #5d32c9;
  --shx-count-bg: #5d32c9;
  --shx-count-ink: #ffffff;
  --shx-accent: #5d32c9;
  --shx-accent-tint: #efeeff;
  --shx-ring: #5d32c9;
  --shx-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shx-mono: "IBM Plex Mono", ui-monospace, monospace;
  --shx-side-w: 240px;
  --shx-top-h: 64px;
  box-sizing: border-box;
  font-family: var(--shx-sans);
}
:where([data-theme="graphite"], html.dark) :where(.shx-side, .shx-top, .shx-scrim, .shx-tabs-row, .shx-tabs-wrap) {
  --shx-ground: #0e0e10;
  --shx-surface: #18181b;
  --shx-sunken: #222226;
  --shx-line: #2e2e33;
  --shx-line-strong: #44444a;
  --shx-ink: #f4f4f5;
  --shx-ink-2: #d4d4d8;
  --shx-ink-3: #a1a1aa;
  --shx-mark: #8f78f5;
  --shx-count-bg: #7a5cf0;
  --shx-count-ink: #ffffff;
  --shx-accent: #ada3ff;
  --shx-accent-tint: #231e3f;
  --shx-ring: #a193fc;
}
.shx-side *,
.shx-top * {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- Left nav */
.shx-side {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex: 0 0 var(--shx-side-w);
  flex-direction: column;
  gap: 20px;
  width: var(--shx-side-w);
  height: 100vh;
  height: 100dvh;
  padding: 20px 12px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--shx-line);
  background: var(--shx-surface);
  color: var(--shx-ink-2);
}
.shx-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shx-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--shx-ink);
  text-decoration: none;
}
.shx-brand-mark {
  flex: none;
  color: var(--shx-mark);
}
.shx-brand-text {
  display: flex;
  flex-direction: column;
}
.shx-brand-name {
  font-size: 16px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.shx-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.shx-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.shx-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--shx-ink-2);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 150ms ease-out,
    color 150ms ease-out;
}
.shx-link:hover {
  background: var(--shx-sunken);
  color: var(--shx-ink);
}
.shx-link[aria-current="page"] {
  background: var(--shx-accent-tint);
  color: var(--shx-accent);
  font-weight: 600;
}
.shx-link:focus-visible,
.shx-brand:focus-visible,
.shx-who:focus-visible,
.shx-icon-btn:focus-visible {
  outline: 2px solid var(--shx-ring);
  outline-offset: 2px;
}
.shx-icon {
  flex: none;
  width: 16px;
  height: 16px;
}
.shx-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shx-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 8px;
  border-radius: 9999px;
  background: var(--shx-count-bg);
  color: var(--shx-count-ink);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The person, at the foot: a button that opens the account menu just above it. */
.shx-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--shx-line);
}
.shx-account {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}
.shx-account[hidden] {
  display: none;
}
.shx-who {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--shx-ink);
  cursor: pointer;
}
.shx-who:hover {
  background: var(--shx-sunken);
}
.shx-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--shx-sunken);
  color: var(--shx-ink);
  font-size: 12px;
  font-weight: 600;
}
.shx-who-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.shx-who-name {
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shx-who-role {
  font-size: 13px;
  line-height: 18px;
  color: var(--shx-ink-3);
}
.shx-who .shx-icon {
  color: var(--shx-ink-3);
  transition: transform 150ms ease-out;
}
.shx-who[aria-expanded="true"] .shx-icon {
  transform: rotate(180deg);
}

/* ---------------------------------------------------------------- Top bar */
.shx-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--shx-top-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--shx-line);
  background: var(--shx-ground);
  color: var(--shx-ink);
}
.shx-top-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.shx-top-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--shx-ink);
  color: var(--shx-ground);
  font-family: var(--shx-mono);
  font-size: 12px;
  font-weight: 500;
}
.shx-top-name {
  overflow: hidden;
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shx-top-end {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.shx-icon-btn {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--shx-ink);
  cursor: pointer;
}
.shx-icon-btn:hover {
  background: var(--shx-sunken);
}
.shx-icon-btn .shx-icon {
  width: 20px;
  height: 20px;
}
.shx-scrim {
  display: none;
}

/* ---------------------------------------------------------------- Phone and small tablet: the nav is a drawer */
@media (max-width: 899px) {
  .shx-side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 96;
    width: min(300px, 86vw);
    box-shadow: 0 12px 32px rgba(23, 24, 30, 0.16);
    transform: translateX(-105%);
    visibility: hidden;
    transition:
      transform 200ms ease-out,
      visibility 0s linear 200ms;
  }
  .shx-side[data-open="true"] {
    transform: none;
    visibility: visible;
    transition: transform 200ms ease-out;
  }
  .shx-scrim[data-open="true"] {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: block;
    background: rgba(13, 13, 16, 0.36);
  }
  .shx-icon-btn {
    display: inline-flex;
  }
  .shx-top {
    gap: 8px;
    padding: 0 12px 0 8px;
  }
  .shx-top-mark {
    display: none;
  }
}
@media (min-width: 900px) {
  .shx-side .shx-icon-btn {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .shx-side,
  .shx-side[data-open="true"],
  .shx-link,
  .shx-who .shx-icon {
    transition: none;
  }
}
@media print {
  .shx-side,
  .shx-top,
  .shx-scrim {
    display: none !important;
  }
}

/* ---------------------------------------------------------------- The open item's tabs (Snappy's pages draw them) */
.shx-tabs-wrap {
  margin: -8px 0 24px;
}
.shx-tabs {
  position: relative;
}
.shx-more {
  position: relative;
  display: inline-flex;
}
.shx-more-chev {
  width: 14px;
  height: 14px;
}
.shx-more-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--shx-line);
  border-radius: 10px;
  background: var(--shx-surface);
  box-shadow: 0 12px 32px rgba(22, 22, 26, 0.12), 0 1px 2px rgba(22, 22, 26, 0.08);
}
.shx-more-menu[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- The open item's tabs, under the SOP pages' top bar
 * Snappy's own pages draw their tabs with ui.css (ui-tabs, ui-tab, ui-subtabs, ui-chip); the SOP pages under /procedures draw
 * the same markup inside .shx-tabs-row, styled here with the same values so the two match. */
.shx-tabs-row { box-sizing: border-box; padding: 24px 24px 0; font-family: var(--shx-sans); }
.shx-tabs-row *, .shx-tabs-row *::after { box-sizing: border-box; }
.shx-tabs-row .shx-tabs-wrap { margin: 0; }
.shx-tabs-row .ui-tabs { display: flex; align-items: flex-end; gap: 24px; border-bottom: 1px solid var(--shx-line); overflow-x: auto; scrollbar-width: none; }
.shx-tabs-row .ui-tabs::-webkit-scrollbar { display: none; }
.shx-tabs-row .ui-tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--shx-ink-3); text-decoration: none; white-space: nowrap; background: none; border: 0; cursor: pointer; font-family: inherit; }
.shx-tabs-row .ui-tab:hover { color: var(--shx-ink); }
.shx-tabs-row .ui-tab[aria-current="page"] { color: var(--shx-accent); }
.shx-tabs-row .ui-tab[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--shx-accent); }
.shx-tabs-row .ui-tab:focus-visible, .shx-tabs-row .ui-chip:focus-visible, .shx-tabs-row .shx-link:focus-visible { outline: 2px solid var(--shx-ring); outline-offset: 2px; }
.shx-tabs-row .ui-subtabs { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }
.shx-tabs-row .ui-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; border: 1px solid var(--shx-line-strong); border-radius: 9999px; background: var(--shx-surface); font: inherit; font-size: 14px; line-height: 20px; color: var(--shx-ink-2); cursor: pointer; text-decoration: none; }
.shx-tabs-row .ui-chip:hover { border-color: var(--shx-ink-3); color: var(--shx-ink); }
.shx-tabs-row .ui-chip.is-on { background: var(--shx-accent-tint); border-color: var(--shx-accent); color: var(--shx-accent); }
@media (max-width: 960px) { .shx-tabs-row { padding: 16px 16px 0; } }
@media print { .shx-tabs-row { display: none !important; } }

/* The More menu opens below its tab. A row that scrolls sideways would cut it off, so the tabs wrap onto a second line instead
 * (both apps). */
.ui-tabs.shx-tabs,
.shx-tabs-row .ui-tabs.shx-tabs {
  overflow: visible;
  flex-wrap: wrap;
  row-gap: 0;
}
