.app-shell {
  --shell-brand: #ff6a00;
  --shell-brand-soft: #fff2e8;
  --shell-sidebar: #ffffff;
  --shell-page: #f5f7fa;
  --shell-ink: #18212f;
  --shell-muted: #667085;
  --shell-line: #e9edf2;
  --shell-width: 260px;
  grid-template-columns: var(--shell-width) minmax(0, 1fr);
  column-gap: 16px;
  background: var(--shell-page);
}

.app-shell .sidebar,
.trainer-shell .sidebar,
.employee-shell .sidebar,
.enterprise-admin-shell .sidebar {
  /* Fixed (not sticky): sticky+overflow scrollports make focus jump the page to top. */
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--shell-width);
  height: 100vh;
  height: 100dvh;
  padding: 18px 14px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  background: var(--shell-sidebar) !important;
  color: var(--shell-ink);
  border-right: 1px solid var(--shell-line);
}
.app-shell .brand { padding: 0 8px 16px; }
.app-shell .brand-mark { width: 44px; height: 44px; border-radius: 7px; background: var(--shell-brand); }
.app-shell .brand small { color: var(--shell-muted); font-size: var(--fs-caption); }
.app-shell .workspace-label { margin: 0 8px 14px; border-color: #ffc9a6; background: #fff7f1; color: #dc5a00; text-align: center; }
.app-shell .workspace {
  grid-column: 2;
  min-width: 0;
  width: auto;
  margin: 12px 16px 16px 0;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  background: #ffffff;
  /* Never clip/hide here — overflow scrollports on content ancestors jump to top on focus. */
  overflow: visible;
}
.grouped-navigation { display: block; }
.nav-group { display: grid; gap: 2px; }
.nav-label { margin: 15px 9px 6px; color: #98a2b3; font-size: var(--fs-caption); letter-spacing: 0.02em; font-weight: 700; text-transform: none; }
.nav-item, .nav-cluster summary { min-height: 38px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px; color: #475467; cursor: pointer; border-left: 3px solid transparent; }
.nav-item i, .nav-cluster summary i { width: 18px; color: #667085; font-style: normal; text-align: center; }
.nav-item:hover, .nav-cluster summary:hover { background: #f5f6f7; color: var(--shell-ink); }
.nav-item.active {
  background: var(--shell-brand-soft) !important;
  color: #d65300 !important;
  font-weight: 700;
  border-left-color: var(--shell-brand) !important;
}
.nav-item.active i { color: var(--shell-brand); }
.nav-cluster { margin: 0; }
.nav-cluster summary { list-style: none; }
.nav-cluster summary::-webkit-details-marker { display: none; }
.nav-cluster .nav-item { min-height: 34px; margin-left: 25px; font-size: var(--fs-body-sm); }
.sidebar-status { color: var(--shell-muted); }
.sidebar-status small { display: block; margin-top: 3px; }

.profile-menu { position: relative; }
.profile-trigger {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--shell-ink);
  cursor: pointer;
}
.profile-trigger .profile-identity,
.profile-trigger > span:not(.avatar) {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}
.profile-trigger strong,
.profile-trigger small {
  display: inline !important;
  text-align: left;
  white-space: nowrap;
}
.profile-trigger small {
  color: var(--shell-muted);
  font-size: var(--fs-caption);
  font-weight: 500;
}
.profile-trigger small::before {
  content: "·";
  margin-right: 8px;
  color: #98a2b3;
}
.profile-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 150; width: 190px; padding: 6px; border: 1px solid var(--shell-line); border-radius: 6px; background: #fff; box-shadow: 0 14px 34px rgba(24, 33, 47, .14); }
.profile-panel a, .profile-panel button { width: 100%; min-height: 38px; display: flex; align-items: center; border: 0; border-radius: 4px; padding: 0 10px; background: #fff; color: var(--shell-ink); text-align: left; cursor: pointer; }
.profile-panel a:hover, .profile-panel button:hover { background: var(--shell-brand-soft); color: #d65300; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; column-gap: 0; }
  .app-shell .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 120; transform: translateX(-100%); transition: transform 160ms ease; }
  .app-shell .sidebar.open { transform: translateX(0); }
  .app-shell .workspace { grid-column: 1; margin: 0; border: 0; border-radius: 0; }
  .shell-nav-scrim { position: fixed; inset: 0; z-index: 110; border: 0; background: rgba(24, 33, 47, .42); }
  .mobile-menu { display: inline-grid; place-items: center; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 16px calc(84px + env(safe-area-inset-bottom)); }
}

.app-shell [hidden],
body[data-role="guest"] [hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 500;
  padding: 10px 14px;
  border-radius: 4px;
  background: #ffffff;
  color: #20262d;
  box-shadow: 0 8px 24px rgba(20, 31, 37, 0.18);
}

.skip-link:focus { top: 12px; }

.global-tool-rail {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid #d7dee2;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(20, 31, 37, 0.16);
}

.global-tool-rail button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #45525a;
  cursor: pointer;
  font-weight: 800;
}

.global-tool-rail button:hover { background: var(--shell-brand-soft); color: #d65300; }
.global-tool-rail .global-agent-button { background: var(--shell-brand); color: #ffffff; }
.global-tool-rail .global-agent-button:hover { background: #e85f00; color: #ffffff; }

@media (min-width: 761px) {
  body:not([data-role="guest"]) {
    box-sizing: border-box;
    padding-right: 72px;
  }

  .global-tool-rail {
    top: 50%;
    right: 10px;
    bottom: auto;
    width: 50px;
    flex-direction: column;
    transform: translateY(-50%);
  }
}

.shell-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 160;
  width: min(420px, 100vw);
  height: 100vh;
  padding: 24px;
  overflow: auto;
  border-left: 1px solid #d7dee2;
  background: #ffffff;
  box-shadow: -18px 0 44px rgba(20, 31, 37, 0.2);
}

.shell-panel-wide { width: min(540px, 100vw); }
.shell-panel[hidden], .shell-dialog[hidden], .page-state[hidden] { display: none; }

.shell-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2e7ea;
}

.shell-panel-head p { margin: 0 0 5px; color: #d65300; font-size: var(--fs-body-sm); font-weight: 800; }
.shell-panel-head h2 { margin: 0; font-size: var(--fs-page); }
.shell-panel-head button, .command-search button {
  width: 36px;
  height: 36px;
  border: 1px solid #d7dee2;
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
  font-size: var(--fs-page);
}

.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
.workspace-switch-field { display: grid; gap: 7px; margin-top: 20px; color: #66717c; font-size: var(--fs-caption); font-weight: 800; }
.workspace-switch-field .field-caption { color: inherit; font: inherit; }
.workspace-switch-field select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid #cfd7db; border-radius: 5px; background: #ffffff; color: #20262d; }
.context-grid div { min-height: 82px; padding: 14px; border: 1px solid #dfe5e8; border-radius: 5px; background: #f7f9f9; }
.context-grid span, .context-grid strong { display: block; }
.context-grid span { margin-bottom: 8px; color: #6a757c; font-size: var(--fs-caption); }
.context-grid strong { font-size: var(--fs-body); overflow-wrap: anywhere; }
.shell-panel-note { padding: 13px 14px; border-left: 3px solid #2d6f95; background: #eef5f7; color: #4f5f68; font-size: var(--fs-body-sm); line-height: 1.65; }

.shell-dialog {
  position: fixed;
  inset: 0;
  z-index: 170;
  display: grid;
  place-items: start center;
  padding: min(12vh, 96px) 18px 18px;
  background: rgba(17, 25, 30, 0.58);
}

.command-dialog {
  width: min(680px, 100%);
  overflow: hidden;
  border: 1px solid #cfd7db;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 26px 70px rgba(12, 20, 25, 0.28);
}

.command-search { display: grid; grid-template-columns: 32px minmax(0, 1fr) 38px; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid #dfe5e8; }
.command-search > span { display: grid; place-items: center; color: #ff6a00; font-size: 24px; }
.command-search input { width: 100%; height: 42px; border: 0; outline: 0; font-size: var(--fs-title); }
.command-content { max-height: 430px; overflow: auto; padding: 16px; }
.command-content > p:first-child { margin: 0 0 10px; color: #6a757c; font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; }
.command-content nav { display: grid; gap: 5px; }
.command-content a { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 50px; padding: 0 13px; border-radius: 5px; }
.command-content a:hover, .command-content a.active { background: #fff4ec; color: #e85f00; }
.command-content a span { color: #78838a; font-size: var(--fs-caption); }
.command-empty { padding: 34px 12px; text-align: center; color: #6a757c; }
.command-dialog footer { display: flex; gap: 20px; padding: 10px 16px; border-top: 1px solid #e1e6e9; background: #f7f9f9; color: #758087; font-size: var(--fs-caption); }

.recovery-dialog { width: min(520px, 100%); padding: 34px; border-radius: 7px; background: #ffffff; text-align: center; box-shadow: 0 26px 70px rgba(12, 20, 25, 0.28); }
.recovery-dialog > p:first-of-type { margin: 16px 0 6px; color: #b8443b; font-size: var(--fs-body-sm); font-weight: 800; }
.recovery-dialog h2 { margin: 0 0 10px; }
.recovery-dialog > p:last-of-type { color: #66717c; line-height: 1.65; }
.recovery-dialog .button-row { justify-content: center; margin-top: 22px; }
.recovery-symbol { width: 58px; height: 58px; display: grid; place-items: center; margin: auto; border-radius: 50%; background: #f5eceb; color: #b8443b; font-size: 30px; }

.page-state {
  position: fixed;
  left: 50%;
  top: 16px;
  z-index: 180;
  width: min(520px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid #cfdadd;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(20, 31, 37, 0.16);
  transform: translateX(-50%);
}

.page-state strong, .page-state p { display: block; margin: 0; }
.page-state p { margin-top: 3px; color: #66717c; font-size: var(--fs-caption); }
.page-state-icon { color: #ff6a00; }

.closure-status { display: flex; gap: 12px; margin: 22px 0; padding: 16px; border: 1px solid #dbe6e2; background: #f3f8f6; }
.closure-status strong, .closure-status p { display: block; margin: 0; }
.closure-status p { margin-top: 4px; color: #66717c; font-size: var(--fs-caption); line-height: 1.5; }
.closure-indicator { width: 10px; height: 10px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: #ff6a00; box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.12); }
.closure-list { list-style: none; padding: 0; margin: 0; }
.closure-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 11px; padding: 14px 0; border-bottom: 1px solid #e5e9eb; }
.closure-list li > span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #bdc7cc; border-radius: 50%; color: #66717c; font-size: var(--fs-caption); }
.closure-list li.done > span { border-color: #ff6a00; background: #ff6a00; color: #ffffff; }
.closure-list strong, .closure-list p { display: block; margin: 0; }
.closure-list p { margin-top: 4px; color: #66717c; font-size: var(--fs-caption); }

.setting-list { display: grid; margin-top: 20px; }
.setting-list label { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e5e9eb; }
.setting-list strong, .setting-list small { display: block; }
.setting-list small { margin-top: 5px; color: #66717c; }
.setting-list input { width: 40px; height: 22px; accent-color: #ff6a00; }
.shortcut-list { margin-top: 28px; }
.shortcut-list h3 { font-size: var(--fs-title-sm); }
.shortcut-list p { display: flex; align-items: center; gap: 6px; color: #66717c; font-size: var(--fs-body-sm); }
kbd { min-width: 24px; padding: 3px 6px; border: 1px solid #cbd3d7; border-bottom-width: 2px; border-radius: 4px; background: #f7f9f9; color: #303b41; font: inherit; text-align: center; }

body.density-compact .content { padding-top: 20px; padding-bottom: 20px; }
body.density-compact .data-section { padding: 15px; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
.recovery-banner { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 10px 16px; background: #fff4d6; border-top: 1px solid #d7b55b; color: #4b3a10; }
.recovery-banner span { flex: 0 1 auto; }
.recovery-banner a { color: #075d49; font-weight: 700; }

@media (max-width: 680px) {
  body[data-role]:not([data-role="guest"]) { padding-bottom: 8px; }
  .global-tool-rail { position: static; width: max-content; max-width: calc(100vw - 20px); margin: 8px auto 0; transform: none; }
  .global-tool-rail button { width: 36px; height: 36px; }
  .shell-panel { padding: 20px; }
  .context-grid { grid-template-columns: 1fr; }
  .shell-dialog { padding: 12px; place-items: center; }
  .command-dialog footer { display: none; }
}
