/* ====================================================================
 * FeeVerify Platform - design system.
 * Register: product (control plane). Lane: "governed control plane" -
 * institutional, evidence-first, restrained. Brand indigo #300066 as a
 * structural spine, not decoration. See PRODUCT.md / DESIGN.md.
 *
 * Class names are a contract with app.js - names are preserved; only the
 * look is upgraded. New primitives (.app-shell, .sidebar, .nav-item,
 * .topbar, .list, .skeleton, status dots) are additive.
 * ==================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;450;500;600;700;800&display=swap');

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */
:root {
  /* Brand - exact #300066 preserved, ramp tuned around its hue (~296). */
  --brand:        #300066;
  --brand-700:    #3a0a78;
  --brand-600:    #4a0099;   /* hover / interactive */
  --brand-500:    #6321b8;
  --brand-400:    #8456d6;
  --brand-300:    #b59ae8;
  --brand-tint:   #f4f1fb;   /* selection / active-row wash */
  --brand-tint-2: #e9e2f7;
  --brand-ink:    #1c0438;   /* deepest, sidebar base */

  /* Cool institutional neutrals (chroma toward brand hue, never warm). */
  --bg:        oklch(98.4% 0.004 292);   /* app canvas */
  --surface:   #ffffff;
  --surface-2: oklch(98% 0.005 292);     /* subtle inset / table head */
  --ink:       oklch(22% 0.03 292);      /* headings */
  --text:      oklch(34% 0.022 292);     /* body */
  --text-2:    oklch(48% 0.018 292);     /* secondary */
  --muted:     oklch(58% 0.014 292);     /* labels */
  --faint:     oklch(70% 0.012 292);     /* tertiary / placeholder-strong */
  --border:    oklch(91% 0.008 292);     /* card / control border */
  --border-2:  oklch(94% 0.006 292);     /* hairline (table rows) */

  /* Semantic - each used only on badges / banners / state, never surface. */
  --ok-bg:   #dcfce7; --ok-fg:   #166534; --ok:   #16a34a;
  --warn-bg: #fef3c7; --warn-fg: #92400e; --warn: #d97706;
  --danger-bg:#fee2e2;--danger-fg:#991b1b;--danger:#dc2626;
  --review-bg:#ffedd5;--review-fg:#9a3412;--review:#ea580c;
  --info-bg: #e0e7ff; --info-fg: #3730a3; --info: #4f46e5;
  --run-bg:  #ede9fe; --run-fg:  #5b21b6; --run:  #7c3aed;
  --teal-bg: #cffafe; --teal-fg: #155e75; --teal: #0891b2;
  --neutral-bg: oklch(95% 0.006 292); --neutral-fg: var(--text-2);

  /* Type scale (fixed rem - product). */
  --fs-display: 1.5rem;   /* 24 */
  --fs-h1:      1.25rem;  /* 20 */
  --fs-h2:      1.0625rem;/* 17 */
  --fs-base:    0.875rem; /* 14 */
  --fs-sm:      0.8125rem;/* 13 */
  --fs-xs:      0.75rem;  /* 12 */
  --fs-2xs:     0.6875rem;/* 11 */
  --lh:         1.55;

  /* Radius */
  --r-sm: 0.375rem; --r-md: 0.5rem; --r-lg: 0.625rem; --r-xl: 0.875rem; --r-pill: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(28, 4, 56, 0.05), 0 1px 1px rgba(28, 4, 56, 0.03);
  --sh-2: 0 2px 6px rgba(28, 4, 56, 0.07), 0 1px 2px rgba(28, 4, 56, 0.04);
  --sh-3: 0 8px 24px rgba(28, 4, 56, 0.10);
  --sh-pop: 0 20px 48px rgba(20, 4, 40, 0.28);
  --ring: 0 0 0 3px rgba(48, 0, 102, 0.16);

  /* Motion */
  --t-fast: 110ms cubic-bezier(0.22, 1, 0.36, 1);
  --t:      170ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Structure */
  --sidebar-w: 244px;
  --topbar-h: 56px;
  --content-max: 1180px;

  /* z-index scale (semantic, never arbitrary) */
  --z-sticky: 20; --z-modal-backdrop: 50; --z-modal: 51; --z-toast: 60;
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--brand-tint-2); color: var(--brand-ink); }

.hidden { display: none !important; }
#login-screen.flex { display: flex; }

/* Tasteful scrollbars on the content side */
.content ::-webkit-scrollbar, .sidebar ::-webkit-scrollbar { width: 10px; height: 10px; }
.content ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid var(--bg); }

code, .mono {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.82em;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 0.05rem 0.34rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
}

/* ------------------------------------------------------------------ */
/* App shell - sidebar + main                                          */
/* ------------------------------------------------------------------ */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  background: #fff;
  color: var(--text);
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 1rem 1.1rem; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
}
.sidebar-section {
  padding: 1rem 1.15rem 0.35rem; font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0.7rem 0.55rem 0.25rem; flex: 1; overflow-y: auto; }
