/* AutoRef Manager application chrome — the authoritative shell CSS.
   Fixed top bar / nav rail / status bar, table rows, toolbars, segmented
   controls, panels. Depends on css/autoref.css tokens; load that first.
   Chrome dimensions (--rail-w, --sidebar-w, --topbar-h, --statusbar-h) come
   from tokens/spacing.css — never redeclare them here or in app code. */
/* AutoRef Manager — application stylesheet.
   Every value resolves to an AutoRef design-system token. No new colours. */

*, *::before, *::after { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font: var(--type-body-sm);
  color: var(--text-body);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--text-link-hover); text-decoration: underline; }

:root {
  --text-brand-contrast: var(--red-500);
  /* One multiplier drives text size and row height together, so a larger setting
     stays legible instead of clipping. */
  --ui-scale: 1;
  --fs-body: calc(13px * var(--ui-scale));
  --fs-sm: calc(12px * var(--ui-scale));
  --fs-label: calc(11px * var(--ui-scale));
  --row-h: calc(28px * var(--ui-scale));
  --topbar-h: 52px;
  --statusbar-h: 26px;
}
[data-density='comfortable'] { --row-h: calc(34px * var(--ui-scale)); }
[data-text-scale='1'] { --ui-scale: 1.12; font-size: 14px; }
[data-text-scale='2'] { --ui-scale: 1.25; font-size: 15px; }

/* Dark theme. The raw paper scale is remapped too — any surface built from
   --paper-N must invert with the semantic tokens or its text flips out of contrast. */
[data-theme='dark'] {
  --paper-0: #1e1e1e;
  --paper-1: #141414;
  --paper-2: #262626;
  --paper-3: #333333;
  --paper-4: #3d3d3d;

  --surface-page: #141414;
  --surface-card: #1e1e1e;
  --surface-sunken: #262626;
  --surface-canvas: #141414;
  --surface-disabled: #2b2b2b;
  --surface-hover: rgba(255,255,255,.06);
  --surface-active: rgba(255,255,255,.12);
  --surface-brand-subtle: #3a1414;

  --text-primary: #f5f5f4;
  --text-body: #e4e4e2;
  --text-secondary: #b0b0b0;
  --text-muted: #8a8a8a;
  --text-inverse: #ffffff; /* chrome ink — charcoal bars exist in both themes */
  --text-brand: var(--red-300);
  --text-brand-contrast: var(--red-300);
  --text-link: var(--red-300);
  --text-link-hover: var(--red-200);
  --text-danger: var(--red-300);

  /* Status hues lighten so they read on charcoal; their tint backgrounds darken. */
  --green-500: #6bbf90; --green-100: #16291f;
  --amber-500: #e0a350; --amber-100: #33240d;
  --blue-500: #79b0dd;  --blue-100: #132534;
  --red-50: #2e1111; --red-100: #3a1414; --red-200: #5a1d1d; --red-700: #e08585; --red-800: #eaa1a1;

  --line-default: #3a3a3a;
  --line-hairline: #2c2c2c;
  --line-strong: #b8b8b8;
}


.ar-app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0,1fr) auto; height: 100%; min-height: 0; }
.ar-body { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 0; }
.ar-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* ---- Top bar ---- */
.ar-topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px; min-width: 0;
  background: var(--surface-chrome); color: var(--text-inverse);
  border-bottom: 1px solid var(--line-chrome);
}
/* Brand mark. The reversed monogram asset from the design system, never re-drawn as type.
   It sits directly on the charcoal bar with clear space, not inside a coloured chip. */
