/* The shell: the rail down the left, the bar across the top, the drawer on a
   phone browser. Colours come from tokens.css (design-tokens.json) only.

   Layout contract for every page:
     --shell-left  what the rail takes (0 on a phone browser)
     --shell-top   what the fixed header takes (48px; 88px on a phone with a
                   module bar). Anything a page pins to the top uses this.
*/
:root {
  --shell-left: 72px;
  --shell-left-wide: 236px;
  --shell-top: 48px;
  --shell-rail-bg: var(--ss-chrome-ink);
  --shell-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Expanded rail: the full names beside the icons. <html data-rail> is set
   before paint by layout.html and toggled by the chevron at the rail's foot. */
:root[data-rail="wide"] { --shell-left: var(--shell-left-wide); }
.ss-lbl-full { display: none; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-lbl-short { display: none; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-lbl-full { display: inline; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-item {
  flex-direction: row; align-items: center; gap: 12px; padding: 7px 14px 7px 11px;
  font-size: 14px; font-weight: 600; text-align: left; text-wrap: wrap;
}
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-item > span:last-child { min-height: 0; display: block; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-item .ss-tile { width: 34px; height: 34px; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-lbl-full small { font-size: 11px; font-weight: 500; opacity: .7; margin-left: 4px; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-logo { text-align: left; padding: 14px 16px 8px; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-logo img { width: 64px; }
.ss-rail-toggle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; color: var(--ss-chrome-onInkSoft); cursor: pointer;
  padding: 8px 0; font-size: 11px; font-weight: 600; font-family: var(--shell-font);
}
.ss-rail-toggle .ss-ic { width: 20px; height: 20px; transform: rotate(180deg); }
.ss-rail-toggle:hover, .ss-rail-toggle:focus-visible { color: var(--ss-chrome-onInk); background: rgba(255,255,255,.06); outline: none; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-toggle { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 14px 8px 18px; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-toggle .ss-ic { transform: none; }
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-toggle .ss-lbl-full { display: inline; }

/* ---- rail ------------------------------------------------------------- */
.ss-rail {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--shell-left);
  background: var(--shell-rail-bg); z-index: 1035;
  display: flex; flex-direction: column; align-items: stretch;
  font-family: var(--shell-font);
}
.ss-rail .ss-logo {
  display: block; padding: 12px 8px 6px; text-align: center; line-height: 0;
}
.ss-rail .ss-logo img { width: 54px; height: auto; }
.ss-rail-nav { display: flex; flex-direction: column; overflow-y: auto; padding: 4px 0; flex: 1 1 auto; }
.ss-rail-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 3px 9px; color: var(--ss-chrome-onInkSoft); text-decoration: none;
  font-size: 10.5px; font-weight: 600; line-height: 1.15; text-align: center;
  border-left: 3px solid transparent; border-right: 3px solid transparent;
  text-wrap: balance;
}
.ss-rail-item > span:last-child { min-height: 2.3em; display: flex; align-items: flex-start; justify-content: center; }
.ss-rail-item .ss-tile {
  width: 36px; height: 36px; border-radius: 9px; background: var(--ss-chrome-paper);
  display: grid; place-items: center; flex: none;
}
.ss-rail-item .ss-tile .ss-ic { width: 26px; height: 26px; }
.ss-rail-item:hover, .ss-rail-item:focus-visible { color: var(--ss-chrome-onInk); background: rgba(255,255,255,.06); outline: none; }
.ss-rail-item:focus-visible .ss-tile { box-shadow: 0 0 0 2px var(--ss-chrome-onInk); }
.ss-rail-item.is-active { color: var(--ss-chrome-onInk); border-left-color: var(--ss-brand-accent); background: rgba(255,255,255,.08); }
.ss-rail-item.is-active .ss-tile { box-shadow: 0 0 0 2px var(--ss-brand-accent); }
.ss-rail-item.is-soon { opacity: .55; }
.ss-rail-item.is-soon .ss-tile { background: rgba(255,255,255,.14); }
.ss-rail-item.is-soon:hover { opacity: .85; }
.ss-rail-home .ss-tile { background: transparent; color: var(--ss-chrome-onInkSoft); }
.ss-rail-home.is-active .ss-tile, .ss-rail-home:hover .ss-tile { color: var(--ss-chrome-onInk); }
.ss-rail-home .ss-ic { width: 24px; height: 24px; }

.ss-rail .ss-account { margin-top: auto; padding: 6px 0 10px; border-top: 1px solid rgba(255,255,255,.12); }
.ss-rail .ss-account .ss-rail-item { width: 100%; background: transparent; border: 0; cursor: pointer; }
.ss-rail .ss-account .ss-tile { background: rgba(255,255,255,.12); color: var(--ss-chrome-onInk); }
.ss-rail .ss-account .ss-tile .ss-ic { width: 22px; height: 22px; }
.ss-rail .ss-account .ss-rail-item.is-in .ss-tile { background: var(--ss-brand-accent); }
.ss-rail .ss-account .dropdown-menu { font-family: var(--shell-font); font-size: 14px; min-width: 220px; }
.ss-rail .ss-account .dropdown-header { font-weight: 700; color: var(--ss-chrome-navy); white-space: normal; }

/* icon-only rail (the planner): no labels, narrower */
.ss-rail.ss-rail-icons { --shell-left: 56px; width: 56px; }
.ss-rail.ss-rail-icons .ss-logo img { width: 42px; }
.ss-rail.ss-rail-icons .ss-rail-item > span:last-child { display: none; }
.ss-rail.ss-rail-icons .ss-rail-item { padding: 7px 0 7px; }
.ss-rail.ss-rail-icons .ss-tile { width: 34px; height: 34px; }

/* ---- top bar ---------------------------------------------------------- */
.ss-top {
  position: fixed; top: 0; left: var(--shell-left); right: 0; height: 48px;
  background: var(--ss-chrome-card); border-bottom: 1px solid var(--ss-chrome-line);
  display: flex; align-items: center; gap: 10px; padding: 0 16px; z-index: 1030;
  font-family: var(--shell-font);
}
.ss-top .ss-module { font-size: 15px; font-weight: 700; color: var(--ss-chrome-navy); white-space: nowrap; text-decoration: none; }
.ss-top .ss-module:hover { color: var(--ss-chrome-navy); }
.ss-bar { display: flex; align-items: center; gap: 2px; margin-left: 10px; }
.ss-bar a, .ss-bar .dropdown-toggle {
  padding: 6px 12px; border-radius: 8px; color: var(--ss-brand-ink); text-decoration: none;
  font-size: 13.5px; font-weight: 600; white-space: nowrap; background: transparent; border: 0;
}
.ss-bar a:hover, .ss-bar .dropdown-toggle:hover { background: var(--ss-chrome-paper); color: var(--ss-brand-ink); }
.ss-bar a.is-active { background: var(--ss-chrome-accentSoft); color: var(--ss-brand-accent); }
.ss-bar .dropdown-menu { font-family: var(--shell-font); font-size: 14px; }
.ss-top .ss-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ss-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; border: 1px solid transparent; cursor: default; white-space: nowrap;
}
.ss-badge .ss-badge-long { display: inline; }
.ss-badge .ss-ic { width: 15px; height: 15px; }
.ss-badge-warn { background: #FFF3CD; color: #7A5A00; border-color: #F2D98A; cursor: pointer; }
.ss-badge-demo { background: var(--ss-chrome-accentSoft); color: var(--ss-brand-accent); border-color: #F5C7B8; }
.ss-iconbtn {
  display: none; align-items: center; justify-content: center; width: 38px; height: 38px;
  border: 0; background: transparent; border-radius: 9px; color: var(--ss-chrome-navy); cursor: pointer;
}
.ss-iconbtn .ss-ic { width: 24px; height: 24px; }
.ss-iconbtn:hover { background: var(--ss-chrome-paper); }
.ss-iconbtn:focus-visible { outline: 2px solid var(--ss-brand-accent); outline-offset: 1px; }

/* the module bar as a chip row under the top bar (phone browsers only) */
.ss-bar-row { display: none; }

/* ---- drawer (phone browsers) ------------------------------------------ */
.ss-drawer { width: min(84vw, 320px); background: var(--shell-rail-bg); color: var(--ss-chrome-onInk); font-family: var(--shell-font); }
.ss-drawer .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }
.ss-drawer .offcanvas-header img { width: 70px; }
.ss-drawer .btn-close { filter: invert(1) grayscale(1); opacity: .8; }
.ss-drawer .offcanvas-body { padding: 8px 0; display: flex; flex-direction: column; }
.ss-drawer-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px; color: var(--ss-chrome-onInkSoft);
  text-decoration: none; font-size: 15px; font-weight: 600;
  border-left: 3px solid transparent;
}
.ss-drawer-item .ss-tile { width: 34px; height: 34px; border-radius: 8px; background: var(--ss-chrome-paper); display: grid; place-items: center; flex: none; }
.ss-drawer-item .ss-tile .ss-ic { width: 24px; height: 24px; }
.ss-drawer-item:hover { color: var(--ss-chrome-onInk); background: rgba(255,255,255,.06); }
.ss-drawer-item.is-active { color: var(--ss-chrome-onInk); border-left-color: var(--ss-brand-accent); background: rgba(255,255,255,.08); }
.ss-drawer-item.is-soon { opacity: .55; }
.ss-drawer-item small { display: block; font-weight: 500; font-size: 12px; color: rgba(255,255,255,.55); }
.ss-drawer-sep { height: 1px; background: rgba(255,255,255,.12); margin: 8px 0; }
.ss-drawer-head { display: block; padding: 6px 18px 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.5); }
.ss-drawer-link { display: block; padding: 9px 18px 9px 30px; color: var(--ss-chrome-onInkSoft); text-decoration: none; font-size: 14px; }
.ss-drawer-link:hover { color: var(--ss-chrome-onInk); }

/* ---- "Open in the app" banner (phone browsers) -------------------------
   Pinned to the bottom so it never collides with a page's own toolbar; the
   page renders and scrolls as usual with or without it. */
.ss-appbanner {
  display: none; align-items: center; gap: 10px; padding: 10px 12px 10px 14px;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1025;
  background: var(--ss-chrome-accentSoft); color: var(--ss-brand-ink); font-family: var(--shell-font); font-size: 13.5px;
  border-top: 1px solid #F5C7B8; box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
body.ss-banner-on { padding-bottom: 60px; }
.ss-appbanner .ss-ic { width: 22px; height: 22px; color: var(--ss-brand-accent); flex: none; }
.ss-appbanner a { color: var(--ss-brand-accent); font-weight: 700; text-decoration: none; white-space: nowrap; }
.ss-appbanner .ss-appbanner-x { margin-left: auto; border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--ss-chrome-muted); min-width: 40px; min-height: 40px; cursor: pointer; }
.ss-appbanner-msg { flex: 1 1 auto; min-width: 0; }

/* ---- alert count --------------------------------------------------------
   The red number on Monitoring when alerts are waiting (js/sapspy-badge.js
   fills every [data-alert-count]; hidden until it does). Danger red from the
   tokens, white figure, 18px round; distinct from .ss-badge, the "View only"
   and "Example" pills in the top bar, which it never touches. */
.ss-count {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; box-sizing: border-box;
  background: var(--ss-brand-danger); color: #fff;
  font: 700 11px/1 var(--shell-font); letter-spacing: 0; text-align: center;
}
.ss-count[hidden] { display: none; }
/* collapsed rail (and the planner's icon rail): the tile's top-right corner.
   The tile is 36px, centred; 34px on the icon rail. */
.ss-rail-item { position: relative; }
.ss-rail-item .ss-count { position: absolute; top: 3px; left: calc(50% + 8px); box-shadow: 0 0 0 2px var(--shell-rail-bg); }
.ss-rail.ss-rail-icons .ss-rail-item .ss-count { top: 2px; left: calc(50% + 7px); }
/* expanded rail: a pill at the row's end */
:root[data-rail="wide"] .ss-rail:not(.ss-rail-icons) .ss-rail-item .ss-count { position: static; order: 9; margin-left: auto; box-shadow: none; }
/* drawer row: at the end */
.ss-drawer-item .ss-count { margin-left: auto; }
/* top bar: beside the module name, inside the Alerts link */
.ss-count-bar { margin-left: 6px; vertical-align: middle; }
.ss-bar a .ss-count-bar, .ss-bar-row a .ss-count-bar { margin-left: 6px; }

/* ---- icons -------------------------------------------------------------- */
.ss-ic { display: inline-block; width: 24px; height: 24px; vertical-align: middle; fill: none; }

/* ---- phone browsers ----------------------------------------------------- */
@media (max-width: 819.98px) {
  :root, :root[data-rail="wide"] { --shell-left: 0px; }
  body.ss-has-bar { --shell-top: 92px; }
  .ss-rail { display: none; }
  .ss-top { left: 0; padding: 0 8px 0 4px; }
  .ss-top .ss-module { overflow: hidden; text-overflow: ellipsis; }
  .ss-iconbtn { display: inline-flex; }
  .ss-bar { display: none; }
  .ss-bar-row {
    display: flex; position: fixed; top: 48px; left: 0; right: 0; height: 44px; z-index: 1029;
    background: var(--ss-chrome-card); border-bottom: 1px solid var(--ss-chrome-line);
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding: 4px 24px 4px 8px; gap: 6px; align-items: center; font-family: var(--shell-font);
    /* the right edge fades so a clipped chip reads as "more this way" */
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent);
  }
  .ss-bar-row::-webkit-scrollbar { display: none; }
  .ss-bar-row a {
    flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
    color: var(--ss-brand-ink); text-decoration: none; border: 1px solid var(--ss-chrome-line);
  }
  .ss-bar-row a.is-active { background: var(--ss-chrome-accentSoft); color: var(--ss-brand-accent); border-color: transparent; }
  .ss-appbanner.is-on { display: flex; }
  .ss-badge .ss-badge-long { display: none; }
}