.nav-group { padding: 1.1rem 0.6rem 0.35rem; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.nav-item {
  position: relative; display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.65rem; border-radius: var(--r-md);
  color: var(--ink); font-size: 0.9375rem; font-weight: 500;
  background: none; border: none; cursor: pointer; text-align: left; width: 100%;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; color: var(--text-2); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item.active svg { color: #fff; }
.nav-item .count {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 700;
  background: var(--brand-tint); color: var(--brand);
  border-radius: 999px; padding: 0.05rem 0.5rem; min-width: 1.4rem; text-align: center;
}
.nav-item.active .count { background: rgba(255, 255, 255, 0.22); color: #fff; }

.sidebar-foot {
  padding: 0.8rem 1.15rem; border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-2);
  display: flex; align-items: center; gap: 0.45rem;
}
.audit-dot { width: 7px; height: 7px; border-radius: 999px; background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.topbar-page { font-weight: 600; color: var(--ink); font-size: var(--fs-base); }
.topbar-right { display: flex; align-items: center; gap: 0.85rem; }
.user-chip { display: flex; align-items: center; gap: 0.45rem; font-size: var(--fs-sm); color: var(--text-2); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); font-weight: 700; font-size: 0.7rem;
  border: 1px solid var(--brand-tint-2);
}
.content { padding: 1.5rem 1.25rem 3rem; }
.content-inner { max-width: var(--content-max); margin: 0 auto; }

/* ------------------------------------------------------------------ */
/* Section header                                                      */
/* ------------------------------------------------------------------ */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.section-head h2 { font-size: var(--fs-h1); font-weight: 700; }
.section-head .sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 0.15rem; max-width: 62ch; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: 100%; padding: 0.55rem 0.85rem; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn svg { width: 15px; height: 15px; }
.btn:focus-visible, .btn-sm:focus-visible, .input:focus-visible, .nav-item:focus-visible, .tab-btn:focus-visible {
  outline: none; box-shadow: var(--ring);
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--brand-600); }
.btn-primary:active { background: var(--brand-700); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); width: auto; padding: 0.55rem 1rem; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-link { background: none; border: none; color: var(--brand-600); cursor: pointer; font-weight: 600; padding: 0; width: auto; }
.btn-link:hover { color: var(--brand); text-decoration: underline; }

.btn-sm {
  display: inline-flex; align-items: center; gap: 0.32rem;
  padding: 0.32rem 0.7rem; font-size: var(--fs-xs); font-weight: 600;
  border-radius: var(--r-sm); cursor: pointer; border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-sm svg { width: 13px; height: 13px; }
.btn-sm.btn-primary { width: auto; box-shadow: var(--sh-1); color: #fff; background: var(--brand); }
.btn-sm.btn-primary:hover { background: var(--brand-600); }
.btn-sm-outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-sm-outline:hover { background: var(--brand-tint); border-color: var(--brand-300); color: var(--brand); }
.btn-sm-danger { background: var(--surface); border: 1px solid var(--border); color: var(--danger-fg); }
.btn-sm-danger:hover { background: var(--danger-bg); border-color: #fca5a5; }

/* ------------------------------------------------------------------ */
/* Form controls                                                       */
/* ------------------------------------------------------------------ */
.input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0.5rem 0.7rem; font-size: var(--fs-base); font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
textarea.input { resize: vertical; min-height: 4.5rem; }
.field-label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-bottom: 0.3rem; }
.req { color: var(--danger); }

.org-select {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0.34rem 1.9rem 0.34rem 0.65rem; font-size: var(--fs-sm); font-weight: 500;
  color: var(--text); background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364607a' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 0.6rem center;
  -webkit-appearance: none; appearance: none;
  max-width: 16rem; cursor: pointer;
}
.org-select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.org-select:disabled { cursor: default; color: var(--text-2); }

/* ------------------------------------------------------------------ */
/* Cards & lists                                                       */
/* ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-pad { padding: 1rem 1.1rem; }

/* List = the institutional replacement for identical card grids. */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.85rem 1.05rem; border-bottom: 1px solid var(--border-2); transition: background var(--t-fast); }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row .grow { min-width: 0; flex: 1; overflow: hidden; }
.list-row .row-title { font-weight: 600; color: var(--ink); font-size: 0.9rem; }
.list-row .row-meta { display: flex; align-items: center; gap: 0.5rem 0.75rem; flex-wrap: wrap; margin-top: 0.25rem; font-size: var(--fs-xs); color: var(--muted); min-width: 0; }
.list-row .row-meta code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.list-row .row-actions { display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0; }

/* Glyph tile (role / type avatar) */
.glyph { width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--r-md);
  display: grid; place-items: center; background: var(--brand-tint); color: var(--brand);
  border: 1px solid var(--brand-tint-2); }
.glyph svg { width: 17px; height: 17px; }

/* row-card kept for backwards-compat (still used by some tabs) */
.row-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); transition: box-shadow var(--t), border-color var(--t); }
.row-card:hover { border-color: var(--brand-300); box-shadow: var(--sh-2); }

/* ------------------------------------------------------------------ */
/* Badges (color ALWAYS paired with text; status/confidence get a dot) */
/* ------------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 0.32rem;
  font-size: var(--fs-2xs); font-weight: 600; border-radius: var(--r-pill);
  padding: 0.12rem 0.55rem; line-height: 1.5; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.badge svg { width: 12px; height: 12px; }

/* worklog free-text statuses */
.badge-status-success     { background: var(--ok-bg);    color: var(--ok-fg); }
.badge-status-partial     { background: var(--warn-bg);  color: var(--warn-fg); }
.badge-status-empty_output{ background: var(--neutral-bg);color: var(--muted); }
.badge-status-in_progress { background: var(--run-bg);   color: var(--run-fg); }
/* confidence */
.badge-conf-high   { background: var(--ok-bg);    color: var(--ok-fg); }
.badge-conf-medium,
.badge-conf-med    { background: var(--warn-bg);  color: var(--warn-fg); }
.badge-conf-low    { background: var(--danger-bg);color: var(--danger-fg); }
.badge-conf-null   { background: var(--neutral-bg);color: var(--muted); }
/* investigation / run status */
.badge-status-draft      { background: var(--neutral-bg); color: var(--text-2); }
.badge-status-queued     { background: var(--info-bg);    color: var(--info-fg); }
.badge-status-running    { background: var(--run-bg);     color: var(--run-fg); }
.badge-status-idle       { background: var(--neutral-bg); color: var(--text-2); }
.badge-status-needs_review { background: var(--review-bg);color: var(--review-fg); }
.badge-status-completed  { background: var(--ok-bg);      color: var(--ok-fg); }
.badge-status-failed,
.badge-status-blocked    { background: var(--danger-bg);  color: var(--danger-fg); }
.badge-status-cancelled,
.badge-status-archived   { background: var(--neutral-bg); color: var(--muted); }
/* agent / skill status */
.badge-status-shadow     { background: var(--info-bg);    color: var(--info-fg); }
.badge-status-live       { background: var(--ok-bg);      color: var(--ok-fg); }
.badge-status-retired    { background: var(--neutral-bg); color: var(--muted); }
.badge-status-dry_run    { background: var(--info-bg);    color: var(--info-fg); }
.badge-status-promoted   { background: var(--teal-bg);    color: var(--teal-fg); }
/* priority */
.badge-pri-critical { background: var(--danger-bg);  color: var(--danger-fg); }
.badge-pri-high     { background: var(--review-bg);  color: var(--review-fg); }
.badge-pri-medium   { background: var(--warn-bg);    color: var(--warn-fg); }
.badge-pri-low      { background: var(--neutral-bg); color: var(--muted); }
/* role / scope pill */
.badge-role { background: var(--brand-tint); color: var(--brand); }

.chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: var(--fs-2xs); font-weight: 500;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); padding: 0.1rem 0.45rem; }
.chip svg { width: 12px; height: 12px; opacity: 0.7; }

/* ------------------------------------------------------------------ */
/* Banners                                                             */
/* ------------------------------------------------------------------ */
.banner-error, .banner-warn, .banner-info {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.6rem 0.8rem; border-radius: var(--r-md); font-size: var(--fs-sm);
  border: 1px solid transparent;
}
.banner-error { background: var(--danger-bg); color: var(--danger-fg); border-color: #fca5a5; }
.banner-warn  { background: var(--warn-bg);  color: var(--warn-fg);  border-color: #fcd34d; }
.banner-info  { background: var(--brand-tint); color: var(--brand);  border-color: var(--brand-tint-2); }

/* ------------------------------------------------------------------ */
/* Empty states - teach the interface, don't say "nothing here"        */
/* ------------------------------------------------------------------ */
.empty-state { text-align: center; padding: 2.75rem 1.25rem; color: var(--muted); font-size: var(--fs-sm); }
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 3rem 1.5rem; gap: 0.55rem;
}
.empty .empty-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); border: 1px solid var(--brand-tint-2);
  margin-bottom: 0.35rem;
}
.empty .empty-icon svg { width: 23px; height: 23px; }
.empty .empty-title { font-weight: 600; color: var(--ink); font-size: 0.95rem; }
.empty .empty-sub { font-size: var(--fs-sm); color: var(--muted); max-width: 42ch; }
.empty .empty-action { margin-top: 0.6rem; }

/* ------------------------------------------------------------------ */
/* Skeletons (content loading, not spinners)                           */
/* ------------------------------------------------------------------ */
.skeleton-list { display: flex; flex-direction: column; gap: 0.6rem; }
.skel-row { height: 64px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); position: relative; overflow: hidden; }
.skel-row::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(48, 0, 102, 0.045), transparent);
  transform: translateX(-100%); animation: shimmer 1.25s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner-sm { width: 15px; height: 15px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */
.tbl { width: 100%; font-size: var(--fs-sm); border-collapse: collapse; }
.tbl th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.6rem 0.85rem; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tbl th:first-child { border-top-left-radius: var(--r-lg); }
.tbl th:last-child { border-top-right-radius: var(--r-lg); }
.tbl td { padding: 0.62rem 0.85rem; border-bottom: 1px solid var(--border-2); vertical-align: middle; color: var(--text); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover td { background: var(--surface-2); }

/* ------------------------------------------------------------------ */
/* Modal                                                               */
/* ------------------------------------------------------------------ */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal-backdrop);
  background: rgba(20, 4, 40, 0.5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: overlay-in var(--t) both;
}
@keyframes overlay-in { from { opacity: 0; } }
.modal-card {
  position: relative; z-index: var(--z-modal);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-pop);
  width: 100%; max-width: 30rem; padding: 1.4rem 1.5rem; max-height: 90vh; overflow-y: auto;
  animation: modal-in var(--t) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.modal-close { font-size: 1.4rem; line-height: 1; color: var(--faint); background: none; border: none; cursor: pointer; padding: 0.1rem 0.3rem; border-radius: var(--r-sm); }
.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast); display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--brand-ink); color: #fff;
  padding: 0.6rem 1rem; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500;
  box-shadow: var(--sh-3); animation: toast-in var(--t) both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast.toast-error { background: #7f1d1d; }
.toast.toast-ok    { background: #14532d; }

/* ------------------------------------------------------------------ */
/* Login                                                               */
/* ------------------------------------------------------------------ */
.login { width: 100%; min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-brand {
  position: relative; overflow: hidden; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  color: #e7ddf7;
  background:
    radial-gradient(110% 70% at 100% 0%, rgba(132, 86, 214, 0.32), transparent 55%),
    linear-gradient(160deg, var(--brand) 0%, var(--brand-ink) 100%);
}
.login-brand .lb-mark { display: flex; align-items: center; gap: 0.6rem; color: #fff; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.login-brand .lb-mark .mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(255,255,255,0.13); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16); }
.login-brand .lb-mark .mark svg { width: 17px; height: 17px; }
.login-brand h2 { color: #fff; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.18; max-width: 16ch; }
.login-proof { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1.5rem; }
.login-proof li { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.9rem; color: #d9cef0; list-style: none; }
.login-proof svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: #b59ae8; }
.login-proof b { color: #fff; font-weight: 600; }
.login-foot { font-size: var(--fs-xs); color: rgba(217, 206, 240, 0.6); display: flex; align-items: center; gap: 0.4rem; }
.login-form-pane { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--surface); }
.login-card { width: 100%; max-width: 23rem; }
.login-card h1 { font-size: 1.3rem; font-weight: 700; }
.login-card .sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 0.25rem; margin-bottom: 1.5rem; }

@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 2rem 1.75rem; }
  .login-brand h2 { font-size: 1.35rem; }
  .login-proof { display: none; }
}

/* ------------------------------------------------------------------ */
/* Responsive: sidebar -> top bar                                      */
/* ------------------------------------------------------------------ */
@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 0.4rem;
    border-right: none; border-bottom: 1px solid var(--border); z-index: var(--z-sticky); }
  .sidebar-brand { height: auto; padding: 0.65rem 0.9rem; border-bottom: none; }
  .sidebar-section, .sidebar-foot, .nav-group { display: none; }
  .nav { flex-direction: row; overflow-x: auto; padding: 0.35rem 0.5rem; gap: 0.15rem; }
  .nav-item { width: auto; padding: 0.4rem 0.62rem; white-space: nowrap; }
  .nav-item .count { margin-left: 0.3rem; }
  .content { padding: 1.1rem 0.9rem 2.5rem; }
}

/* ------------------------------------------------------------------ */
/* Reduced motion                                                      */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .skel-row::after { display: none; }
}

/* ====================================================================
 * Data / Activity suite - upload modal, pipeline timeline, seal motif.
 * Added for the integrated upload experience. Uses the same tokens.
 * ==================================================================== */

