/* Relay, support console chrome for the light azure theme. */

html,
body { height: 100%; }
body { overflow: hidden; }

.relay-shell {
  height: 100vh;
  grid-template-columns: 232px minmax(0, 1fr);
  background: transparent;
}

/* ------------------------------------------------------------------ sidebar */

.relay-sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(238, 244, 252, 0.72));
  border-right: 1px solid var(--line);
  padding: 18px 14px 16px;
  overflow: hidden;
}
.relay-brand { padding: 4px 8px 16px; }
.relay-brand .brand-mark { color: #fff; }
.relay-sidebar .nav-label { padding: 16px 10px 6px; }
.relay-sidebar .nav-item { border-radius: 9px; padding: 8px 10px; gap: 9px; font-size: 13px; }
.relay-sidebar .nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.8; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  background: rgba(255, 255, 255, 0.7);
}
.nav-badge.mono { font-family: var(--font-mono); font-size: 9.5px; }
.nav-item.active .nav-badge { border-color: var(--gold-line); color: var(--gold); background: #fff; }

.side-meta {
  margin: 4px 10px 0;
  display: grid;
  gap: 6px;
}
.side-meta > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--muted);
}
.side-meta b { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); }

.side-status { margin-top: 12px; }
.side-status p { font-size: 10.5px; line-height: 1.45; }

/* ------------------------------------------------------------------- layout */

