/* EgyptAuth — application shell and page scaffolding (docs/DESIGN_SYSTEM.md §4.1–4.2).
   Shell: .shell .sidebar .main .sb-* .nav-* .app-switch* .app-mark* .app-menu* .sb-backdrop .sb-close .sb-theme .topbar
          .crumbs .crumb* .topbar-tools .search-trigger .status-pill .topbar-sep .bell .account-btn .notif-* .theme-seg*
          .sidebar-theme (the command palette is a component: components.css)
   Scaffolding: .content .page-host .page .split .chart-box .skip-link .sub-banner* .boot* .notfound .brand-word .num
          (the page header, settings template, save bar, danger zone and timeline are components: components.css)
   Detail-page scaffolding (ui/resource.js): .resource-* .text-link .section-heading
   Shared fragments used by more than one area: .keys-out .meter* .card-body.flush > .table-card */

/* ---------- Shell frame ----------
   Docked, theme-adaptive navigation: quiet paper in light, neutral charcoal in dark.
   The drawer below 900px preserves the existing scrim and focus behavior. Selection stays restrained and explicit. */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: var(--z-sidebar); width: var(--sidebar-w);
  display: flex; flex-direction: column; background: var(--surface-nav); color: var(--nav-ink); border-inline-end: 1px solid var(--nav-line);
  transition: width var(--t) var(--ease), transform var(--t-slow) var(--ease);
}
.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; background: var(--surface-canvas); transition: margin var(--t) var(--ease); }

.sb-head { display: flex; align-items: center; height: var(--header-h); padding-inline: 14px 10px; flex-shrink: 0; border-bottom: 1px solid var(--nav-line); }
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; height: 34px; padding-inline: 6px 8px; border-radius: var(--r); }
.sb-brand:hover { background: var(--nav-hover); }
.sb-brand img { width: 29px; height: 29px; flex-shrink: 0; object-fit: contain; }
.sb-brand .name { color: var(--nav-ink); white-space: nowrap; font-size: 18px; font-weight: 500; letter-spacing: -0.045em; }
.sb-close { display: none; margin-inline-start: auto; }
.sidebar .btn-icon { color: var(--nav-ink-muted); }
.sidebar .btn-icon:hover { background: var(--nav-hover); color: var(--nav-ink); }
.sidebar :focus-visible { outline-color: var(--nav-focus); }

/* ---------- Sidebar navigation ---------- */
.sb-nav { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; scrollbar-color: var(--nav-line) transparent; }
.nav-group + .nav-group { margin-top: 16px; }
/* Group labels stay subordinate to the destinations under them. */
.nav-label {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 26px; padding-inline: 10px 8px; border-radius: var(--r-sm);
  font-family: var(--label-font); font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: var(--label-tracking);
  text-transform: var(--label-transform); color: var(--nav-ink-muted); white-space: nowrap; overflow: hidden; text-align: start;
}
button.nav-label { transition: color var(--t-fast); }
button.nav-label:hover { color: var(--nav-ink); }
button.nav-label:focus-visible { outline-offset: -2px; }
/* Keep the fold affordance visible; hover, focus and collapsed groups strengthen it. */
.nav-label .caret { margin-inline-start: auto; width: 12px; height: 12px; color: var(--nav-ink-muted); opacity: .75; transition: opacity var(--t-fast), transform var(--t) var(--ease); }
button.nav-label:hover .caret, button.nav-label:focus-visible .caret, .nav-group.is-collapsed .nav-label .caret { opacity: 1; }
.nav-group.is-collapsed .nav-label .caret { transform: rotate(-90deg); }
@media (hover: none) { .nav-label .caret { opacity: 1; } }
/* A folded group keeps its active destination visible. */
.nav-group.is-collapsed .nav-item:not(.is-active) { display: none; }
.nav-items { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }

.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; height: 40px; padding-inline: 11px 9px; border-radius: var(--r);
  color: var(--nav-ink); font-size: var(--fs-base); font-weight: 400; white-space: nowrap;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.nav-item > .icon { width: 16px; height: 16px; color: var(--nav-ink-muted); transition: color var(--t-fast); }