/* Brand-adjacent "verified/sourced" teal (data-suite motif) */
:root { --verified: #0e7490; }

/* Extra upload-status badges (schema enums already covered above) */
.badge-status-received   { background: var(--neutral-bg); color: var(--text-2); }
.badge-status-scanning   { background: var(--run-bg);     color: var(--run-fg); }
.badge-status-loaded     { background: var(--teal-bg);    color: var(--teal-fg); }
.badge-status-dictionary { background: var(--review-bg);  color: var(--review-fg); }
.badge-status-ready      { background: var(--ok-bg);      color: var(--ok-fg); }
.badge-status-rejected   { background: var(--danger-bg);  color: var(--danger-fg); }

/* The confidence seal / sourced motif */
.seal {
  display: inline-flex; align-items: center; gap: 0.38rem;
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--verified); background: var(--teal-bg);
  border: 1px solid color-mix(in srgb, var(--verified) 42%, transparent);
  border-radius: var(--r-pill); padding: 0.16rem 0.5rem 0.16rem 0.38rem;
}
.seal .seal-ring { width: 13px; height: 13px; border-radius: 999px; border: 1.5px solid currentColor; display: inline-grid; place-items: center; }
.seal .seal-ring svg { width: 8px; height: 8px; }
.ptr-glyph { color: var(--brand); }

/* Stat tiles */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 0.8rem; margin-bottom: 1.2rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 0.9rem 1.05rem; }
.stat-tile .st-fig { font-size: 1.55rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.stat-tile .st-fig.warn { color: var(--review-fg); }
.stat-tile .st-fig.ok { color: var(--ok-fg); }
.stat-tile .st-label { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.4rem; }

/* Filter toolbar */
.upl-toolbar { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.85rem; }
.upl-toolbar .input { width: auto; min-width: 9rem; padding-block: 0.4rem; font-size: var(--fs-sm); }

/* Upload modal: dropzone */
.modal-card.modal-lg { max-width: 40rem; }
.dropzone { border: 2px dashed var(--brand-300); background: var(--brand-tint); border-radius: var(--r-lg); padding: 1.6rem 1.25rem; text-align: center; cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-tint-2); }
.dropzone svg { width: 28px; height: 28px; color: var(--brand); margin-bottom: 0.4rem; }
.dropzone .dz-main { font-size: var(--fs-base); font-weight: 600; color: var(--ink); }
.dropzone .dz-sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.25rem; }
.filelist { margin-top: 0.65rem; display: flex; flex-direction: column; gap: 0.35rem; }
.file-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.65rem; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-md); font-size: var(--fs-sm); }
.file-row .f-icn { color: var(--brand); display: grid; place-items: center; flex-shrink: 0; }
.file-row .f-icn svg { width: 15px; height: 15px; }
.file-row .f-name { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-row .f-size { color: var(--muted); font-size: var(--fs-xs); margin-left: auto; flex-shrink: 0; }
.file-row .f-x { background: none; border: none; color: var(--faint); cursor: pointer; padding: 0.1rem; display: grid; place-items: center; border-radius: var(--r-sm); flex-shrink: 0; }
.file-row .f-x:hover { color: var(--danger); background: var(--danger-bg); }
.file-row .f-x svg { width: 14px; height: 14px; }

/* Market cards */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
.market-card { display: flex; align-items: center; gap: 0.55rem; border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 0.5rem 0.65rem; cursor: pointer; background: var(--surface); transition: border-color var(--t-fast), background var(--t-fast); text-align: left; }
.market-card:hover { border-color: var(--brand-300); }
.market-card.selected { border-color: var(--brand); background: var(--brand-tint); }
.market-card .m-tile { width: 28px; height: 28px; border-radius: 6px; background: var(--brand-tint); color: var(--brand); border: 1px solid var(--brand-tint-2); display: grid; place-items: center; font-size: 0.66rem; font-weight: 700; flex-shrink: 0; }
.market-card .m-name { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); line-height: 1.15; }
.market-card .m-code { font-size: var(--fs-2xs); color: var(--muted); }
.market-add { display: inline-flex; align-items: center; gap: 0.3rem; border: 1.5px dashed var(--border); border-radius: var(--r-md); padding: 0.5rem 0.65rem; color: var(--muted); font-size: var(--fs-sm); cursor: pointer; background: none; }
.market-add:hover { border-color: var(--brand-300); color: var(--brand); }
.market-add svg { width: 14px; height: 14px; }

/* PII attestation */
.attest { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.7rem 0.85rem; border: 1px solid #fcd34d; background: var(--warn-bg); border-radius: var(--r-md); cursor: pointer; }
.attest input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--brand); flex-shrink: 0; }
.attest .a-main { font-size: var(--fs-sm); font-weight: 600; color: var(--warn-fg); }
.attest .a-sub { font-size: var(--fs-xs); color: var(--warn-fg); opacity: 0.85; margin-top: 0.1rem; }

