:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f4;
  --ink: #182224;
  --muted: #657174;
  --line: #d9e1e3;
  --accent: #0f766e;
  --accent-2: #134e4a;
  /* VLTRN house brand color — hot magenta from the official VLTRN AGENCY
     wordmark. Locked to the "V" glyph and the full "VLTRN" wordmark only;
     a client palette NEVER overrides --vltrn (theming writes --accent). */
  --vltrn: #ff00a2;
  --vltrn-2: #c7007e;
  --warn: #a16207;
  --danger: #b42318;
  --ok: #157347;
  --shadow: 0 12px 32px rgba(24, 34, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  transition: margin-right 0.18s ease;
}

.sidebar {
  background: #162326;
  color: #f3fbfb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  /* Pin to the viewport so the bottom V-Line / V.AGENCY signature is always in
     view — the grid cell would otherwise stretch to the (very tall) queue and
     push the branding far below the fold. The footer uses margin-top:auto to
     sit at the bottom of this 100vh column. */
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #20363a;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

/* Client logo replaces the default mark. It never overrides the V-Line lockup,
   which sits in its own element with the protected VLTRN gradient. */
.brand-mark.has-logo {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  padding: 3px;
  overflow: hidden;
}
.brand-mark .brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 5px;
}

.brand span,
.sidebar-footer span {
  color: #a8bbbf;
  font-size: 13px;
}

/* V-Line — powered by V.AGENCY: product wordmark in the VLTRN house color.
   Gradient text reads on both the dark sidebar and the light login card. */
/* Company name (org.name) — the primary line of the hero brand block. */
.brand-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}
.vline-lockup {
  display: flex !important;
  flex-direction: column;
  gap: 1px;
  line-height: 1.15;
  margin-top: 3px;
}
/* NOTE: these are scoped under .vline-lockup (specificity 0,2,0) so they beat the
   sidebar's `.brand span { display:block; font-size:13px; color:… }` rule (0,1,1)
   — otherwise, inside the sidebar, the inline "V" is forced to its own line and
   the "powered by" line inherits the wrong size/color. */
.vline-lockup .vline-mark {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: inherit; /* LINE / AGENCY stay neutral — only the "V" is branded */
  white-space: nowrap; /* "V-Line" is one unit — never wrap */
}
/* The VLTRN "V" glyph (and any full "VLTRN" wordmark) is locked to the house
   color. It must stay INLINE and at the surrounding text's size — so the "V"
   never drops to its own line or grows larger than the word it belongs to. The
   .vline-lockup-scoped selector overrides `.brand span`. Never written by the
   client-theming engine (which only sets --accent). */
.vltrn-v,
.vltrn-wordmark,
.vline-lockup .vltrn-v {
  display: inline;
  font-size: inherit;
  letter-spacing: inherit;
  color: var(--vltrn);
  -webkit-text-fill-color: var(--vltrn);
  font-weight: 800;
}
.vline-lockup .vline-by {
  font-size: 9px;
  font-weight: 400; /* subtitle — "powered by" is NOT bold; only the "V" stays heavy */
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8a9a9e;
  white-space: nowrap; /* "powered by V.AGENCY" is one unit — never wrap */
  margin-top: 2px;
}
.login-brand .vline-by { color: var(--muted); }

nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #d8e6e8;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #244044;
  color: #ffffff;
}

/* The bottom group (tools dropdown + mode + V-Line signature) pins to the base
   of the 100vh sidebar. Expanding the dropdown grows it upward into the gap. */
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-footer {
  display: grid;
  gap: 4px;
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}
.sidebar-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: #f3fbfb;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-menu-toggle:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar-menu-toggle .chev { transition: transform 0.15s ease; opacity: 0.7; }
.sidebar-menu-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sidebar-menu-list { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.sidebar-menu-list.hidden { display: none; }
.sidebar-menu-item {
  text-align: left;
  background: transparent;
  color: #cfe0e2;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.sidebar-menu-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
a.sidebar-menu-item { display: block; text-decoration: none; }
.sidebar-menu-item.hidden { display: none; }

/* Platform endorsement, pinned to the very bottom of the sidebar — below the
   client's own name badge at the top. Sits just under the Mode box (tightened
   from the sidebar's flex gap). The VLTRN "V" stays locked to --vltrn. */
.sidebar-signature {
  margin-top: -14px;
  padding: 2px 2px 0;
}

main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  /* Keep the tool frame in view while the queue scrolls. Opaque page-colored
     background occludes content sliding underneath; the shadow reads it as a
     pinned header. z-index sits below the AgentV drawer (60) and dialogs. */
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  padding-top: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  box-shadow: 0 8px 16px -14px rgba(0, 0, 0, 0.4);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

.topbar p {
  color: var(--muted);
  margin-top: 5px;
}

.topbar-actions,
.approval-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 13px;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

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

.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(340px, 0.38fr) minmax(0, 0.62fr);
  gap: 16px;
  align-items: start;
}

.queue-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-heading,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.detail-header h2 {
  font-size: 18px;
}

.search-wrap {
  display: grid;
  gap: 4px;
}

.search-wrap label {
  color: var(--muted);
  font-size: 12px;
}

.search-wrap input {
  width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

.email-list {
  max-height: calc(100vh - 235px);
  overflow: auto;
}

.email-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 14px 16px;
  cursor: pointer;
}

.email-item:hover,
.email-item.active {
  background: var(--surface-2);
}

.email-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.email-meta,
.email-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
}

.email-recipients {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
}

.email-recipients b {
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf3f3;
  color: #304245;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.badge.high {
  background: #fff1f0;
  color: var(--danger);
}

.badge.medium {
  background: #fff7e6;
  color: var(--warn);
}

.badge.low {
  background: #eaf7ef;
  color: var(--ok);
}

.detail-panel {
  min-height: calc(100vh - 161px);
}

.empty-state {
  padding: 42px;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--ink);
}

.hidden {
  /* !important so this utility always wins over component display rules
     (e.g. .login-overlay/.user-menu set display:flex later in the file). */
  display: none !important;
}

.detail-view {
  padding: 18px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.detail-header p {
  color: var(--muted);
  margin-top: 5px;
}

.confidence {
  min-width: 92px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--muted);
}

.confidence strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.45fr);
  gap: 14px;
  margin-top: 16px;
}

.section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 14px;
}

.detail-grid .section {
  margin-top: 0;
}

.section-title h3 {
  font-size: 15px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.field-list {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(0, 0.65fr);
  gap: 8px 12px;
  margin: 14px 0 0;
}

.field-list dt {
  color: var(--muted);
}

.field-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.missing-list {
  margin: 12px 0 0;
  padding-left: 19px;
  color: var(--danger);
}

.missing-list.ok {
  color: var(--ok);
  padding-left: 0;
  list-style: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.action-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.action-summary div {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}

.action-summary span,
.action-summary strong {
  display: block;
}

.action-summary span {
  color: var(--muted);
  font-size: 12px;
}

.action-summary strong {
  margin-top: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent-2);
  background: #e8f6f4;
  font-weight: 800;
}

.draft-output,
.original-email {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0 0;
  max-height: 330px;
  overflow: auto;
  line-height: 1.45;
}

.approval-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
  margin-top: 14px;
}

.approval-bar span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 27, 30, 0.36);
}

form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

label input,
label textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

