/* ==== Ally design system foundation (CCUK edition) ====
   Vendored from docs/design-system.md; Ally Signals is the reference
   implementation. This block is byte-for-byte identical in every Ally
   interface that is not Signals and tests/test_interface_style.py enforces
   that. Change every copy together. Service feature rules follow the end
   marker and may add feature tokens but must not redefine these. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Josefin Sans";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("/assets/fonts/josefin-sans-latin.woff2") format("woff2");
}
:root {
  color-scheme: light;

  /* Brand */
  --ccuk-red: #dc0714;
  --ccuk-red-strong: #b4050f;
  --ccuk-red-soft: #fdeced;
  --ccuk-orange: #ff5f00;
  --ccuk-orange-soft: #fff1e8;
  --ccuk-black: #2c2929;
  --ccuk-grey: #f5f5f5;

  /* Chrome (navigation rail) */
  --chrome: var(--ccuk-black);
  --chrome-raised: #3b3737;
  --chrome-line: rgba(255, 255, 255, 0.1);
  --chrome-text: #e1dcdb;
  --chrome-muted: #a39b9a;

  /* Surfaces and text */
  --canvas: #ffffff;
  --app: #f7f6f5;
  --raised: #faf9f8;
  --sunken: #f1efee;
  --ink: var(--ccuk-black);
  --ink-2: #4a4545;
  --muted: #5f5a5a;
  --subtle: #8f8888;
  --line: #e3e0e0;
  --line-soft: #efeded;
  --line-strong: #cdc8c8;

  /* Semantic */
  --brand: var(--ccuk-red);
  --brand-strong: var(--ccuk-red-strong);
  --brand-soft: var(--ccuk-red-soft);
  --accent: var(--ccuk-orange);
  --accent-soft: var(--ccuk-orange-soft);
  --success: #0f7a4a;
  --success-soft: #e8f6ee;
  --warning: #9a5b00;
  --warning-soft: #fff6e5;
  --danger: #b42318;
  --danger-soft: #fef0ee;
  --info: #2557a7;
  --info-soft: #edf3fc;
  --focus: var(--ccuk-red);

  /* Shape, depth and type */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(30, 27, 27, 0.06);
  --shadow: 0 1px 3px rgba(30, 27, 27, 0.06), 0 6px 18px rgba(30, 27, 27, 0.05);
  --shadow-lg: 0 18px 48px rgba(30, 27, 27, 0.16);
  --font: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --font-display: "Josefin Sans", Inter, "Segoe UI", system-ui, sans-serif;

  /* Compatibility names used by feature rules written before the design
     system. They resolve to design-system tokens; do not give them values. */
  --bg: var(--app);
  --surface: var(--canvas);
  --surface-subtle: var(--raised);
  --accent-ink: var(--brand-strong);
  --ok: var(--success);
  --ok-bg: var(--success-soft);
  --warn: var(--warning);
  --warn-bg: var(--warning-soft);
  --alert: var(--danger);
  --alert-bg: var(--danger-soft);
  --info-bg: var(--info-soft);
  --planned: var(--info);
  --planned-bg: var(--info-soft);
  --navy: var(--chrome);
  --navy-raised: var(--chrome-raised);
  --orange: var(--brand);
  --orange-soft: var(--brand-soft);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--app);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  /* No tnum on body: Inter's tabular figures widen hyphens ("Data - service").
     Figures opt in with font-variant-numeric: tabular-nums. */
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--info); text-decoration: none; }
a:hover { color: var(--brand); text-decoration: underline; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.08rem; letter-spacing: -0.01em; }
h2 { margin-bottom: 0; font-size: clamp(1.3rem, 2vw, 1.6rem); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h3 { margin-bottom: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
h4 { margin-bottom: 0; font-size: 0.88rem; font-weight: 650; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--brand-soft); color: var(--ink); }

/* Icons: one inline sprite per page, referenced with <svg><use href="#i-name"/></svg>. */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg:has(> use) { width: 1em; height: 1em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Forms */
label { color: var(--ink-2); font-size: 0.78rem; font-weight: 600; }
.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 6px; }
/* :where() keeps the base field rule at zero specificity so feature rules win. */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea) {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6766' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 16px;
}
textarea { resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--subtle); }
input:focus, select:focus, textarea:focus { border-color: var(--ink-2); outline: 0; box-shadow: 0 0 0 3px rgba(220, 7, 20, 0.14); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); }
.form-error, .form-message { min-height: 18px; margin: 0; font-size: 0.78rem; }
.form-error { color: var(--danger); }

