/* ============================================================
   ELMA Vendors Console — "Blueprint Console" design system
   ============================================================ */

:root {
  --ink:        #0B1220;
  --ink-soft:   #1A2333;
  --paper:      #F7F8FA;
  --surface:    #FFFFFF;
  --surface-2:  #FBFCFD;
  --signal:     #1F6FEB;
  --signal-dk:  #1858BE;
  --signal-wash:#EAF1FE;
  --amber:      #C77400;
  --amber-wash: #FBF1E2;
  --emerald:    #0F8A5F;
  --emerald-wash:#E6F4EE;
  --rose:       #C5303A;
  --rose-wash:  #FBEAEB;
  --line:       #E2E6EC;
  --line-soft:  #EDF0F4;
  --slate:      #5B6675;
  --slate-2:    #8A93A1;

  --radius:     10px;
  --radius-sm:  7px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 2px rgba(11,18,32,.06), 0 1px 3px rgba(11,18,32,.04);
  --shadow:     0 4px 16px rgba(11,18,32,.08);
  --shadow-lg:  0 12px 32px rgba(11,18,32,.14);

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

[data-theme="dark"] {
  --ink:        #E8ECF3;
  --ink-soft:   #C4CCD8;
  --paper:      #0A0F18;
  --surface:    #111826;
  --surface-2:  #0D1420;
  --signal:     #4D8DF5;
  --signal-dk:  #3B7AE0;
  --signal-wash:#16243C;
  --amber:      #E0972F;
  --amber-wash: #2A1F0E;
  --emerald:    #2DB37F;
  --emerald-wash:#0E241A;
  --rose:       #E25560;
  --rose-wash:  #2A1216;
  --line:       #222C3D;
  --line-soft:  #1A2230;
  --slate:      #9AA4B2;
  --slate-2:    #6B7585;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
  --shadow:     0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-ligatures: none; }
.muted { color: var(--slate); }

/* ============ LOGIN ============ */
.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--signal-wash), transparent 60%),
    var(--paper);
}
.login-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.logo-mark {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--signal), var(--signal-dk));
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(31,111,235,.35);
}
.logo-mark.sm { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
/* Real brand icon: the mark itself carries the color — no gradient box */
.logo-mark.brand { background: transparent; box-shadow: none; border-radius: 0; }
.logo-mark.brand img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-title { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.login-sub { color: var(--slate); font-size: 12.5px; }
.login-actions { margin-top: 18px; }
.btn-block { width: 100%; }
.link-quiet {
  display: block;
  margin: 14px auto 0;
  background: none; border: none;
  color: var(--slate); font-size: 12.5px;
  cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.login-foot { color: var(--slate-2); font-size: 12px; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* Left rail */
.rail {
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
[data-theme="dark"] .rail { background: #060A12; border-right: 1px solid var(--line); }
.rail-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.rail-brand-text { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; }
.rail-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,.62);
  font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.rail-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.rail-link.active {
  background: var(--signal);
  color: #fff;
  box-shadow: 0 2px 8px rgba(31,111,235,.4);
}
.rail-ico { width: 18px; text-align: center; font-size: 14px; opacity: .9; }

.rail-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.6); margin-bottom: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.dot-err { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
.dot-unknown { background: var(--slate-2); }
.rail-user { display: flex; align-items: center; gap: 8px; }
.rail-user-name {
  flex: 1; font-size: 12.5px; color: rgba(255,255,255,.78);
  font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.8);
  border-radius: 8px;
  cursor: pointer; font-size: 14px;
  display: grid; place-items: center;
  transition: background .12s;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* Content */
.content {
  padding: 28px 32px 64px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;   /* center the column — no more dead right half */
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { margin: 4px 0 0; color: var(--slate); font-size: 13.5px; }

/* ============ BUTTONS ============ */
.btn {
  font-family: var(--sans);
  font-size: 13.5px; font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--slate-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--signal); border-color: var(--signal); color: #fff;
  box-shadow: 0 1px 3px rgba(31,111,235,.3);
}
.btn-primary:hover { background: var(--signal-dk); border-color: var(--signal-dk); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-group { display: flex; gap: 8px; }
.icon-act {
  padding: 5px 9px; font-size: 12px;
  border-radius: 6px;
}

/* ============ FIELDS ============ */
.field {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
}
.field:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-wash);
}
.textarea { resize: vertical; line-height: 1.55; }
.field-label {
  display: block;
  margin: 12px 0 6px;
  font-size: 12.5px; font-weight: 500;
  color: var(--slate);
}
.field-label.req::after { content: " *"; color: var(--rose); }

.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--slate); cursor: pointer; }
.toggle input { accent-color: var(--signal); }

/* ============ TOOLBAR / SEARCH ============ */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.search-input-wrap { position: relative; flex: 1; }
.search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--slate-2); font-size: 15px; pointer-events: none;
}
.search-field { padding-left: 34px; }