@media (max-width: 1100px) {
  .workbench,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .email-list {
    max-height: 410px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  main {
    padding: 16px;
  }

  .topbar,
  .approval-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    position: static; /* a tall stacked header shouldn't eat the mobile viewport */
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-summary {
    grid-template-columns: 1fr;
  }

  .field-list {
    grid-template-columns: 1fr;
  }

  .search-wrap input {
    width: 100%;
  }
}

/* --- Integration status chips --- */
.integration-status {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-right: 4px;
}

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.chip.live {
  background: rgba(21, 115, 71, 0.12);
  color: var(--ok);
  border-color: rgba(21, 115, 71, 0.3);
}

.chip.demo {
  background: var(--surface-2);
  color: var(--muted);
}

/* --- Execution result panel --- */
.execution-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #f8fafb;
}

.exec-badge {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.exec-badge.success { color: var(--ok); }
.exec-badge.error { color: var(--danger); }
.exec-badge.skipped { color: var(--muted); }

.exec-summary {
  margin: 4px 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.exec-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.exec-detail div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}

.exec-detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.exec-detail strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.exec-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .exec-detail {
    grid-template-columns: 1fr;
  }
}

/* --- Auth: login gate, user chip, ghost button --- */
.button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.button.ghost:hover { color: var(--ink); border-color: var(--muted); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--line);
}
.user-info { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.user-info strong { font-size: 0.86rem; color: var(--ink); }
.user-info span { font-size: 0.72rem; color: var(--muted); }

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--surface-2), var(--bg));
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong { display: block; color: var(--ink); }
.login-brand span { font-size: 0.75rem; color: var(--muted); }
.login-card h1 { margin: 4px 0 0; font-size: 1.35rem; color: var(--ink); }
#loginSubtitle { margin: 0 0 4px; color: var(--muted); font-size: 0.86rem; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.login-card .button { justify-content: center; margin-top: 4px; }
.login-error {
  margin: 0;
  padding: 8px 10px;
  background: #fdecea;
  color: var(--danger);
  border-radius: 8px;
  font-size: 0.82rem;
}

