/* Brand palette — derived from the Comms One logo (#0e1143 navy, #2fc1d6 cyan). */

:root {
  /* Brand */
  --brand-navy: #0e1143;
  --brand-cyan: #2fc1d6;

  /* Light surface palette (default) */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #d8dde5;
  --border-strong: #c4cbd6;
  --text: #14182b;
  --text-muted: #5a6478;
  --text-faint: #8089a0;
  --header-bg: #f4f6fa;
  --header-border: #e3e7ee;
  --row-hover: #f1f5fb;

  /* Accents */
  --accent: var(--brand-cyan);
  --accent-fg: #ffffff;
  --accent-hover: #21a8bc;
  --danger: #c02b3a;
  --danger-hover: #a32230;
  --ok: #15803d;
  --err: #b91c1c;
  /* Warning: --warn is for text and icons, --warn-border for outlines. */
  --warn: #a16207;
  --warn-bg: #fff8e6;
  --warn-border: #eab308;

  --shadow-sm: 0 1px 2px rgba(14, 17, 67, 0.04);
  --focus-ring: 0 0 0 3px rgba(47, 193, 214, 0.35);
}

:root[data-theme='dark'] {
  /* Neutral warm-grey surfaces. Brand colour appears only at accents,
     not as wallpaper. */
  --bg: #15171c;
  --surface: #1d2027;
  --surface-alt: #242830;
  --border: #353a44;
  --border-strong: #4a5060;
  --text: #e6e8ec;
  --text-muted: #a0a6b2;
  --text-faint: #6e7480;
  --header-bg: #15171c;
  --header-border: #2a2e37;
  --row-hover: #262a33;

  --accent: var(--brand-cyan);
  --accent-fg: #ffffff;
  --accent-hover: #5fd3e3;
  --danger: #e65968;
  --danger-hover: #f07484;
  --ok: #4ade80;
  --err: #f87171;
  /* A translucent amber wash over the surface instead of an olive fill. */
  --warn: #f2c14e;
  --warn-bg: rgba(242, 193, 78, 0.06);
  --warn-border: rgba(242, 193, 78, 0.35);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --focus-ring: 0 0 0 3px rgba(47, 193, 214, 0.5);
}

* {
  box-sizing: border-box;
}

/* The HTML `hidden` attribute must beat author `display:` declarations like
   `.error-banner { display: flex }` and `.badge { display: inline-block }`.
   Without this, [hidden] elements still render (e.g. an empty yellow banner
   stays visible). */