.nav-item:hover { background: var(--nav-hover); color: var(--nav-ink); }
.nav-item:hover > .icon { color: var(--nav-ink); }
.nav-item:focus-visible { outline-offset: -2px; }
/* Selection has both a quiet surface and a narrow edge marker. */
.nav-item.is-active { background: var(--nav-selected); color: var(--nav-selected-ink); font-weight: 500; }
.nav-item.is-active::before { content: ""; position: absolute; inset-inline-start: 0; inset-block: 11px; width: 2px; border-radius: 2px; background: var(--nav-focus); }
.nav-item.is-active > .icon { color: inherit; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Counters share one right-aligned, tabular column; only the live session count carries a dot. */
.nav-item .count { flex: none; min-width: 24px; margin-inline-start: auto; text-align: end; color: var(--nav-ink-muted); font-size: var(--fs-xs); font-weight: 400; font-variant-numeric: tabular-nums; line-height: 1; }
.nav-item.is-active .count { color: var(--nav-ink); }
.nav-item[data-nav="sessions"] .count:not([hidden]) { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--nav-ink); }
.nav-item[data-nav="sessions"] .count:not([hidden])::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--nav-ok); }
/* Unread support conversations keep a compact count in the same aligned column. */
.nav-item [data-count="inbox"]:not([hidden]), .nav-item [data-count="support"]:not([hidden]) {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding-inline: 5px; border-radius: var(--r-pill);
  background: var(--nav-selected); color: var(--nav-selected-ink); font-size: var(--fs-2xs); font-weight: 600;
}
@media (forced-colors: active) {
  .nav-item.is-active { outline: 1px solid CanvasText; outline-offset: -1px; }
}