/* --- Audit trail dialog --- */
.audit-dialog {
  width: min(640px, 92vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.audit-dialog::backdrop { background: rgba(24, 34, 36, 0.35); }
.audit-sub { margin: 2px 0 12px; color: var(--muted); font-size: 0.82rem; }
.audit-integrity { margin-bottom: 12px; font-size: 0.85rem; }
.audit-ok { color: var(--ok); font-weight: 600; }
.audit-broken { color: var(--danger); font-weight: 600; }
.audit-loading { color: var(--muted); }
.audit-list { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.audit-row {
  display: flex;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--surface-2);
}
.audit-when { flex: 0 0 88px; font-size: 0.72rem; color: var(--muted); }
.audit-body { flex: 1; min-width: 0; }
.audit-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.audit-type { font-weight: 600; font-size: 0.82rem; color: var(--ink); }
.audit-actor { font-size: 0.76rem; color: var(--accent); }
.audit-detail { font-size: 0.78rem; color: var(--muted); word-break: break-word; }
.audit-empty { padding: 16px; color: var(--muted); text-align: center; }

/* --- Team & back office --- */
.team-dialog {
  width: min(860px, 94vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.team-dialog::backdrop { background: rgba(24, 34, 36, 0.35); }
.add-user-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}
.add-user-form input,
.add-user-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface);
}
.add-user-form input { flex: 1; min-width: 130px; }
.button.small { padding: 5px 10px; font-size: 0.76rem; }
.temp-pw-banner {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #eefaf3;
  border: 1px solid #b6e3cd;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--ink);
}
.temp-pw-banner code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.temp-pw-error { color: var(--danger); }
.team-table-wrap { max-height: 56vh; overflow: auto; }
.team-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.team-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.team-table td { padding: 9px 10px; border-bottom: 1px solid var(--surface-2); vertical-align: top; }
.team-emp strong { color: var(--ink); }
.team-email { color: var(--muted); font-size: 0.76rem; }
.team-sub { color: var(--muted); font-size: 0.72rem; }
.team-loading { color: var(--muted); text-align: center; padding: 16px; }

/* --- Teams & assignment (P1) -------------------------------------------------
   Team colors are their OWN token (--team-color per pill). color-mix keeps any
   admin-picked hex legible. NEVER applied to .vltrn-v (the brand mark). */
.who-chip.team-chip {
  gap: 5px;
  font-weight: 600;
  --team-color: #64748b;
  background: color-mix(in srgb, var(--team-color) 14%, var(--surface));
  color: color-mix(in srgb, var(--team-color) 72%, #12211f);
  border: 1px solid color-mix(in srgb, var(--team-color) 38%, var(--surface));
}
.who-chip.team-chip::before {
  content: "";
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--team-color);
  flex: none;
}

/* --- Teams & assignment (P2) -------------------------------------------------
   Row Claim chip, team filter bar, and the round-robin confirm toast. Team
   colors stay their own token (--team-color) — never the brand mark. */
.who-chip.claim-chip {
  cursor: pointer;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent, #0f766e) 12%, var(--surface));
  color: color-mix(in srgb, var(--accent, #0f766e) 78%, #12211f);
  border: 1px solid color-mix(in srgb, var(--accent, #0f766e) 36%, var(--surface));
}
.who-chip.claim-chip:hover { background: color-mix(in srgb, var(--accent, #0f766e) 22%, var(--surface)); }
.claim-btn { margin-left: 2px; }

.team-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 2px 2px; }
.team-filter-bar:empty { display: none; }
.team-filter-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
.team-filter-chip {
  --team-color: #64748b;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #d8dee0; background: #fff; color: #364043;
  border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.team-filter-chip:hover { border-color: #9aa6a9; }
.team-filter-chip .tf-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--team-color); flex: none; }
.team-filter-chip.active {
  background: color-mix(in srgb, var(--team-color) 16%, var(--surface));
  color: color-mix(in srgb, var(--team-color) 74%, #12211f);
  border-color: color-mix(in srgb, var(--team-color) 45%, var(--surface));
}
.team-filter-chip.clear { background: #fdecea; color: #8a1c12; border-color: #f5c6c0; }

.app-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  z-index: 9000; max-width: 80vw;
  background: #12211f; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease;
}
.app-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Roster: team badges + no-team hint */
.team-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.team-none-hint { color: var(--muted); font-size: 0.72rem; font-style: italic; }
.team-row-actions { white-space: nowrap; }
.team-row-actions .button + .button { margin-left: 4px; }

/* User form: assign-to-teams choice chips */
.add-user-row { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.add-user-row input { flex: 1; min-width: 130px; }
.add-user-teams { width: 100%; margin-top: 10px; }
.team-choice-label { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.team-choice-label em { font-style: normal; color: var(--warn); font-weight: 600; }
.team-choice-set { display: flex; flex-wrap: wrap; gap: 6px; }
.team-choice {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  font-size: 0.78rem; font-weight: 600; user-select: none;
  --team-color: #64748b;
  border: 1px solid color-mix(in srgb, var(--team-color) 40%, var(--line));
  background: var(--surface);
  color: color-mix(in srgb, var(--team-color) 68%, #12211f);
}
.team-choice input { accent-color: var(--team-color); margin: 0; }
.team-choice:has(input:checked) { background: color-mix(in srgb, var(--team-color) 16%, var(--surface)); }
.team-choice-empty { color: var(--muted); font-size: 0.78rem; margin: 0; }
.team-choice-error { color: var(--danger); font-size: 0.76rem; margin: 6px 0 0; font-weight: 600; }

/* Teams management section */
.teams-section { margin: 4px 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.teams-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.teams-head h4 { margin: 0; font-size: 0.95rem; }
.teams-sub { color: var(--muted); font-size: 0.76rem; margin: 4px 0 10px; }
.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.teams-empty { color: var(--muted); font-size: 0.82rem; grid-column: 1 / -1; margin: 0; }
.teams-nudge { margin: 10px 0 0; padding: 8px 11px; border-radius: 8px; background: #fdf6ea; border: 1px solid #ecd9b0; color: #7a5b16; font-size: 0.78rem; }
.teams-archived { margin-top: 10px; }
.teams-archived summary { cursor: pointer; color: var(--muted); font-size: 0.78rem; }

.team-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface); }
.team-card.is-archived { opacity: 0.62; }
.team-card-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.team-card-meta { color: var(--muted); font-size: 0.72rem; flex: 1; min-width: 90px; }
.team-card-actions { display: inline-flex; gap: 4px; }

.team-form { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.team-form-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.team-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.team-field input[type="text"], .team-field select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.84rem; color: var(--ink); background: var(--surface); min-width: 150px;
}
.team-field-color input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.team-form-error, .team-choice-error.hidden { }
.team-form-error { color: var(--danger); font-size: 0.76rem; margin: 8px 0 0; font-weight: 600; }
.team-form-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.team-archive-btn { margin-left: auto; }

.team-members { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.team-member-set { display: grid; gap: 4px; max-height: 200px; overflow: auto; }
.team-member-choice { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; padding: 3px 2px; cursor: pointer; }
.team-member-choice em { color: var(--muted); font-style: normal; font-size: 0.74rem; }

/* P4 auto-routing rules */
.routes-list { display: grid; gap: 6px; }
.route-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.route-summary { font-size: 0.82rem; color: var(--ink); flex: 1; min-width: 120px; }
.route-summary code { font-size: 0.78rem; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); }
.route-priority { font-size: 0.72rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.route-remove { min-width: 26px; padding: 2px 8px; font-size: 1.05rem; line-height: 1; color: var(--muted); }
.route-remove:hover { color: var(--danger); }
.routes-empty { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }

.team-edit-row td { background: var(--surface-2); }
.team-edit-inline { padding: 6px 2px; }
.team-edit-actions { display: flex; gap: 6px; margin-top: 8px; }
.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  vertical-align: middle;
}
.pill.warn { background: #fdf1dc; color: var(--warn); }

/* --- View switch + load pipeline --- */
.view-switch { display: flex; gap: 4px; background: #0f1c1f; border: 1px solid rgba(255,255,255,0.14); border-radius: 9px; padding: 4px; }
.view-tab { flex: 1; border: 0; background: transparent; color: #cfe0e2; padding: 8px 6px; border-radius: 6px; font-weight: 700; font-size: 0.8rem; cursor: pointer; }
.view-tab.active { background: var(--accent); color: #fff; }

.pipeline { min-width: 0; }
.pipeline-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.pipeline-head p { color: var(--muted); margin-top: 4px; }
.pipeline-counts { display: flex; gap: 10px; color: var(--muted); font-size: 0.82rem; }
.pipeline-counts span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }

.load-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.board-lane { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-width: 0; }
.lane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lane-head h3 { font-size: 0.86rem; color: var(--ink); }
.lane-head span { color: var(--muted); font-size: 0.78rem; background: var(--surface); border-radius: 999px; padding: 1px 8px; }
.lane-cards { display: grid; gap: 8px; }
.lane-empty { color: var(--muted); font-size: 0.78rem; padding: 8px; text-align: center; }

.load-card { text-align: left; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); border-radius: 8px; padding: 10px; cursor: pointer; display: grid; gap: 5px; }
.load-card:hover { box-shadow: var(--shadow); }
.load-card.tone-q { border-left-color: #0ea5a0; }
.load-card.tone-s { border-left-color: #2563eb; }
.load-card.tone-t { border-left-color: #a16207; }
.load-card.tone-b { border-left-color: #157347; }
.load-card-top { display: flex; justify-content: space-between; align-items: baseline; }
.load-value { font-weight: 800; color: var(--ink); }
.load-cust { font-weight: 700; color: var(--ink); font-size: 0.86rem; }
.load-lane { color: var(--muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.load-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.next-hint { font-size: 0.72rem; color: var(--accent-2); font-weight: 600; }
.next-hint.done { color: var(--ok); }
.board-loading { color: var(--muted); padding: 24px; text-align: center; grid-column: 1 / -1; }

.stage-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.68rem; font-weight: 800; background: #e6f4f3; color: #0f5f59; }
.stage-badge.tone-s { background: #e7edfd; color: #1e40af; }
.stage-badge.tone-t { background: #fdf1dc; color: #92500a; }
.stage-badge.tone-b { background: #e6f5ec; color: #0f6b39; }

/* Load detail dialog */
.load-dialog { width: min(720px, 95vw); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.load-dialog::backdrop { background: rgba(24,34,36,0.4); }
.load-body { max-height: 72vh; overflow: auto; }
.load-progress { display: flex; align-items: center; gap: 5px; margin-bottom: 14px; }
.prog-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.prog-dot.on { background: var(--accent); border-color: var(--accent); }
.prog-label { margin-left: 8px; color: var(--muted); font-size: 0.78rem; }
.load-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 16px; margin-bottom: 14px; }
.load-grid div { display: flex; flex-direction: column; }
.load-grid span { color: var(--muted); font-size: 0.72rem; }
.load-grid strong { font-size: 0.86rem; overflow-wrap: anywhere; }
.load-section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.load-section h4 { font-size: 0.82rem; margin-bottom: 8px; color: var(--ink); }
.bid-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.bid-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.bid-table td { padding: 5px 6px; border-top: 1px solid var(--surface-2); }
.bid-table tr.sel { background: #eefaf3; }
.bid-notes { color: var(--muted); }
.muted { color: var(--muted); }
.quote-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.quote-row label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.quote-row input { width: 110px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.margin-note { color: var(--muted); font-size: 0.76rem; }
.load-template { background: #0f1c1f; color: #d7ebe9; border-radius: 8px; padding: 12px; font-size: 0.76rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.payload-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.payload-row label { display: flex; flex-direction: column; gap: 3px; font-size: 0.76rem; color: var(--muted); }
.payload-row input, .payload-row select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.load-action { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.advance-note { color: var(--muted); font-size: 0.76rem; }
.block-reason { color: var(--danger); font-size: 0.82rem; width: 100%; margin: 0 0 4px; }
.done-note { color: var(--ok); font-weight: 700; }
.load-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.load-timeline li { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; font-size: 0.78rem; align-items: baseline; }
.tl-when { color: var(--muted); }
.tl-actor { color: var(--muted); font-size: 0.72rem; }

/* --- F2 shipment packets (inside the load dialog) --- */
.packet-hint { margin-bottom: 10px; }
.packet-list { display: grid; gap: 8px; }
.packet-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.packet-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.packet-label { font-size: 0.84rem; font-weight: 700; color: var(--ink); }
.packet-aud { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: 0.03em; text-transform: uppercase; }
.aud-customer { background: #e7edfd; color: #1e40af; }
.aud-carrier { background: #e6f4f3; color: #0f5f59; }
.aud-tms { background: #efe7fd; color: #6d28d9; }
.packet-pill { margin-left: auto; display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; }
.packet-pill.ready { background: #e6f5ec; color: var(--ok); }
.packet-pill.need { background: #eef1f2; color: var(--muted); }
.packet-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
/* A not-ready packet can't be sent — grey the (solid) Send button out. */
.packet-actions .button[disabled] { opacity: 0.45; cursor: default; }
.packet-actions .button.primary[disabled]:hover { background: var(--accent); }
.packet-preview { margin-top: 10px; }
.packet-missing { background: #fdf1dc; color: #92500a; border-radius: 6px; padding: 7px 10px; font-size: 0.76rem; margin-bottom: 8px; }
.packet-prev-head { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.packet-body { margin: 0; max-height: 260px; }
.packet-flash { background: #e6f5ec; color: #157347; border-radius: 6px; padding: 8px 10px; font-size: 0.78rem; font-weight: 700; margin-bottom: 10px; }

@media (max-width: 900px) {
  .load-board { grid-template-columns: 1fr 1fr; }
}

/* --- Team queue: workflow status badges, @assign, flash notification --- */
.badge.qs-needs_response { background: #fdecea; color: var(--danger); animation: qs-pulse 1.6s ease-in-out infinite; }
.badge.qs-action_needed { background: #fdecea; color: var(--danger); }
.badge.qs-assigned { background: #efe7fd; color: #6d28d9; }
.badge.qs-in_progress { background: #e7edfd; color: #1e40af; }
.badge.qs-quoted { background: #e6f4f3; color: #0f5f59; }
.badge.qs-pending_customer { background: #fdf1dc; color: var(--warn); }
.badge.qs-completed { background: #e6f5ec; color: var(--ok); }
.badge.qs-closed { background: #eef1f2; color: var(--muted); }
/* Auto-label filter bar + per-email tags. */
.label-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 2px 10px; }
.label-bar:empty { display: none; }
.label-chip { border: 1px solid #d8dee0; background: #fff; color: #364043; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.label-chip:hover { border-color: #9aa6a9; }
.label-chip.active { background: #123; color: #fff; border-color: #123; }
.label-chip.clear { background: #fdecea; color: #8a1c12; border-color: #f5c6c0; }
.label-chip .lc-count { opacity: 0.6; font-weight: 700; }
.email-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.auto-label { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: 0.02em; }
/* Kind colors — shared by the filter chips and per-email tags. */
.lk-type { background: #e7edfd; color: #1e40af; }
.lk-equip { background: #e6f4f3; color: #0f5f59; }
.lk-ref { background: #eef1f2; color: #55636a; }
.lk-flag { background: #fdf1dc; color: #9a6a00; }
.label-chip.lk-type, .label-chip.lk-equip, .label-chip.lk-ref, .label-chip.lk-flag { background: #fff; color: #364043; }
.label-chip.lk-flag.active, .label-chip.lk-type.active, .label-chip.lk-equip.active, .label-chip.lk-ref.active { background: #123; color: #fff; }

/* The "V" in AgentV must hold the VLTRN house color even inside a button,
   whose .button.secondary color (0,2,0) would otherwise beat .vltrn-v (0,1,0).
   Id/class-scoped selectors win and set both color + text-fill. */
#agentvButton .vltrn-v,
.agentv-head .vltrn-v {
  color: var(--vltrn);
  -webkit-text-fill-color: var(--vltrn);
  font-weight: 800;
}

/* AgentV chat drawer. */
.agentv-panel { position: fixed; top: 0; right: 0; width: 380px; max-width: 92vw; height: 100vh; background: #fff; border-left: 1px solid #e2e7e9; box-shadow: -8px 0 28px rgba(0,0,0,0.10); display: flex; flex-direction: column; z-index: 60; }
.agentv-panel.hidden { display: none; }
/* When AgentV is open, reflow the app so nothing hides behind the drawer —
   the content shrinks by the drawer width instead of being covered. On narrow
   screens the drawer overlays (reserving 380px wouldn't fit). */
@media (min-width: 900px) {
  body.agentv-open .app-shell { margin-right: 380px; }
}
.agentv-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid #eef1f2; }
.agentv-head strong { font-size: 15px; }
.agentv-head .agentv-sub { color: var(--muted); font-size: 12px; }
.agentv-head .button { margin-left: auto; }
.agentv-bar { display: flex; gap: 8px; padding: 8px 16px; border-bottom: 1px solid #eef1f2; }
.av-bar-btn { background: #f2f5f6; border: 1px solid #e2e7e9; color: #364043; border-radius: 8px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.av-bar-btn:hover { background: #e9eef0; }
.agentv-history { border-bottom: 1px solid #eef1f2; padding: 10px 12px; max-height: 45%; overflow-y: auto; background: #fafbfb; }
.agentv-history.hidden { display: none; }
.av-scope { display: flex; gap: 6px; margin-bottom: 8px; }
.av-scope-btn { background: #fff; border: 1px solid #d8dee0; color: #364043; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600; cursor: pointer; }
.av-scope-btn.active { background: #123; color: #fff; border-color: #123; }
.av-conv-list { display: flex; flex-direction: column; gap: 4px; }
.av-conv { text-align: left; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid #e8edee; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.av-conv:hover { border-color: #9aa6a9; }
.av-conv-preview { font-size: 12.5px; color: #1b2528; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-conv-meta { font-size: 10.5px; color: var(--muted); }

.agentv-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.av-empty { color: var(--muted); font-size: 13px; line-height: 1.5; }
.av-msg { padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; max-width: 90%; white-space: pre-wrap; }
.av-user { align-self: flex-end; background: #123; color: #fff; border-bottom-right-radius: 3px; }
.av-bot { align-self: flex-start; background: #f2f5f6; color: #1b2528; border-bottom-left-radius: 3px; }
.av-thinking { opacity: 0.6; font-style: italic; }
.av-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.av-action { font-size: 10px; font-weight: 700; background: #e6f4f3; color: #0f5f59; padding: 2px 7px; border-radius: 6px; }
.agentv-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #eef1f2; align-items: center; }
.agentv-form input[type="text"] { flex: 1; padding: 9px 12px; border: 1px solid #d8dee0; border-radius: 8px; font-size: 13px; }

/* Screenshots in and out of the drawer. The thumbnails are deliberately small:
   they confirm WHICH image is attached, they aren't a viewer. */
.av-icon-btn { flex: 0 0 auto; width: 32px; height: 32px; padding: 0; border: 1px solid #d8dee0; border-radius: 8px; background: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
.av-icon-btn:hover:not(:disabled) { background: #f2f5f6; border-color: #b9c4c7; }
.av-icon-btn:disabled { opacity: 0.5; cursor: progress; }
.av-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 0; }
.av-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 190px; padding: 3px 6px 3px 3px; background: #f2f5f6; border: 1px solid #e0e6e8; border-radius: 8px; font-size: 11px; }
.av-chip-thumb { width: 26px; height: 26px; object-fit: cover; border-radius: 5px; flex: 0 0 auto; }
.av-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #46555a; }
.av-chip-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 11px; padding: 0 2px; }
.av-chip-x:hover { color: #b3261e; }
.av-msg-shots { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.av-msg-thumb { max-width: 132px; max-height: 100px; border-radius: 7px; display: block; }
/* Drop target feedback — the whole drawer accepts a dragged screenshot. */
.av-dropping { outline: 2px dashed var(--accent, #0f5f59); outline-offset: -6px; }

/* Queue-view toggle pills. */
.view-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 2px 2px; }
.view-filters:empty { display: none; }
.view-pill { border: 1px solid #d8dee0; background: #fff; color: #364043; border-radius: 8px; padding: 4px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.view-pill:hover { border-color: #9aa6a9; }
.view-pill.active { background: #123; color: #fff; border-color: #123; }

/* "My Mail" narrows the queue where its neighbours widen it, so it breaks to
   the far end of the bar and takes the brand accent instead of the ink fill —
   the shape says "this one is hiding things" before the label is read. */
.view-pill.mine { margin-left: auto; border-color: color-mix(in srgb, var(--accent) 40%, #d8dee0); }
.view-pill.mine:hover { border-color: var(--accent); }
.view-pill.mine.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Active-filter indicator: what is hidden, which address matched, how many
   survived. Without it a filtered queue is indistinguishable from a quiet one. */
.addressed-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 6px 2px 2px; padding: 7px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--surface));
  font-size: 12px; color: #364043; line-height: 1.35;
}
.addressed-note .an-badge {
  padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
}
.addressed-note .an-text { flex: 1 1 200px; }
.addressed-note .an-clear {
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--surface));
  background: #fff; color: var(--accent-2);
  border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.addressed-note .an-clear:hover { border-color: var(--accent); }

/* Row marker — only shown in a MIXED queue (see renderList), so it stays a
   scanning aid rather than a badge on every row. */
.who-chip.to-me {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent-2); font-weight: 700;
}

/* Open email: the To/Cc line under the sender, my own address called out. */
.detail-recipients { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.detail-recipients .rcpt { margin-right: 10px; }
.detail-recipients .rcpt-key { font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; }
.detail-recipients .me-addr { color: var(--accent-2); font-weight: 800; }
.detail-recipients .rcpt-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent-2); font-size: 11px; font-weight: 700;
}

/* Server-paged queue: "Load more" sits under the last row of the page. */
.list-more { display: flex; justify-content: center; padding: 12px 10px 16px; }
.list-more .button { min-width: 180px; }
.list-more .button[disabled] { opacity: 0.6; cursor: default; }

/* Queue-clear actions on the open email. */
.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.queue-actions .button { font-size: 12px; padding: 6px 12px; }

/* Per-email queue state in the list. */
.email-item.unread strong { font-weight: 800; }
.email-item:not(.unread) strong { font-weight: 600; color: #4a565b; }
.email-item.dismissed { opacity: 0.62; }
.email-item .bm-star { color: #e0a400; margin-right: 5px; }

/* Ingestion-stall banner — unmissable, sits under the topbar. */
.ingest-banner { margin: 0 0 14px; padding: 11px 16px; border-radius: 10px; background: #fdecea; color: #8a1c12; border: 1px solid #f5c6c0; font-size: 13px; line-height: 1.4; }
.ingest-banner.hidden { display: none; }
.ingest-banner.ingest-banner-history { background: #edf3f8; color: #28445a; border-color: #cddde9; }
.ingest-banner.ingest-banner-review { background: #fff4df; color: #754b0c; border-color: #e8ce9d; }

/* Demoted envelope roles — muted, never alarm-colored (they don't need action). */
.badge.qs-cc { background: #eef1f2; color: var(--muted); }
.badge.qs-sent { background: #eef1f2; color: var(--muted); }
.badge.qs-internal { background: #eef1f2; color: var(--muted); }
.badge.qs-no_response_needed { background: #eef1f2; color: var(--muted); }
@keyframes qs-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.who-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.who-chip.done { background: #e6f5ec; color: var(--ok); font-weight: 700; }
/* "Who's on it" — muted, read-only; the ● reads as a live presence dot. */
.who-chip.claimed { gap: 5px; background: #eef1f2; color: var(--muted); font-weight: 600; }

/* Team-resolved marker on the open email: muted, sits next to the reopen btn. */
.resolved-tag { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 8px; background: #eef1f2; color: var(--muted); font-size: 12px; font-weight: 700; }

/* Team-cleared queue status — muted like the other no-action envelopes. The
   exact key the server ships for a resolved email is covered below. */
.badge.qs-cleared, .badge.qs-resolved, .badge.qs-no_action { background: #eef1f2; color: var(--muted); }

.email-item.flash { animation: assign-flash 1.2s ease-in-out infinite; border-left: 3px solid #6d28d9; }
@keyframes assign-flash { 0%,100% { background: #f3ecff; } 50% { background: #e2d4ff; } }

/* Team accent on a queue row: a 3px bar in the owning team's --team-color so an
   operator can scan ownership down the list. Drawn as an inset shadow, not a
   border, so team rows keep exactly the same text alignment as team-less ones.
   A flash row (@mention aimed at me) keeps its purple border — that's the
   louder signal, and stacking both reads as noise. */
.email-item.has-team:not(.flash) { box-shadow: inset 3px 0 0 var(--team-color, transparent); }

.assign-ctl { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: #6d28d9; font-size: 13px; }
.assign-ctl select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; color: var(--ink); background: var(--surface); }

/* --- Team notes: INTERNAL coordination thread. Visually distinct from the
   customer-facing drafts (warm amber tint + "internal" tag) so an operator can
   never confuse a note with an outbound customer reply. --- */
.notes-section { border-left: 3px solid #d8a657; background: #fdfaf3; }
.notes-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #f5e6c8; color: #8a6d1f; font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: middle; }
.notes-thread { display: grid; gap: 8px; margin-top: 12px; }
.notes-empty, .notes-loading { color: var(--muted); font-size: 0.85rem; padding: 4px 0; }
.note-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.note-row.mine { border-color: #e5cfa0; background: #fffdf8; }
.note-head { display: flex; align-items: baseline; gap: 8px; }
.note-author { font-weight: 700; font-size: 0.82rem; }
.note-time { color: var(--muted); font-size: 0.72rem; }
.note-body { margin-top: 4px; font-size: 0.88rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.who-chip.mention { background: #efe7fd; color: #6d28d9; font-weight: 700; padding: 0 6px; min-height: 0; font-size: inherit; }
.note-composer { margin-top: 12px; }
.note-composer textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; background: var(--surface); color: var(--ink); }
.note-composer textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.note-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.note-hint { color: var(--muted); font-size: 0.72rem; }

/* Muted internal-note count on a queue row — read-only. */
.who-chip.note-chip { background: #fdfaf3; color: #8a6d1f; border: 1px solid #e5cfa0; }

/* F3 — load binding. Queue-row load badge + subtle unbound hint. */
.who-chip.load-chip-row { background: #eef3f4; color: #47555a; border: 1px solid var(--line); font-weight: 600; }
.who-chip.needs-load { background: transparent; color: var(--warn); border: 1px dashed #e2c48a; font-weight: 600; }

/* Detail-pane binding row: the "Attach load #" control / bound chip. */
.load-binding { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; position: relative; }
.load-binding:empty { display: none; }
.attach-hint { color: var(--warn); font-size: 0.72rem; font-weight: 600; }
.attach-count { color: var(--ok); font-size: 0.74rem; font-weight: 700; }

/* Bound load chip (detail) — muted, clickable → Load pipeline. */
.load-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; border: 1px solid var(--line); background: var(--surface-2); color: #3d4a4e; cursor: pointer; }
.load-chip.bound:hover { border-color: var(--accent); color: var(--accent-2); }
.load-chip.suggested { background: #e6f2f0; border-color: #bcdcd6; color: var(--accent-2); }
.load-chip.suggested:hover { background: #d8ebe7; }

/* Attach panel: suggestion + typeahead + create-new. */
.attach-load-panel { flex-basis: 100%; margin-top: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.attach-loading { color: var(--muted); font-size: 0.82rem; }
.attach-typeahead { display: flex; flex-direction: column; gap: 6px; }
.attach-typeahead input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 0.85rem; color: var(--ink); background: var(--surface); }
.attach-typeahead input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.attach-results { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.attach-result { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.attach-result:hover { border-color: var(--accent); background: var(--surface-2); }
.attach-result strong { font-size: 0.84rem; color: var(--ink); }
.attach-result span { font-size: 0.74rem; color: var(--muted); }
.attach-empty { color: var(--muted); font-size: 0.8rem; padding: 4px 2px; }
.attach-create { align-self: flex-start; }
.attach-error { color: var(--danger); font-size: 0.78rem; margin: 0; }

/* Inline "add a note while assigning" field, revealed when a teammate is picked. */
.assign-note-row { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.assign-note-row input { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; min-width: 200px; color: var(--ink); background: var(--surface); }

/* --- Quote health, scope tracker, refresh failsafe --- */
.qh-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qh-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; }
.qh-badge.ok { background: #e6f5ec; color: var(--ok); }
.qh-badge.warn { background: #fdf1dc; color: var(--warn); }
.qh-badge.bad { background: #fdecea; color: var(--danger); animation: qs-pulse 1.6s ease-in-out infinite; }
.scope-list { margin: 10px 0 0; padding-left: 18px; font-size: 0.8rem; display: grid; gap: 5px; }
.refresh-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.refresh-row label { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.refresh-row input { width: 110px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.stage-badge.refresh-tag { background: #fdecea; color: var(--danger); }

/* --- Undo-send --- */
.undo-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; padding: 9px 12px; background: #fff9ec; border: 1px solid #f3dfae; border-radius: 8px; font-size: 0.82rem; }
.sending-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); animation: qs-pulse 1s ease-in-out infinite; }
.undo-row .recalled { color: var(--ok); }
.undo-row .too-late { color: var(--muted); }

/* --- Company inbox (Workspace DWD) panel in the back office --- */
.workspace-panel { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; background: var(--surface-2); }
.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ws-head h4 { font-size: 0.84rem; }
.ws-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ws-row input { flex: 1; min-width: 160px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.84rem; }
.ws-steps { margin: 10px 0 0; padding-left: 20px; font-size: 0.8rem; display: grid; gap: 8px; color: var(--ink); }
.ws-grant { display: grid; gap: 6px; margin-top: 6px; }
.ws-grant div { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ws-grant span { color: var(--muted); font-size: 0.74rem; min-width: 84px; }
.ws-grant code { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; overflow-wrap: anywhere; user-select: all; }
.ws-result { margin-top: 8px; font-size: 0.8rem; }
.ws-result.ok { color: var(--ok); }
.ws-result.err { color: var(--danger); }

/* --- Interactive walkthrough --- */
.tour-ring { z-index: 4000; pointer-events: none; border-radius: 10px; transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease; }
.tour-tip { z-index: 4001; width: min(400px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 48px rgba(24,34,36,0.28); padding: 16px 18px; }
.tour-tip h3 { font-size: 1rem; margin-bottom: 6px; color: var(--ink); }
.tour-tip p { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }
.tour-tip p strong { color: var(--ink); }
.tour-count { font-size: 0.7rem; font-weight: 800; color: var(--accent); letter-spacing: 0.06em; margin-bottom: 4px; }
.tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tour-spacer { flex: 1; }

/* Timezone-resolved appointment badge (P18) */
.appt-resolved { margin-top: 3px; font-size: 0.72rem; font-weight: 600; color: var(--accent, #2f7); opacity: 0.9; letter-spacing: 0.01em; }
.appt-warn { color: #c9820a; font-weight: 700; white-space: nowrap; }

/* --- Settings · Brand dialog ------------------------------------------------ */
.brand-dialog { width: min(560px, 92vw); border: 1px solid var(--line); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); }
.brand-dialog::backdrop { background: rgba(24, 34, 36, 0.35); }
.brand-editor { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; margin-top: 14px; }
.brand-preview-col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.brand-preview { width: 100%; height: 120px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.brand-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-preview-empty { color: var(--muted); font-size: 0.8rem; }
.brand-upload-btn { text-align: center; cursor: pointer; }
.brand-controls-col { display: flex; flex-direction: column; gap: 12px; }
.brand-color-field { font-size: 0.82rem; color: var(--muted); font-weight: 600; display: grid; gap: 6px; }
.brand-color-row { display: flex; align-items: center; gap: 10px; }
.brand-color-row input[type="color"] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.brand-color-hex { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.brand-note { font-size: 0.78rem; color: var(--muted); line-height: 1.5; margin: 0; }
.brand-note .vline-mark { font-size: 0.78rem; }
.brand-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* --- Auth hardening: forgot/reset + 2FA security section --- */
.link-button {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px;
  text-align: center;
}
.link-button:hover { text-decoration: underline; }
.login-subtitle { color: var(--muted); font-size: 0.85rem; margin: 0 0 4px; }
.login-notice {
  margin: 0;
  padding: 8px 10px;
  background: #eef6f4;
  color: var(--text);
  border-radius: 8px;
  font-size: 0.82rem;
}
.field-hint { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 3px; font-weight: 400; }
.field-optional { color: var(--muted); font-weight: 400; font-size: 0.72rem; }
.pill.ok { background: #e4f5ec; color: #157347; }

.settings-section { padding: 4px 0 14px; border-top: 1px solid var(--line); margin-top: 14px; }
.settings-section:first-of-type { border-top: none; margin-top: 0; }
.settings-section h3 { margin: 6px 0 2px; font-size: 0.95rem; }

.twofa-status { margin: 8px 0; display: flex; align-items: center; gap: 8px; }
.twofa-hint, .twofa-on { color: var(--muted); font-size: 0.8rem; }
.twofa-panel { margin-top: 8px; }
.twofa-steps { margin: 4px 0 12px; padding-left: 18px; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.twofa-enroll-row { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.twofa-qr { width: 176px; height: 176px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.twofa-qr svg { width: 100%; height: 100%; display: block; }
.twofa-manual { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.twofa-secret { font-family: ui-monospace, Menlo, monospace; font-size: 0.9rem; letter-spacing: 0.06em; word-break: break-all; background: var(--surface, #f4f6f7); padding: 6px 8px; border-radius: 6px; }
.twofa-confirm { display: flex; align-items: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.twofa-confirm label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; }
.twofa-confirm input, .twofa-disable input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.twofa-disable { display: flex; align-items: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.twofa-disable label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); }
.twofa-backup h4 { margin: 6px 0 2px; }
.twofa-backup-note { color: var(--muted); font-size: 0.8rem; margin: 0 0 8px; }
.twofa-backup-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.twofa-backup-list code { font-family: ui-monospace, Menlo, monospace; font-size: 0.88rem; background: var(--surface, #f4f6f7); padding: 5px 8px; border-radius: 6px; display: block; text-align: center; }
.twofa-backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   AgentV UX Studio — design draft banner, density modes, and spec-driven
   progressive controls. All applied by applyUiSpec() in app.js. The VLTRN "V"
   is brand-locked in <head> (see #ui-brand-lock) so nothing here can recolor it.
   ========================================================================== */

/* Slim design banner (editors only), pinned above the topbar inside <main>. */
.ui-design-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: -6px 0 12px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.ui-design-banner.has-draft {
  /* Distinct-but-not-garish: a soft accent-tinted rail while a draft previews. */
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--ink);
}
.ui-design-banner .udb-msg { font-weight: 600; }
.ui-design-banner .udb-hint { font-weight: 500; }
.ui-design-banner .udb-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.ui-design-banner .button.small { font-size: 12px; padding: 5px 11px; }

/* Revert history dropdown. */
.udb-revert-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 70;
  min-width: 240px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.udb-revert-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 7px 9px;
  cursor: pointer;
  color: var(--ink);
}
.udb-revert-item:hover { background: var(--surface-2); }
.udb-rv-note { font-size: 12.5px; font-weight: 600; }
.udb-rv-meta { font-size: 11px; color: var(--muted); }

/* --- Tier-2 code pipeline: the Settings approval panel (uiStudio admins). --- */
.cc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cc-head h3 { margin: 6px 0 2px; font-size: 0.95rem; }
.cc-explainer { max-width: 46ch; }
.cc-toolbar { display: flex; gap: 8px; margin: 8px 0 10px; }

.cc-new-form { display: flex; flex-direction: column; gap: 10px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.cc-field { display: flex; flex-direction: column; gap: 4px; }
.cc-field input, .cc-field textarea, .cc-field select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--bg, #fff); color: var(--ink); }
.cc-field textarea { resize: vertical; }
.cc-field-inline select { max-width: 200px; }
.cc-form-actions { display: flex; justify-content: flex-end; }

.cc-empty { color: var(--muted); font-size: 0.85rem; padding: 10px 2px; }
.cc-list { display: flex; flex-direction: column; gap: 8px; }
.cc-row { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.cc-row.open { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.cc-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; cursor: pointer; text-align: left; color: var(--ink); }
.cc-row-head:hover { background: var(--surface-2); }
.cc-row-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cc-title { font-weight: 700; font-size: 0.9rem; }
.cc-row-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.who-chip.cc-scope { font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.cc-diffstat { color: var(--muted); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.cc-row-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.cc-caret { color: var(--muted); font-size: 0.8rem; }

.cc-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; white-space: nowrap; }
.cc-pill.neutral { background: var(--surface-2); color: var(--muted); }
.cc-pill.amber { background: #fdf1dc; color: var(--warn); }
.cc-pill.blue { background: #e4eefb; color: #1d4ed8; }
.cc-pill.green { background: #e4f5ec; color: #157347; }
.cc-pill.muted-red { background: #fdecea; color: #b4443a; }

.cc-detail { padding: 4px 12px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.cc-detail .field-label { display: block; margin-bottom: 3px; }
.cc-intent p { margin: 0; font-size: 0.86rem; line-height: 1.5; }
.cc-guard { padding: 9px 12px; border-radius: 8px; background: #fdf1dc; border: 1px solid #e5cfa0; color: #8a5a0f; font-weight: 600; font-size: 0.83rem; }
.cc-note { padding: 8px 10px; border-radius: 8px; }
.cc-note p { margin: 0; font-size: 0.84rem; line-height: 1.5; white-space: pre-wrap; }
.cc-note-warn { background: #fdf1dc; border: 1px solid #e5cfa0; }
.cc-note-error { background: #fdecea; border: 1px solid #f3c9c3; color: #7f2a22; }

.cc-diff-wrap { min-width: 0; }
/* Preview screenshot — see the change before reading it. */
.cc-shot-wrap { min-width: 0; }
.cc-shot-link { display: block; margin-top: 4px; }
.cc-shot { display: block; width: 100%; max-height: 420px; object-fit: contain; object-position: top left; border: 1px solid #e0e6e8; border-radius: 8px; background: #fff; }
.cc-shot-note { margin: 5px 0 0; font-size: 11px; color: var(--muted); }
.cc-diff, .cc-buildlog { margin: 0; max-height: 320px; overflow: auto; padding: 10px; border-radius: 8px; background: #0f1c1f; color: #cfe0e2; font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.5; }
.cc-diff { white-space: pre; }
.cc-buildlog { white-space: pre-wrap; }
.cc-dl { display: block; }
.cc-dl-add { color: #7ee2a8; }
.cc-dl-del { color: #f0908a; }
.cc-dl-file { color: #e6d27a; font-weight: 700; }
.cc-dl-hunk { color: #8bb4ff; }
.cc-commit { margin: 0; font-size: 0.76rem; color: var(--muted); }
.cc-commit code { font-family: ui-monospace, Menlo, monospace; }
.cc-action-error { margin: 0; }

.cc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cc-actions a.button { text-decoration: none; display: inline-flex; align-items: center; }

/* Progressive panel/feature hooks (spec panels/features act on data-ui-* nodes).
   No elements opt in yet — this keeps unknown keys as clean no-ops. */
.ui-hidden,
.ui-feature-off { display: none !important; }

/* --- Density modes (theme.density). cozy = default/no-op. A tasteful handful
   of spacing rules; compact tightens, roomy loosens the high-traffic surfaces. */
body.density-compact main { padding: 16px; }
body.density-compact .email-item { padding: 9px 14px; }
body.density-compact .metric { padding: 12px 14px; }
body.density-compact .section { padding: 14px; }
body.density-compact .metrics { gap: 10px; }
body.density-compact .topbar { padding-top: 6px; padding-bottom: 8px; }

body.density-roomy main { padding: 32px; }
body.density-roomy .email-item { padding: 20px 20px; }
body.density-roomy .metric { padding: 24px 22px; }
body.density-roomy .section { padding: 26px; }
body.density-roomy .metrics { gap: 20px; }
body.density-roomy .topbar { padding-top: 16px; padding-bottom: 18px; }

/* --radius is exposed by the spec; wire it into the main card surfaces so a
   spec-set radius is visible without every component being retrofitted. */
.metric,
.section,
.queue-panel,
.detail-view,
.ui-design-banner { border-radius: var(--radius, 8px); }

/* --- LTL margin capture: charge ledger, exposure, disputes --------------- */

.ltl-grid {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

/* Dollars at risk sits next to the Charges heading. It is the number the whole
   feature exists to produce, so it reads as a warning, not as a statistic. */
.exposure-chip {
  color: var(--warn, #b45309);
  font-weight: 600;
  font-size: 0.85em;
}

.charge-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  margin: 6px 0;
}

.charge-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 4px 6px;
}

.charge-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-soft, rgba(128, 128, 128, 0.15));
}

/* Billed above quote — the leak. Tinted so it is findable while scanning. */
.charge-table tr.over td {
  background: var(--warn-bg, rgba(180, 83, 9, 0.07));
}

.charge-table tr.over td strong { color: var(--warn, #b45309); }
.charge-table tr.under td strong { color: var(--muted); }

.charge-lines-wrap { margin-top: 8px; }
.charge-lines-wrap > summary { cursor: pointer; color: var(--muted); font-size: 0.9em; }

.charge-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.charge-add input { flex: 1 1 140px; min-width: 0; }
.charge-add #chargeAmount { flex: 0 0 100px; }

.charge-add + .hint { font-size: 0.8em; margin-top: 4px; }

.button.tiny {
  padding: 2px 8px;
  font-size: 0.8em;
  line-height: 1.6;
}

/* Carrier scorecard */
.carrier-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.carrier-table th { text-align: left; color: var(--muted); border-bottom: 1px solid var(--border); padding: 6px; }
.carrier-table td { padding: 6px; border-bottom: 1px solid var(--border-soft, rgba(128, 128, 128, 0.15)); }
.carrier-table tr.watch-caution td:first-child::before { content: "▲ "; color: var(--warn, #b45309); }
.carrier-table tr.watch-avoid td:first-child::before { content: "■ "; color: var(--danger, #b91c1c); }

/* $ at risk on a pipeline card — sorts the eye to the money. */
.load-card .exposure-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 600;
  background: var(--warn-bg, rgba(180, 83, 9, 0.12));
  color: var(--warn, #b45309);
}

/* Below-threshold variance: recorded, visible, but not shouting. */
.charge-table tr.over.immaterial td { background: transparent; }
.charge-table tr.over.immaterial td strong { color: var(--muted); font-weight: 500; }

/* Service-guarantee claim. A provable miss is stated; an unprovable one is
   offered as "worth checking" — our delivery timestamp is usually a recording
   time, and the UI must not imply certainty the data can't carry. */
.guarantee-claim {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.guarantee-claim.provable { border-color: var(--warn, #b45309); background: var(--warn-bg, rgba(180, 83, 9, 0.07)); }
.guarantee-claim.review { border-style: dashed; }
.guarantee-claim .claim-amount { font-weight: 600; color: var(--warn, #b45309); }
.guarantee-claim p { flex: 1 1 100%; margin: 0; font-size: 0.85em; }
.guarantee-ok { font-size: 0.85em; margin-top: 8px; }

/* --- Feature requests -----------------------------------------------------
   The backlog the build pipeline may not touch. Visually a quieter sibling of
   the code-change list next to it: same rhythm and row shape, no preview/diff
   furniture, and a status chip carrying what the build states carry there.
   Uses the existing tokens (--line/--surface-2/--muted) so it inherits the
   tenant's branding and both themes rather than inventing its own colours. */
.fr-list { display: flex; flex-direction: column; gap: 8px; }
.fr-row { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.fr-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; background: none; border: 0; cursor: pointer; text-align: left; color: inherit;
  font: inherit;
}
.fr-head:hover { background: var(--surface-2); }
.fr-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fr-meta { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.fr-status {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap;
}
.fr-status-open { color: var(--warn); }
.fr-status-planned { color: var(--accent); }
.fr-status-declined { color: var(--muted); }
.fr-status-done { color: var(--ok); }
.fr-detail { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.fr-spec {
  margin: 0; padding: 10px; border-radius: 8px; background: var(--surface-2); color: var(--ink);
  font-size: 0.78rem; line-height: 1.5; white-space: pre-wrap;
  overflow-x: auto; max-height: 320px; overflow-y: auto;
}
.fr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fr-edit {
  width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.78rem; line-height: 1.5; resize: vertical;
}

/* ---- Bulk triage: row checkboxes, select-all bar, floating action bar ----
   The queue row is now a flex wrapper (checkbox + the existing .email-item
   button), so the row's bottom rule and hover/active wash move to the wrapper
   and the checkbox cell stays in step with the row it belongs to. */
.email-row {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
}
.email-row .email-item {
  border-bottom: 0;
  flex: 1;
  min-width: 0;
}
.email-row:has(.email-item:hover),
.email-row:has(.email-item.active) {
  background: var(--surface-2);
}
/* A ticked row reads as picked, not merely hovered — a faint accent wash keeps
   it distinct from the open row's neutral highlight. */
.email-row.picked,
.email-row.picked:has(.email-item.active) {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.row-check {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding: 0 2px 0 12px;
  cursor: pointer;
}
.row-check input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent, #0f5f59);
}

.select-all-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}
.select-all-bar.hidden { display: none; }
.select-all-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}
.select-all-toggle input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent, #0f5f59);
}
.select-all-count { margin-left: auto; font-weight: 600; }

/* Fixed to the bottom of the viewport, under the toast (9000) but above the
   AgentV drawer's trigger. body.has-bulk-bar pads the page so the bar can't
   cover the last queue row or the detail actions. */
.bulk-action-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  max-width: min(92vw, 760px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #12211f;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.bulk-action-bar.hidden { display: none; }
.bulk-count { font-size: 13px; font-weight: 700; white-space: nowrap; }
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bulk-actions .button[disabled] { opacity: 0.55; cursor: default; }
.bulk-assign select {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
}
.bulk-assign select option,
.bulk-assign select optgroup { color: #12211f; background: #fff; }
body.has-bulk-bar { padding-bottom: 76px; }

@media (max-width: 760px) {
  .bulk-action-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    transform: none;
    max-width: none;
  }
  /* The bar wraps to two rows at this width — pad for the taller footprint. */
  body.has-bulk-bar { padding-bottom: 132px; }
}
/* Ghost buttons are muted-on-light by default; on the dark bar they need the
   inverse treatment to stay legible. */
.bulk-action-bar .button.ghost {
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.88);
}
.bulk-action-bar .button.ghost:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}

/* --- Dock appointment notices (DockLink / Target) --------------------------- */
/* The section leads with the appointment and the load it will be written to,
   because those are the two things an operator has to be right about. */
.appt-section { border-left: 3px solid var(--accent); }
.appt-status { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em; }
.appt-status.matched { color: var(--accent); }
.appt-status.unmatched { color: #c9820a; }
.appt-body { display: flex; flex-direction: column; gap: 12px; }
.appt-fields {
  display: grid;
  grid-template-columns: minmax(140px, 0.3fr) minmax(0, 0.7fr);
  gap: 8px 12px;
  margin: 12px 0 0;
}
.appt-fields dt { color: var(--muted); font-size: 0.82rem; }
.appt-fields dd { margin: 0; overflow-wrap: anywhere; font-size: 0.86rem; }
.appt-unparsed { color: #c9820a; font-weight: 600; }
.appt-ref { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; font-size: 0.76rem; font-weight: 700; margin-right: 4px; }
.appt-match { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.appt-match-load { font-weight: 700; font-size: 0.86rem; }
.appt-why { color: var(--muted); font-size: 0.74rem; font-weight: 600; }
.appt-current { font-size: 0.74rem; font-weight: 600; color: #c9820a; }
.appt-current.none { color: var(--muted); font-weight: 500; }
.appt-nomatch { color: #92500a; background: #fdf1dc; border-radius: 6px; padding: 7px 10px; font-size: 0.8rem; font-weight: 600; }
.appt-picker { display: flex; flex-direction: column; gap: 8px; }
.appt-candidates { display: flex; flex-direction: column; gap: 4px; }
.appt-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.appt-hint { color: var(--muted); font-size: 0.74rem; }
.appt-action-btn { white-space: nowrap; }
.appt-confirm-label { color: var(--accent); font-size: 0.72rem; font-weight: 700; }

/* Packet preview modal — same review-then-approve shape as the load packets. */
.packet-dialog { width: min(640px, 94vw); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.packet-dialog::backdrop { background: rgba(24, 34, 36, 0.4); }
.packet-dialog-body { margin: 4px 0 16px; }
.packet-dialog-actions { flex-wrap: wrap; justify-content: flex-end; }
.appt-overwrite { background: #fdf1dc; color: #92500a; border-radius: 6px; padding: 8px 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 10px; }
.appt-raw { margin-top: 14px; }
.appt-raw summary { cursor: pointer; color: var(--muted); font-size: 0.76rem; font-weight: 700; }

.gmail-sync-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0 14px;
}

.gmail-folder-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin: 12px 0;
}

.gmail-folder-form label { flex: 1; }
.gmail-folder-form input { width: 100%; }
.gmail-folder-list { display: flex; flex-wrap: wrap; gap: 8px; }
.gmail-folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface, #fff);
}
.gmail-folder-chip small { color: var(--muted); }
.gmail-folder-chip button { border: 0; background: transparent; cursor: pointer; }
.gmail-sync-jobs h4 { margin: 16px 0 6px; }
.gmail-job { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 5px 0; border-top: 1px solid var(--line); }
.gmail-job small { grid-column: 1 / -1; color: var(--danger, #991b1b); }
.gmail-job .confirmed { color: #047857; }
.folder-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.folder-picker select { max-width: 180px; }

#worldtrakDialog { width: min(960px, 92vw); max-height: 85vh; overflow: auto; border: 1px solid #cbd5e1; border-radius: 12px; padding: 24px; color: #172033; background: #fff; }
#worldtrakDialog::backdrop { background: rgb(15 23 42 / 45%); }
.worldtrak-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#worldtrakDialog form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
#worldtrakDialog label { display: grid; gap: 5px; }
#worldtrakDialog input { padding: 8px; border: 1px solid #cbd5e1; border-radius: 5px; }
.worldtrak-table { overflow-x: auto; }
.worldtrak-table table { width: 100%; border-collapse: collapse; text-align: left; }
.worldtrak-table th, .worldtrak-table td { padding: 10px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }

/* Showcase build notice (DEMO_MODE). Neutral, not alarming, always visible. */
.demo-ribbon {
  padding: 6px 16px;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  background: var(--surface-2);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