[hidden] {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

/* Every text control shares one themed look, wherever it lives (filter bars,
   inline row editors) — nothing falls back to the browser's white default. */
input:not([type='checkbox']):not([type='radio']),
select {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

input::placeholder {
  color: var(--text-faint);
}

/* Focus ring (used by anything that opts in via :focus-visible). */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 2px;
}

/* --- Header -------------------------------------------------------------- */

header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0.65rem 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-sep {
  width: 1px;
  height: 22px;
  background: var(--header-border);
}

.brand img {
  height: 30px;
  width: auto;
  display: block;
}

/* The CommsOne logo and the app icon (branding/label-click, cropped to the
   badge so it is sized by height) each have a light and a dark file,
   swapped via theme so the cyan accent stays brand-correct in both modes. */
.brand .logo-dark,
.signin .logo-dark {
  display: none;
}

:root[data-theme='dark'] .brand .logo-light,
:root[data-theme='dark'] .signin .logo-light {
  display: none;
}

:root[data-theme='dark'] .brand .logo-dark,
:root[data-theme='dark'] .signin .logo-dark {
  display: block;
}

/* --- Sign-in landing page (auth on; rendered by src/gui/signin.ts) ------- */

.signin {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* Same surface as the console's cards (.sbc-card, .filters). */
.signin-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2.25rem 2rem 2rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.signin-theme {
  position: fixed;
  top: 1rem;
  right: 1rem;
}

.signin-logo {
  height: 40px;
  width: auto;
}

.signin-icon {
  height: 56px;
  width: auto;
}

.signin form {
  width: 100%;
}

.signin button.primary {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 1rem;
}

.signin-error {
  width: 100%;
  text-align: left;
  border: 1px solid var(--err);
  border-radius: 4px;
  background: var(--surface-alt);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.signin-error p {
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}

.signin-error p:last-child {
  margin-bottom: 0;
}

.signin-error-title {
  font-weight: 600;
  color: var(--err);
}

.signin-error-code code {
  color: var(--text-muted);
}

header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* Dry run must be obvious on every page: nothing is sent to the SBC. */
.dry-run-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* --- Service icons -------------------------------------------------------- */
/* Compact row of per-role status glyphs in the header bar.                  */

.service-icons {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Each icon is a small square button-like element: icon-only, tooltip via  */
/* the native `title` attribute. No visible label — status is conveyed via  */
/* glyph shape and fill colour.                                              */
.svc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  padding: 0;
  cursor: default;
  /* SVG fills inherit this colour */
  color: var(--text-faint);
  transition:
    color 0.15s,
    border-color 0.15s;
}

.svc-icon svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  /* Use currentColor so status classes drive the fill. */
  fill: currentColor;
}

/* Status colours — reuse existing design tokens. */
.svc-icon.status-running {
  color: var(--ok);
}

.svc-icon.status-stale {
  color: var(--warn);
  border-color: var(--warn-border);
}

.svc-icon.status-paused {
  color: var(--warn);
}

/* disabled + never share muted appearance; never uses a hollow stroke style */
.svc-icon.status-disabled,
.svc-icon.status-never {
  color: var(--text-faint);
}

.identity-email {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Sign Out is an <a> styled as a button so it pairs with .theme-toggle —
   same height + border + background, just wider to fit the label. */
.signout {
  display: inline-flex;
  align-items: center;
  height: 2.1rem;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.signout:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.theme-toggle {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.theme-toggle::before {
  content: '☀';
}

:root[data-theme='dark'] .theme-toggle::before {
  content: '☾';
}

.theme-toggle:hover {
  border-color: var(--border-strong);
}

/* --- Nav tabs ------------------------------------------------------------ */

nav.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}

button.tab {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

button.tab:hover {
  color: var(--text);
}

button.tab.active {
  border-bottom-color: var(--accent);
  color: var(--text);
  /* font-weight intentionally unchanged */
}

.badge {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.2;
  font-weight: 600;
  text-align: center;
  background: var(--border);
  color: var(--text);
}

.badge.attention {
  background: var(--danger);
  color: #fff;
}

/* --- Main panels --------------------------------------------------------- */

main {
  padding: 1rem 1.5rem;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.filters,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
}

/* Filters use bottom alignment so stacked label+input columns line up at
   the input edge regardless of label text wrapping. Action toolbars only
   contain buttons + short status text, so centre-align so the status text
   sits mid-button instead of riding the baseline. */
.filters {
  align-items: end;
}

.actions {
  align-items: center;
}

.filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-muted);
  gap: 0.25rem;
}

.filters input:not([type='checkbox']),
.filters select {
  min-width: 10rem;
}

/* A field on a row of its own; its input is at most half the card wide on
   large screens and full width below. */
.filters label.own-row {
  flex: 0 0 100%;
}

.filters label.own-row input {
  width: 100%;
  max-width: 50%;
}

@media (max-width: 1024px) {
  .filters label.own-row input {
    max-width: none;
  }
}

.filters label.checkbox {
  flex-direction: row;
  align-items: center;
  align-self: flex-end;
  gap: 0.4rem;
  padding-bottom: 0.45rem;
}

.level-multi {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  background: var(--surface);
}

.level-multi legend {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.level-multi label.inline {
  font-size: 0.85rem;
  color: var(--text);
  flex-direction: row;
  gap: 0.25rem;
  align-items: center;
  min-width: 0;
}

/* Quick-time chips for logs. */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.chip-label {
  color: var(--text-muted);
  margin-right: 0.25rem;
}

button.chip {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button.chip:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

button.chip-clear {
  color: var(--text-muted);
}

.actions-spacer {
  flex: 1;
}

button {
  font-size: 0.9rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
}

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

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

button:disabled:hover {
  background: var(--surface-alt);
  border-color: var(--border);
}

/* Inline spinner used in refresh / load-more buttons while a fetch is in
   flight. Pure CSS — no JS animation loop. */
.spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  margin-right: 0.45em;
  vertical-align: -0.15em;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
}

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

button.success {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}

button.success:hover {
  filter: brightness(1.08);
  background: var(--ok);
  border-color: var(--ok);
}

button.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

/* --- Tables -------------------------------------------------------------- */

.table-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  padding-left: 0.25rem;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  color: var(--text);
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--text);
  position: sticky;
  top: 0;
}

th.checkbox-col,
td.checkbox-col {
  width: 2rem;
  padding-right: 0.25rem;
}

td.error {
  white-space: nowrap;
  /* min-width pins the column so its width doesn't jump between refreshes when
     the longest error string changes; max-width keeps long errors truncating. */
  min-width: 16rem;
  max-width: 30rem;
  color: var(--err);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

td.error.expanded {
  white-space: normal;
  word-break: break-word;
}

td.meta {
  white-space: nowrap;
  /* Pin like td.error so the metadata column width stays stable across polls. */
  min-width: 14rem;
  max-width: 30rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* Housekeeper-compacted log rows show "(×N)" after the message. */
.repeat-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: 0.25rem;
  font-weight: 600;
  font-size: 0.82rem;
}

td.meta.expanded {
  white-space: normal;
  word-break: break-all;
}

td.time {
  /* Relative time + absolute tooltip. */
}

tbody tr:hover {
  background: var(--row-hover);
}

tbody tr.selected {
  background: rgba(47, 193, 214, 0.12);
}

.status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* One-paragraph guidance under a toolbar — sized and toned like .table-meta
   so it reads as part of the table chrome, not as body copy. */
.hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  padding-left: 0.25rem;
  max-width: 64rem;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--err);
}

.audit-queued {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.75rem;
}

/* Button styled as an inline link, used for the clickable Last Result cell. */
.link-like {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent-hover);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.link-like:hover {
  text-decoration-style: solid;
}

.link-like:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 3px;
}

