/* Shell (B6, RD-1a): floating top bar card, icon rail on the right, content area, mobile bottom bar.
   Desktop (>= 1024px): top bar 24px from the edges, rail 64px at 24px from the right, content 112px / 104px / 24px.
   Mobile: top bar 12px from the edges, rail hidden, floating bottom bar with labels (paya 30_home_mobile). */

body.shell { padding: 0; }
.demo-bar { position: fixed; z-index: 70; bottom: 12px; left: 50%; transform: translateX(-50%); padding: 2px 12px; border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 11px; line-height: 18px; white-space: nowrap; pointer-events: none; opacity: .9; }
body.shell .demo-bar { bottom: calc(var(--nav-h) + 16px); }
@media (min-width: 1024px) { body.shell .demo-bar { bottom: 12px; } }
/* B7: room under the page so the demo note never sits on the content */
body:has(> .demo-bar) .container { padding-bottom: calc(var(--nav-h) + 72px); }
@media (min-width: 1024px) { body:has(> .demo-bar) .container { padding-bottom: 48px; } }
.impersonate-bar { position: relative; z-index: 70; display: flex; align-items: center; justify-content: center; gap: var(--s3); flex-wrap: wrap; padding: 6px var(--s4); background: var(--danger); color: #ffffff; font-weight: 700; }
.impersonate-bar form { margin: 0; }
.impersonate-bar .btn { background: #ffffff; color: var(--danger); box-shadow: none; }

/* ---------- top bar ---------- */
.topbar-scrim { position: fixed; z-index: 30; top: 0; inset-inline: 0; height: 116px; background: var(--scrim-top); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.topbar {
  position: fixed; z-index: 31; top: 24px; inset-inline: 24px; height: var(--topbar-h); display: flex; align-items: center; gap: var(--s5);
  padding: var(--s4) var(--s5); background: var(--surface); border-radius: var(--radius-card);
}
.tb-brand { display: flex; align-items: center; gap: var(--s5); min-width: 0; }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--text-strong); font-size: var(--fs-lg); font-weight: 900; line-height: 22px; text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 6px; }
.tb-company { display: flex; align-items: center; gap: var(--s1); color: var(--text-company); white-space: nowrap; min-width: 0; }
.tb-company .ico { width: 16px; height: 16px; }
.tb-company span { overflow: hidden; text-overflow: ellipsis; }
.tb-tools { flex: 1; display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.proj select { height: var(--control-h); max-width: 260px; padding: 0 12px; padding-inline-end: 30px; border: 1px solid var(--border-hairline); border-radius: var(--radius-pill); background-color: var(--surface); color: var(--text-body); font-size: var(--fs-xs); font-weight: 700; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: var(--select-arrow); background-position: left 11px center; background-size: 12px 12px; background-repeat: no-repeat; }
.proj select:hover { border-color: var(--border-hairline-strong); }
.supervisor-chip { display: inline-flex; align-items: center; height: var(--control-h); padding: 0 12px; border-radius: var(--radius-pill); background: var(--accent-tint); color: var(--accent); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; text-decoration: none; }
.supervisor-chip:hover { text-decoration: none; opacity: .9; }
.tb-actions { display: flex; align-items: center; gap: var(--s3); margin-inline-start: auto; }
.icon-btn .bell-badge { position: absolute; top: -2px; inset-inline-end: -2px; }
.avatar-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border-hairline); border-radius: var(--radius-pill); color: var(--text-muted); }
.avatar-btn:hover { background: var(--surface-hover); }
.avatar-btn .ico { width: 20px; height: 20px; }
.tb-user .dropdown-menu { inset-inline-end: auto; inset-inline-start: 0; min-width: 220px; }
.theme-toggle { display: inline-flex; padding: 2px; border-radius: 9999px; background: var(--segment-track); }
.theme-toggle button { display: flex; align-items: center; justify-content: center; width: 38px; height: 28px; padding: 0 11px; border: 0; border-radius: 9999px; background: transparent; color: var(--text-body); cursor: pointer; }
.theme-toggle button .ico { width: 16px; height: 16px; }
.theme-toggle button[aria-checked="true"] { background: var(--segment-thumb); box-shadow: var(--shadow-soft); }