/* ---------- Application scope: the group's label, the switcher that heads it, its pages ---------- */
.nav-scope-head { margin-block: 4px 8px; }
.app-switch {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 48px; padding: 6px 10px; text-align: start;
  border: 1px solid var(--nav-line); border-radius: var(--r); background: var(--nav-hover);
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.app-switch:hover { background: var(--nav-hover); }
.app-switch[aria-expanded="true"] { background: var(--nav-selected); }
.app-switch > .app-mark { display: grid; flex-shrink: 0; color: var(--nav-ink); background: var(--surface-nav); border-color: var(--nav-line); }
.app-switch .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.app-switch .val { color: var(--nav-ink); font-size: var(--fs-base); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-switch.is-empty .val { color: var(--nav-ink-muted); }
.app-switch .lbl { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--nav-ink-muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-switch-version { font-family: var(--font-mono); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-switch-status { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }
.app-switch-status.warn { color: var(--nav-warn); }
.app-switch-status .dot { width: 6px; height: 6px; }
.app-switch-status .dot.ok { background: var(--nav-ok); }
.app-switch-status .dot.warn { background: var(--nav-warn); }
.app-switch-status .dot.neutral { background: var(--nav-ink-muted); }
.app-switch > .app-switch-caret { flex: none; width: 14px; height: 14px; color: var(--nav-ink-muted); transition: transform var(--t-fast); }
.app-switch[aria-expanded="true"] > .app-switch-caret { transform: rotate(180deg); }

/* A stable, quiet mark identifies the selected application without spending status colours. */
.avatar.app-mark { width: 28px; height: 28px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); color: var(--ink-2); font-size: 11px; }
.app-mark-empty { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border: 1px dashed var(--line-3); border-radius: var(--r); color: var(--ink-3); }
.app-mark-empty > .icon { width: 16px; height: 16px; }

.app-menu { width: 300px; }
.app-menu .app-menu-item { min-height: 52px; height: auto; padding: 8px; gap: 10px; white-space: normal; }
.app-menu .app-menu-item.is-active { background: var(--state-selected); }
.app-menu .avatar.app-mark { width: 28px; height: 28px; font-size: 10.5px; }
.app-menu-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.app-menu-name { color: var(--ink-1); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-menu-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 10px; color: var(--ink-3); font-size: var(--fs-xs); line-height: 1.3; }
.app-menu-status { display: inline-flex; align-items: center; gap: 5px; }
.app-menu-status .dot { width: 6px; height: 6px; }
.app-menu-owner { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-menu-check { display: grid; place-items: center; flex: 0 0 16px; width: 16px; }
.app-menu .app-menu-check > .icon { color: var(--accent-text); }

/* ---------- Sidebar footer: what this server is, and the rail control ---------- */
.sb-foot { flex-shrink: 0; padding: 10px 12px 12px 22px; border-top: 1px solid var(--nav-line); }
.sb-foot-row { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.sb-foot-meta { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; color: var(--nav-ink-muted); font-size: var(--fs-xs); }
.sb-foot-label { flex: none; font-family: var(--label-font); font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: var(--label-tracking); text-transform: var(--label-transform); color: var(--nav-ink-muted); white-space: nowrap; }
.sb-foot-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-foot-value.mono { font-size: var(--fs-xs); }
/* Appearance is a persistent preference, grouped with server details instead of page actions. */
.sb-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 4px; }
.sb-accent { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 4px; }
.sb-accent .appearance-picker { width: 100%; justify-content: flex-start; }
.sb-accent .appearance-picker .accent-picker-caret { margin-inline-start: auto; }
.sidebar-accent { min-width: 0; color: var(--nav-ink); background: var(--surface-nav); border-color: var(--nav-line); }
.sidebar-accent:hover, .sidebar-accent[aria-expanded="true"] { color: var(--nav-ink); background: var(--nav-hover); border-color: var(--nav-line); }
.sidebar-accent:focus-visible { outline-color: var(--nav-focus); }
.sidebar-accent .accent-picker-caret { color: var(--nav-ink-muted); }

/* ---------- Rail (desktop only): 56px of icons with tooltips ---------- */
.shell:not(.is-rail) .sidebar [data-tip]::after { display: none; }
@media (min-width: 900px) {
  .sidebar { overflow: hidden; }
  .shell.is-rail .sidebar { width: var(--rail-w); }
  .shell.is-rail .main { margin-inline-start: var(--rail-w); }
  .shell.is-rail .sb-head { padding-inline: 0; justify-content: center; }
  .shell.is-rail .sb-brand { padding-inline: 4px; }
  .shell.is-rail .sb-brand .name,
  .shell.is-rail .nav-label,
  .shell.is-rail .nav-item .label,
  .shell.is-rail .nav-item .count,
  .shell.is-rail .app-switch .meta,
  .shell.is-rail .app-switch > .app-switch-caret,
  .shell.is-rail .sb-foot-meta { display: none; }
  .shell.is-rail .sb-nav { padding-inline: 8px; }
  .shell.is-rail .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--nav-line); }
  .shell.is-rail .nav-group.is-collapsed .nav-item:not(.is-active) { display: flex; }
  .shell.is-rail .nav-item { justify-content: center; padding: 0; }
  .shell.is-rail .nav-scope-head { margin-block: 0 4px; }
  .shell.is-rail .app-switch { justify-content: center; min-height: 40px; padding: 3px; border-color: transparent; }
  .shell.is-rail .app-switch > .app-mark { display: grid; background: var(--nav-hover); border-color: var(--nav-line); color: var(--nav-ink); }
  .shell.is-rail .sb-foot { padding-inline: 0; }
  .shell.is-rail .sb-foot-row { justify-content: center; }
  .shell.is-rail .sb-theme { justify-content: center; }
  .shell.is-rail .sb-theme > .sb-foot-label { display: none; }
  .shell.is-rail .sidebar-theme { flex-direction: column; }
  .shell.is-rail .sb-accent { justify-content: center; }
  .shell.is-rail .sb-accent > .sb-foot-label, .shell.is-rail .sidebar-accent .accent-picker-label, .shell.is-rail .sidebar-accent .accent-picker-caret { display: none; }
  .shell.is-rail .sb-accent .sidebar-accent { width: 36px; padding-inline: 4px; justify-content: center; }
}

/* ---------- Drawer below 900px: hamburger, scrim, 40px items, the switcher stays inside ---------- */
.sb-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity var(--t) var(--ease); }
@media (max-width: 899px) {
  .sidebar {
    z-index: var(--z-drawer); width: min(304px, 86vw); transform: translateX(-100%); visibility: hidden;
    transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
  }
  .shell.is-mobile-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-dialog); transition: transform var(--t-slow) var(--ease), visibility 0s; }
  .shell.is-mobile-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .main { margin-inline-start: 0; }
  .sb-close { display: inline-grid; width: 40px; height: 40px; }
  .nav-item { height: 40px; font-size: var(--fs-base); }
  .nav-label { height: 32px; }
  .sb-collapse { display: none; }
}

