:root {
  --brand: #2f5ea9;
  --brand-strong: #244d8d;
  --brand-soft: #eaf2ff;
  --bg: #eef3f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dbe4ef;
  --line-strong: #c8d5e4;
  --text: #122033;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --cyan: #0891b2;
  --shadow: 0 24px 70px rgba(15, 23, 42, .10), 0 8px 22px rgba(47, 94, 169, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(47, 94, 169, .42) rgba(231, 238, 248, .7);
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(231, 238, 248, .72); border-radius: 999px; }
*::-webkit-scrollbar-thumb {
  border: 2px solid rgba(231, 238, 248, .72);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(47, 94, 169, .72), rgba(8, 145, 178, .62));
}
*::-webkit-scrollbar-corner { background: transparent; }
body {
  margin: 0;
  overflow: hidden;
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus { outline: none; }
button:focus-visible {
  outline: 2px solid #bdd4f4;
  outline-offset: 2px;
}

.demo-app {
  width: 100%;
  height: 100vh;
  min-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
}

.side-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 7px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.78);
}
.rail-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #2f63b4, #17448c);
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(47,94,169,.22);
}
.rail-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #52627a;
  font-size: 15px;
  font-weight: 800;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.rail-btn.active,
.rail-btn:hover {
  border-color: #b9cff1;
  background: var(--brand-soft);
  color: var(--brand);
  transform: translateY(-1px);
}

.agent-shell {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 40px;
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
}
.workspace-title { font-size: 13px; font-weight: 800; letter-spacing: 0; }
.workspace-subtitle { margin-top: 1px; color: var(--muted-2); font-size: 10px; font-weight: 700; }
.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 11px;
  font-weight: 750;
}
.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16,185,129,.12);
}

.workflow-tabs {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(248,250,252,.82);
}
.workflow-tab {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}
.workflow-tab span {
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: #94a3b8;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}
.workflow-tab.active {
  border-color: #aac5f0;
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px rgba(47,94,169,.05);
}

.workbench {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px 0;
}
.view {
  position: absolute;
  inset: 10px 12px 0;
  display: none;
  min-height: 0;
}
.view.active {
  display: flex;
  flex-direction: column;
  animation: viewIn .24s ease both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-layout,
.supplier-grid,
.mail-grid,
.final-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
}
.chat-layout { grid-template-columns: minmax(0, 1fr) 320px; }
.supplier-grid { grid-template-columns: minmax(0, 1fr) 380px; }
.mail-grid { grid-template-columns: 220px minmax(0, 1fr) 270px; }
.final-grid { grid-template-columns: 390px minmax(0, 1fr); }

.chat-feed,
.intake-card,
.supplier-table-panel,
.supplier-detail,
.thread-list,
.mail-editor,
.reply-panel,
.recommendation,
.comparison-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .07);
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: hidden;
}
.feed-date {
  align-self: center;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
}
.message {
  max-width: 78%;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.54;
}
.message p { margin: 0; }
.message.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, #2f63b4, #1f4c8d);
  border-bottom-right-radius: 5px;
}
.message.agent {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: #fff;
  color: #516172;
  border-bottom-left-radius: 5px;
}
.message-title {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}
.typing-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 750;
}
.typing-line span {
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: #94a3b8;
  animation: pulse 1s ease-in-out infinite;
}
.typing-line span:nth-child(2) { animation-delay: .14s; }
.typing-line span:nth-child(3) { animation-delay: .28s; }
@keyframes pulse { 50% { opacity: .35; transform: translateY(-2px); } }

.intake-card,
.recommendation,
.reply-panel {
  padding: 15px;
}
.card-label,
.section-title {
  color: #66778d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h2, h3, p { margin: 0; }
h2 {
  margin-top: 7px;
  color: #0f172a;
  font-size: 19px;
  line-height: 1.15;
  font-weight: 850;
  letter-spacing: 0;
}
h3 {
  color: #0f172a;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: 0;
}
.intake-card dl,
.commerce-list {
  display: grid;
  gap: 0;
  margin: 15px 0;
}
.intake-card dl div,
.commerce-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}
dt { color: var(--muted); font-size: 12px; font-weight: 760; }
dd { margin: 0; text-align: right; color: #0f172a; font-size: 12px; font-weight: 820; }
.primary-action,
.table-tools button,
.mail-actions button,
.supplier-detail button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #334155;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 820;
}
.primary-action {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0e7490);
  box-shadow: 0 12px 26px rgba(14,116,144,.20);
}
.stretch { width: 100%; }