/* ---------- rail (the «sidebar»: icons only, label as tooltip) ---------- */
.sidebar { display: none; }
.sidebar nav { display: flex; flex-direction: column; align-items: center; }
.sb-link { position: relative; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 12px 0; border-radius: var(--radius-icon); color: var(--text-body); text-decoration: none; transition: background var(--dur), color var(--dur); }
.sb-link:hover { background: var(--surface-hover); text-decoration: none; }
.sb-link .ico { width: 20px; height: 20px; }
.sb-link[aria-current="page"] { background: var(--primary); color: #ffffff; }
.sb-link > span:not(.sb-count) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* label tooltip, placed by static/js/ui.js (the rail scrolls, so a CSS tooltip inside it would be clipped) */
.rail-tip { position: fixed; z-index: 80; padding: 6px 8px; border-radius: 6px; background: #000000d9; color: #ffffff; font-size: var(--fs); line-height: 22px; white-space: nowrap; pointer-events: none; transform: translateY(-50%); }
.sb-count { position: absolute; top: -6px; inset-inline-end: -8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-pill); background: var(--badge-count); color: #ffffff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 1px var(--surface); }
.sb-group { width: 32px; height: 1px; margin: 4px 0; background: var(--separator); font-size: 0; color: transparent; overflow: hidden; }
.sb-group:first-child { display: none; }

/* the «⋯» button at the foot of the rail and its menu (icons that do not fit); placed by static/js/ui.js */
.sb-hide { display: none !important; }
button.sb-link { padding: 0; border: 0; background: none; cursor: pointer; font: inherit; }
button.sb-link[aria-expanded="true"] { background: var(--surface-hover); }
.rail-menu { position: fixed; z-index: 80; min-width: 180px; padding: 4px; background: var(--surface-raised); border-radius: 8px; box-shadow: var(--shadow-pop); }
.rail-menu a { display: flex; align-items: center; gap: var(--s2); min-height: 32px; padding: 5px 12px; border-radius: 4px; color: var(--text-body); text-decoration: none; white-space: nowrap; }
.rail-menu a:hover { background: var(--surface-hover); text-decoration: none; }
.rail-menu a[aria-current="page"] { background: var(--primary); color: #ffffff; }
.rail-menu .ico { width: 16px; height: 16px; }
.rail-menu .sb-count { position: static; margin-inline-start: auto; }

/* ---------- content ---------- */
.container { margin: 80px 12px 0; padding: 0 0 96px; min-width: 0; }

/* ---------- notifications (bell dropdown; sheet on mobile) ---------- */
.notif-wrap { position: relative; }
.notif-panel { position: fixed; z-index: 45; inset-inline: 12px; bottom: calc(var(--nav-h) + 24px); background: var(--surface-raised); color: var(--text-body); border-radius: 8px; box-shadow: var(--shadow-pop); }
/* B15: short phones (360×640 with the demo strip): only the first three notifications, so the panel stays inside the page. */
@media (max-height: 700px) { .notif-panel > a.notif:nth-of-type(n+4) { display: none; } }
.np-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); }
.np-head h2 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); font-weight: 700; line-height: 22px; }
.np-head h2 .ico { width: 16px; height: 16px; }
.np-close { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 6px; color: var(--text-muted); cursor: pointer; }
.np-close:hover { background: var(--surface-hover); color: var(--text-strong); }
.np-close .ico { width: 16px; height: 16px; }
.np-empty { text-align: center; padding: var(--s5) var(--s4); border-top: 1px solid var(--separator); color: var(--text-muted); }
.np-empty .ico { width: 32px; height: 32px; color: var(--text-faint); stroke-width: 1.5; }
.np-empty p { margin: var(--s1) 0 0; }
.np-empty b { color: var(--text-body); }
.notif { display: grid; grid-template-columns: 32px 1fr auto; gap: var(--s3); align-items: center; padding: 10px var(--s4); border-top: 1px solid var(--separator); color: inherit; text-decoration: none; position: relative; }
.notif:hover { background: var(--surface-hover); text-decoration: none; }
.notif .n-ic { width: 32px; height: 32px; border-radius: var(--radius-icon); background: var(--accent-tint); color: var(--accent); display: grid; place-items: center; }
.notif .n-ic .ico { width: 16px; height: 16px; }
.notif.unread::after { content: ""; position: absolute; inset-inline-end: 8px; top: 12px; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }
.notif .n-title { font-weight: 700; color: var(--text-strong); line-height: 20px; }
.notif .n-sub { font-size: var(--fs-xs); color: var(--text-muted); line-height: 16px; }
.notif .n-time { font-size: var(--fs-xs); color: var(--text-subtle); white-space: nowrap; }
.inbox-foot { border-top: 1px solid var(--separator); padding: var(--s2) var(--s4); text-align: center; }
.inbox-foot a { display: inline-flex; min-height: 32px; align-items: center; color: var(--link); font-size: var(--fs); }