/* ---- Modals (audit delta, pipeline evidence) ----------------------------- */

.modal {
  width: min(720px, 92vw);
  max-height: 80vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(14, 17, 67, 0.25);
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(14, 17, 67, 0.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.modal-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
}

.modal-close:hover {
  color: var(--text);
}

.modal-sub {
  margin: 0;
  padding: 0.6rem 1.1rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 0.75rem 1.1rem 1.1rem;
  overflow-y: auto;
  max-height: calc(80vh - 7rem);
}

.modal-body .table-wrap {
  margin-bottom: 0.5rem;
}

.delta-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.delta-group + .delta-group {
  margin-top: 0.4rem;
}

/* One concern per row: sign, block, and what it does, in one line. */
.delta-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

summary.delta-row {
  cursor: pointer;
  list-style: none;
}

summary.delta-row::-webkit-details-marker {
  display: none;
}

/* The flex row drops the native marker, so the chevron says it opens. */
summary.delta-row::before {
  content: '';
  flex: none;
  align-self: center;
  width: 0.4rem;
  height: 0.4rem;
  margin: 0 0.2rem 0 0.1rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

details[open] > summary.delta-row::before {
  transform: rotate(45deg);
}

.delta-group.static .delta-row {
  padding-left: 1.95rem;
}

.delta-sign.add {
  color: var(--ok);
}

.delta-sign.remove {
  color: var(--err);
}

.delta-sign.conflict {
  color: var(--warn);
}

.delta-fields {
  color: var(--text-muted);
}

.delta-sign {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  width: 0.8rem;
}

.delta-prefix {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
}

.delta-row .block-size,
.delta-list .block-size {
  color: var(--text-faint);
}

.delta-note {
  margin-left: auto;
  color: var(--text-muted);
  white-space: nowrap;
}

.delta-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.7rem 0.5rem 1.95rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  max-height: 16rem;
  overflow-y: auto;
}

.delta-list li {
  display: flex;
  gap: 0.5rem;
  padding: 0.1rem 0;
}

.delta-more {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Audit v2: five groups, each status a collapsed .delta-group. */
.audit-group + .audit-group {
  margin-top: 0.9rem;
}

.audit-group h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}

.audit-count {
  color: var(--text-muted);
  font-weight: 400;
}

.audit-banner,
.audit-note {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.82rem;
}

.audit-banner {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}

.audit-note {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
}

.audit-lead {
  margin: 0;
  padding: 0.35rem 0.7rem 0 1.95rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.delta-list li.audit-route {
  display: block;
  padding: 0.35rem 0;
}

.delta-list li.audit-route + li.audit-route {
  border-top: 1px dashed var(--border);
}

.audit-message,
.audit-other {
  margin-top: 0.15rem;
}

.audit-other,
.audit-secondary {
  color: var(--text-muted);
}

.audit-secondary {
  margin: 0.15rem 0 0;
  padding-left: 1.1rem;
}

.audit-fix {
  margin-top: 0.3rem;
  padding: 0.3rem 0.5rem;
  border-left: 2px solid var(--accent);
  background: var(--surface-alt);
}

.audit-fix-head {
  font-weight: 600;
}

.audit-status {
  font-weight: 600;
}

.delta-list .audit-fix li {
  display: block;
}

.audit-fix-settings {
  color: var(--text-muted);
}

.audit-fix ul {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  max-height: 10rem;
  overflow-y: auto;
}

.row-actions {
  display: flex;
  gap: 0.3rem;
}

.row-actions button {
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
}

.empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
}

/* Labels tab — column-level select-all checkbox in the <th>. */
.col-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  cursor: pointer;
}