/* ---------- Top bar: scope, search, connection state, notifications and account ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar); height: var(--header-h); display: flex; align-items: center; gap: 12px;
  padding-inline: var(--gutter); background: var(--surface-canvas); border-bottom: 1px solid var(--line-1);
}
.topbar .menu-btn { display: none; }

/* Breadcrumbs: at most three levels, the application first on app-scoped pages; the page itself is not a link. */
.crumbs { flex: 1; min-width: 0; font-size: var(--fs-sm); }
.crumbs-list { display: flex; align-items: center; min-width: 0; }
.crumb { display: flex; align-items: center; min-width: 0; flex: 0 1 auto; }
.crumb.is-current { min-width: 0; }
.crumbs .sep { flex: none; margin-inline: 10px; color: var(--ink-4); font-family: var(--font-mono); }
.crumb-link, .crumb-text, .crumbs .current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-link, .crumb-text { color: var(--ink-3); }
.crumb-link { border-radius: var(--r-sm); transition: color var(--t-fast); }
.crumb-link:hover { color: var(--ink-1); }
.crumbs .current { color: var(--ink-1); font-weight: 500; }
/* The application crumb carries the switcher's mark, so the scope reads the same in both places. */
.crumb-app { display: inline-flex; align-items: center; gap: 7px; min-width: 0; height: 28px; padding-inline: 4px 8px; margin-inline-start: -4px; border-radius: var(--r); color: var(--ink-2); transition: background-color var(--t-fast), color var(--t-fast); }
a.crumb-app:hover { background: var(--state-hover); color: var(--ink-1); }
.crumb-app .avatar.app-mark { width: 20px; height: 20px; border-radius: var(--r-sm); font-size: 8.5px; }
.crumb-app-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.topbar-tools { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
/* The command palette trigger reads as the search field it opens; icon only below 1200px. */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px; width: 216px; height: 34px; padding-inline: 10px 6px; margin-inline-end: 8px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-1); color: var(--ink-3); font-size: var(--fs-sm);
  transition: border-color var(--t-fast), color var(--t-fast), background-color var(--t-fast);
}
.search-trigger:hover { border-color: var(--line-3); color: var(--ink-2); }
.search-trigger .lbl { flex: 1; min-width: 0; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger .keys { display: inline-flex; gap: 2px; }
/* Realtime status: a static dot and a word (the only pulsing dot is the live session reading). */
.status-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding-inline: 6px; margin-inline-end: 4px; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap; cursor: default; }
.status-pill .dot { width: 6px; height: 6px; }
.status-pill.is-bad { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-tint); }
.status-pill.is-bad.is-offline { color: var(--danger-text); border-color: var(--danger-line); background: var(--danger-tint); }
.status-retry { min-height: 26px; padding-inline: 4px; border-radius: var(--r-sm); color: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.status-retry:hover { background: var(--state-hover); }
.bell { position: relative; }
.bell[aria-expanded="true"] { background: var(--state-hover); color: var(--ink-1); }
.bell .badge-count {
  position: absolute; top: 1px; inset-inline-end: 1px; display: grid; place-items: center; min-width: 17px; height: 17px; padding-inline: 4px;
  border-radius: var(--r-pill); background: var(--ink-1); color: var(--surface-1); box-shadow: 0 0 0 2px var(--surface-1);
  font-size: var(--fs-2xs); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
}
.topbar-sep { width: 1px; height: 20px; margin-inline: 6px 2px; background: var(--line-1); }
.account-btn { display: inline-flex; align-items: center; gap: 8px; height: var(--control-h); padding-inline: 4px 6px; margin-inline-start: 2px; border-radius: var(--r); transition: background-color var(--t-fast); }
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--state-hover); }
.account-btn .avatar { width: 24px; height: 24px; border-radius: 50%; font-size: 10px; }
.account-btn .name { max-width: 140px; color: var(--ink-1); font-size: var(--fs-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn > .caret { color: var(--ink-3); }

/* Notifications: compact activity rows, quiet controls and a single unread mark. */
.notif-menu {
  display: flex; flex-direction: column; width: 420px; min-width: 0; max-width: calc(100vw - 16px);
  max-height: min(560px, calc(100dvh - var(--header-h) - 16px)); padding: 0; overflow: hidden;
}
.notif-head { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 12px; min-height: 56px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line-1); }
.notif-heading { display: flex; align-items: center; min-width: 0; gap: 8px; }
.notif-title { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink-1); font-size: var(--fs-base); font-weight: 600; line-height: var(--lh-snug); }
.notif-title:focus { outline: none; }
.notif-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: var(--r-sm); background: var(--neutral-soft); color: var(--ink-2); font-size: var(--fs-2xs); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.notif-head-actions { display: flex; align-items: center; flex: none; gap: 2px; }
.notif-head-actions .btn-icon { width: 32px; height: 32px; color: var(--ink-3); }
.notif-head-actions .btn-icon > .icon { width: 16px; height: 16px; }
.notif-scroll.menu-scroll { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
.notif-scroll:focus-visible { outline-offset: -3px; }
.notif-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.notif-item { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 13px 16px; }
.notif-item + .notif-item { border-top: 1px solid var(--line-1); }
.notif-icon { display: grid; place-items: center; width: 20px; height: 20px; color: var(--ink-3); }
.notif-icon > .icon { width: 16px; height: 16px; }
.notif-icon.warn { color: var(--warn-text); }
.notif-icon.danger { color: var(--danger-text); }
.notif-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 3px 12px; min-width: 0; }
.notif-item-head { display: flex; align-items: flex-start; grid-column: 1; grid-row: 1; min-width: 0; gap: 6px; }
.notif-event { min-width: 0; color: var(--ink-1); font-size: var(--fs-base); font-weight: 400; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.notif-item.is-unread .notif-event { font-weight: 500; }
.notif-unread { flex: none; width: 4px; height: 4px; margin-top: 8px; margin-inline-start: auto; border-radius: 50%; background: var(--ink-3); }
.notif-detail { grid-column: 1 / -1; grid-row: 2; color: var(--ink-3); font-size: var(--fs-sm); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.notif-time { grid-column: 2; grid-row: 1; color: var(--ink-3); font-size: var(--fs-xs); line-height: var(--lh-snug); font-variant-numeric: tabular-nums; white-space: nowrap; }
.notif-foot { display: flex; align-items: center; justify-content: space-between; flex: none; flex-wrap: wrap; gap: 4px 8px; min-height: 42px; padding: 4px 8px 4px 16px; border-top: 1px solid var(--line-1); }
.notif-retention { color: var(--ink-3); font-size: var(--fs-xs); line-height: var(--lh-snug); }
.notif-clear.btn { color: var(--ink-3); }
.notif-empty { display: flex; flex-direction: column; align-items: center; padding: 28px 24px 32px; text-align: center; }
.notif-empty-icon { display: grid; place-items: center; flex: none; width: 24px; height: 24px; margin-bottom: 12px; color: var(--ink-3); }
.notif-empty-icon > .icon { width: 20px; height: 20px; }
.notif-empty h3 { margin: 0; color: var(--ink-1); font-size: var(--fs-base); font-weight: 500; line-height: var(--lh-snug); }
.notif-empty p { max-width: 32ch; margin: 4px 0 0; color: var(--ink-3); font-size: var(--fs-sm); line-height: var(--lh); }
@media (max-width: 640px) {
  .notif-head { padding: 6px 8px 6px 16px; }
}
@media (max-width: 480px) {
  .notif-body { grid-template-columns: minmax(0, 1fr); row-gap: 3px; }
  .notif-time { grid-column: 1; grid-row: 3; margin-top: 2px; white-space: normal; }
  .notif-time .nowrap { white-space: normal; }
  .notif-menu .btn, .notif-menu .btn-icon { min-height: var(--touch-h); }
  .notif-menu .btn-icon { min-width: var(--touch-h); }
}
@media (forced-colors: active) {
  .bell .badge-count, .notif-count { border: 1px solid CanvasText; }
  .notif-unread { background: CanvasText; }
}

/* Light / Dark / System: the 28px segmented control (DESIGN_SYSTEM §4.4), shared with the sign-in screens. */
.theme-seg { display: inline-flex; align-items: center; gap: 2px; min-height: var(--control-h-sm); padding: 2px; border: 1px solid var(--line-1); border-radius: var(--r); background: var(--surface-2); flex-shrink: 0; }
.theme-seg-btn { display: inline-grid; place-items: center; width: 28px; height: 22px; border-radius: var(--r-sm); color: var(--ink-3); transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast); }
.theme-seg-btn:hover:not(.is-on) { color: var(--ink-1); }
.theme-seg-btn.is-on { background: var(--surface-1); color: var(--ink-1); box-shadow: 0 0 0 1px var(--line-2); cursor: default; }
:root[data-theme="dark"] .theme-seg-btn.is-on { background: var(--state-active); box-shadow: none; }
.theme-seg-btn:focus-visible { outline: 2px solid var(--focus-color); outline-offset: 1px; }
.sidebar-theme { padding: 0; border: 0; background: transparent; }
.sidebar-theme .theme-seg-btn { width: 24px; height: 24px; color: var(--nav-ink-muted); }
.sidebar-theme .theme-seg-btn:hover:not(.is-on) { background: var(--nav-hover); color: var(--nav-ink); }
.sidebar .sidebar-theme .theme-seg-btn.is-on { background: var(--nav-selected); color: var(--nav-selected-ink); box-shadow: none; }
.sidebar .theme-seg-btn:focus-visible { outline-color: var(--nav-focus); }

@media (max-width: 1199px) {
  :root { --gutter: 24px; }
  .account-btn .name { display: none; }
  .search-trigger { width: var(--control-h); padding: 0; justify-content: center; margin-inline-end: 0; border-color: transparent; background: transparent; }
  .search-trigger:hover { background: var(--state-hover); color: var(--ink-1); }
  .search-trigger .lbl, .search-trigger .keys { display: none; }
}
@media (max-width: 899px) { .topbar .menu-btn { display: inline-grid; margin-inline-start: -6px; } }
@media (max-width: 639px) {
  :root { --gutter: 16px; }
  .topbar { gap: 4px; padding-inline: 6px 10px; }
  .crumbs-list { flex-direction: column; align-items: flex-start; gap: 1px; }
  .crumbs .crumb { max-width: 100%; }
  .crumbs .crumb:not(.is-current):not(:first-child) { display: none; }
  .crumbs .crumb:first-child:not(.is-current) { font-size: var(--fs-xs); }
  .crumbs .sep, .crumb-app .app-mark { display: none; }
  .crumb-app { height: auto; padding: 0; margin: 0; }
  .crumbs .current { font-size: var(--fs-sm); }
  .topbar .status-pill:not(.is-bad), .topbar-sep { display: none; }
  .topbar-tools { gap: 0; }
  .has-connection-issue .topbar { height: calc(var(--header-h) + 36px); padding-bottom: 36px; }
  .topbar .status-pill.is-bad { position: absolute; inset-inline: 0; bottom: 0; min-height: 36px; margin: 0; padding-inline: 16px; border-inline: 0; border-radius: 0; }
  .status-retry { min-height: 34px; margin-inline-start: auto; padding-inline: 8px; }
  .search-trigger { width: var(--touch-h); height: var(--touch-h); }
  .account-btn { height: var(--touch-h); padding-inline: 6px; }
  .account-btn > .caret { display: none; }
  .sidebar-theme .theme-seg-btn { width: var(--touch-h); height: var(--touch-h); }
}

/* ---------- Page scaffolding ---------- */

.content { flex: 1; width: 100%; max-width: var(--content-max); margin-inline: auto; padding: 30px var(--gutter) 56px; min-width: 0; }
.page-host { min-width: 0; }
.page { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.page > :empty:not(canvas):not(img) { display: none; }
@media (max-width: 640px) {
  .content { padding-top: 18px; padding-bottom: 40px; }
  .page { gap: 16px; }
}

.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 180px; }

/* ---------- Skip link ---------- */
.skip-link { position: fixed; inset-block-start: -80px; inset-inline-start: 16px; z-index: 100; padding: 10px 16px; background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--r); }
.skip-link:focus { inset-block-start: 8px; }

