/* ============================================================================
   Rule Approvals page (Rule Builder > My Submissions / Review queue) — styles
   Every class is prefixed ap-. Colours/fonts/radii come only from the tokens in
   styles.css :root, so the dark theme works without any overrides here.
   brand.css (loaded earlier) uppercases h1–h4 and <label>; the rule title and
   the logic-panel headings opt out with text-transform:none.
   ============================================================================ */

.ap-layout { padding-bottom: 48px; }

/* ── A. role bar ─────────────────────────────────────────────── */
.ap-layout .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.ap-rolebar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.ap-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ap-who-name { font-weight: 600; color: var(--ink); line-height: 1.25; }
.ap-who-role { font-size: 0.82rem; color: var(--ink-2); }
.ap-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border);
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em; line-height: 1;
}
.ap-avatar--lg { width: 40px; height: 40px; font-size: 0.85rem; }
.ap-preview {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 5px 6px 5px 14px; border: 1px dashed var(--border-strong); border-radius: 999px;
  background: var(--surface-1);
}
.ap-preview-label { font-size: 0.74rem; color: var(--ink-3); font-weight: 500; }
.ap-seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-3); border-radius: 999px; }
.ap-seg-btn {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
}
.ap-seg-btn:hover { color: var(--ink); }
.ap-seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.ap-seg-btn:focus-visible, .ap-tab:focus-visible, .ap-row:focus-visible,
.ap-btn-reject:focus-visible, .ap-textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* A. who is signed in (the old preview switch is gone: role = permissions) */

/* ── B. stats ───────────────────────────────────────────────── */
.ap-stats { margin-bottom: 20px; }
.ap-stat:hover { transform: none; }

/* ── C. grid ────────────────────────────────────────────────── */
.ap-grid { display: grid; grid-template-columns: 436px minmax(0, 1fr); gap: 20px; align-items: start; }
.ap-queue {
  position: sticky; top: 16px; display: flex; flex-direction: column; min-height: 0;
  max-height: calc(100vh - 68px - 32px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ap-tabs {
  display: flex;
  gap: 4px;
  padding: 0 10px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  overflow: hidden !important;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
  scrollbar-width: none !important;
  box-sizing: border-box;
}
.ap-tabs::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
.ap-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
  height: 100%;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 4px;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ap-tab:hover { color: var(--ink); }
.ap-tab[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.ap-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  text-align: center;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
  flex-shrink: 0;
}
.ap-tab[aria-pressed="true"] .ap-chip { background: var(--accent-soft); color: var(--accent); }
.ap-queue-tools { display: flex; gap: 8px; padding: 12px 12px 10px; }
.ap-queue .ap-search { min-width: 0; flex: 1; padding: 8px 12px; font-size: 0.84rem; }
.ap-queue .ap-sort { flex: none; max-width: 130px; }
.ap-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 2px; }

.ap-row {
  display: flex; flex-direction: column; gap: 5px; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--ink); font: inherit;
  padding: 11px 12px; border-radius: var(--radius); cursor: pointer;
}
.ap-row:hover { background: var(--surface-1); }
.ap-row:focus-visible { outline-offset: -2px; }
.ap-row.is-selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-border); }
.ap-row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ap-row-name { font-weight: 600; font-size: 0.9rem; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; flex: 0 1 auto; }
.ap-row-warn { display: inline-flex; color: var(--warn); margin-left: auto; flex: none; }
.ap-ver {
  flex: none; font-size: 0.66rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--note-soft); color: var(--note); border: 1px solid var(--note-border);
}
.ap-ver--lg { font-size: 0.7rem; padding: 3px 10px; }
.ap-row-sum {
  font-size: 0.8rem; color: var(--ink-2); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ap-row-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.74rem; color: var(--ink-3); }
.ap-row-author { color: var(--ink-2); }
.ap-age { margin-left: auto; font-variant-numeric: tabular-nums; }
.ap-age.is-old { color: var(--warn); font-weight: 600; }