.ar-mark { display: grid; place-items: center; height: 26px; padding: 0 4px; flex: none; }
.ar-mark img { height: 20px; width: auto; display: block; }
.ar-topbar > * { min-width: 0; }
.ar-pill {
  display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; min-width: 0;
  background: transparent; border: 1px solid var(--line-chrome); border-radius: 2px;
  color: var(--text-inverse); cursor: pointer; max-width: 240px;
}
.ar-pill:hover { background: var(--surface-hover-inverse); }
.ar-pill__k { font: var(--type-label); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--ink-200); flex: none; }
.ar-pill__v { font: 600 12px/1.2 var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-topbar__spacer { flex: 1; }
.ar-search {
  display: flex; align-items: center; gap: 6px; height: 32px; min-width: 0; max-width: 420px; flex: 1 1 160px;
  background: var(--ink-900); border: 1px solid var(--line-chrome); border-radius: 2px; padding: 0 8px; color: var(--ink-200);
}
.ar-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text-inverse); font-size: 12px; }
.ar-search input::placeholder { color: var(--ink-300); }
.ar-signal { display: flex; align-items: center; gap: 6px; padding: 0 8px; height: 32px; white-space: nowrap; background: transparent; color: var(--text-inverse); border: 1px solid var(--line-chrome); border-radius: 2px; cursor: pointer; }
.ar-signal:hover { background: var(--surface-hover-inverse); }
.ar-avatar { width: 32px; height: 32px; border-radius: 2px; background: var(--ink-600); color: var(--text-inverse); display: grid; place-items: center; font: var(--type-mono-sm); cursor: pointer; border: 1px solid var(--line-chrome); }

/* ---- Offline / notice banner ---- */
.ar-banner {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  font: var(--type-body-sm); border-bottom: 1px solid var(--line-default);
}
.ar-banner--offline { background: var(--amber-100); color: var(--text-primary); }
.ar-banner--danger { background: var(--red-50); color: var(--red-800); }

/* ---- Nav rail ---- */
.ar-rail {
  background: var(--surface-chrome-sunken); border-right: 1px solid var(--line-chrome);
  display: flex; flex-direction: column; align-items: stretch; padding: 6px 5px; gap: 2px;
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
}
.ar-rail__btn {
  width: 100%; flex: none; min-height: 44px; display: grid; justify-items: center; align-content: center; gap: 3px;
  padding: 5px 4px; border-radius: 2px;
  background: none; border: 0; color: var(--ink-200); cursor: pointer; position: relative;
}
.ar-rail__label {
  font-family: Archivo, sans-serif; font-size: 10px; font-weight: 600; line-height: 1;
  letter-spacing: .02em; text-align: center; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ar-rail__btn:hover { background: var(--surface-hover-inverse); color: var(--text-inverse); }
.ar-rail__btn[aria-current='true'] { color: var(--text-inverse); background: var(--ink-700); }
.ar-rail__btn[aria-current='true']::before {
  content: ''; position: absolute; left: -5px; top: 6px; bottom: 6px; width: 2px; background: var(--red-500);
}
.ar-rail__spacer { flex: 1; }

/* ---- Status bar ---- */
.ar-statusbar {
  height: var(--statusbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--surface-chrome); border-top: 1px solid var(--line-chrome);
  color: var(--ink-200); font: var(--type-mono-sm); letter-spacing: var(--tracking-mono);
  overflow: hidden; white-space: nowrap;
}
.ar-statusbar b { color: var(--text-inverse); font-weight: 600; }
.ar-statusbar__spacer { flex: 1; }

/* ---- Generic bits ---- */
.ar-label { font: var(--type-label); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-secondary); }
.ar-mono { font: var(--type-mono); font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-mono); }
.ar-mono-sm { font: var(--type-mono-sm); font-variant-numeric: tabular-nums; }
.ar-muted { color: var(--text-secondary); }
.ar-h3 { font: var(--type-h3); color: var(--text-primary); margin: 0; letter-spacing: var(--tracking-tight); }
.ar-h4 { font: var(--type-h4); color: var(--text-primary); margin: 0; }
.ar-hr { height: 1px; background: var(--line-default); border: 0; margin: 0; }
.ar-row { display: flex; align-items: center; gap: 8px; }
.ar-col { display: flex; flex-direction: column; min-height: 0; }
.ar-scroll { overflow: auto; min-height: 0; }
.ar-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Buttons ---- */
.ar-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-default); border-radius: var(--radius-1, 2px);
  background: var(--surface-card); color: var(--text-primary); cursor: pointer;
  font: 500 13px/1 var(--font-sans); white-space: nowrap;
}
.ar-btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--line-strong); }
.ar-btn:active:not(:disabled) { transform: translateY(1px); background: var(--surface-active); }
.ar-btn:disabled { background: var(--surface-disabled); color: var(--text-muted); cursor: not-allowed; border-color: var(--line-default); }
.ar-btn--primary { background: var(--surface-brand); border-color: var(--surface-brand); color: var(--text-inverse); font-weight: 600; }
.ar-btn--primary:hover:not(:disabled) { background: var(--surface-brand-hover); border-color: var(--surface-brand-hover); }
.ar-btn--primary:disabled { background: var(--surface-disabled); border-color: var(--line-default); color: var(--text-muted); }
.ar-btn--ghost { background: transparent; border-color: transparent; }
.ar-btn--ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: transparent; }
.ar-btn--danger { color: var(--text-danger); border-color: var(--red-200); }
.ar-btn--lg { height: 40px; padding: 0 18px; font-size: 14px; }
.ar-btn--sm { height: calc(26px * var(--ui-scale)); padding: 0 8px; font-size: var(--fs-sm); }
.ar-btn--full { width: 100%; justify-content: center; }
/* inverse = on charcoal chrome, the variant the design system defines for the top bar and rail. */
.ar-btn--inverse { background: transparent; color: var(--text-inverse); border-color: var(--line-chrome); }
.ar-btn--inverse:hover:not(:disabled) { background: var(--surface-hover-inverse); border-color: var(--line-chrome); }
.ar-iconbtn { width: 32px; padding: 0; justify-content: center; }
.ar-btn--sm.ar-iconbtn { width: 26px; }
.ar-btn--lg.ar-iconbtn { width: 40px; }
.ar-iconbtn[aria-pressed='true'] { background: var(--surface-brand-subtle); border-color: var(--red-200); color: var(--text-brand-contrast); }
.ar-spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ar-spin 700ms linear infinite; }
@keyframes ar-spin { to { transform: rotate(360deg); } }

