/* ── ADX-5 (2026-09-26): CityGlass tokens for the console ────────────────
   One action blue (#007EE5, actions + selection only), white 16px cards with a
   hairline on a cool ground (#EEF1F6), semantic good/warn/bad colours kept
   separate from the accent, a light and a dark palette. Every colour below is
   a token; components never hard-code one (tests/adx5-design-system enforces
   it). The old names (--bg, --panel, --focus, --blue …) stay as aliases so no
   selector had to change meaning. */
:root {
  color-scheme: light;
  --ground: #eef1f6;
  --card: #ffffff;
  --card-2: #f5f7fa;
  --card-hover: #f8fafc;
  --ink: #121826;
  --ink-2: #35445a;
  --muted: #5c6b7f;
  --line: rgba(17, 24, 39, 0.13);
  --line-strong: #b9c5d4;
  --accent: #007ee5;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2fd;
  --accent-strong: #005fb0;
  --good: #147a5b;
  --good-soft: #def7ed;
  --warn: #a96800;
  --warn-soft: #fff1cf;
  --warn-line: #f0c36d;
  --warn-ink: #5b3b00;
  --bad: #b42318;
  --bad-soft: #ffe3e0;
  --bad-line: #f1aaa4;
  --bad-ink: #7a1b13;
  --on-solid: #ffffff;
  --rail: #121826;
  --rail-ink: #d9e2ec;
  --rail-ink-strong: #ffffff;
  --rail-muted: #95a7bd;
  --rail-hover: #263449;
  --rail-accent: #5ab2ff;
  --star: #f2c94c;
  --topbar-bg: rgba(238, 241, 246, 0.92);
  --scrim: rgba(18, 24, 38, 0.55);
  --scrim-soft: rgba(18, 24, 38, 0.42);
  --shadow: 0 2px 12px rgba(18, 24, 38, 0.08);
  --shadow-pop: 0 12px 32px rgba(18, 24, 38, 0.16);
  --radius-card: 16px;
  --radius-control: 8px;
  --radius-pill: 999px;
  --focus-ring: 0 0 0 3px rgba(0, 126, 229, 0.35);
  /* legacy aliases */
  --bg: var(--ground);
  --panel: var(--card);
  --panel-2: var(--card-2);
  --focus: var(--accent);
  --blue: var(--accent);
  --amber: var(--warn);
  --red: var(--bad);
  --green: var(--good);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0e1117;
    --card: #161b22;
    --card-2: #1c222b;
    --card-hover: #1f2630;
    --ink: #e6ebf2;
    --ink-2: #c3ccd8;
    --muted: #8b97a7;
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: #3a4552;
    --accent: #3b9bf0;
    --accent-ink: #0b1220;
    --accent-soft: #132a44;
    --accent-strong: #7cc0ff;
    --good: #5cc28a;
    --good-soft: #13301f;
    --warn: #e9a24a;
    --warn-soft: #3a2a12;
    --warn-line: #6b4e1e;
    --warn-ink: #f3d39b;
    --bad: #f0705f;
    --bad-soft: #3a1a17;
    --bad-line: #6e2a24;
    --bad-ink: #ffc9c2;
    --on-solid: #0b1220;
    --rail: #0b0f15;
    --rail-hover: #1b2533;
    --topbar-bg: rgba(14, 17, 23, 0.9);
    --scrim: rgba(0, 0, 0, 0.62);
    --scrim-soft: rgba(0, 0, 0, 0.5);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0e1117;
  --card: #161b22;
  --card-2: #1c222b;
  --card-hover: #1f2630;
  --ink: #e6ebf2;
  --ink-2: #c3ccd8;
  --muted: #8b97a7;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: #3a4552;
  --accent: #3b9bf0;
  --accent-ink: #0b1220;
  --accent-soft: #132a44;
  --accent-strong: #7cc0ff;
  --good: #5cc28a;
  --good-soft: #13301f;
  --warn: #e9a24a;
  --warn-soft: #3a2a12;
  --warn-line: #6b4e1e;
  --warn-ink: #f3d39b;
  --bad: #f0705f;
  --bad-soft: #3a1a17;
  --bad-line: #6e2a24;
  --bad-ink: #ffc9c2;
  --on-solid: #0b1220;
  --rail: #0b0f15;
  --rail-hover: #1b2533;
  --topbar-bg: rgba(14, 17, 23, 0.9);
  --scrim: rgba(0, 0, 0, 0.62);
  --scrim-soft: rgba(0, 0, 0, 0.5);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

/* ADX-7: `hidden` always wins. Layout rules such as `.form-grid label
   { display: grid }` otherwise override the attribute, which left the
   "Other…" reason-code field on screen when it should not be. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  border-radius: var(--radius-control);
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
  color: var(--on-solid);
}

button.ghost {
  background: transparent;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  min-height: 36px;
  padding: 8px 10px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand img {
  width: 44px;
  height: 44px;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.2;
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.login-advanced {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.login-advanced summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.login-advanced[open] summary {
  margin-bottom: 12px;
}

.login-advanced label {
  display: block;
  margin-bottom: 12px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 14px;
  margin: 6px 0 10px;
}

.role-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.role-check input {
  width: auto;
  margin: 0;
}

.inline-form .role-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

button.danger {
  background: var(--bad);
  color: var(--on-solid);
  border: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.sidebar .brand {
  margin: 0 4px 18px;
}

.sidebar .brand img {
  width: 36px;
  height: 36px;
}

.sidebar .brand h1 {
  color: var(--rail-ink-strong);
  font-size: 16px;
}

.nav-group {
  margin-top: 14px;
}

.nav-label {
  color: var(--rail-muted);
  font-size: 11px;
  font-weight: 800;
  padding: 8px 10px;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  color: var(--rail-ink);
  text-decoration: none;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
}

.nav-link.active,
.nav-link:hover {
  background: var(--rail-hover);
  color: var(--rail-ink-strong);
}

.nav-icon {
  width: 18px;
  text-align: center;
  color: var(--rail-accent);
  font-weight: 900;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.global-search {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 8px;
}

.admin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 22px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.page-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.toolbar label {
  width: min(240px, 100%);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-body {
  padding: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 92px;
}

.stat strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.stat-link:hover {
  border-color: var(--accent);
}

.banner {
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.banner.red {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  background: var(--panel-2);
}

tr:hover td {
  background: var(--card-hover);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--card-2);
  color: var(--ink-2);
}

.pill.green {
  background: var(--good-soft);
  color: var(--green);
}

.pill.amber {
  background: var(--warn-soft);
  color: var(--amber);
}

.pill.red {
  background: var(--bad-soft);
  color: var(--red);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.kv {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
  font-weight: 800;
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-results {
  display: grid;
  gap: 8px;
}

.result-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--red);
  font-weight: 800;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--scrim);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal h3 {
  margin: 0 0 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  /* ADX-5: the sidebar becomes an off-canvas drawer instead of stacking all
     120 links above the page. */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    /* sized by its insets, not 100vh — 100vh is the LARGE viewport on phones
       and left the drawer short of (or past) the visible screen */
    height: auto;
    z-index: 40;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-pop);
  }

  .sidebar.open {
    transform: none;
  }

  .nav-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: var(--scrim-soft);
  }

  .nav-toggle {
    display: inline-flex !important;
  }

  .admin-chip > span {
    display: none;
  }

  .main {
    min-height: 0;
  }

  .topbar,
  .page-header,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .content {
    padding: 14px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .global-search {
    grid-template-columns: 1fr;
  }

  .result-row {
    grid-template-columns: 1fr;
  }
}