/* The "what happens next" process panel (modal) */
.process { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); }
.process-head { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border-2); display: flex; align-items: center; gap: 0.45rem; background: var(--surface); }
.process-head .ph-title { font-size: var(--fs-xs); font-weight: 700; color: var(--ink); }
.process-head .seal { margin-left: auto; }
.pl-step { display: grid; grid-template-columns: 26px 1fr; gap: 0.6rem; padding: 0.55rem 0.85rem; position: relative; }
.pl-step:not(:last-child)::after { content: ''; position: absolute; left: calc(0.85rem + 12px); top: 1.8rem; bottom: -0.1rem; width: 2px; background: var(--border); }
.pl-num { width: 24px; height: 24px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); border: 1px solid var(--brand-tint-2); position: relative; z-index: 1; }
.pl-num svg { width: 13px; height: 13px; }
.pl-step.is-gate .pl-num { background: var(--review-bg); color: var(--review-fg); border-color: #fdba74; }
.pl-step.is-done .pl-num { background: var(--ok-bg); color: var(--ok-fg); border-color: #86efac; }
.pl-body .pl-t { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.pl-body .pl-d { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.05rem; }
.pl-tag { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.04rem 0.36rem; border-radius: var(--r-sm); }
.pl-tag.gate { background: var(--review-bg); color: var(--review-fg); }
.pl-tag.auto { background: var(--neutral-bg); color: var(--muted); }

/* Activity row expand: pipeline timeline */
.act-row { cursor: pointer; }
.timeline { padding: 0.5rem 1.05rem 0.9rem calc(34px + 1.05rem + 0.9rem); background: var(--surface-2); border-bottom: 1px solid var(--border-2); }
.timeline.hidden { display: none; }
.tl-step { display: grid; grid-template-columns: 16px 1fr; gap: 0.55rem; padding: 0.34rem 0; position: relative; }
.tl-step:not(:last-child)::after { content: ''; position: absolute; left: 7px; top: 1.2rem; bottom: -0.25rem; width: 2px; background: var(--border); }
.tl-dot { width: 14px; height: 14px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface); position: relative; z-index: 1; }
.tl-dot.done { background: var(--ok); border-color: var(--ok); }
.tl-dot.active { background: var(--run); border-color: var(--run); box-shadow: 0 0 0 3px var(--run-bg); }
.tl-dot.gate { background: var(--review); border-color: var(--review); }
.tl-dot.fail { background: var(--danger); border-color: var(--danger); }
.tl-body .tl-t { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.tl-body .tl-d { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.02rem; }
.tl-body .tl-when { font-size: var(--fs-2xs); color: var(--faint); }

/* ------------------------------------------------------------------ */
/* Agent builder                                                       */
/* ------------------------------------------------------------------ */
.modal-card-wide { max-width: 46rem; }
.builder-body { max-height: 62vh; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 0.85rem; }
.builder-section { border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 0.85rem 0.95rem; background: var(--surface); }
.builder-section-head h4 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.builder-section-head p { font-size: var(--fs-xs); color: var(--muted); margin: 0.15rem 0 0.65rem; max-width: 64ch; }
.builder-subhead { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); margin: 0.6rem 0 0.35rem; display: flex; align-items: center; gap: 0.5rem; }
.builder-check { display: flex; align-items: center; gap: 0.4rem; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.builder-check input { accent-color: var(--brand); }
.builder-check-muted span { color: var(--muted); font-size: var(--fs-xs); }
.builder-tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.3rem 1.1rem; transition: opacity var(--t-fast); }
.builder-tool-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.18rem 0; }
.builder-chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.builder-pill { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-xs); border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.6rem; cursor: pointer; background: var(--surface); color: var(--text); }
.builder-pill input { accent-color: var(--brand); margin: 0; }
.builder-pill-disabled { opacity: 0.5; cursor: not-allowed; }
.builder-row { border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 0.55rem 0.6rem; margin-bottom: 0.5rem; background: var(--surface-2); }
.chip-accent { background: var(--brand-tint); color: var(--brand); border-color: var(--brand-300); }
.btn-xs { font-size: var(--fs-2xs); padding: 0.2rem 0.5rem; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: 0.25rem; cursor: pointer; line-height: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-xs:hover { background: var(--brand-tint); border-color: var(--brand-300); color: var(--brand); }
.btn-xs svg { width: 12px; height: 12px; }
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.3rem; }
textarea.mono, .input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); }

/* ------------------------------------------------------------------ */
/* Agent builder - craft refinement pass                               */
/* Selection is legible at the pill/row level (not just the native     */
/* checkbox); sections gain rhythm; the toolset grid aligns cleanly.   */
/* ------------------------------------------------------------------ */
.builder-section { padding: 0.95rem 1.05rem; transition: border-color var(--t-fast); }
.builder-section:hover { border-color: var(--border); }
.builder-section-head h4 { letter-spacing: -0.01em; }

/* Pills light up when their checkbox is checked (progressive enhancement). */
.builder-pill { transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.builder-pill:hover:not(.builder-pill-disabled) { border-color: var(--brand-300); background: var(--brand-tint); }
.builder-pill:has(input:checked) {
  background: var(--brand-tint);
  border-color: var(--brand-400);
  color: var(--brand);
  font-weight: 600;
}
.builder-pill:has(input:focus-visible) { box-shadow: var(--ring); }

/* Toolset rows: a hairline-separated grid, the "ask" gate visually secondary
   and only meaningful when the tool itself is enabled. */
.builder-tool-row { border-bottom: 1px solid var(--border-2); padding: 0.32rem 0; }
.builder-tool-grid > .builder-tool-row:nth-last-child(-n+2) { border-bottom: none; }
.builder-tool-row:has(.b-tool-on:not(:checked)) { opacity: 0.5; }
.builder-tool-row:has(.b-tool-on:not(:checked)) .b-tool-ask { visibility: hidden; }
.builder-check input { width: 15px; height: 15px; }

/* Custom-tool / MCP rows read as filed records, not loose inputs. */
.builder-row { transition: border-color var(--t-fast); }
.builder-row:focus-within { border-color: var(--brand-300); }
.builder-row .b-ct-name, .builder-row .b-mcp-name { font-weight: 500; max-width: 12rem; }
.builder-row textarea.mono { background: var(--surface); }

/* The orchestrator panel is the one place an agent gains authority over
   others - give it a quiet brand spine so it reads as a distinct mode. */
#b-orch-detail:not(.hidden) {
  border-top: 1px solid var(--border-2);
  margin-top: 0.6rem; padding-top: 0.7rem;
}
#b-orch-detail .builder-subhead:first-child { margin-top: 0; }

/* Save&provision is the consequential action - let it carry a touch more weight. */
#agent-builder-save-provision { box-shadow: var(--sh-1); }

/* ====================================================================
 * Investigation detail, run progress, findings and rendered markdown.
 * Same tokens as the rest of the system.
 * ==================================================================== */