/* Labels tab — checkbox-style toggle inside a row. */
.row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
}

.row-toggle input[type='checkbox']:checked + span {
  color: var(--ok);
  font-weight: 600;
}

/* --- Pager: one under every paged list ------------------------------------ */

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pager:empty {
  display: none;
}

.pager button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.7rem;
}

.pager button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.pager button:disabled {
  opacity: 0.45;
  cursor: default;
}

.pager-status {
  padding: 0 0.4rem;
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.6rem;
}

/* --- Carriers: incomplete mappings + trunk groups ------------------------- */

/* Auto-registered PIDs awaiting a trunk — warn-toned so they read as
   actionable, not broken. Declared after tbody tr:hover at equal specificity
   so the tint survives hover. */
tbody tr.incomplete {
  background: var(--warn-bg);
}

.badge-unmapped {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--text);
  margin-right: 0.4rem;
}

td .inline-trunk {
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  min-width: 9rem;
  margin-right: 0.35rem;
}

.hint-inline {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 0.4rem;
}

/* Trunk Groups table below the carrier mappings on the same tab. */
.subsection {
  margin-top: 1.5rem;
}

.subsection > .section-title {
  margin-bottom: 0.6rem;
}

/* --- DIDs tab ------------------------------------------------------------- */

/* Vacated rows are the last known state of a removed number — keep them
   visible but visually receded. */
tbody tr.vacated td {
  color: var(--text-faint);
}

.coverage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem 0.9rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.coverage-head {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.coverage-current {
  margin: 0 0 0.5rem;
}

.coverage-empty {
  margin: 0;
  color: var(--text-faint);
  font-style: italic;
}

/* SBC tab — one SBC per app instance, so a single read-only status card
   replaces the old table. */
.sbc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1.1rem 1rem;
  box-shadow: var(--shadow-sm);
}

/* Connection and Latest Discovery sit side by side at one height, the
   discovery card wider for its two columns; they stack on narrow screens. */
.sbc-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.sbc-grid > .sbc-card {
  flex: 1 1 24rem;
}

.sbc-grid > .sbc-discovery {
  flex: 2 1 36rem;
}

/* Connection is only as wide as its longest line; discovery takes the rest. */
.sbc-grid > .sbc-connection {
  flex: 0 0 auto;
  max-width: 100%;
}