:focus-visible { outline: 2px solid var(--red-500); outline-offset: 1px; }

/* Text selection. The browser default lands red-on-red against brand-coloured ink,
   so both themes set it explicitly. */
::selection { background: var(--red-100); color: var(--ink-900); }
[data-theme='dark'] ::selection { background: #7a2a2a; color: #ffffff; }

/* ---- Inputs ---- */
.ar-input, .ar-select, .ar-textarea {
  height: 32px; padding: 0 9px; border: 1px solid var(--line-default); border-radius: 2px;
  background: var(--surface-card); color: var(--text-primary); font-size: var(--fs-body); width: 100%; min-width: 0;
}
.ar-textarea { height: auto; padding: 6px 8px; resize: vertical; font: var(--type-body-sm); }
.ar-input:focus, .ar-select:focus, .ar-textarea:focus { outline: 2px solid var(--red-500); outline-offset: -1px; border-color: var(--red-500); }
.ar-input:disabled, .ar-select:disabled { background: var(--surface-disabled); color: var(--text-muted); cursor: not-allowed; }
.ar-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ar-field__hint { font: var(--type-caption); color: var(--text-secondary); }
.ar-field__err { font: var(--type-caption); color: var(--text-danger); }
.ar-input--sm, .ar-select--sm { height: 26px; padding: 0 7px; font-size: 12px; }
.ar-input--lg, .ar-select--lg { height: 40px; padding: 0 12px; font-size: 14px; }
.ar-check { width: 14px; height: 14px; accent-color: var(--red-500); cursor: pointer; margin: 0; }

/* ---- Badges, dots, chips ---- */
.ar-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 18px; padding: 0 6px;
  border-radius: 2px; font: 600 var(--fs-label)/1 var(--font-sans); border: 1px solid transparent; white-space: nowrap;
}
.ar-badge--neutral { background: var(--surface-sunken); color: var(--text-body); border-color: var(--line-default); }
.ar-badge--brand { background: var(--surface-brand-subtle); color: var(--text-brand-contrast); }
.ar-badge--success { background: var(--green-100); color: var(--green-500); }
.ar-badge--warning { background: var(--amber-100); color: var(--amber-500); }
.ar-badge--info { background: var(--blue-100); color: var(--blue-500); }
.ar-badge--danger { background: var(--red-50); color: var(--red-700); }
/* variant: subtle (default) · outline · solid */
.ar-badge--outline { background: transparent; border-color: var(--line-default); }
.ar-badge--solid { background: var(--ink-700); color: var(--text-inverse); border-color: var(--line-chrome); }
.ar-badge--mono { font: var(--type-mono-sm); font-variant-numeric: tabular-nums; }
.ar-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: currentColor; }
.ar-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 4px 0 8px;
  background: var(--surface-sunken); border: 1px solid var(--line-default); border-radius: 2px;
  font-size: 12px; color: var(--text-primary); white-space: nowrap;
}
.ar-chip button { border: 0; background: none; cursor: pointer; color: var(--text-secondary); padding: 0 3px; line-height: 1; }
.ar-chip button:hover { color: var(--text-danger); }