.supplier-table-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: #cfe0f6;
}
.table-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.95);
}
.table-top.compact { padding: 14px 16px; }
.table-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.table-icon,
.detail-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  color: var(--brand);
  font-weight: 900;
}
.table-heading h2,
.table-top h2 {
  margin: 0;
  font-size: 14px;
}
.table-heading p,
.table-top p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.table-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-box {
  min-width: 230px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted-2);
  font-size: 12px;
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}
.table-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  text-align: left;
  font-size: 11px;
  table-layout: fixed;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(248,250,252,.94);
  color: #75849a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf2f7;
  color: #334155;
  vertical-align: top;
  font-weight: 650;
}
tr.selected td {
  background: linear-gradient(90deg, #eff6ff, rgba(239,246,255,.35));
  border-top: 1px solid #a9cfff;
  border-bottom: 1px solid #a9cfff;
}
tr.selected td:first-child { box-shadow: inset 2px 0 0 #7bb2ff; }
.supplier-row { cursor: pointer; }
.supplier-row:hover td { background: #f8fbff; }
td b { display: block; color: #0f172a; font-size: 12px; line-height: 1.25; }
td small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
td small,
td b {
  overflow-wrap: anywhere;
}
td em {
  display: inline-flex;
  margin-top: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
}
.stage-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}
.stage-badge.success {
  border-color: #86efac;
  background: #ecfdf5;
  color: #047857;
}
.stage-badge.muted {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.supplier-detail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: #cfe0f6;
}
.detail-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.detail-head div:nth-child(2) { min-width: 0; flex: 1; }
.detail-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 11px;
}
.detail-section {
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.detail-section p {
  margin-top: 8px;
  color: #475569;
  font-size: 12px;
  line-height: 1.42;
}
.product-cards { display: grid; gap: 7px; margin-top: 8px; }
.product-card {
  padding: 8px 10px;
  border: 1px solid #dbe5f2;
  border-radius: 10px;
  background: #f8fafc;
}
.product-card strong { display: block; font-size: 12px; color: #0f172a; }
.product-card span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.catalog-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 820;
  text-decoration: none;
}
.criteria-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.criteria-grid span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green-soft), #eff6ff);
  color: #047857;
  font-size: 11px;
  font-weight: 780;
}
.contact-card {
  margin: 10px 0;
  padding: 10px 11px;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 760;
}

.thread-list {
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}
.thread {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  text-align: left;
}
.thread.active { border-color: #b9cff1; background: #eff6ff; }
.thread b { display: block; color: #0f172a; font-size: 12px; }
.thread span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.35; font-weight: 720; }
.mail-editor,
.reply-panel {
  padding: 12px;
}
.mail-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.mail-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid #edf2f7;
}
.mail-field {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 12px;
}
.mail-field span { width: 46px; color: var(--muted-2); font-weight: 850; }
.mail-field b { color: #0f172a; }
.mail-body {
  flex: 1;
  min-height: 0;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  line-height: 1.42;
  overflow: hidden;
}
.mail-actions { display: flex; gap: 8px; margin-top: 11px; }
.reply-panel p,
.recommendation p {
  margin-top: 10px;
  color: #475569;
  font-size: 13px;
  line-height: 1.55;
}
.reply-facts {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.reply-facts span {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 790;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 10px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  color: var(--brand-strong);
}
.score-card span { color: var(--brand); font-size: 12px; font-weight: 830; }
.score-card b { font-size: 22px; }
.final-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0 0 12px;
}
.final-metrics span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  color: #475569;
  font-size: 12px;
  font-weight: 760;
}
.final-metrics b { color: var(--brand-strong); font-size: 14px; }
.comparison-panel {
  overflow: hidden;
}
.comparison-panel table { min-width: 0; }
.decision-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
}
.decision-panel article {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff, #f6fbff);
}
.decision-panel b {
  display: block;
  color: #0f172a;
  font-size: 13px;
}
.decision-panel span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}

.composer {
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 10px;
  padding: 8px 9px 8px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 30px rgba(15,23,42,.06);
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 650;
}
.composer span { flex: 1; }
.composer button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #2f63b4, #1f4c8d);
}

@media (max-width: 900px) {
  .demo-app { height: 640px; }
  .chat-layout,
  .supplier-grid,
  .mail-grid,
  .final-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .supplier-detail,
  .reply-panel { display: none; }
  .thread-list { grid-auto-flow: column; overflow-x: auto; }
  .thread { min-width: 220px; }
}

@media (max-width: 680px) {
  .demo-app {
    height: 680px;
  }
  .side-rail { display: none; }
  .workflow-tabs { overflow-x: auto; }
  .workflow-tab { flex: 0 0 auto; }
  .topbar-actions,
  .workspace-subtitle { display: none; }
  .workbench { padding: 10px; }
  .view { inset: 10px; }
  .table-tools { display: none; }
  .composer { margin: 8px 10px 10px; }
}