.ap-empty { padding: 28px 20px; text-align: center; }
.ap-empty-title { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.ap-empty-text { margin: 0; font-size: 0.84rem; color: var(--ink-2); }
.ap-empty-btn { margin: 14px auto 0; }

/* ── detail card ────────────────────────────────────────────── */
.ap-detail { min-width: 0; }
.ap-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.ap-card--empty { padding: 56px 24px; text-align: center; }
.ap-sec { padding: 22px 28px; border-top: 1px solid var(--border); }
.ap-sec:first-child { border-top: 0; }
.ap-sec--flush { padding: 0; border-top: 0; }
.ap-head { display: flex; flex-direction: column; gap: 12px; }
.ap-head-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-title {
  margin: 0; font-family: var(--font-sans); font-size: 1.55rem; font-weight: 600; letter-spacing: 0;
  text-transform: none; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere;
}
.ap-byline { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--ink-2); }
.ap-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid;
}
.ap-status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ap-status--pending  { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.ap-status--approved { background: var(--pos-soft);  color: var(--pos);  border-color: var(--pos-border); }
.ap-status--rejected { background: var(--neg-soft);  color: var(--neg);  border-color: var(--neg-border); }

.ap-sec-title { margin: 0 0 12px; font-size: 0.72rem; color: var(--ink-3); }

/* decision banner */
.ap-banner { display: flex; gap: 12px; padding: 16px 28px; border-top: 1px solid; border-bottom: 1px solid; }
.ap-banner--pos { background: var(--pos-soft); border-color: var(--pos-border); color: var(--pos); }
.ap-banner--neg { background: var(--neg-soft); border-color: var(--neg-border); color: var(--neg); }
.ap-banner-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid currentColor; }
.ap-banner-body { min-width: 0; }
.ap-banner-title { margin: 0; font-weight: 600; }
.ap-banner-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 0.86rem; }
.ap-resubmit { margin-top: 12px; }
.ap-note-quote {
  margin: 10px 0 0; padding: 4px 0 4px 12px; border-left: 3px solid var(--border-strong);
  color: var(--ink); font-size: 0.88rem; line-height: 1.5;
}

/* what it does */
.ap-summary { margin: 0 0 14px; font-size: 1rem; line-height: 1.55; color: var(--ink); }
.ap-quote { margin: 0; padding: 12px 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.ap-quote blockquote { margin: 0; font-size: 0.9rem; line-height: 1.5; color: var(--ink); }
.ap-quote figcaption { margin-top: 6px; font-size: 0.74rem; color: var(--ink-3); }

/* logic */
.ap-logic { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ap-panel { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); min-width: 0; }
.ap-panel--when { background: var(--surface-1); }
.ap-panel--then { background: var(--accent-soft); border-color: var(--accent-border); }
.ap-panel-title { margin: 0 0 10px; font-size: 0.82rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink-2); }
.ap-conds, .ap-acts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ap-conds li { font-size: 0.88rem; color: var(--ink); line-height: 1.7; overflow-wrap: anywhere; }
.ap-field { font-weight: 600; }
.ap-op { color: var(--ink-3); }
.ap-val {
  display: inline-block; font-family: var(--font-mono); font-size: 0.8rem; padding: 1px 8px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--ink);
}
.ap-every { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.ap-muted { margin: 0; font-size: 0.84rem; color: var(--ink-2); }
.ap-acts li { font-size: 0.95rem; color: var(--ink); line-height: 1.5; }
.ap-act-val { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }
.ap-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 20px; margin: 18px 0 0; }
.ap-facts dt { font-size: 0.72rem; color: var(--ink-3); margin-bottom: 2px; }
.ap-facts dd { margin: 0; font-size: 0.88rem; color: var(--ink); overflow-wrap: anywhere; }
.ap-mono { font-family: var(--font-mono); }