/* ---- Toolbar / panel furniture ---- */
.ar-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; flex-wrap: wrap;
  background: var(--surface-card); border-bottom: 1px solid var(--line-default);
}
.ar-toolbar--sub { background: var(--surface-sunken); }
.ar-panelhead {
  height: 26px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--surface-sunken); border-bottom: 1px solid var(--line-default); flex: none;
}
.ar-card { background: var(--surface-card); border: 1px solid var(--line-default); border-radius: 3px; }
.ar-viewhead { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px 8px; }

/* ---- Table ---- */
.ar-tablewrap { position: relative; flex: 1; min-height: 0; overflow: auto; background: var(--surface-card); }
.ar-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.ar-table thead th {
  position: sticky; top: 0; z-index: 3; height: 26px; padding: 0 8px; text-align: left;
  background: var(--surface-sunken); border-bottom: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-default);
  font: var(--type-label); letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--text-secondary); user-select: none; white-space: nowrap;
}
.ar-table thead th button { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; letter-spacing: inherit; display: inline-flex; align-items: center; gap: 4px; }
.ar-table td {
  height: var(--row-h); padding: 0 8px; border-bottom: 1px solid var(--line-hairline);
  border-right: 1px solid var(--line-hairline); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: var(--fs-body); color: var(--text-body); background: var(--surface-card);
}
/* Rows are a selection surface, so dragging across them must not start a text selection.
   Editors and the expand panel keep normal text behaviour. */
.ar-table tbody { user-select: none; }
.ar-table tbody input, .ar-table tbody textarea, .ar-table tbody select { user-select: text; }
.ar-peek, .ar-peek textarea { user-select: text; }
.ar-table tr:hover td { background: var(--surface-hover); }
.ar-table tr[data-focused='true'] td { background: var(--surface-hover); }
/* Selection reads as a whole row: subtle brand fill plus a 2px red inline-start rule. */
.ar-table tr[data-selected='true'] td,
.ar-table tr[data-selected='true']:hover td { background: var(--surface-brand-subtle); }
.ar-table tr[data-selected='true'] td:first-child { box-shadow: inset 2px 0 0 var(--red-500); }
.ar-table tr[data-selected='true'][data-focused='true'] td { background: var(--surface-brand-subtle); }
.ar-table tr[data-archived='true'] td { color: var(--text-secondary); font-style: italic; }
.ar-table tr[data-provisional='true'] td { background: repeating-linear-gradient(135deg, var(--surface-card) 0 6px, var(--surface-sunken) 6px 12px); }
.ar-cell--pinned { position: sticky; z-index: 2; }
.ar-table thead th.ar-cell--pinned { z-index: 4; }
.ar-cell--focusmark { box-shadow: inset 2px 0 0 var(--red-500); }
.ar-cell--num { text-align: right; }
.ar-cell--mono { font: var(--type-mono); font-variant-numeric: tabular-nums; }
.ar-cell--id { direction: rtl; text-align: left; }
.ar-cell--id > span { direction: ltr; unicode-bidi: bidi-override; }
.ar-cell--editing { padding: 0; }
.ar-cell--editing input, .ar-cell--editing select, .ar-cell--editing textarea {
  width: 100%; height: calc(var(--row-h) - 1px); border: 0; outline: 2px solid var(--red-500); outline-offset: -2px;
  padding: 0 6px; background: var(--surface-card); color: var(--text-primary); font-size: var(--fs-body);
}
.ar-cell--dirty { box-shadow: inset 0 -2px 0 var(--amber-500); }
.ar-cell--error { box-shadow: inset 0 -2px 0 var(--red-500); }
.ar-resize { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; z-index: 5; }
.ar-th-inner { position: relative; display: flex; align-items: center; gap: 4px; height: 100%; }
.ar-tablefoot select.ar-select { height: 26px; min-width: 112px; padding: 0 6px; font-size: 11px; }
.ar-tablefoot {
  height: 30px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 10px;
  border-top: 1px solid var(--line-default); background: var(--surface-sunken);
  font: var(--type-mono-sm); color: var(--text-secondary); overflow: hidden; white-space: nowrap;
}
/* Metadata yields space; controls never do. Without this the counts push the
   pagination and rows-per-page control out of the visible strip. */