.relay-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.relay-topbar {
  flex: none;
  height: 60px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.crumb { font-size: 12.5px; color: var(--muted); }
.crumb b { color: var(--text); font-weight: 600; }
.crumb-sep { margin: 0 6px; color: var(--line-strong); }
.top-divider { width: 1px; height: 22px; background: var(--line); }
.avatar.lilac { background: linear-gradient(135deg, #cdb9ff, #7c5cff); color: #fff; }
.avatar.relay-avatar { background: linear-gradient(135deg, #4d8ee8, #1f5fbf); color: #fff; }
.avatar.blue { color: #fff; }

.relay-main-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 54px;
  overflow: hidden;
}

[data-view-panel] { display: none; }
[data-view-panel]:not(.hide) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.relay-page-head {
  flex: none;
  align-items: flex-end;
  margin-bottom: 14px;
  gap: 16px;
}
.relay-page-head h1 { font-size: 28px; margin-bottom: 3px; }
.relay-page-head .lede { font-size: 13px; max-width: 74ch; }
.relay-page-head .eyebrow { margin-bottom: 4px; }

/* --------------------------------------------------------------------- chat */

.chat-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 352px;
  gap: 16px;
}

.chat-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
}

.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}
.chat-head .avatar { width: 38px; height: 38px; font-size: 12.5px; }
.chat-head-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-head-meta b { font-size: 13.5px; color: var(--text); }
.chat-head-meta span { font-size: 11px; color: var(--muted); }
.chat-status { margin-left: auto; }

.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 20px 8px;
  scroll-behavior: smooth;
}

.day-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.day-chip::before,
.day-chip::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.msg {
  display: flex;
  gap: 10px;
  margin-bottom: 13px;
  align-items: flex-start;
}
.msg.customer { flex-direction: row-reverse; }
.msg .avatar { width: 30px; height: 30px; font-size: 10px; flex: none; margin-top: 1px; }
.msg-body { min-width: 0; max-width: 84%; }
.msg.customer .msg-body { display: flex; flex-direction: column; align-items: flex-end; }
.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 10.5px;
  color: var(--muted);
}
.msg-meta b { font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.msg.customer .msg-meta { flex-direction: row-reverse; }

.bubble {
  padding: 10px 14px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.58;
  color: var(--text-2);
  white-space: pre-wrap;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-top-left-radius: 4px;
}
.msg.customer .bubble {
  background: linear-gradient(180deg, #2f74d6, #1f5fbf);
  border-color: #174a96;
  color: #fff;
  border-top-left-radius: 13px;
  border-top-right-radius: 4px;
}
.bubble .cite {
  color: var(--gold);
  font-weight: 700;
  font-size: 11px;
  vertical-align: super;
}
.msg.customer .bubble .cite { color: #cfe0ff; }

/* evidence attached to an agent answer */
.evidence { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; max-width: 100%; }

.citation-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: var(--gold-soft);
  color: var(--gold);
  font: 600 10.5px/1.2 var(--font-sans);
  cursor: pointer;
  text-align: left;
}
.citation-chip:hover { background: rgba(31, 95, 191, 0.16); }
.citation-chip .idx {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-size: 9px;
  font-family: var(--font-mono);
}
.citation-chip span.title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citation-detail {
  margin-top: 2px;
  padding: 9px 12px;
  border-left: 2px solid var(--gold-line);
  background: #f6f9fe;
  border-radius: 0 8px 8px 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.citation-detail .src {
  display: block;
  margin-top: 5px;
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.citation-detail[hidden] { display: none; }

.tool-call {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  font-size: 11.5px;
}
.tool-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  background: #f4f8fe;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
}
.tool-head svg { width: 13px; height: 13px; color: var(--gold); }
.tool-head .mono { font-size: 10.5px; color: var(--text); }
.tool-head .args {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-result { padding: 7px 10px; color: var(--text-2); line-height: 1.45; }
.tool-result.err { color: var(--red); }

.confidence-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 10px;
  color: var(--muted);
}
.conf-bar { width: 74px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.conf-bar > i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.conf-bar.medium > i { background: var(--amber); }
.conf-bar.low > i { background: var(--red); }

.ticket-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(179, 54, 54, 0.28);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff8f8, #fff);
}
.ticket-event .ticket-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--red-soft);
  color: var(--red);
  flex: none;
}
.ticket-event .ticket-icon svg { width: 16px; height: 16px; }
.ticket-event b { display: block; font-size: 12.5px; color: var(--text); }
.ticket-event p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.ticket-event .ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 2px; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.resolution {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px 40px;
  color: var(--muted);
  font-size: 10.5px;
}
.resolution .dot { color: var(--green); }

/* composer */
.composer-wrap {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 10px 14px 12px;
  background: linear-gradient(180deg, #fbfdff, #f6f9fe);
}
.suggestions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.suggest-label { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.suggest {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font: 500 10.5px/1 var(--font-sans);
  padding: 5px 9px;
  cursor: pointer;
}
.suggest:hover { border-color: var(--gold-line); color: var(--gold); background: var(--gold-soft); }
.composer { display: flex; gap: 8px; }
.composer .input { flex: 1; height: 40px; font-size: 12.5px; }
.composer .btn { height: 40px; padding: 0 18px; }
.composer-note { margin: 7px 0 0; font-size: 9.5px; color: var(--muted); }

/* ------------------------------------------------------------------- trace */

.trace-card {
  padding: 15px;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 16px;
  scrollbar-width: thin;
}
.trace-head { display: flex; align-items: center; gap: 8px; }
.trace-head .card-title { font-size: 14px; }
.trace-head .badge { margin-left: auto; }
.trace-sub { margin: -6px 0 0; font-size: 10.5px; color: var(--muted); }

.confidence-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #f1f6fd, #fbfdff);
}
.conf-top { display: flex; align-items: flex-start; gap: 10px; }
.conf-score {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--gold);
  letter-spacing: -0.03em;
}
.conf-score small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 1px; }
.conf-label { margin-left: auto; }
.conf-meter { height: 7px; margin: 10px 0 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.conf-meter > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4d8ee8, #1f5fbf); }
.conf-meter.medium > i { background: linear-gradient(90deg, #e0a93a, #9a6b12); }
.conf-meter.low > i { background: linear-gradient(90deg, #d96a6a, #b33636); }
.conf-note { font-size: 10px; color: var(--muted); }
.decision-badge { font-size: 9.5px; }
.components { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.component { border-radius: 7px; background: rgba(255, 255, 255, 0.8); border: 1px solid var(--line); padding: 5px 6px; text-align: center; }
.component span { display: block; font-size: 8.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.component b { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-2); }

.trace-section h4 {
  margin: 0 0 6px;
  font: 600 9.5px/1 var(--font-sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.retrieval-list { display: flex; flex-direction: column; gap: 6px; }
.retrieval-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 8px;
  align-items: center;
  font-size: 10.5px;
}
.retrieval-row .title { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.retrieval-row .cat { display: block; font-size: 8.5px; color: var(--muted); letter-spacing: 0.03em; }
.retrieval-row .score { text-align: right; font-family: var(--font-mono); font-size: 9px; color: var(--muted); }
.retrieval-row .bar { height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.retrieval-row .bar > i { display: block; height: 100%; background: var(--gold-line); }

.trace-tools { display: flex; flex-direction: column; gap: 6px; }
.trace-tool { border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: #fff; font-size: 10px; }
.trace-tool .row { gap: 6px; }
.trace-tool .mono { font-size: 9.5px; }
.trace-tool p { margin: 4px 0 0; color: var(--muted); line-height: 1.4; }

.handoff-btn {
  width: 100%;
  background: linear-gradient(180deg, #c24a4a, #a52f2f);
  border: 1px solid #8f2727;
  color: #fff;
  box-shadow: 0 10px 22px -14px rgba(143, 39, 39, 0.7);
}
.handoff-btn:hover { background: linear-gradient(180deg, #ce5a5a, #b33636); color: #fff; }
.trace-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  color: var(--muted);
  margin-top: auto;
}

.ticket-mini {
  border: 1px solid rgba(179, 54, 54, 0.26);
  background: #fff8f8;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 10.5px;
}
.ticket-mini b { font-family: var(--font-mono); font-size: 10.5px; color: var(--red); }
.ticket-mini p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.ticket-mini .row { margin-top: 6px; }

/* --------------------------------------------------------------- admin tabs */

.stat-grid { flex: none; margin-bottom: 14px; gap: 12px; }
.stat-grid .card { padding: 13px 15px; }
.stat-grid .stat-label { font-size: 9.5px; }
.stat-grid .stat-value { font-size: 24px; }
.stat-grid .small { font-size: 10.5px; }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.conv-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
}
.table-card { min-height: 0; display: flex; flex-direction: column; padding: 14px 16px; }
.table-card .card-head { flex: none; margin-bottom: 10px; }
.table-card .table-wrap { flex: 1; min-height: 0; overflow: auto; border-radius: 10px; }
.table-card .table th { position: sticky; top: 0; background: #f6f9fe; z-index: 1; font-size: 9.5px; }
.table-card .table td { padding: 9px 10px; font-size: 11.5px; }
.table-card .table .num { white-space: nowrap; }
.customer-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.customer-cell .avatar { width: 24px; height: 24px; font-size: 8.5px; flex: none; }
.customer-cell b { display: block; font-size: 11.5px; color: var(--text); line-height: 1.2; }
.customer-cell span { display: block; font-size: 9.5px; color: var(--muted); }
.question-cell { max-width: 320px; color: var(--text-2); }
.question-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-row { cursor: pointer; }
.conv-row:hover td { background: var(--gold-soft); }

.conv-side { min-height: 0; overflow-y: auto; }
.conv-side .card { padding: 13px 15px; }
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
}
.ticket-item .row { gap: 6px; }
.ticket-item b { font-family: var(--font-mono); font-size: 10.5px; color: var(--red); }
.ticket-item p { margin: 4px 0 0; font-size: 10.5px; color: var(--text-2); line-height: 1.35; }
.ticket-item .meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ticket-item .meta span { font-size: 8.5px; color: var(--muted); }

.conf-mix { display: flex; flex-direction: column; gap: 10px; }
.conf-mix-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 28px; gap: 8px; align-items: center; font-size: 10px; color: var(--muted); }
.conf-mix-row .bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.conf-mix-row .bar > i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.conf-mix-row.medium .bar > i { background: var(--amber); }
.conf-mix-row.low .bar > i { background: var(--red); }
.conf-mix-row b { font-family: var(--font-mono); font-size: 10px; color: var(--text-2); text-align: right; }

/* evaluation */
.eval-card { flex: 1; min-height: 0; }
.eval-table .question-cell { max-width: 300px; }
.eval-table td { font-size: 11px; }
.expected { display: flex; flex-direction: column; gap: 2px; font-size: 9.5px; color: var(--muted); }
.expected .mono { font-size: 8.4px; color: var(--text-2); line-height: 1.2; }
.eval-note { margin: 8px 0 0; font-size: 9.5px; }

@media (max-width: 1180px) {
  .relay-shell { grid-template-columns: 200px minmax(0, 1fr); }
  .chat-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .conv-layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .relay-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .relay-sidebar .brand-word, .relay-sidebar .brand-sub, .relay-sidebar .nav-label,
  .relay-sidebar .nav-item:not(.active) { font-size: 0; }
  .relay-sidebar .nav-item { justify-content: center; padding: 10px; }
  .relay-sidebar .nav-item svg { width: 18px; height: 18px; }
  .nav-badge, .side-meta, .side-status { display: none; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .trace-card { display: none; }
  .conv-layout { grid-template-columns: minmax(0, 1fr); }
  .conv-side { display: none; }
}

/* small additions used by the transcript */
.system-note {
  margin: 0 0 12px;
  padding: 7px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.citation-chip.active { border-color: var(--gold); background: rgba(31, 95, 191, 0.14); }
.suggest:disabled { cursor: default; opacity: 0.6; }
.eval-table td { padding: 3px 8px; font-size: 9.8px; line-height: 1.25; }
.eval-table th { padding: 6px 8px; font-size: 8.8px; }

.trace-tool svg,
.ticket-mini svg {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--gold);
}

/* higher specificity than the shared table rule for the dense eval grid */
.table-card .eval-table td { padding: 2px 8px; font-size: 9.6px; line-height: 1.22; }
.table-card .eval-table th { padding: 6px 8px; font-size: 8.8px; }