/* ---------- Boot / 404 ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--surface-canvas); }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; color: var(--ink-3); }
.boot-inner img { width: 32px; height: 32px; object-fit: contain; }
.boot-bar { position: relative; width: 96px; height: 2px; border-radius: 2px; background: var(--state-active); overflow: hidden; }
.boot-bar > span { position: absolute; inset-block: 0; width: 40%; background: var(--brand); animation: lbar 1.1s var(--ease) infinite; }
.notfound { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 96px 16px; }
.notfound .code { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); background: none; border: 0; padding: 0; }
.notfound h1 { font-size: var(--fs-xl); }

/* ---------- Reseller generate result ---------- */
.keys-out { max-height: 320px; overflow: auto; border: 1px solid var(--line-1); border-radius: var(--r); background: var(--surface-sunken); }
.keys-out .k { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line-1); }
.keys-out .k:last-child { border-bottom: 0; }
.keys-out .k .idx { color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; min-width: 28px; }
.keys-out .k .v { flex: 1; min-width: 0; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 12px; color: var(--ink-1); direction: ltr; text-align: left; user-select: all; }

/* Customer subscription banner (under the top bar) */
.sub-banner-wrap { padding: 16px var(--gutter) 0; max-width: var(--content-max); width: 100%; margin-inline: auto; }
.sub-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface-1); color: var(--ink-2); flex-wrap: wrap; font-size: var(--fs-sm);
}
.sub-banner > .icon { flex-shrink: 0; }
.sub-banner.warn { border-color: var(--warn-line); background: var(--warn-tint); }
.sub-banner.warn > .icon { color: var(--warn-text); }
.sub-banner.danger { border-color: var(--danger-line); background: var(--danger-tint); }
.sub-banner.danger > .icon { color: var(--danger-text); }
.sub-banner.info { border-color: var(--info-line); background: var(--info-tint); }
.sub-banner.info > .icon { color: var(--accent-text); }
.sub-banner .grow { min-width: 200px; color: var(--ink-1); }
.sub-banner + .sub-banner { margin-top: 8px; }