.ar-meta-run {
  display: flex; align-items: center; gap: 14px;
  flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap;
  mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent 100%);
}
.ar-ctl-run { display: flex; align-items: center; gap: 10px; flex: none; }
.ar-selbar {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px; flex-wrap: wrap;
  background: var(--surface-brand-subtle); border-bottom: 1px solid var(--red-200); font-size: 12px;
}

/* ---- Split layout with detail panel ---- */
.ar-split { display: grid; min-height: 0; flex: 1 1 auto; }
.ar-split > * { min-height: 0; min-width: 0; }
.ar-detail { border-left: 1px solid var(--line-default); background: var(--surface-card); display: flex; flex-direction: column; min-height: 0; }
.ar-detail__tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-default); background: var(--surface-sunken); flex: none; }
.ar-tab {
  height: 28px; padding: 0 10px; background: none; border: 0; border-bottom: 2px solid transparent;
  font: 500 12px/1 var(--font-sans); color: var(--text-secondary); cursor: pointer;
}
.ar-tab:hover { color: var(--text-primary); background: var(--surface-hover); }
.ar-tab[aria-selected='true'] { color: var(--text-primary); border-bottom-color: var(--red-500); }
.ar-kv { display: grid; grid-template-columns: 108px minmax(0,1fr); gap: 4px 10px; align-items: baseline; }
.ar-kv dt { font: var(--type-label); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-secondary); }
.ar-kv dd { margin: 0; font-size: var(--fs-body); color: var(--text-primary); overflow-wrap: anywhere; }

/* ---- Overlays ---- */
.ar-scrim { position: fixed; inset: 0; background: rgba(20,20,20,.44); z-index: 60; display: grid; place-items: center; padding: 24px; }
.ar-dialog {
  background: var(--surface-card); border: 1px solid var(--line-default); border-radius: 3px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22); display: flex; flex-direction: column;
  max-height: calc(100vh - 48px); width: 100%; overflow: hidden;
}
.ar-dialog__head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-default); }
.ar-dialog__body { padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.ar-dialog__foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-default); background: var(--surface-sunken); }
.ar-menu {
  position: absolute; z-index: 70; min-width: 200px; background: var(--surface-card);
  border: 1px solid var(--line-default); border-radius: 3px; box-shadow: 0 8px 22px rgba(0,0,0,.16);
  padding: 4px; display: flex; flex-direction: column; max-height: 420px; overflow: auto;
}
.ar-menu__item {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 0; background: none;
  text-align: left; cursor: pointer; border-radius: 2px; font-size: var(--fs-body); color: var(--text-primary); width: 100%;
}
.ar-menu__item:hover:not(:disabled) { background: var(--surface-hover); }
.ar-menu__item:disabled { color: var(--text-muted); cursor: not-allowed; }
.ar-menu__sep { height: 1px; background: var(--line-default); margin: 4px 0; }
.ar-menu__label { padding: 6px 8px 2px; }
.ar-peek {
  position: fixed; z-index: 75; max-width: 520px; min-width: 260px;
  background: var(--surface-card); color: var(--text-body);
  border: 1px solid var(--line-strong); border-radius: 3px;
  box-shadow: 0 10px 26px rgba(0,0,0,.22); padding: 10px 11px;
  font: var(--type-body-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto;
}
.ar-peek__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ar-peek textarea {
  width: 100%; min-height: 120px; resize: vertical; font: var(--type-body-sm);
  color: var(--text-primary); background: var(--surface-card);
  border: 1px solid var(--line-default); border-radius: 2px; padding: 6px 7px;
}
.ar-peek textarea:focus { outline: 2px solid var(--red-500); outline-offset: -1px; }
.ar-peek__foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.ar-expand {
  flex: none; width: 15px; height: 15px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line-default); border-radius: 2px; background: var(--surface-sunken);
  color: var(--text-secondary); cursor: pointer; line-height: 1;
}
.ar-expand:hover { color: var(--text-primary); border-color: var(--line-strong); }