.col-filter { margin-bottom: 14px; }
.col-filter summary {
  cursor: pointer; color: var(--slate); font-size: 12.5px;
  user-select: none; width: fit-content;
}
.col-toggles { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.col-toggles label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--slate); }
.col-toggles input { accent-color: var(--signal); }

/* ============ DATA TABLE ============ */
.data-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  white-space: nowrap;
}
.data-table thead th.num { text-align: right; }
.data-table tbody td {
  padding: 11px 14px;
  border-top: 1px solid var(--line-soft);
  vertical-align: top;
  font-size: 13px;
}
.data-table tbody td.num { text-align: right; font-family: var(--mono); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody td:first-child { color: var(--ink); }

.empty-state {
  display: none;
  flex-direction: column; align-items: center; gap: 10px;
  padding: 56px 20px; color: var(--slate-2);
}
.empty-state.show { display: flex; }
.empty-mark { font-size: 30px; opacity: .5; }

/* ============ PANEL ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}
.panel.narrow { max-width: 460px; }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 12px;
}
.panel-title { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { margin: 0 0 14px; color: var(--slate); font-size: 13px; }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px;
}
.panel-foot .btn-group { margin-left: auto; }
.meta { font-size: 12.5px; color: var(--slate); }
.meta-row { display: flex; gap: 24px; font-size: 12.5px; color: var(--slate); margin: 4px 0 12px; }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.span2 { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }

/* ============ PILLS / TAGS / BADGES ============ */
.pill {
  font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line);
}
.pill-ok { background: var(--emerald-wash); color: var(--emerald); border-color: transparent; }
.pill-err { background: var(--rose-wash); color: var(--rose); border-color: transparent; }
.pill-unknown { background: var(--line-soft); color: var(--slate); border-color: transparent; }

.gate-tag {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--signal);
  background: var(--signal-wash);
  padding: 3px 9px; border-radius: 5px;
  margin-bottom: 8px;
}
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-oem { background: var(--emerald-wash); color: var(--emerald); }
.badge-state { background: var(--signal-wash); color: var(--signal); text-transform: capitalize; }
.badge-state.state-approved { background: var(--emerald-wash); color: var(--emerald); }
.badge-state.state-failed { background: var(--rose-wash); color: var(--rose); }

/* ============ PROGRESS ============ */
.progress-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.progress-msg { flex: 1; font-size: 13.5px; }
.progress-pct { font-size: 13px; color: var(--slate); }
.progress-track { height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--signal), var(--signal-dk));
  border-radius: 999px;
  transition: width .4s ease;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RESULT BODY ============ */
.result-body {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  max-height: 560px; overflow: auto;
  margin-bottom: 14px;
}
.result-body code { background: var(--signal-wash); padding: 1px 5px; border-radius: 4px; }

/* ============ EDIT TABLE (H1) ============ */
.edit-table tbody td { padding: 6px 8px; }
.edit-table input {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink);
  font-family: var(--sans); font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}
.edit-table input:hover { border-color: var(--slate-2); }
.edit-table input:focus { border-color: var(--signal); outline: none; background: var(--surface); box-shadow: 0 0 0 3px var(--signal-wash); }
.edit-table tr.deleted { opacity: .4; }
.edit-table tr.deleted input { text-decoration: line-through; }