/* ---------- mobile bottom bar ---------- */
.bottom-nav { position: fixed; z-index: 30; bottom: 12px; inset-inline: 12px; height: var(--nav-h); display: flex; gap: 4px; align-items: center; padding: 4px; background: var(--surface); border: 1px solid var(--border-hairline-soft); border-radius: var(--radius-card); }
.bottom-nav > a, .more > summary { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 56px; border-radius: 12px; color: var(--text-subtle); font-size: 11px; font-weight: 600; line-height: 17px; text-decoration: none; }
.bottom-nav > a:hover { text-decoration: none; color: var(--text-body); }
.bottom-nav .ico { width: 20px; height: 20px; }
.bottom-nav > a span:last-child, .more > summary span { padding: 0 4px; }
.bottom-nav > a[aria-current="page"] { background: var(--primary); color: #ffffff; }
.bottom-nav .dot { position: absolute; top: 8px; margin-inline-start: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--badge-count); box-shadow: 0 0 0 2px var(--surface); }
.more { flex: 1; display: flex; }
.more > summary { list-style: none; cursor: pointer; }
.more > summary::-webkit-details-marker { display: none; }
.more[open] > summary { color: var(--text-strong); }
.more-sheet { position: fixed; inset-inline: 12px; bottom: calc(var(--nav-h) + 24px); z-index: 40; display: grid; gap: var(--s2); padding: var(--s4); background: var(--surface-raised); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); }
.more-sheet .who { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-weight: 700; color: var(--text-strong); padding-bottom: var(--s2); border-bottom: 1px solid var(--separator); }
.more-sheet select { width: 100%; height: var(--control-h); padding: 0 11px; border: 1px solid var(--border-input); border-radius: var(--radius-button); background: var(--surface); color: var(--text-body); }
.more-sheet form { margin: 0; }
.more-sheet .btn { width: 100%; }

@media (max-width: 1023.98px) {
  .topbar-scrim { height: 80px; }
  .topbar { top: 12px; inset-inline: 12px; height: auto; min-height: 55px; padding: 8px 12px; gap: var(--s3); }
  .tb-brand { flex-direction: column; align-items: center; gap: 0; }
  .brand { font-size: var(--fs-md); }
  .brand img { width: 22px; height: 22px; }
  .tb-company { font-size: var(--fs-xs); line-height: 18px; }
  .tb-tools, .tb-actions > .icon-btn:not([data-notif-toggle]), .tb-actions > .theme-toggle { display: none; }
  .tb-actions .notif-wrap { position: static; }
}
@media (min-width: 1024px) {
  .sidebar { display: block; position: fixed; z-index: 29; top: 112px; inset-inline-start: 24px; width: 64px; padding: var(--s4); background: var(--surface); border-radius: var(--radius-card); }
  /* The rail never scrolls: icons close up on short screens (never closer than 4px), and static/js/ui.js moves the ones that still do not fit into the «⋯» menu at its foot. */
  .sb-link { margin: clamp(2px, calc((100vh - 700px) / 30), 12px) 0; }
  .container { margin: 112px 0 0; margin-inline-start: 104px; margin-inline-end: 24px; padding: 0 0 var(--s5); }
  .bottom-nav { display: none; }
  .notif-panel { position: absolute; inset-inline: auto; inset-inline-start: auto; inset-inline-end: 0; top: calc(100% + 8px); bottom: auto; width: min(380px, calc(100vw - 48px)); }
}
body:has(> .demo-bar) .savebar { bottom: calc(var(--nav-h) + 48px); }
body:has(> .demo-bar) .notif-panel, body:has(> .demo-bar) .more-sheet { bottom: calc(var(--nav-h) + 48px); }
@media (min-width: 1024px) { body:has(> .demo-bar) .savebar { bottom: 44px; } body:has(> .demo-bar) .notif-panel { bottom: auto; } }