/* Buttons: primary is red and warms to orange on hover, as on the website. */
.button, .icon-button, .filter-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.button:hover, .icon-button:hover, .filter-button:hover { border-color: var(--subtle); background: var(--raised); color: var(--ink); text-decoration: none; }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: 0.55; }
.button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.button.primary:hover { border-color: var(--accent); background: var(--accent); color: #fff; }
/* Filters are pills; the active one is tinted, never a second primary action. */
.filter-button { min-height: 32px; padding: 0 12px; border-radius: 999px; box-shadow: none; font-size: 0.78rem; }
.filter-button.is-active, .filter-button.is-active:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.button.secondary { background: #fff; }
.button.danger { border-color: #f0c2bc; background: #fff; color: var(--danger); }
.button.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.button svg { width: 16px; height: 16px; }

/* Sign-in: brand hero on the left, Microsoft sign-in first on the right. */
.login-view { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 520px); background: var(--canvas); }
.login-brand-panel {
  position: relative;
  display: grid;
  align-content: end;
  gap: 22px;
  padding: clamp(32px, 6vw, 72px);
  overflow: hidden;
  background: radial-gradient(120% 90% at 0% 100%, rgba(220, 7, 20, 0.28) 0%, transparent 55%), var(--chrome);
  color: #fff;
}
.login-brand-panel::before {
  position: absolute;
  top: -18%;
  right: -22%;
  width: 70vmin;
  height: 70vmin;
  border: 34px solid rgba(220, 7, 20, 0.16);
  border-radius: 50%;
  box-shadow: 0 0 0 52px var(--chrome), 0 0 0 86px rgba(220, 7, 20, 0.1);
  content: "";
}
.login-ccuk-mark { position: relative; width: 104px; height: auto; padding: 16px; border-radius: 22px; background: #fff; }
.login-brand-panel p { position: relative; max-width: 420px; margin: 0; color: var(--chrome-text); font-family: var(--font-display); font-size: clamp(1.3rem, 2.2vw, 1.8rem); font-weight: 600; line-height: 1.3; }
.login-panel { width: 100%; max-width: 440px; align-self: center; justify-self: center; padding: 40px 36px; }
.login-panel > p { margin: 6px 0 24px; color: var(--muted); line-height: 1.55; }
.login-title { margin-top: 36px; font-size: 1.5rem; }
.login-brand .brand-kicker { color: var(--muted); }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 18px; color: var(--subtle); font-size: 0.74rem; font-weight: 600; }
.login-divider::before, .login-divider::after { flex: 1; height: 1px; background: var(--line); content: ""; }
.login-notice { margin: -10px 0 20px; padding: 10px 12px; border: 1px solid #f5c6c0; border-left: 3px solid var(--danger); border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-size: 0.82rem; line-height: 1.45; }
.sso-button { width: 100%; min-height: 44px; }
.sso-button[hidden] + .login-divider { display: none; }
.login-panel .form-stack .button { width: 100%; }

/* Application shell: 250px chrome rail and a fluid workspace. */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 1200;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  overflow-y: auto;
  background: var(--chrome);
  color: #fff;
}
.brand-lockup { display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 11px; padding: 0 6px; color: inherit; text-decoration: none; }
.brand-lockup:hover { color: inherit; text-decoration: none; }
.brand-lockup img { width: 36px; height: 36px; display: block; border-radius: 9px; }
.brand-lockup h1 { margin: 0; font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; line-height: 1; letter-spacing: 0; transform: translateY(2px); }
.brand-lockup h1 span { color: var(--ccuk-red); }
.sidebar .brand-lockup h1 { color: #fff; }
.sidebar .brand-lockup h1 span { color: #ff4651; }
.sidebar .brand-lockup img { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.login-brand { grid-template-columns: 44px minmax(0, 1fr); padding: 0; color: var(--ink); }
.login-brand img { width: 44px; height: 44px; border-radius: 11px; }
.login-brand h1 { font-size: 1.45rem; }
.brand-kicker, .eyebrow, .nav-label, .label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-kicker { margin: 5px 0 0; font-size: 0.62rem; }
.sidebar .brand-kicker, .sidebar .label { color: var(--chrome-muted); }
.side-nav { display: grid; gap: 2px; margin-top: 26px; }
.side-nav a, .nav-item {
  position: relative;
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--chrome-text);
  cursor: pointer;
  font: inherit;
  font-weight: 550;
  text-align: left;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-nav a:hover, .nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; text-decoration: none; }
.side-nav a.is-active, .side-nav a.active, .side-nav a[aria-current="page"], .nav-item.is-active { background: var(--chrome-raised); color: #fff; font-weight: 650; }
.side-nav a.is-active::before, .side-nav a.active::before, .side-nav a[aria-current="page"]::before, .nav-item.is-active::before { position: absolute; top: 9px; bottom: 9px; left: -12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); content: ""; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; color: var(--chrome-muted); }
.side-nav a:hover .nav-icon, .nav-item:hover .nav-icon { color: var(--chrome-text); }
.side-nav a.is-active .nav-icon, .side-nav a.active .nav-icon, .side-nav a[aria-current="page"] .nav-icon, .nav-item.is-active .nav-icon { color: #ff4651; }
.nav-label { margin: 22px 12px 6px; color: var(--chrome-muted); font-size: 0.62rem; }
.nav-label-first { margin-top: 0; }
.sidebar-note { display: grid; gap: 4px; margin: 18px 6px 0; padding: 12px; border: 1px solid var(--chrome-line); border-radius: var(--radius); color: var(--chrome-text); font-size: 0.74rem; line-height: 1.45; }
.sidebar-note strong { color: #fff; font-size: 0.8rem; }

/* Estate switcher: identical in every Ally service (rendered by system-ui.js).
   Collapsible because the estate will keep growing; four columns per row. */
.system-footer { display: grid; gap: 8px; margin-top: auto; padding: 12px 6px 2px; border-top: 1px solid var(--chrome-line); }
.estate-toggle { width: 100%; min-height: 32px; display: flex; align-items: center; gap: 7px; padding: 0 6px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--chrome-muted); cursor: pointer; font: inherit; text-align: left; }
.estate-toggle:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.estate-toggle > svg:first-child { width: 13px; height: 13px; }
.estate-toggle .estate-label { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.estate-current { margin-left: auto; color: var(--chrome-text); font-size: 0.72rem; font-weight: 600; }
.estate-chevron { width: 14px; height: 14px; transition: transform 0.15s ease; }
.estate-toggle[aria-expanded="true"] .estate-chevron { transform: rotate(180deg); }
.system-footer .estate-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.04); }
.system-footer .estate-links[hidden] { display: none; }
.system-footer .estate-links a { padding: 5px 0; border-radius: var(--radius-sm); color: var(--chrome-muted); font-size: 0.72rem; font-weight: 550; text-align: center; text-decoration: none; }
.system-footer .estate-links a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.system-footer .estate-links a.active { background: var(--chrome-raised); color: #fff; font-weight: 650; }
.system-footer small { padding: 0 6px; color: #6f6766; font-size: 0.6rem; }

/* Workspace and top bar */
.workspace { min-width: 0; background: var(--app); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 1100;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(18px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
}
.page-identity { min-width: 0; }
.page-identity h2 { font-family: var(--font-display); font-size: 1.32rem; font-weight: 700; letter-spacing: 0; line-height: 1.1; transform: translateY(2px); }
.page-identity p { margin: 2px 0 0; color: var(--muted); font-size: 0.76rem; }
.page-identity p strong { color: var(--ink); font-weight: 650; }
.menu-button { display: none; }
.menu-button svg { display: block; width: 20px; height: 20px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.topbar-search { position: relative; width: min(340px, 32vw); }
.topbar-search svg { position: absolute; top: 50%; left: 11px; width: 16px; height: 16px; color: var(--subtle); transform: translateY(-50%); pointer-events: none; }
.topbar-search input { min-height: 38px; padding-left: 34px; border-color: var(--line); border-radius: 999px; background: var(--raised); }
.freshness-pill { min-height: 28px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: 0.72rem; font-weight: 550; white-space: nowrap; }
.freshness-pill::before { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); content: ""; }
.freshness-pill.loading::before { animation: pulse 1.25s ease-in-out infinite; }
.freshness-pill.ready::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.freshness-pill.stale { border-color: #f0d9a8; background: var(--warning-soft); color: var(--warning); }
.freshness-pill.stale::before { background: var(--warning); }
.freshness-pill.error { border-color: #f5c6c0; background: var(--danger-soft); color: var(--danger); }
.freshness-pill.error::before { background: var(--danger); }

/* Account: avatar only; name, email and sign-out live in the menu. */
.account-menu { position: relative; display: inline-flex; }
.account-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.account-button:hover .account-avatar, .account-button[aria-expanded="true"] .account-avatar { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--line-strong); }
.account-avatar { width: 36px; height: 36px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--chrome); color: #fff; font-size: 0.74rem; font-weight: 650; letter-spacing: 0.02em; transition: box-shadow 0.12s ease; }
.account-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.account-avatar-large { width: 44px; height: 44px; flex: 0 0 44px; font-size: 0.86rem; }
.account-panel { position: absolute; top: calc(100% + 10px); right: 0; z-index: 40; width: 270px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-lg); }
.account-identity { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line-soft); }
.account-identity > div { min-width: 0; }
.account-identity strong, .account-identity small { display: block; overflow-wrap: anywhere; }
.account-identity small { margin-top: 2px; color: var(--muted); font-size: 0.74rem; }
.account-identity .status { margin-top: 6px; }
.account-panel button, .account-panel a { width: 100%; min-height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer; font-weight: 500; text-align: left; text-decoration: none; }
.account-panel button svg, .account-panel a svg { width: 17px; height: 17px; color: var(--muted); }
.account-panel button:hover, .account-panel button:focus, .account-panel a:hover, .account-panel a:focus { background: var(--raised); color: var(--ink); outline: 0; text-decoration: none; }
.account-panel .account-signout { margin-top: 6px; border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* Content */
main { width: min(1500px, 100%); margin: 0 auto; padding: 24px clamp(18px, 3vw, 40px) 60px; }
.page-section { scroll-margin-top: 88px; }
.section-heading, .panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 15px; }
.section-heading p:not(.eyebrow) { max-width: 720px; margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.section-note, .muted { color: var(--muted); line-height: 1.5; }
.meta { margin: 0; color: var(--muted); line-height: 1.5; }
.panel, .metric-card, .metric, .card, .list-item, .locked-panel, .answer-box { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--canvas); box-shadow: var(--shadow-sm); }
.panel { padding: 16px; }
.panel > .panel-heading { margin: -16px -16px 14px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--raised); align-items: center; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card, .metric { min-height: 92px; padding: 14px 16px; }
.metric-card strong, .metric strong { display: block; margin-top: 6px; font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-card .meta, .metric .meta { font-size: 0.76rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cards.compact { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card, .list-item { padding: 14px; }
.card-title { margin: 8px 0 6px; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stack-list { display: grid; gap: 10px; }
.code-path { margin: 4px 0 8px; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; overflow-wrap: anywhere; }

/* Status chips */
.status, .tag {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.status.configured, .status.operational, .status.ready, .status.active, .status.success, .status.ok, .status.reviewed, .status.met, .status.healthy, .status.connected, .status.entra { background: var(--success-soft); color: var(--success); }
.status.warning, .status.planned, .status.partial, .status.stub, .status.inactive, .status.development, .status.draft, .status.intermediate, .status.degraded, .status.stale { background: var(--warning-soft); color: var(--warning); }
.status.alert, .status.error, .status.failed, .status.failure, .status.high, .status.fail, .status.incident, .status.unavailable, .status.critical { background: var(--danger-soft); color: var(--danger); }
.status.info, .status.local, .status.session { background: var(--info-soft); color: var(--info); }

/* Notices and tables */
.notice { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--canvas); }
.error-notice { border-color: #f5c6c0; background: var(--danger-soft); color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-top: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.68rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.empty-state { padding: 24px; color: var(--muted); text-align: center; }

/* Loading comfort: skeletons render instantly; copy and a progress bar
   escalate when a load takes longer than a second (reassureWhileLoading). */
.page-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; background: var(--brand-soft); }
.page-progress::after { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: linear-gradient(90deg, transparent, var(--brand), var(--accent)); content: ""; animation: progress-slide 1.3s ease-in-out infinite; }
.loading-status { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-sm); color: var(--ink); }
.loading-status strong { font-size: 0.92rem; }
.loading-status p { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.loading-status.is-slow { border-color: #f1d99b; }
.spinner { width: 22px; height: 22px; flex: 0 0 auto; border: 2.5px solid var(--sunken); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
.skeleton-line, .skeleton-block, .skeleton-tile { position: relative; display: block; overflow: hidden; border-radius: var(--radius); background: var(--sunken); }
.skeleton-line { height: 14px; width: 45%; }
.skeleton-line.wide { height: 22px; width: 60%; }
.skeleton-block { height: 96px; }
.skeleton-tile { min-height: 92px; border: 0; border-radius: var(--radius-lg); box-shadow: none; }
.skeleton-card { display: grid; align-content: start; gap: 12px; min-height: 150px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.skeleton-line::after, .skeleton-block::after, .skeleton-tile::after { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); content: ""; transform: translateX(-100%); animation: shimmer 1.4s ease-in-out infinite; }

.sidebar-scrim { position: fixed; inset: 0; z-index: 1150; background: rgba(44, 41, 41, 0.52); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 1300; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; border-left: 3px solid var(--brand); border-radius: var(--radius); background: var(--chrome); color: #fff; box-shadow: var(--shadow-lg); }

/* Optional collapsible rail (body[data-nav-collapsible]); icons only when collapsed. */
.nav-collapse-toggle { width: 30px; height: 30px; display: grid; place-items: center; margin: 14px 6px -10px auto; padding: 0; border: 1px solid var(--chrome-line); border-radius: var(--radius); background: transparent; color: var(--chrome-muted); cursor: pointer; }
.nav-collapse-toggle:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-collapse-toggle svg { width: 16px; height: 16px; }
@media (min-width: 861px) {
  body.nav-collapsed .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  body.nav-collapsed .sidebar { padding-inline: 10px; }
  body.nav-collapsed .brand-lockup { grid-template-columns: 36px; justify-content: center; padding: 0; }
  body.nav-collapsed .brand-lockup > div, body.nav-collapsed .nav-label, body.nav-collapsed .side-nav a span, body.nav-collapsed .sidebar-note, body.nav-collapsed .system-footer { display: none; }
  body.nav-collapsed .nav-collapse-toggle { margin: 14px auto 0; }
  body.nav-collapsed .side-nav a { justify-content: center; padding: 0; }
  body.nav-collapsed .side-nav a.is-active::before, body.nav-collapsed .side-nav a.active::before, body.nav-collapsed .side-nav a[aria-current="page"]::before { left: -10px; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.45; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes progress-slide { to { left: 100%; } }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-search { width: min(260px, 28vw); }
}
@media (max-width: 860px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; width: min(280px, 86vw); transform: translateX(-102%); box-shadow: var(--shadow); transition: transform 0.2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; padding-inline: 16px; }
  .nav-collapse-toggle { display: none; }
  .menu-button { width: 39px; height: 39px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); cursor: pointer; }
  .topbar-search { display: none; }
  main { padding: 20px 18px 50px; }
  .split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  body { font-size: 13px; }
  .login-panel { padding: 28px 20px; }
  .topbar { min-height: 63px; gap: 9px; padding: 8px 12px; }
  .page-identity h2 { font-size: 1rem; }
  .page-identity p { max-width: 360px; overflow: hidden; font-size: 0.62rem; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .freshness-pill, .topbar-actions .status { display: none; }
  .topbar-actions .button { width: 38px; padding: 0; }
  .topbar-actions .button-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .account-panel { position: fixed; top: 64px; right: 10px; }
  main { padding: 16px 12px 40px; }
  .metric-grid { gap: 8px; }
  .metric-card, .metric { min-height: 72px; padding: 11px 12px; }
  .metric-card strong, .metric strong { font-size: 1.45rem; }
  .section-heading, .panel-heading { display: grid; gap: 6px; align-items: start; }
  .cards, .cards.compact { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
/* ==== End of Ally design system foundation ==== */

/* Ally Pulse feature rules */
main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; }
main > .loading-status, main > .notice { margin-bottom: 0; }
.form-error[data-status="configured"], .form-error[data-status="operational"] { color: var(--success); }
.form-error[data-status="warning"] { color: var(--warning); }
.config-grid { align-items: start; margin-bottom: 14px; }
.config-form { display: grid; gap: 10px; margin-bottom: 14px; }
.config-form label { display: grid; gap: 5px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.button-row, .config-item-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.button-row .button { flex: 1; }
.horizontal-form { grid-template-columns: minmax(160px, 1fr) minmax(260px, 2fr) minmax(140px, 0.8fr) auto auto; align-items: end; }
.check-row { display: flex !important; align-items: center; gap: 8px; min-height: 40px; color: var(--ink) !important; }
.mini-button { min-height: 28px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; color: var(--ink-2); cursor: pointer; font-size: 0.74rem; font-weight: 600; }
.mini-button:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1100px) {
  .horizontal-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .form-row, .horizontal-form { grid-template-columns: 1fr; }
  .button-row { flex-direction: column; align-items: stretch; }
}