/* Rows that open something */
.inv-row { cursor: pointer; }
.inv-row:focus-visible { outline: none; box-shadow: inset var(--ring); }
.report-card { display: block; width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.report-card:focus-visible { outline: none; box-shadow: var(--ring); }
.tl-link { font-weight: 600; margin-left: 0.3rem; white-space: nowrap; }

/* Upload modal fixes */
.dropzone svg { display: block; margin: 0 auto 0.4rem; }
.market-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.dict-table { margin-top: 0.7rem; max-height: 46vh; overflow: auto; }
.dict-table .tbl th { position: sticky; top: 0; z-index: 1; }

/* Detail header */
.inv-detail { display: flex; flex-direction: column; gap: 0.9rem; }
.inv-back { align-self: flex-start; font-size: var(--fs-sm); }
.inv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.inv-head-main { min-width: 0; flex: 1 1 28rem; }
.inv-head h2 { font-size: var(--fs-h1); font-weight: 700; overflow-wrap: anywhere; }
.inv-meta { display: flex; align-items: center; gap: 0.5rem 0.7rem; flex-wrap: wrap; margin-top: 0.45rem; font-size: var(--fs-xs); color: var(--muted); }
.inv-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.inv-label { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.inv-question .md { font-size: var(--fs-sm); color: var(--text-2); }
.inv-q-details summary { cursor: pointer; list-style: none; font-size: var(--fs-sm); color: var(--text-2); }
.inv-q-details summary::-webkit-details-marker { display: none; }
.inv-q-details[open] .inv-q-preview { display: none; }
.inv-q-more { color: var(--brand-600); font-weight: 600; white-space: nowrap; }
.inv-q-details[open] .inv-q-more { display: none; }
.inv-q-details[open] summary { margin-bottom: 0.2rem; }

/* Run in progress */
.run-card { overflow: hidden; border-color: var(--brand-300); }
.run-head { display: flex; align-items: center; gap: 0.85rem; padding: 1rem 1.1rem; background: var(--brand-tint); border-bottom: 1px solid var(--brand-tint-2); }
.run-pulse { width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--brand-tint-2); }
.run-head-main { min-width: 0; flex: 1; }
.run-title { font-weight: 700; color: var(--ink); font-size: 0.95rem; }
.run-latest { font-size: var(--fs-sm); color: var(--text-2); margin-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-latest strong { color: var(--ink); font-weight: 600; }
.run-clock { text-align: right; flex-shrink: 0; }
.run-elapsed { font-size: 1.55rem; font-weight: 800; color: var(--brand); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.run-clock-label { font-size: var(--fs-2xs); color: var(--muted); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; }
.run-stats { display: flex; align-items: center; gap: 0.4rem 1.2rem; flex-wrap: wrap; padding: 0.6rem 1.1rem; font-size: var(--fs-xs); color: var(--muted); border-bottom: 1px solid var(--border-2); }
.run-stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.run-stats-note { margin-left: auto; }
.run-quiet { display: flex; align-items: center; gap: 0.45rem; padding: 0.5rem 1.1rem; font-size: var(--fs-xs); color: var(--warn-fg); background: var(--warn-bg); border-bottom: 1px solid #fcd34d; }
.run-quiet svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Run feed (live and in the run log) */
.run-feed { max-height: 23rem; overflow-y: auto; padding: 0.35rem 0; }
.run-feed-static { max-height: 30rem; border-top: 1px solid var(--border-2); }
.run-feed-empty { padding: 1rem 1.1rem; font-size: var(--fs-sm); color: var(--muted); }
.rf-row { display: grid; grid-template-columns: 4.6rem 18px minmax(0, 1fr); gap: 0.6rem; align-items: start; padding: 0.3rem 1.1rem; font-size: var(--fs-sm); }
.rf-time { font-size: var(--fs-2xs); color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 0.14rem; white-space: nowrap; }
.rf-icn { color: var(--brand); display: grid; place-items: center; padding-top: 0.14rem; }
.rf-icn svg { width: 14px; height: 14px; }
.rf-text { color: var(--text); overflow-wrap: anywhere; }
.rf-detail { font-size: 0.78em; overflow-wrap: anywhere; }
.rf-minor .rf-text { color: var(--muted); }
.rf-minor .rf-icn { color: var(--faint); }
.rf-error .rf-text, .rf-error .rf-icn { color: var(--danger-fg); }
.rf-quote { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--brand-300); border-radius: var(--r-sm); padding: 0.4rem 0.6rem; overflow-wrap: anywhere; }
.rf-quote strong { color: var(--ink); }

/* Result banners */
.run-result { display: flex; align-items: center; gap: 0.85rem; padding: 0.85rem 1.1rem; }
.run-result .rr-icon { width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--r-md); display: grid; place-items: center; }
.run-result .rr-icon svg { width: 17px; height: 17px; }
.run-result .rr-title { font-weight: 700; color: var(--ink); font-size: 0.95rem; }
.run-result .rr-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 0.05rem; overflow-wrap: anywhere; }
.run-result .rr-action { margin-left: auto; flex-shrink: 0; }
.run-result-review { border-color: #fdba74; background: color-mix(in srgb, var(--review-bg) 45%, var(--surface)); }
.run-result-review .rr-icon { background: var(--review-bg); color: var(--review-fg); }
.run-result-done { border-color: #86efac; background: color-mix(in srgb, var(--ok-bg) 40%, var(--surface)); }
.run-result-done .rr-icon { background: var(--ok-bg); color: var(--ok-fg); }
.run-result-failed { border-color: #fca5a5; background: color-mix(in srgb, var(--danger-bg) 40%, var(--surface)); }
.run-result-failed .rr-icon { background: var(--danger-bg); color: var(--danger-fg); }

/* Findings */
.findings-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.9rem; align-items: start; }
.findings-layout.has-side { grid-template-columns: minmax(0, 1fr) 17rem; }
@media (max-width: 1100px) { .findings-layout.has-side { grid-template-columns: minmax(0, 1fr); } }
.findings-card { min-width: 0; }
.findings-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; padding: 0.8rem 1.25rem; border-bottom: 1px solid var(--border-2); }
.findings-title { font-weight: 700; color: var(--ink); font-size: 0.95rem; min-width: 0; overflow-wrap: anywhere; }
.findings-meta { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.findings-body { padding: 1.25rem 1.5rem 1.6rem; min-width: 0; }
.findings-fallback { font-size: var(--fs-sm); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 0.6rem 0.8rem; margin-bottom: 0.9rem; }
.findings-fallback:last-child { margin-bottom: 0; }
.outputs-card { padding: 0.7rem 0.5rem; }
.outputs-label { padding: 0.1rem 0.6rem 0; }
.output-row { display: flex; align-items: flex-start; gap: 0.55rem; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--r-md); padding: 0.45rem 0.6rem; cursor: pointer; font: inherit; color: inherit; }
.output-row:hover { background: var(--surface-2); }
.output-row.active { background: var(--brand-tint); border-color: var(--brand-tint-2); }
.output-icn { color: var(--brand); padding-top: 0.1rem; flex-shrink: 0; }
.output-icn svg { width: 15px; height: 15px; }
.output-main { min-width: 0; display: flex; flex-direction: column; }
.output-title { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.output-sub { font-size: var(--fs-2xs); color: var(--muted); }

/* Run log (collapsed once a run has landed) */
.run-log summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.75rem 1.1rem; cursor: pointer; list-style: none; }
.run-log summary::-webkit-details-marker { display: none; }
.run-log-title { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; color: var(--ink); font-size: var(--fs-sm); }
.run-log-title svg { width: 15px; height: 15px; color: var(--brand); }
.run-log-meta { display: flex; gap: 0.4rem 1rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }

/* Worklog table */
.worklog-tbl td { vertical-align: top; }
.worklog-what { max-width: 46rem; overflow-wrap: anywhere; }
.worklog-what strong { color: var(--ink); }

/* Rendered markdown (findings reports, questions, agent notes) */
.md { font-size: 0.9rem; line-height: 1.62; color: var(--text); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { color: var(--ink); font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; margin: 1.5em 0 0.5em; text-wrap: balance; }
.md h1 { font-size: 1.3rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.md h2 { font-size: 1.1rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border-2); }
.md h3 { font-size: 0.98rem; }
.md h4, .md h5, .md h6 { font-size: 0.9rem; color: var(--text-2); }
.md p { margin: 0 0 0.8em; }
.md strong { color: var(--ink); font-weight: 600; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md ul, .md ol { margin: 0 0 0.8em; padding-left: 1.45rem; }
.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.md ul ul { list-style: circle; }
.md li { margin: 0.2em 0; }
.md li > ul, .md li > ol { margin: 0.2em 0 0.2em; }
.md li.md-nest { list-style: none; }
.md li.md-task { list-style: none; margin-left: -1.2rem; }
.md .md-check { display: inline-block; width: 13px; height: 13px; border: 1.5px solid var(--faint); border-radius: 3px; margin-right: 0.45rem; vertical-align: -2px; }
.md .md-check.on { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--surface); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md blockquote { margin: 0 0 0.8em; padding: 0.5rem 0.9rem; border-left: 3px solid var(--brand-300); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--text-2); }
.md pre { margin: 0 0 0.9em; padding: 0.75rem 0.9rem; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-md); overflow-x: auto; }
.md pre code { background: none; border: none; padding: 0; font-size: 0.8rem; line-height: 1.5; white-space: pre; color: var(--text); }
.md .md-table { margin: 0 0 1em; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.md table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: 1.45; }
.md th { text-align: left; font-weight: 600; color: var(--text-2); font-size: var(--fs-xs); padding: 0.5rem 0.7rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.md td { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border-2); vertical-align: top; overflow-wrap: break-word; }
.md tbody tr:last-child td { border-bottom: none; }
.md tbody tr:hover td { background: var(--surface-2); }
.md .md-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.md .md-center { text-align: center; }
.md .md-left { text-align: left; }

/* ====================================================================
 * Generated reports: template picker, parent link, child rows.
 * ==================================================================== */
.template-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.template-card { display: flex; align-items: flex-start; gap: 0.7rem; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 0.7rem 0.85rem; transition: border-color var(--t-fast), background var(--t-fast); }
.template-card:hover { border-color: var(--brand-300); }
.template-card:focus-visible { outline: none; box-shadow: var(--ring); }
.template-card.selected { border-color: var(--brand); background: var(--brand-tint); }
.template-radio { width: 15px; height: 15px; flex-shrink: 0; margin-top: 0.18rem; border-radius: 999px; border: 1.5px solid var(--faint); background: var(--surface); }
.template-card.selected .template-radio { border-color: var(--brand); background: var(--brand); box-shadow: inset 0 0 0 3px var(--surface); }
.template-main { display: flex; flex-direction: column; min-width: 0; }
.template-label { font-size: var(--fs-base); font-weight: 600; color: var(--ink); }
.template-desc { font-size: var(--fs-sm); color: var(--text-2); margin-top: 0.1rem; }
.inv-based { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.3rem; font-size: var(--fs-sm); color: var(--text-2); }
.inv-based svg { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; }
.inv-based a { font-weight: 600; }
.inv-row-child { padding-left: 3.1rem; background: var(--surface-2); }
.inv-row-child .glyph { width: 28px; height: 28px; }
.inv-row-child .glyph svg { width: 14px; height: 14px; }
.rr-actions { display: inline-flex; align-items: center; gap: 0.6rem; }
.outputs-label-next { margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px solid var(--border-2); }
.output-status { margin-top: 0.25rem; }
.output-row .spinner-sm { width: 13px; height: 13px; }

/* ====================================================================
 * Rules tab: rulebook list, filters, and the rule beside its source row.
 * ==================================================================== */
.rules-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.rules-stats { display: flex; align-items: center; gap: 1rem; font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.rules-stats > span { display: inline-flex; align-items: center; gap: 0.35rem; }
.rules-stats strong { color: var(--ink); font-size: var(--fs-base); }
.rules-filters { display: flex; gap: 0.5rem; }
.rules-filters select { font: inherit; font-size: var(--fs-sm); color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.32rem 0.55rem; }
.rules-filters select:focus-visible { outline: none; box-shadow: var(--ring); }
.rules-tbl td { vertical-align: middle; }
.rules-row { cursor: pointer; }
.rules-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--brand-300); }
.rules-name { font-weight: 600; color: var(--ink); }
.rules-id { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: var(--fs-2xs); color: var(--muted); margin-top: 0.1rem; }
.rules-code { display: inline-block; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: var(--fs-xs); font-weight: 600; color: var(--ink); background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 0.05rem 0.4rem; margin-right: 0.45rem; }
.rules-muted { color: var(--muted); font-size: var(--fs-xs); }
.rules-rate { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rules-subhead { font-size: var(--fs-h2); font-weight: 700; color: var(--ink); margin: 1.6rem 0 0.6rem; }
.rules-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0.9rem 0 1rem; }
.rules-detail-head h2 { font-size: var(--fs-h1); font-weight: 700; color: var(--ink); }
.rules-badges { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.rules-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.rules-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.rules-card-title { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.6rem; }
.rules-dl { margin: 0; }
.rules-kv { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 0.8rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-2); font-size: var(--fs-sm); }
.rules-kv:last-child { border-bottom: none; padding-bottom: 0; }
.rules-kv dt { color: var(--muted); }
.rules-kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.rules-kv dd strong { color: var(--ink); font-size: var(--fs-base); }
.rules-note { color: var(--text-2); margin-top: 0.25rem; }
.rules-conds { margin: 0; padding-left: 1.05rem; list-style: disc; }
.rules-conds li + li { margin-top: 0.2rem; }
.rules-file { display: flex; align-items: center; gap: 0.45rem; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); margin-bottom: 0.55rem; }
.rules-file svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.rules-quote { margin: 0 0 0.7rem; padding: 0.65rem 0.8rem; background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--brand-300); border-radius: 0 var(--r-md) var(--r-md) 0; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: var(--fs-xs); line-height: 1.55; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.rules-cells { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.rules-cells td { padding: 0.28rem 0; border-bottom: 1px solid var(--border-2); vertical-align: top; overflow-wrap: anywhere; }
.rules-cells tr:last-child td { border-bottom: none; }
.rules-cells td:first-child { width: 9.5rem; color: var(--muted); font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; padding-right: 0.6rem; }
.rules-conf { display: flex; align-items: flex-start; gap: 0.6rem; font-size: var(--fs-sm); color: var(--text); line-height: 1.5; }
.rules-conf .badge { flex-shrink: 0; margin-top: 0.1rem; }
.rules-checks { margin-top: 0.75rem; font-size: var(--fs-xs); color: var(--text-2); }
.rules-checks summary { cursor: pointer; font-weight: 600; color: var(--ok-fg); }
.rules-checks ul { margin: 0.45rem 0 0; padding-left: 1.05rem; list-style: disc; }
.rules-checks li + li { margin-top: 0.15rem; }
.rules-prov { margin-top: 0.75rem; padding-top: 0.65rem; border-top: 1px solid var(--border-2); font-size: var(--fs-xs); color: var(--muted); }
.rules-prov a { font-weight: 600; }
@media (max-width: 900px) { .rules-grid { grid-template-columns: minmax(0, 1fr); } }

/* Brand mark: dot-grid glyph plus wordmark, matching feeverify.com */
.fv-mark { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-family: 'Geist', ui-sans-serif, system-ui, sans-serif; font-weight: 600; font-size: 19px; letter-spacing: -0.02em; line-height: 1; }
.fv-mark-glyph { display: inline-grid; grid-template-columns: repeat(3, 4px); gap: 3px; }
.fv-mark-glyph i { width: 4px; height: 4px; border-radius: 50%; background: #c3b1f2; opacity: 0.55; }
.fv-mark-glyph i:nth-child(5) { opacity: 1; }
.fv-mark-glyph i:nth-child(9) { background: #f5a524; opacity: 1; }
.fv-mark-lg { font-size: 24px; gap: 12px; }
.fv-mark-lg .fv-mark-glyph { grid-template-columns: repeat(3, 5px); gap: 4px; }
.fv-mark-lg .fv-mark-glyph i { width: 5px; height: 5px; }
/* Brand mark on a light surface (sidebar) */
.sidebar .fv-mark { color: var(--ink); }
.sidebar .fv-mark-glyph i { background: var(--brand); opacity: 0.4; }
.sidebar .fv-mark-glyph i:nth-child(5) { opacity: 1; }
.sidebar .fv-mark-glyph i:nth-child(9) { background: #f5a524; opacity: 1; }

/* User menu: bottom of the sidebar, opens upward. Holds administration + sign out. */
.user-menu { position: relative; padding: 0.55rem; border-top: 1px solid var(--border); }
.user-menu-btn {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.5rem 0.55rem; border-radius: var(--r-md);
  background: none; border: none; cursor: pointer; text-align: left; color: var(--ink);
}
.user-menu-btn:hover, .user-menu-btn[aria-expanded="true"] { background: var(--surface-2); }
.user-menu-btn .user-avatar { width: 32px; height: 32px; font-size: 0.75rem; flex-shrink: 0; }
.user-menu-id { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-menu-name { font-size: var(--fs-base); font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-email { font-size: var(--fs-xs); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-chev { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-2); }
.user-menu-pop {
  position: absolute; left: 0.55rem; right: 0.55rem; bottom: calc(100% - 0.25rem); z-index: 40;
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(28, 4, 56, 0.16); padding: 0.3rem;
}
.user-menu-item {
  display: flex; align-items: center; gap: 0.65rem; width: 100%;
  padding: 0.55rem 0.6rem; border-radius: var(--r-sm);
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--ink); font-size: var(--fs-base); font-weight: 500;
}
.user-menu-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-2); }
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-sep { height: 1px; background: var(--border); margin: 0.3rem 0; }
@media (max-width: 860px) {
  .user-menu { border-top: none; margin-left: auto; padding: 0.3rem 0.6rem; }
  .user-menu-id, .user-menu-chev { display: none; }
  .user-menu-pop { left: auto; right: 0.6rem; bottom: auto; top: 100%; min-width: 12rem; }
}

/* Activity: one heading per kind of data */
.list-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.55rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border-2);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.list-group-head:not(:first-child) { border-top: 1px solid var(--border-2); }
.list-group-head .lg-count { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-2); }

/* Worklog: filter by piece of work */
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.85rem; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.35rem 0.7rem;
  border: 1px solid var(--border); border-radius: 999px; background: #fff; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text);
}
.filter-chip:hover { border-color: var(--brand-300); }
.filter-chip .fc-count { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); }
.filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-chip.active .fc-count { color: rgba(255, 255, 255, 0.8); }
.worklog-work { margin-top: 0.15rem; font-size: var(--fs-xs); color: var(--muted); }

/* Worklog: queue and log views */
.view-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.view-tab {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.9rem; margin-bottom: -1px;
  background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
  font-size: 0.9375rem; font-weight: 600; color: var(--text-2);
}
.view-tab:hover { color: var(--ink); }
.view-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.vt-count { font-size: var(--fs-xs); font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); }
.vt-count.warn { background: var(--review-bg); color: var(--review-fg); }
.list-group-title { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.55rem; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.list-group-title .lg-count { font-size: var(--fs-xs); font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); }