/* checks */
.ap-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ap-check { display: flex; gap: 12px; }
.ap-check-ico {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1px solid;
  display: inline-flex; align-items: center; justify-content: center;
}
.ap-check--pass    .ap-check-ico { background: var(--pos-soft);  color: var(--pos);  border-color: var(--pos-border); }
.ap-check--warn    .ap-check-ico { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.ap-check--info    .ap-check-ico { background: var(--note-soft); color: var(--note); border-color: var(--note-border); }
.ap-check--neutral .ap-check-ico { background: var(--surface-2); color: var(--ink-3); border-color: var(--border-strong); }
.ap-check-body { min-width: 0; }
.ap-check-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ap-check-title { font-weight: 600; color: var(--ink); }
.ap-check-state { font-size: 0.74rem; font-weight: 700; }
.ap-check--pass .ap-check-state { color: var(--pos); }
.ap-check--warn .ap-check-state { color: var(--warn); }
.ap-check--info .ap-check-state { color: var(--note); }
.ap-check--neutral .ap-check-state { color: var(--ink-3); }
.ap-check-text { margin: 2px 0 0; font-size: 0.86rem; color: var(--ink-2); line-height: 1.5; }
.ap-conflict {
  margin-top: 8px; padding: 10px 12px; font-size: 0.86rem; line-height: 1.5; color: var(--ink);
  background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: var(--radius-sm);
}

/* activity */
.ap-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.ap-timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.ap-timeline li:last-child { padding-bottom: 0; }
.ap-timeline li:not(:last-child)::before {
  content: ''; position: absolute; left: 9px; top: 20px; bottom: 0; width: 2px; background: var(--border);
}
.ap-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.ap-dot--ring { border: 2px solid var(--border-strong); background: var(--surface); }
.ap-dot--pos { background: var(--pos); color: var(--surface); }
.ap-dot--neg { background: var(--neg); color: var(--surface); }
.ap-tl-body { min-width: 0; }
.ap-tl-body p { margin: 0; font-size: 0.86rem; color: var(--ink-2); line-height: 1.5; }
.ap-tl-body b { color: var(--ink); font-weight: 600; }

/* activity: one block per version */
.ap-dot { box-sizing: border-box; }
.ap-dot--info { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.ap-dot--wait { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.ap-dot--mute { background: var(--surface-1); color: var(--ink-3); border: 1px solid var(--border-strong); }

.ap-rd { padding: 14px 16px 16px; background: var(--surface); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); }
.ap-rd--solo { padding: 0; background: transparent; border: 0; border-radius: 0; }
.ap-rd--pos  { border-left-color: var(--pos); }
.ap-rd--neg  { border-left-color: var(--neg); }
.ap-rd--warn { border-left-color: var(--warn); }
.ap-rd--mute { border-left-color: var(--border-strong); }
.ap-rd-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.ap-rd-ver { font-size: 0.84rem; font-weight: 700; color: var(--ink); }
.ap-rd-now { margin-left: auto; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.ap-st { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; border: 1px solid var(--border-strong); color: var(--ink-2); background: var(--surface-1); }
.ap-st--pos  { color: var(--pos);  background: var(--pos-soft);  border-color: var(--pos-border); }
.ap-st--neg  { color: var(--neg);  background: var(--neg-soft);  border-color: var(--neg-border); }
.ap-st--warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-border); }

.ap-tl-time { color: var(--ink-3); }
.ap-tl-body p.ap-tl-sub { margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.76rem; color: var(--ink-3); }
.ap-tl-pill { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; color: var(--ink-2); background: var(--surface-1); border: 1px solid var(--border); }
.ap-tl-note {
  margin: 8px 0 0; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 0.88rem; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-1); border: 1px solid var(--border);
}
.ap-tl-note--neg { background: var(--neg-soft); border-color: var(--neg-border); }
.ap-tl-note--pos { background: var(--pos-soft); border-color: var(--pos-border); }
.ap-tl-note-label { display: block; margin-bottom: 2px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }

/* what changed */
.ap-chg { margin-top: 8px; }
.ap-chg > summary, .ap-earlier > summary { list-style: none; cursor: pointer; }
.ap-chg > summary::-webkit-details-marker, .ap-earlier > summary::-webkit-details-marker { display: none; }
.ap-chg > summary { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 600; color: var(--accent); }
.ap-chg > summary::before, .ap-earlier > summary::before { content: '\25B8'; font-size: 0.72rem; transition: transform 0.15s ease; }
.ap-chg[open] > summary::before, .ap-earlier[open] > summary::before { transform: rotate(90deg); }
.ap-chg-n { font-weight: 500; color: var(--ink-3); }
.ap-chg-n::before { content: '\00B7'; margin-right: 8px; }
.ap-chg-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ap-chg-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; align-items: baseline; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.84rem; line-height: 1.45; }
.ap-chg-tag { padding: 0 7px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; border: 1px solid var(--border-strong); color: var(--ink-2); }
.ap-chg-tag--changed { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-border); }
.ap-chg-tag--added   { color: var(--pos);  background: var(--pos-soft);  border-color: var(--pos-border); }
.ap-chg-tag--removed { color: var(--neg);  background: var(--neg-soft);  border-color: var(--neg-border); }
.ap-chg-what { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.ap-chg-vals { grid-column: 2; color: var(--ink-2); overflow-wrap: anywhere; }
.ap-chg-vals del {
  color: var(--ink-2); text-decoration: none; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.ap-chg-vals ins { color: var(--pos); font-weight: 600; text-decoration: none; }
.ap-chg-none { margin: 8px 0 0; font-size: 0.84rem; color: var(--ink-2); }

/* earlier versions fold */
.ap-earlier { margin-top: 14px; }
.ap-earlier > summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 0.84rem; font-weight: 600; color: var(--ink-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.ap-earlier > summary:hover { color: var(--ink); border-color: var(--ink-3); }
.ap-earlier-n { margin-left: auto; font-weight: 500; font-size: 0.78rem; color: var(--ink-3); }
.ap-earlier-body { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.ap-chg > summary:focus-visible, .ap-earlier > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .ap-chg > summary::before, .ap-earlier > summary::before { transition: none; } }

/* decision bar */
.ap-bar {
  position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end;
  padding: 16px 28px; background: var(--surface); border-top: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.ap-bar--readonly { align-items: center; background: var(--surface-1); }
.ap-bar-msg { margin: 0; font-size: 0.88rem; color: var(--ink-2); }
.ap-bar-msg b { color: var(--ink); }
.ap-bar-note label { display: block; margin-bottom: 6px; font-size: 0.72rem; color: var(--ink-3); }
.ap-textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 54px; padding: 9px 12px;
  font: inherit; font-size: 0.88rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.ap-textarea::placeholder { color: var(--ink-3); }
.ap-textarea[aria-invalid="true"] { border-color: var(--neg); }
.ap-error { margin: 6px 0 0; font-size: 0.82rem; font-weight: 600; color: var(--neg); }
.ap-error[hidden] { display: none; }
.ap-bar-actions { display: flex; gap: 10px; align-items: center; }
.ap-btn-reject {
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--neg); background: transparent;
  color: var(--neg); font: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ap-btn-reject:hover { background: var(--neg-soft); }

/* ── sidebar badge: warn on surface, in every sidebar state ──────
   unified.css gives .no-bid-badge red styling (incl. !important rules for the
   active tab and the collapsed dot). This badge is amber, so re-state them. */
.no-bid-badge.ap-nav-badge {
  background: var(--warn); color: var(--surface); border: 1px solid var(--warn); animation: none;
}
.sidebar-nav .tab-btn.active .no-bid-badge.ap-nav-badge {
  background: var(--warn) !important; color: var(--surface) !important; border-color: var(--surface) !important;
}
.app-layout.sidebar-collapsed .no-bid-badge.ap-nav-badge,
.app-layout.sidebar-collapsed .sidebar-nav .tab-btn.active .no-bid-badge.ap-nav-badge {
  background: var(--warn) !important; color: transparent !important; border: 2px solid var(--surface) !important;
}

/* ── responsive ─────────────────────────────────────────────── */
@media (max-width: 1099px) {
  .ap-grid { grid-template-columns: minmax(0, 1fr); }
  .ap-queue { position: static; max-height: 420px; }
}
@media (max-width: 719px) {
  .ap-layout.db-layout { padding: 16px; }
  .ap-sec { padding: 18px 16px; }
  .ap-banner { padding: 14px 16px; }
  .ap-logic { grid-template-columns: 1fr; }
  .ap-bar { grid-template-columns: 1fr; padding: 14px 16px; }
  .ap-bar-actions { justify-content: flex-end; flex-wrap: wrap; }
  .ap-title { font-size: 1.3rem; }
  .ap-preview { border-radius: var(--radius); }
}
@media (prefers-reduced-motion: reduce) { .no-bid-badge.ap-nav-badge { animation: none; } }

/* ── additions for live data ─────────────────────────────────── */
.ap-branch + .ap-branch { margin-top: 18px; }
.ap-branch-title { margin: 0 0 8px; font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.ap-join { margin: 8px 0 0; font-size: 0.8rem; color: var(--ink-3); }
.ap-join b { color: var(--ink-2); }
.ap-subgroup { list-style: none; margin-top: 4px; padding: 8px 0 0 12px; border-left: 2px solid var(--border-strong); }
.ap-subgroup-label { display: block; margin-bottom: 4px; font-size: 0.76rem; font-weight: 600; color: var(--ink-3); }
.ap-subgroup .ap-conds { margin: 0; }
.ap-bar button:disabled { opacity: 0.6; cursor: progress; }
/* ── conflict snapshot + Stack up / Override requests ─────────── */
.ap-req-chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.66rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.ap-req-chip--pending  { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.ap-req-chip--applied  { background: var(--pos-soft);  color: var(--pos);  border-color: var(--pos-border); }
.ap-req-chip--rejected,
.ap-req-chip--withdrawn { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-border); }

.ap-req { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid; border-radius: var(--radius); }
.ap-req--warn { background: var(--warn-soft); border-color: var(--warn-border); }
.ap-req--pos  { background: var(--pos-soft);  border-color: var(--pos-border); }
.ap-req--neg  { background: var(--neg-soft);  border-color: var(--neg-border); }
.ap-req-ico {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid currentColor;
  display: inline-flex; align-items: center; justify-content: center;
}
.ap-req--warn .ap-req-ico, .ap-req--warn .ap-req-title { color: var(--warn); }
.ap-req--pos  .ap-req-ico, .ap-req--pos  .ap-req-title { color: var(--pos); }
.ap-req--neg  .ap-req-ico, .ap-req--neg  .ap-req-title { color: var(--neg); }
.ap-req-body { min-width: 0; }
.ap-req-title { margin: 0; font-weight: 600; }
.ap-req-sub { margin: 2px 0 0; font-size: 0.86rem; color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }

.ap-conflict-mini { margin: 8px 0 0; padding: 0 0 0 18px; font-size: 0.86rem; color: var(--ink); line-height: 1.6; }
.ap-see-conflicts { margin-top: 10px; }

.ap-cf { position: fixed; inset: 0; z-index: 9500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.ap-cf-scrim { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.ap-cf-panel {
  position: relative; display: flex; flex-direction: column; width: min(720px, 100%); max-height: calc(100vh - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg, var(--shadow-sm));
}
.ap-cf-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.ap-cf-title { margin: 0; font-family: var(--font-sans); font-size: 1.05rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink); overflow-wrap: anywhere; }
.ap-cf-x { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); display: inline-flex; }
.ap-cf-x:hover { background: var(--surface-1); color: var(--ink); }
.ap-cf-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-cf-body { padding: 16px 22px; overflow-y: auto; }
.ap-cf-intro { margin: 0 0 8px; font-size: 0.86rem; color: var(--ink-2); }
.ap-cf-choice { margin: 0 0 12px; font-size: 0.86rem; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ap-cf-choice b { color: var(--ink); }
.ap-cf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ap-cf-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.ap-cf-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-cf-name { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.ap-cf-tag { font-size: 0.66rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid; }
.ap-cf-tag--duplicate { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-border); }
.ap-cf-tag--conflict, .ap-cf-tag--overlap { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.ap-cf-sum { margin: 6px 0 0; font-size: 0.86rem; color: var(--ink); line-height: 1.5; }
.ap-cf-note { margin: 4px 0 0; font-size: 0.82rem; color: var(--ink-2); line-height: 1.5; }
.ap-cf-meta { margin: 8px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.76rem; color: var(--ink-3); }
.ap-cf-foot { display: flex; justify-content: flex-end; padding: 12px 22px; border-top: 1px solid var(--border); }
@media (max-width: 719px) {
  .ap-cf { padding: 0; align-items: flex-end; }
  .ap-cf-panel { max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .ap-cf-top, .ap-cf-body, .ap-cf-foot { padding-left: 16px; padding-right: 16px; }
}

/* refresh button in the role bar */
.ap-refresh { display: inline-flex; align-items: center; gap: 6px; }
.ap-refresh.is-busy svg { animation: ap-spin 0.8s linear infinite; }
@keyframes ap-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ap-refresh.is-busy svg { animation: none; } }
.ap-resubmit-form { margin-top: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--ink); }
.ap-resubmit-fields { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.ap-resubmit-fields label { display: block; margin-bottom: 4px; font-size: 0.72rem; color: var(--ink-3); }
.ap-date { padding: 8px 10px; font: inherit; font-size: 0.86rem; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.ap-date:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-resubmit-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ap-bar button:disabled, .ap-resubmit-form button:disabled { opacity: 0.6; cursor: progress; }

/* ── review workflow (request changes, diff, conversation) ───────── */
.ap-status--changes_requested { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.ap-banner--warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.ap-banner-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ap-banner-actions .btn-ghost { color: var(--ink); background: var(--surface); margin: 0; }
.ap-banner-actions .btn-primary { margin: 0; }
.ap-banner-actions button:disabled { opacity: 0.6; cursor: progress; }
.ap-row-top .ipe-dot { margin-right: -2px; }
.ap-row-comments { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-2); }
.ap-sec-headrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ap-sec-headrow .ap-sec-title { margin: 0; }
.ap-full > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; margin: 0; }
.ap-full > summary::-webkit-details-marker { display: none; }
.ap-full > summary::before { content: '▸'; font-size: 0.8rem; transition: transform 0.15s ease; }
.ap-full[open] > summary::before { transform: rotate(90deg); }
.ap-full > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-full-body { margin-top: 12px; }
.ap-btn-changes { color: var(--warn); border-color: var(--warn-border); font-weight: 600; white-space: nowrap; }
.ap-btn-changes:hover { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.ap-btn-batch { white-space: nowrap; }
.ap-bar-actions { flex-wrap: wrap; justify-content: flex-end; }
.ap-bar { grid-template-columns: minmax(0, 1fr); }
.ap-anchored { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--note-soft); border: 1px solid var(--note-border); }
.ap-anchored-head { margin: 0 0 6px; font-size: 0.78rem; color: var(--ink-2); }
.ap-anchored ul { margin: 0; padding-left: 18px; font-size: 0.84rem; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.ap-anchored-label { font-weight: 600; color: var(--note); }
.ap-link {
  border: 0; background: transparent; padding: 0; color: var(--accent); font: inherit; font-weight: 600;
  text-decoration: underline; cursor: pointer;
}
.ap-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-rs-reply { margin-bottom: 8px; }
.ap-rs-reply label { display: block; margin-bottom: 4px; font-size: 0.72rem; color: var(--ink-3); }
.ap-conds li, .ap-acts li { position: relative; }

/* ── Reusable button loading state ─────────────────────────────── */
.btn-loading {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  box-sizing: border-box !important;
  opacity: 0.9 !important;
}

.btn-loading .btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  box-sizing: border-box;
  animation: btn-spin 0.75s linear infinite;
  flex-shrink: 0;
  vertical-align: middle;
}

@keyframes btn-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}



/* ── Page heading: the view tabs ARE the heading ─────────────────────────────
   "Rule approvals" | "Rate suggestions" (the second only for users who have
   it), set smaller than the Rule Builder pill tabs above (.ipe-tab, 11.5px) so
   the pill bar stays the primary navigation. One line of explanation under it;
   Refresh on the right. Shared by rate_suggestions.html. */
#rb-sub-submissions .ap-layout { padding-top: 24px; } /* + .rb-subtabs margin = 40px below the pill bar */
.ap-heading { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ap-viewtabs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 24px; }
.ap-viewtab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 0 6px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
  font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  line-height: 1.2; text-transform: uppercase; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.ap-viewtab:hover { color: var(--ink); }
.ap-viewtab.active, .ap-viewtab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.ap-viewtab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-viewtab-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 10px; font-weight: 700; letter-spacing: 0; line-height: 1;
}
.ap-viewtab-count[hidden] { display: none; }
.ap-subtitle { margin: 0; font-size: 0.78rem; line-height: 1.45; color: var(--ink-2); }
.ap-rolebar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-left: auto; }
.ap-rolebar-right .ap-refresh { height: 40px; padding: 0 14px; font-size: 0.8rem; }
@media (max-width: 760px) {
  .ap-viewtabs { gap: 4px 16px; }
  .ap-rolebar-right { margin-left: 0; }
}

/* ── "What changed" Field Diff Component ───────────────────────────────────── */
.ap-field-diff {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ap-diff-headbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ap-diff-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.ap-diff-against-text {
  font-size: 0.8rem;
  color: var(--ink-2);
}
.ap-diff-empty {
  padding: 16px;
  background: var(--surface-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.ap-diff-empty .ap-muted {
  margin: 0;
  font-size: 0.86rem;
}
.ap-diff-card {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ap-diff-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ap-diff-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
}
.ap-diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.3;
  flex-shrink: 0;
}
.ap-diff-badge--added {
  background: rgba(16, 185, 129, 0.12);
  color: var(--pos, #10b981);
  border: 1px solid rgba(16, 185, 129, 0.28);
}
.ap-diff-badge--removed {
  background: rgba(239, 68, 68, 0.12);
  color: var(--neg, #ef4444);
  border: 1px solid rgba(239, 68, 68, 0.28);
}
.ap-diff-badge--modified {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn, #f59e0b);
  border: 1px solid rgba(245, 158, 11, 0.28);
}
.ap-diff-card-badges {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ap-diff-source-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
}
.ap-diff-source-tag--live {
  background: var(--surface-3, #f3f4f6);
  color: var(--ink-2, #4b5563);
  border: 1px solid var(--border, #d1d5db);
}
.ap-diff-source-tag--both {
  background: var(--warn-soft, rgba(245, 158, 11, 0.12));
  color: var(--warn, #b45309);
  border: 1px solid var(--warn-border, rgba(245, 158, 11, 0.3));
}
.ap-diff-card-body {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ap-diff-before, .ap-diff-before-box {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: var(--ink-2);
  font-size: 0.85rem;
  word-break: break-word;
}
.ap-diff-after, .ap-diff-after-box {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.22);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.85rem;
  word-break: break-word;
}
.ap-diff-strike {
  opacity: 0.85;
}
.ap-diff-arrow {
  flex: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-3);
  user-select: none;
}
.ap-diff-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.ap-diff-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ap-diff-item-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.ap-diff-unchanged-note {
  margin: 6px 0 0 2px;
  font-size: 0.76rem;
  color: var(--ink-3);
  font-style: italic;
}

/* Skeleton loader for diff area */
.ap-diff-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}
.ap-diff-skel-line {
  height: 48px;
  border-radius: var(--radius);
  background: var(--surface-2);
  animation: ap-diff-pulse 1.4s ease-in-out infinite;
}
@keyframes ap-diff-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.25; }
}

@media (max-width: 640px) {
  .ap-diff-card-body, .ap-diff-item-pair {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .ap-diff-arrow {
    text-align: center;
    transform: rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ap-diff-skel-line {
    animation: none;
    opacity: 0.45;
  }
}