/* ============ MATCH CARDS (H2) ============ */
.match-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(470px, 1fr));
  gap: 12px;
  align-items: start;
}
.match-list .match-card { min-width: 0; overflow: hidden; }
.match-card .match-meta > div { min-width: 0; }
.match-card .match-meta .mono { overflow-wrap: anywhere; }
@media (max-width: 980px) { .match-list { grid-template-columns: 1fr; } }
.match-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface-2);
}
.match-card.c-high { border-left-color: var(--emerald); }
.match-card.c-med  { border-left-color: var(--amber); }
.match-card.c-low  { border-left-color: var(--rose); }
.match-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.match-item { font-size: 12px; color: var(--slate); margin-bottom: 2px; }
.match-vendor { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.conf-tag { font-family: var(--mono); font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.match-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 18px; margin: 10px 0; font-size: 12.5px; }
.match-meta .k { color: var(--slate-2); margin-right: 6px; }
.match-meta .mono { font-size: 12px; }
.reasoning {
  font-size: 12px; color: var(--slate);
  background: var(--surface); border-left: 2px solid var(--line);
  padding: 8px 10px; border-radius: 0 6px 6px 0;
  margin: 8px 0 12px;
}
.match-actions { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.match-actions .btn { font-weight: 600; }
.match-actions .btn.selected { background: var(--signal); color: #fff; border-color: var(--signal); box-shadow: 0 2px 6px rgba(31,111,235,.35); }
.match-actions .btn-accept.selected::before { content: "✓ "; }
.match-actions .btn-reject.selected { background: var(--rose); color: #fff; border-color: var(--rose); box-shadow: 0 2px 6px rgba(197,48,58,.35); }
.match-actions .btn-reject.selected::before { content: "✕ "; }
.match-actions .btn-ext.selected { background: var(--amber); color: #fff; border-color: var(--amber); box-shadow: 0 2px 6px rgba(199,116,0,.35); }
.match-actions .btn:not(.selected) { opacity: 0.75; }
.match-actions .btn:not(.selected):hover { opacity: 1; }

/* ============ EMAIL CARDS (H4) ============ */
.email-list { display: flex; flex-direction: column; gap: 14px; }
.email-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.email-to { font-size: 12.5px; color: var(--slate); margin-bottom: 10px; }
.email-to strong { color: var(--ink); }
.email-card .email-subject { font-family: var(--mono); font-weight: 500; }
.email-card .email-body { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.email-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ============ FINAL ============ */
.final-mark {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--emerald-wash); color: var(--emerald);
  display: grid; place-items: center; font-size: 24px;
  margin-bottom: 14px;
}

/* ============ SEGMENTED (Admin) ============ */
.seg { display: inline-flex; gap: 4px; background: var(--line-soft); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 18px; }
.seg-btn {
  border: none; background: transparent;
  padding: 7px 16px; border-radius: 6px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--slate); cursor: pointer; transition: all .12s;
}
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.log {
  background: var(--ink); color: #D6E1F0;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; max-height: 320px; overflow: auto;
  margin-top: 12px;
}

td.actions { white-space: nowrap; }

/* ============ FORM MESSAGES ============ */
.form-msg { margin-top: 12px; font-size: 13px; }
.form-msg.error { color: var(--rose); }
.form-msg.ok { color: var(--emerald); }

/* ============ MODAL ============ */
.modal { border: none; padding: 0; background: transparent; }
.modal::backdrop { background: rgba(11,18,32,.5); backdrop-filter: blur(2px); }
.modal-card {
  width: min(680px, 92vw);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0;
    height: auto; width: 100%; z-index: 50;
    flex-direction: row; align-items: center;
  }
  .rail-brand, .rail-foot { display: none; }
  .rail-nav { flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .rail-link { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 10px; white-space: nowrap; }
  .rail-ico { font-size: 16px; }
  .content { padding: 18px 16px 90px; }
  .form-grid { grid-template-columns: 1fr; }
  .match-meta { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}

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

/* focus visibility */
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ============ RFQ ASSISTANT — CHAT THREAD ============ */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  max-width: 1400px;
  margin: 0 auto;
}
.chat-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.chat-head-right { display: flex; align-items: center; gap: 12px; }

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 22px 4px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

/* message rows */
.msg-row { display: flex; gap: 10px; max-width: 100%; }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  margin-top: 2px;
}
.msg-avatar.ai { background: linear-gradient(135deg, var(--signal), var(--signal-dk)); color: #fff; }
.msg-avatar.user { background: var(--ink); color: #fff; }
[data-theme="dark"] .msg-avatar.user { background: var(--ink-soft); color: var(--paper); }

.msg-bubble {
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 14px; line-height: 1.55;
  max-width: 76%;
}
.msg-row.user .msg-bubble {
  background: var(--signal); color: #fff;
  border-bottom-right-radius: 5px;
}
.msg-row.ai .msg-bubble {
  background: var(--surface); border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.msg-bubble.wide { max-width: 100%; width: 100%; }
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble code { background: var(--signal-wash); color: var(--signal-dk); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.msg-row.user .msg-bubble code { background: rgba(255,255,255,.2); color: #fff; }

/* typing indicator */
.typing { display: inline-flex; gap: 3px; align-items: flex-end; height: 16px; padding: 2px 0; }
.typing span {
  width: 3.5px; border-radius: 2px;
  background: linear-gradient(180deg, var(--signal), #7aa8f7);
  animation: wave 1.05s ease-in-out infinite;
  height: 6px;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wave { 0%, 100% { height: 5px; opacity: .55; } 50% { height: 15px; opacity: 1; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* contact cards inside a bubble */
.contact-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; background: var(--surface-2);
  margin-top: 8px;
}
.contact-card + .contact-card { margin-top: 10px; }
.contact-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.contact-name { font-weight: 600; font-size: 14.5px; }
.contact-co { font-size: 12.5px; color: var(--slate); margin-top: 1px; }
.contact-rows { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.contact-line { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.contact-line .ci { width: 16px; text-align: center; opacity: .7; flex-shrink: 0; }
.contact-line a { color: var(--signal); text-decoration: none; word-break: break-all; }
.contact-line a:hover { text-decoration: underline; }
.contact-line .mono { font-size: 12.5px; }
.copy-mini {
  margin-left: auto; flex-shrink: 0;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 6px; padding: 2px 8px; font-size: 11px;
  color: var(--slate); cursor: pointer;
}
.copy-mini:hover { border-color: var(--signal); color: var(--signal); }

/* composer */
.chat-composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 14px 0 18px;
  border-top: 1px solid var(--line);
}
.chat-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  background: var(--surface); color: var(--ink);
  resize: none; max-height: 180px; overflow-y: auto;
}
.chat-input:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-wash); }
.chat-send {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  border: none; background: var(--signal); color: #fff;
  cursor: pointer; display: grid; place-items: center;
  transition: background .12s;
}
.chat-send:hover { background: var(--signal-dk); }
.chat-send:disabled { background: var(--slate-2); cursor: not-allowed; }
.chat-send-ico { font-size: 18px; font-weight: 700; line-height: 1; }

/* progress line inside a bubble */
.bubble-progress { display: flex; align-items: center; gap: 10px; }
.bubble-progress .progress-track { flex: 1; }

/* gate blocks inside the thread */
.thread-gate { width: 100%; }
.thread-gate .panel { margin-bottom: 0; }

/* welcome / empty */
.chat-welcome {
  text-align: center; color: var(--slate);
  margin: auto; padding: 40px 20px; max-width: 460px;
}
.chat-welcome .ww-mark {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--signal), var(--signal-dk));
  color: #fff; display: grid; place-items: center; font-size: 24px;
}
.chat-welcome h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.chat-welcome p { margin: 0 0 16px; font-size: 13.5px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chat-chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px;
  color: var(--ink); cursor: pointer; transition: all .12s;
}
.chat-chip:hover { border-color: var(--signal); color: var(--signal); }

@media (max-width: 820px) {
  .chat-shell { height: calc(100vh - 140px); }
  .msg-bubble { max-width: 86%; }
}

/* step status (typing dots + friendly label) */
.step-status { display: flex; align-items: center; gap: 10px; }
.step-status .step-label { color: var(--slate); font-size: 13.5px; }
.step-status .typing { padding: 0; }

/* ---- Vendor override picker (H2) ---- */
.override-slot { margin: 8px 0 4px; }
.vpick {
  border: 1px solid var(--signal);
  border-radius: 10px; padding: 10px;
  background: var(--surface); box-shadow: 0 0 0 3px var(--signal-wash);
}
.vpick-input { margin-bottom: 8px; }
.vpick-results { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.vpick-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; text-align: left;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; padding: 8px 10px; cursor: pointer;
  transition: background .1s, border-color .1s;
}
.vpick-row:hover { background: var(--surface-2); border-color: var(--line); }
.vpick-name { font-weight: 600; font-size: 13px; }
.vpick-sub { font-size: 11.5px; color: var(--slate); }

/* review round: H2 polish */
details.why { margin: 6px 0 2px; }
details.why summary { cursor: pointer; font-size: 12px; color: var(--slate); user-select: none; }
details.why[open] summary { margin-bottom: 4px; }
.h2-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.h2-counts { font-size: 12.5px; font-weight: 600; }

/* elaborated welcome */
.ww-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0 6px; text-align: left; }
.ww-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface); }
.ww-card .ww-ico { font-size: 20px; margin-bottom: 6px; }
.ww-card h4 { margin: 0 0 5px; font-size: 13.5px; }
.ww-card p { margin: 0; font-size: 12.5px; color: var(--slate); line-height: 1.45; }
.ww-try { margin: 14px 0 6px; }

/* manual vendor + gated accept */
.vpick-manual { width: 100%; margin-top: 8px; font-size: 12.5px; }
.vpick-form .field { margin-bottom: 6px; }
.match-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }
.h2-notes { margin-top: 4px; }
.ai-attach { font-size: 16px; padding: 8px 10px; margin-right: 6px; }
.badge-attach { background: var(--signal-wash); color: var(--signal); font-size: 11px; }

/* ============ Phase D: enterprise polish ============ */
/* Stage chips (RFQ Register) — muted, status-coded, uppercase */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; border: 1px solid transparent;
}
.chip-review { background: rgba(59,130,246,.10); color: #2563eb; border-color: rgba(59,130,246,.25); }
.chip-proc   { background: rgba(245,158,11,.10); color: #b45309; border-color: rgba(245,158,11,.25); }
.chip-done   { background: rgba(16,185,129,.10); color: #047857; border-color: rgba(16,185,129,.25); }
.chip-failed { background: rgba(244,63,94,.10);  color: #be123c; border-color: rgba(244,63,94,.25); }
[data-theme="dark"] .chip-review { color: #93c5fd; }
[data-theme="dark"] .chip-proc   { color: #fcd34d; }
[data-theme="dark"] .chip-done   { color: #6ee7b7; }
[data-theme="dark"] .chip-failed { color: #fda4af; }

/* Icon buttons: consistent optical alignment */
.btn svg { flex: none; }
.match-actions .btn { display: inline-flex; align-items: center; }

/* Phase D r13: progress bar in chat bubbles */
.pg-track { height: 5px; border-radius: 3px; background: rgba(120,130,150,.18); margin-top: 8px; overflow: hidden; min-width: 220px; }
.pg-fill  { height: 100%; border-radius: 3px; background: var(--accent, #2563eb); transition: width .5s ease; }
.step-status { display: flex; align-items: center; gap: 10px; }
.pg-pct { font-size: 11px; opacity: .7; }

/* Composer attach button: match the send button's footprint */
.ai-attach { display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.ai-attach svg { display: block; }

/* Brand mark renders the SVG cleanly */
.logo-mark svg { display: block; margin: auto; }

/* Phase D r16 */
.edit-table .h1-desc-col { width: 34%; }
.edit-table textarea.h1-desc {
  width: 100%; min-width: 240px; resize: none; overflow: hidden;
  font: inherit; line-height: 1.35; padding: 6px 8px;
  border: 1px solid var(--border, #d7dce3); border-radius: 6px;
  background: inherit; color: inherit;
}
.edit-table tr.row-lowconf td { background: rgba(244, 63, 94, .05); }


/* Phase D r18 */
/* The hidden attribute must beat .rail-link's display:flex — this is why
   the Admin button stayed visible for non-admin users. */
.rail-link[hidden] { display: none !important; }
.rail-brand-wrap { display: flex; flex-direction: column; line-height: 1.1; }
.brand-by { font-size: 10px; font-weight: 500; letter-spacing: .3px; color: rgba(255,255,255,.45); }
.rail-product-by { font-size: 10px; color: rgba(255,255,255,.35); padding: 4px 2px 6px; }

/* r19: link-styled buttons (final summary .eml downloads) */
.linklike { background: none; border: none; padding: 0; color: var(--accent, #2563eb); cursor: pointer; font: inherit; text-decoration: underline; }
.linklike:disabled { opacity: .6; cursor: default; }

/* r20: staged attachment chip */
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px;
  padding: 4px 8px; margin-right: 6px; border-radius: 8px; font-size: 12px;
  background: rgba(37,99,235,.08); border: 1px solid rgba(37,99,235,.25); color: var(--accent, #2563eb); }
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-x { background: none; border: none; cursor: pointer; color: inherit; font-size: 14px; padding: 0 2px; }


/* r23: tracking */
.seg .seg-btn.active { background: rgba(37,99,235,.12); color: var(--accent, #2563eb); }
.track-row { cursor: pointer; }
.track-row:hover td { background: rgba(120,130,150,.06); }
.qcmp th, .qcmp td { padding: 6px 9px; font-size: 12.5px; }
.qcmp .best { background: rgba(16,185,129,.10); font-weight: 600; }

/* r25 */
.file-chips-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 6px; }
.plain-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; user-select: none; }
.plain-check input { width: 15px; height: 15px; accent-color: var(--accent, #2563eb); cursor: pointer; }


/* r46: number-only (uncorroborated) comparison cells — visible, never default */
.qcmp td.suspectcell { background: var(--rose-wash); color: var(--rose); font-weight: 600; }