/* ── Help system (HELP-1) ────────────────────────────────────────────────── */

/* "?" chip next to a page title, and the smaller inline tip next to a field. */
.help-chip,
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--focus);
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
}

.help-chip {
  width: 22px;
  height: 22px;
  min-height: 0;
  font-size: 13px;
  margin-left: 4px;
  transform: translateY(-2px);
}

.help-tip {
  width: 16px;
  height: 16px;
  min-height: 0;
  font-size: 11px;
  margin-left: 5px;
}

.help-chip:hover,
.help-tip:hover,
.help-chip:focus-visible,
.help-tip:focus-visible {
  background: var(--focus);
  color: var(--on-solid);
  border-color: var(--focus);
  outline: none;
}

/* Backdrop shared by the drawer (dim) and popover (transparent, click-catcher). */
.help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim-soft);
  animation: help-fade 0.14s ease;
}

.help-backdrop.transparent {
  background: transparent;
}

/* Right-side section help drawer. */
.help-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 61;
  width: min(440px, 100%);
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: help-slide 0.18s ease;
}

.help-drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.help-drawer-head h3 {
  margin: 2px 0 0;
  font-size: 20px;
}

.help-eyebrow {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--focus);
}

.help-close {
  min-height: 30px;
  width: 30px;
  padding: 0;
  border-radius: 6px;
  color: var(--muted);
  flex: none;
}