/* Usage meters (subscription page, reseller quotas) */
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); }
.meter-head .lbl { color: var(--ink-2); }
.meter-head .val { color: var(--ink-1); font-variant-numeric: tabular-nums; }
.meter.is-off .lbl { color: var(--ink-3); }
.meter.is-off .val { color: var(--ink-3); font-size: var(--fs-xs); }
.meter.is-off::after { content: ""; height: 4px; border-radius: var(--r-pill); border: 1px dashed var(--line-2, var(--line-1)); box-sizing: border-box; }

/* Tables embedded inside a card drop their own frame so the card provides it. */
.card-body.flush > .table-card,
.card-body.flush > div > .table-card { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); background: transparent; }

/* ---------- Resource workspaces (moved from workspaces.css) ---------- */

.brand-word { font-weight: 600; letter-spacing: -.045em; font-size: 16px; }

.num, .resource-facts { font-variant-numeric: tabular-nums; }

.resource-layout { display: grid; grid-template-columns: 230px minmax(0,1fr); gap: 36px; align-items: start; }
.resource-aside { padding-top: 6px; position: sticky; top: calc(var(--header-h) + 24px); min-width: 0; }
.resource-context > summary { display: none; cursor: var(--cursor-action, pointer); font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
.resource-related { display: flex; align-items: center; gap: 9px; font-weight: 500; padding-block: 10px; overflow-wrap: anywhere; }
.resource-related > .icon:last-child { margin-left: auto; }
.resource-related:hover, .text-link:hover { color: var(--accent-text); }
.text-link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.resource-facts { display: grid; gap: 5px; padding-block: 22px; border-top: 1px solid var(--line-1); margin-top: 12px; }
.resource-facts dt { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 10px; }
.resource-facts dd { color: var(--ink-2); overflow-wrap: anywhere; min-width: 0; }
.resource-facts dd .mono { font-size: 11px; white-space: normal; }
.resource-main { min-width: 0; }
/* Section navigation (ui/resource.js sectionNav) renders a .tabs strip; only its placement is set here. */
.resource-nav { margin-bottom: 28px; }
.customer-view .count { border-radius: var(--r-sm); padding: 1px 6px; background: var(--neutral-soft); color: var(--ink-3); font-size: 11px; }
.resource-page .secret { align-items: center; flex-wrap: wrap; }
.resource-page .secret .value { min-width: 0; overflow-wrap: anywhere; flex: 1 1 200px; }
.resource-page .kv { grid-template-columns: minmax(130px, .6fr) minmax(0,1.4fr); }
.resource-page .kv dd { min-width: 0; overflow-wrap: anywhere; }
/* Section title on detail pages (DESIGN_SYSTEM §3.1: 18/600) with one line of description. */
.section-heading { margin-bottom: 20px; }
.section-heading h2 { font-size: var(--fs-xl); letter-spacing: var(--tracking-heading); line-height: var(--lh-tight); margin-bottom: 5px; }
.section-heading p { max-width: 72ch; line-height: 1.6; }

.resource-page .page-sub { overflow-wrap: anywhere; }

.resource-page [data-resource-panel]:not([hidden]) { animation: workspace-enter var(--t) var(--ease); }

@keyframes workspace-enter { from { opacity: .5; transform: translateY(2px); } to { opacity: 1; transform: none; } }

@media (max-width: 1150px) {
  .resource-layout { grid-template-columns: 190px minmax(0,1fr); gap: 24px; }
}

@media (max-width: 800px) {
  .resource-layout { grid-template-columns: minmax(0,1fr); gap: 20px; }
  .resource-aside { position: static; border-bottom: 1px solid var(--line-1); padding-bottom: 16px; }
  .resource-context > summary { display: list-item; }
  .resource-context[open] > summary { margin-bottom: 18px; }
  .resource-facts { grid-template-columns: minmax(95px,.5fr) minmax(0,1fr); align-items: baseline; padding-block: 10px; }
  .resource-facts dt { margin-top: 0; }
  .resource-aside > p { display: none; }
}

@media (max-width: 480px) {
  .resource-page .kv { grid-template-columns: minmax(0,1fr); gap: 6px; }
  .resource-page .kv dt { margin-top: 12px; }
  .resource-page .list-item { flex-wrap: wrap; }
}


/* A short spatial arrival on route mounts; live data updates never replay it. */
.page-host.is-entering > .page { animation: workspace-arrive 380ms var(--ease) both; }
@keyframes workspace-arrive { from { opacity: .4; transform: translateY(12px) scale(.994); } to { opacity: 1; transform: none; } }