.sbc-connection .sbc-fields dd {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .sbc-grid > .sbc-connection {
    flex: 1 1 100%;
  }

  .sbc-connection .sbc-fields dd {
    white-space: normal;
  }
}

/* The run and its timings down the left, what it read down the right. */
.sbc-fields.two-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, auto);
  grid-auto-flow: column;
  column-gap: 2rem;
}

@media (max-width: 720px) {
  .sbc-fields.two-columns {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }
}

.sbc-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sbc-fields {
  margin: 0.85rem 0 0;
}

.sbc-fields > div {
  display: flex;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.sbc-fields dt {
  flex: 0 0 10rem;
  color: var(--text-muted);
}

.sbc-fields dd {
  margin: 0;
}

/* --- Error banner above tables ------------------------------------------ */

.error-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  color: var(--text);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.error-banner .retry-link {
  font-size: 0.85rem;
  color: var(--accent-hover);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* --- Header reconciler pause control ------------------------------------- */
/* The reconciler's run/paused state is conveyed by the service-icon row; this
   button is the only pause CONTROL. It flips its own styling (.danger when
   running -> click to pause; .primary when paused -> click to resume). */

.recon-toggle {
  height: 2.1rem;
  font-size: 0.85rem;
}

/* --- Health strip -------------------------------------------------------- */

/* A band under the tabs; its bottom border separates it from the page body,
   where the attention banners lead. */
.health-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.health-cell {
  flex: 1 1 7rem;
  min-width: 7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

a.health-cell {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

a.health-cell:hover {
  border-color: var(--accent);
}

a.health-cell:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.health-cell.good {
  border-left-color: var(--ok);
}

.health-cell.warn {
  border-left-color: var(--warn);
}

.health-cell.bad {
  border-left-color: var(--danger);
}

.health-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.health-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* --- Planned changes (Reconciliation tab) --------------------------------- */

.section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.plan-note {
  font-size: 0.8rem;
  color: var(--text-faint);
  font-style: italic;
}

.plan-stat {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.plan-stat.warn {
  color: var(--warn);
  border-color: var(--warn-border);
}

.text-faint {
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* --- Timeline: DID event history ------------------------------------------ */

.did-history {
  margin-bottom: 0.75rem;
}

.did-history > .section-title {
  margin-bottom: 0.5rem;
}

/* Capped so a long chain never pushes the registry table off-screen. */
.did-history .timeline {
  max-height: 26rem;
  overflow-y: auto;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  box-shadow: var(--shadow-sm);
}

.history-item.status-completed,
.history-item.status-applied {
  border-left-color: var(--ok);
}

.history-item.status-failed,
.history-item.status-invalid {
  border-left-color: var(--danger);
}

.history-item.status-simulated,
.history-item.status-uncertain,
.history-item.status-cancelled,
.history-item.status-blocked,
.history-item.status-blocked_unmanaged {
  border-left-color: var(--warn);
}

.history-item.status-superseded,
.history-item.status-skipped,
.history-item.status-excluded {
  border-left-color: var(--text-faint);
}

.history-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: baseline;
}

.history-source {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 0.3rem;
}

.history-type {
  font-weight: 600;
}

.history-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-error {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--err);
  word-break: break-word;
}

nav.tabs {
  overflow-x: auto;
}
nav.tabs .tab {
  flex-shrink: 0;
  white-space: nowrap;
}
@media (max-width: 720px) {
  header {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0.75rem;
  }
  .brand img {
    height: 24px;
  }
  header h1 {
    flex: 1;
    min-width: 7rem;
  }
  .header-right {
    margin-left: 0;
    flex-wrap: wrap;
    gap: 0.6rem;
  }
  main,
  .health-strip {
    padding: 0.75rem;
  }
}

/* --- Sub-tabs, detail pages, status pills --------------------------------- */

.subtabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.subtab {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subtab:hover {
  color: var(--text);
}

.subtab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.subtab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 3px;
}

.subpanel > .section-title,
.detail-view > .section-title {
  margin-top: 1.5rem;
  margin-bottom: 0.35rem;
}

.detail-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.detail-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.back-link {
  color: var(--accent-hover);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.25rem;
}

.stat-row .plan-stat strong {
  color: var(--text);
}

.status-pill {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  white-space: nowrap;
}

.status-pill.status-live,
.status-pill.status-completed,
.status-pill.status-applied,
.status-pill.status-succeeded,
.status-pill.outcome-mapped {
  color: var(--ok);
  border-color: var(--ok);
}

.status-pill.status-failed,
.status-pill.status-invalid,
.status-pill.outcome-failed {
  color: var(--err);
  border-color: var(--err);
}

.status-pill.status-dry_run,
.status-pill.status-simulated,
.status-pill.status-blocked_unmanaged,
.status-pill.outcome-blocked_unmanaged {
  color: var(--warn);
  border-color: var(--warn-border);
}

.change-create {
  color: var(--ok);
  font-weight: 600;
}

.change-delete {
  color: var(--danger);
  font-weight: 600;
}

/* An attempt's evidence opens as a full-width row under the attempt. */
tbody > tr.evidence-row > td {
  white-space: normal;
  background: var(--surface-alt);
  padding: 0.75rem 1rem;
}

tbody > tr.evidence-row:hover {
  background: none;
}

.evidence .fields-grid {
  margin-bottom: 0.5rem;
}

.mini-table {
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.mini-table th,
.mini-table td {
  padding: 0.3rem 0.5rem;
}

.coverage-route {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.coverage-card > .section-title {
  margin-top: 0.75rem;
}

.coverage-card .hint {
  margin-bottom: 0.5rem;
}

/* The card leading the event and cycle pages: verdict and reason, then tiles. */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1.1rem 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.detail-card:empty {
  display: none;
}

/* Labelled values as tiles: label small and muted above its value. */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.fields-grid dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.fields-grid dd {
  margin: 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.fields-grid > .wide {
  grid-column: 1 / -1;
}

/* Page-head actions are full-size buttons, the same as Refresh beside them. */
.head-actions {
  display: flex;
  gap: 0.5rem;
}

.head-actions:empty {
  display: none;
}

/* An actions column hugs its buttons at the table's right edge. */
th.actions-col,
td.actions-col {
  width: 1%;
  white-space: nowrap;
}

.status-pill.status-observed {
  color: var(--ok);
  border-color: var(--ok);
}

/* Operator attention banners, first in the page body under the health strip. */
.attention-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
}

.attention-banner[hidden] {
  display: none;
}

.attention-banner a {
  color: var(--accent-hover);
  white-space: nowrap;
}

.warn-hint {
  border-left: 3px solid var(--warn);
  padding-left: 0.6rem;
  max-width: none;
}

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

.arrow {
  color: var(--text-faint);
  padding: 0 0.15rem;
}

.change-update {
  color: var(--accent-hover);
  font-weight: 600;
}

.status-pill.status-cleared,
.status-pill.status-excluded,
.status-pill.outcome-excluded,
.status-pill.status-cancelled,
.status-pill.status-blocked,
.status-pill.status-uncertain {
  color: var(--warn);
  border-color: var(--warn-border);
}

.svc-icon.status-mode_mismatch {
  color: var(--danger);
}

.action-list {
  margin: 0.25rem 0 1rem;
  padding-left: 1.2rem;
  color: var(--text-muted);
}

.action-list strong {
  color: var(--text);
}

/* Cycle stage stepper: Planned → Creates & Updates → Deletes → Settled. */
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
}

.stepper .stage {
  flex: 1 1 9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stepper .stage-name {
  font-weight: 600;
}

.stepper .stage-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stepper .stage-done {
  border-top-color: var(--ok);
}

.stepper .stage-current {
  border-top-color: var(--accent);
}

.stepper .stage-failed {
  border-top-color: var(--danger);
}

.stepper .stage-failed .stage-detail {
  color: var(--err);
}

.stepper .stage-pending,
.stepper .stage-skipped {
  opacity: 0.65;
}

.health-strip.unreachable {
  opacity: 0.75;
}