.help-drawer-body {
  padding: 18px 20px 28px;
  overflow: auto;
}

.help-oneliner {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
}

.help-block {
  margin-top: 18px;
}

.help-block h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.help-block p {
  margin: 0;
  line-height: 1.5;
}

/* The "when you turn this ON / OFF" table — the marquee feature. */
.help-effects {
  display: grid;
  gap: 12px;
}

.help-effect {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.help-effect-name {
  background: var(--panel-2);
  padding: 8px 12px;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
}

.help-effect-onoff {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}

.help-effect-on,
.help-effect-off {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  line-height: 1.45;
  font-size: 13px;
}

.help-effect-tag {
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  border-radius: 999px;
  padding: 3px 0;
  letter-spacing: 0.04em;
}

.help-effect-tag.on {
  background: var(--good-soft);
  color: var(--green);
}

.help-effect-tag.off {
  background: var(--bad-soft);
  color: var(--red);
}

.help-term-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.help-term-chip {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.help-term-chip span {
  color: var(--focus);
  font-weight: 900;
}

.help-term-chip:hover {
  border-color: var(--focus);
}

.help-permission {
  margin-top: 20px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

/* Term popover (inline definition). */
.help-popover {
  position: fixed;
  z-index: 62;
  width: min(320px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  animation: help-fade 0.12s ease;
}

.help-popover-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.help-popover-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}

.help-popover-example {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

/* Guide (reference) page. */
.help-intro-tagline {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
}

.help-intro-model {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.help-intro-step {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.help-intro-step-h {
  font-weight: 800;
  color: var(--focus);
  margin-bottom: 4px;
}

.help-intro-step p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.help-intro-orientation {
  margin: 0;
  color: var(--muted);
}

.guide-group {
  margin-top: 4px;
}

.guide-group + .guide-group {
  margin-top: 18px;
}

.guide-group-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}

.guide-rows {
  display: grid;
  gap: 8px;
}

.guide-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.guide-row-title {
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}

.guide-row-title:hover {
  color: var(--focus);
}

.guide-row-copy {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Welcome card (first run). */
.welcome-card {
  position: relative;
  border-color: var(--line);
  background: linear-gradient(180deg, var(--accent-soft), var(--panel));
}

.welcome-eyebrow {
  font-weight: 800;
  color: var(--focus);
  font-size: 13px;
  margin-bottom: 4px;
}

.welcome-card h3 {
  margin: 0 0 6px;
}

.welcome-dismiss {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 6px;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.welcome-cta {
  margin-top: 12px;
}

/* Topbar Guide link (an anchor, so it needs its own ghost-button styling). */
.topbar-guide {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--focus);
  font-weight: 700;
  text-decoration: none;
}

.topbar-guide:hover {
  border-color: var(--focus);
  background: var(--panel);
}

@keyframes help-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes help-slide {
  from { transform: translateX(16px); opacity: 0.4; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 620px) {
  .help-intro-model {
    grid-template-columns: 1fr;
  }
}

/* ── ADM-G10 (BP-1744): nav favorites/collapse + command palette + Entity-360 tabs ── */

.nav-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-row .nav-link {
  flex: 1;
  min-width: 0;
}

.nav-fav {
  background: none;
  border: none;
  color: var(--rail-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}

.nav-fav:hover {
  background: var(--rail-hover);
  color: var(--star);
}

.nav-fav.on {
  color: var(--star);
}

.nav-label-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--rail-muted);
  font-size: 11px;
  font-weight: 800;
  padding: 8px 10px;
  text-transform: uppercase;
}

.nav-collapse-caret {
  font-size: 10px;
  opacity: 0.8;
}

.palette {
  width: min(560px, 100%);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.palette-input {
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  font-size: 16px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.palette-results {
  overflow-y: auto;
  padding: 8px;
}

.palette-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
}

.palette-result:hover {
  background: var(--card-2);
}

.palette-result-group {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 90px;
}

.palette-result-label {
  font-size: 14px;
}

.palette-empty {
  padding: 14px 10px;
  color: var(--muted);
  font-size: 13px;
}

.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px 0;
}

.tab-btn {
  background: var(--card-2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}

.tab-btn.active {
  background: var(--ink);
  color: var(--on-solid);
}

/* ADX-1 (BP-2958): `btn small` was used 15 times and defined nowhere, so those
   buttons fell back to the browser default size inside dense tables. */
.btn.small,
button.small {
  min-height: 28px;
  padding: 0 9px;
  font-size: 13px;
}

/* ADX-1 (BP-2948): the step-up modal sits above an open reason modal. */
.step-up-backdrop {
  z-index: 60;
}

/* ── ADX-3: employee pages ─────────────────────────────────────────────── */
.invite-panel > summary { cursor: pointer; list-style: none; }
.invite-panel > summary::-webkit-details-marker { display: none; }
.invite-panel > summary::after { content: " ▾"; color: var(--muted); }
.button-link {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.button-link:hover { border-color: var(--line-strong); }
.employee-head-body { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.employee-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.employee-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.role-template-list { display: grid; gap: 4px; }
.role-template-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding: 4px 0; }
.role-template-row input[type="date"] { min-height: 30px; }
.perm-toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.perm-toolbar input[type="search"] { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; }
.perm-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-module h4 { margin: 16px 0 6px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.perm-row {
  display: grid; grid-template-columns: minmax(220px, 1fr) auto auto 64px; gap: 12px;
  align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.perm-row[hidden], .perm-module[hidden] { display: none; }
.perm-name code { font-size: 11px; }
.perm-state { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.perm-state .seg { display: inline-flex; gap: 4px; align-items: center; padding: 4px 10px; font-size: 13px; cursor: pointer; border-right: 1px solid var(--line); }
.perm-state .seg:last-child { border-right: 0; }
.perm-state .seg:has(input:checked) { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.perm-state .seg-deny:has(input:checked) { background: var(--bad-soft); color: var(--bad); }
.perm-state .seg:has(input:disabled) { cursor: not-allowed; opacity: .55; }
/* the global `input { width:100%; min-height:36px }` rule stretches radios
   and checkboxes; controls inside the toggle and the role lists stay native */
.perm-state .seg input,
.role-check input[type="checkbox"],
.role-template-row input[type="checkbox"] { margin: 0; width: auto; min-height: 0; flex: none; }
.perm-row input[type="date"], .role-template-row input[type="date"] { width: auto; }
.perm-expiry input { min-height: 28px; }
.perm-summary { margin: 14px 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); }
.tab-row { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-row .tab-btn { text-decoration: none; }
.view-as-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-left: 4px solid var(--accent); }
@media (max-width: 720px) {
  .perm-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ── ADX-5: shared components ──────────────────────────────────────────── */
.nav-toggle { display: none; align-items: center; justify-content: center; min-width: 40px; font-size: 18px; }
.topbar { grid-template-columns: auto minmax(180px, 1fr) auto; }
@media (min-width: 921px) { .topbar { grid-template-columns: minmax(180px, 1fr) auto; } }
.theme-toggle { white-space: nowrap; }

.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.th-sort {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}
.th-sort:focus-visible { box-shadow: var(--focus-ring); border-radius: 4px; }
.th-sort-ind::after { content: "↕"; opacity: 0.35; font-size: 11px; }
.th-sort[aria-sort="ascending"] .th-sort-ind::after { content: "▲"; opacity: 0.8; }
.th-sort[aria-sort="descending"] .th-sort-ind::after { content: "▼"; opacity: 0.8; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); }
.select-cell { width: 34px; }
.select-cell input { width: auto; min-height: 0; margin: 0; }
tr:has([data-row-select]:checked) td { background: var(--accent-soft); }

#toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: center;
  background: var(--ink); color: var(--ground);
  border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow-pop); font-size: 14px;
}
.toast-good { border-left: 4px solid var(--good); }
.toast-bad { border-left: 4px solid var(--bad); }
.toast span { flex: 1; }
.toast button { min-height: 28px; padding: 0 10px; background: transparent; color: inherit; border-color: color-mix(in srgb, var(--ground) 40%, transparent); }
.toast .toast-close { border: 0; font-size: 18px; padding: 0 4px; }

.skeleton-line {
  height: 12px; border-radius: 6px; margin: 12px 0;
  background: linear-gradient(90deg, var(--card-2), var(--card-hover), var(--card-2));
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── ADX-6: workspaces, My queue, quick look ────────────────────────────── */
.sidebar { padding: 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 16px 14px 8px; margin: 0; }
.nav-tree { display: grid; grid-template-columns: 64px minmax(0, 1fr); flex: 1; min-height: 0; }
.ws-rail { display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 16px; border-right: 1px solid color-mix(in srgb, var(--rail-ink) 12%, transparent); }
.ws-btn {
  all: unset; box-sizing: border-box; cursor: pointer; position: relative;
  display: grid; justify-items: center; gap: 2px; padding: 8px 2px; border-radius: 12px;
  color: var(--rail-muted); font-size: 10px; text-align: center; line-height: 1.15;
}
.ws-btn .ws-icon { font-size: 18px; line-height: 1; }
.ws-btn:hover { background: var(--rail-hover); color: var(--rail-ink); }
.ws-btn.on { background: var(--rail-hover); color: var(--rail-ink-strong); box-shadow: inset 3px 0 0 var(--rail-accent); }
.ws-btn:focus-visible { box-shadow: var(--focus-ring); }
.ws-count {
  position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--bad); color: var(--on-solid); font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.ws-section { padding: 6px 10px 20px; overflow: auto; }
.ws-title { font-weight: 700; color: var(--rail-ink-strong); padding: 8px 10px 4px; font-size: 15px; }
.nav-count {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; text-align: center;
}
.table-tools { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line); }
tr.kbd-active td { box-shadow: inset 0 0 0 2px var(--accent); }
tr.quick-lookable { cursor: pointer; }
.queue-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.queue-card { display: flex; flex-direction: column; }
.queue-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 14px 16px 8px; }
.queue-card-head h3 { margin: 0 0 2px; font-size: 16px; }
.queue-items { list-style: none; margin: 0; padding: 0 8px 10px; }
.queue-items a { display: grid; gap: 2px; padding: 8px; border-radius: 10px; color: inherit; text-decoration: none; }
.queue-items a:hover { background: var(--card-hover); }
.queue-when { font-size: 12px; }
.empty-state { text-align: center; padding: 40px 16px; }
.empty-state h3 { margin: 0 0 6px; }
.drawer-scrim { position: fixed; inset: 0; background: var(--scrim-soft); z-index: 55; }
.quick-look {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 96vw); z-index: 56;
  background: var(--ground); box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
}
.quick-look-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.quick-look-body { padding: 16px; overflow: auto; }
@media (max-width: 920px) {
  .nav-tree { grid-template-columns: 64px minmax(0, 1fr); }
}
.bulk-bar { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--accent); border-radius: var(--radius-control); background: var(--accent-soft); }
.bulk-bar[hidden] { display: none; }
.palette-section { padding: 10px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.palette-records a.palette-empty { display: block; color: var(--accent); text-decoration: none; }

/* ADX-7: keep the top bar on one line at laptop widths — the name moves into
   the tooltip and Save view / theme / refresh shrink to their icons. */
.admin-chip { flex-wrap: nowrap; gap: 6px; }
.admin-chip button, .admin-chip a { white-space: nowrap; }
@media (max-width: 1400px) {
  .admin-chip > span { display: none; }
  .admin-chip .topbar-compact-label { display: none; }
}

/* ADX-15 (BP-2951): announcement composer — audience checkboxes and the
   push / in-app previews (CityGlass: white 16px card, hairline, soft shadow). */
.broadcast-composer fieldset { border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.broadcast-composer fieldset legend { font-weight: 600; padding: 0 4px; }
.broadcast-composer fieldset p { flex-basis: 100%; margin: 4px 0 0; }
.broadcast-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 10px; }
.broadcast-preview-label { font-size: 12px; margin-bottom: 6px; }
.broadcast-push-mock { background: var(--card-hover); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 10px 14px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.broadcast-push-app { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.broadcast-card-mock { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 12px 14px; display: grid; gap: 4px; box-shadow: var(--shadow); }
.broadcast-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.broadcast-card-close { color: var(--muted); font-size: 18px; line-height: 1; }

/* ADX-18 PART B: Live Pulse — one card per feature family with two inline SVG
   sparklines (ui.js sparkline(): currentColor, so they follow the theme). */
.pulse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.pulse-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.pulse-card:hover,
.pulse-card:focus-visible {
  border-color: var(--accent);
}

.pulse-card.pulse-unusual {
  border-color: var(--warn-line);
}

.pulse-card-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.pulse-card-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.pulse-card-count strong {
  font-size: 26px;
}

.pulse-card-spark {
  color: var(--accent);
  line-height: 0;
}

.pulse-card-spark-long {
  color: var(--ink-2);
}

.pulse-card-meta {
  font-size: 12px;
}

.sparkline {
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.pulse-auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.pulse-auto input[type="checkbox"] {
  margin: 0;
  width: auto;
  min-height: 0;
  flex: none;
}

.timeline-chips {
  padding: 0 0 8px;
}

.timeline-chips .tab-btn {
  font-size: 12px;
  padding: 4px 10px;
}

/* ADX-21 / ADM-3 (BP-153): promotion pacing — the fill is views served, the
   mark is how much of the window has passed. */
.pacing-bar { position: relative; height: 8px; min-width: 120px; background: var(--line); border-radius: 999px; overflow: visible; margin-bottom: 4px; }
.pacing-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--good); }
.pacing-fill.amber { background: var(--warn); }
.pacing-fill.red { background: var(--bad); }
.pacing-mark { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); transform: translateX(-1px); }
.ads-trend { color: var(--accent); }
.ads-trend .sparkline { width: 100%; }
/* A row of stat tiles inside a panel (walkie, ads, app.js pages used this
   class with no rule, so the tiles stacked one per line). */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
/* Section headings inside panels (used across the console with no rule). */
.panel-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.panel-head:only-child { border-bottom: 0; }
/* Phone width: the account/tools strip gets its own wrapping row instead of
   widening the top bar (it pushed every page to ~660px of sideways scroll). */
@media (max-width: 560px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr); }
  .topbar .admin-chip { grid-column: 1 / -1; flex-wrap: wrap; }
}