.ar-toasts { position: fixed; right: 14px; bottom: 38px; z-index: 80; display: flex; flex-direction: column; gap: 8px; width: 340px; }
.ar-toast { background: var(--surface-card); border: 1px solid var(--line-default); border-left: 2px solid var(--line-strong); border-radius: 2px; box-shadow: 0 6px 18px rgba(0,0,0,.14); padding: 9px 10px; }
.ar-toast--success { border-left-color: var(--green-500); }
.ar-toast--warn { border-left-color: var(--amber-500); }
.ar-toast--danger { border-left-color: var(--red-500); }
.ar-toast--info { border-left-color: var(--blue-500); }

/* ---- Stage / wizard ---- */
.ar-stages { display: flex; align-items: center; gap: 0; padding: 0 10px; background: var(--surface-card); border-bottom: 1px solid var(--line-default); flex: none; }
.ar-stage {
  display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border: 0; background: none;
  cursor: pointer; color: var(--text-secondary); font: 500 13px/1 var(--font-sans); border-bottom: 2px solid transparent;
}
.ar-stage[aria-current='true'] { color: var(--text-primary); border-bottom-color: var(--red-500); }
.ar-stage:disabled { color: var(--text-muted); cursor: not-allowed; }
.ar-stage__n { font: var(--type-mono-sm); width: 17px; height: 17px; display: grid; place-items: center; border: 1px solid var(--line-default); border-radius: 2px; }
.ar-stage[aria-current='true'] .ar-stage__n { border-color: var(--red-500); color: var(--red-500); }
.ar-stage__done { color: var(--green-500); }
.ar-wizfoot { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line-default); background: var(--surface-sunken); flex: none; }
/* Stage navigation sitting with the content rather than pinned to the window bottom. */
.ar-wiznav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 2px; }

/* ---- Matching ---- */
.ar-match { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); min-height: 0; flex: 1; }
.ar-tree { font: var(--type-mono-sm); }
.ar-tree__row { display: flex; align-items: center; gap: 6px; padding: 2px 8px; cursor: pointer; border: 1px solid transparent; }
.ar-tree__row:hover { background: var(--surface-hover); }
.ar-tree__row[data-active='true'] { background: var(--surface-brand-subtle); border-color: var(--red-200); }
.ar-tree__row[data-used='true'] { color: var(--text-muted); }
.ar-dropzone { border: 1px dashed var(--line-strong); border-radius: 2px; padding: 6px 8px; font-size: 12px; color: var(--text-secondary); }
.ar-dropzone[data-over='true'] { border-color: var(--red-500); background: var(--surface-brand-subtle); color: var(--text-primary); }

/* ---- Preflight ---- */
.ar-checkitem { display: grid; grid-template-columns: 18px minmax(0,1fr) auto; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-hairline); align-items: start; }
.ar-checkitem:last-child { border-bottom: 0; }
.ar-progress { height: 4px; background: var(--surface-canvas); border: 1px solid var(--line-hairline); border-radius: 2px; overflow: hidden; }
.ar-progress > div { height: 100%; background: var(--red-500); transition: width var(--dur-base, 180ms) var(--ease-out, cubic-bezier(.2,.7,.3,1)); }

/* ---- Receipt preview ---- */
.ar-receipt { background: var(--surface-card); border: 1px solid var(--line-default); padding: 20px; font-size: 12px; color: var(--text-body); }
.ar-receipt table { width: 100%; border-collapse: collapse; }
.ar-receipt th, .ar-receipt td { border-bottom: 1px solid var(--line-default); padding: 4px 6px; text-align: left; font-size: 11px; }
.ar-receipt th { font: var(--type-label); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-secondary); }

.ar-empty { display: grid; place-items: center; gap: 8px; padding: 40px; text-align: center; color: var(--text-secondary); }
.ar-stub { max-width: 560px; margin: 40px auto; }
.ar-stub ul { margin: 8px 0 0; padding-left: 18px; }
.ar-stub li { margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition-duration: 0ms !important; animation-duration: 0ms !important; } }
