:root {
  --bg: #eef1f3;
  --surface: #fffdfa;
  --surface-2: #f6f8f4;
  --ink: #17202a;
  --ink-2: #344255;
  --muted: #6f7b8d;
  --line: #d8dfdd;
  --accent: #0f6a46;
  --accent-blue: #245f8f;
  --accent-warm: #c9772c;
  --shadow: 0 18px 40px rgba(23, 32, 42, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(36, 95, 143, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 106, 70, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, #eef1f3 0%, #f8f5ed 100%);
  background-size: 32px 32px, 32px 32px, auto;
}

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

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 16px auto 32px;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
  gap: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.96);
  box-shadow: var(--shadow);
}

.gallery-link {
  position: absolute;
  top: 16px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-blue);
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
}

.gallery-link::before {
  content: "";
  width: 18px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 3px;
}

.brand-block {
  padding-top: 24px;
}

.brand-eyebrow,
.section-kicker,
.rail-section header span,
.inspector-panel header span,
.tab-panel-header span,
.registry-panel header span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.brand-block h1 {
  margin-top: 8px;
  font-size: clamp(1.65rem, 2.5vw, 2.55rem);
  line-height: 1.06;
  letter-spacing: 0;
}

.brand-subtitle {
  margin-top: 10px;
  max-width: 76ch;
  color: var(--ink-2);
  line-height: 1.45;
}

.topbar-actions {
  display: grid;
  align-content: start;
  gap: 12px;
}

.workspace-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.summary-cell {
  min-height: 76px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.summary-cell:nth-child(2n) {
  border-right: 0;
}

.summary-cell:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.summary-cell span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-cell strong {
  font-size: 1.32rem;
}

.summary-cell small {
  color: var(--muted);
  line-height: 1.3;
}

.tour-trigger,
.secondary-button,
.tour-card button {
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--accent);
  color: #f8fff9;
  font-weight: 800;
}

.tour-trigger {
  justify-self: start;
  background: #edf7f1;
  color: var(--accent);
  border: 1px solid rgba(15, 106, 70, 0.26);
}

.tour-trigger-ready {
  box-shadow: 0 0 0 4px rgba(15, 106, 70, 0.08);
}

.secondary-button {
  background: #f7f8f3;
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.workspace-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 300px minmax(520px, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.left-rail,
.center-workspace,
.right-rail {
  min-width: 0;
}

.left-rail,
.right-rail {
  display: grid;
  gap: 14px;
}

.rail-section,
.workspace-header,
.model-panel,
.conversation-panel,
.inspector-panel,
.registry-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.96);
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.06);
}

.rail-section,
.inspector-panel,
.registry-panel,
.conversation-panel {
  padding: 14px;
}

.rail-section header,
.inspector-panel > header,
.tab-panel-header,
.registry-panel header {
  display: grid;
  gap: 5px;
}

.rail-section h2,
.inspector-panel h2,
.tab-panel-header h3,
.registry-panel h2 {
  font-size: 1rem;
}

.chat-list,
.user-list,
.document-matches,
.source-list {
  margin-top: 12px;
  display: grid;
  gap: 9px;
}

.chat-item,
.user-item,
.model-pill {
  width: 100%;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d7e0dc;
  border-radius: var(--radius);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.chat-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-left: 4px solid #9ab29b;
}

.chat-item span {
  color: #6f885f;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-item strong {
  font-size: 0.95rem;
}

.chat-item small {
  color: var(--muted);
  line-height: 1.35;
}

.chat-item:hover,
.chat-item.active,
.user-item:hover,
.user-item.active,
.model-pill:hover,
.model-pill.active {
  border-color: var(--accent);
  background: #f3fbf5;
  box-shadow: 0 10px 18px rgba(15, 106, 70, 0.12);
  transform: translateY(-1px);
}

.user-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e8f0ea;
  color: var(--accent);
  font-weight: 900;
}

.user-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-copy strong,
.user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy small {
  color: var(--muted);
}

.center-workspace {
  display: grid;
  gap: 14px;
}

.workspace-header {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.workspace-header h2 {
  margin-top: 4px;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  letter-spacing: 0;
}

.workspace-header p {
  margin-top: 7px;
  color: var(--ink-2);
  line-height: 1.45;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.metric-strip div {
  padding: 12px 10px 0;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.metric-strip div:first-child {
  padding-left: 0;
}

.metric-strip div:last-child {
  border-right: 0;
  padding-right: 0;
}

.metric-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-strip strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-panel {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 0.62fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.model-panel p,
.conversation-panel header p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.model-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.model-pill {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.model-pill span {
  color: var(--muted);
  font-size: 0.78rem;
}

.conversation-log {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.message {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 13px;
  background: #fff;
}

.user-message {
  background: #f5faf6;
  border-color: #c8d9c6;
}

.assistant-message {
  background: #fffefb;
}

.primary-question,
.primary-answer {
  position: relative;
  padding: 18px 20px;
  border-left-width: 6px;
}

.primary-question {
  background: linear-gradient(180deg, #f4fbf6 0%, #ffffff 100%);
  border-color: #b7d4bf;
  border-left-color: var(--accent);
  box-shadow: 0 12px 26px rgba(15, 106, 70, 0.1);
}

.primary-answer {
  background: linear-gradient(180deg, #fffaf2 0%, #fffefb 62%);
  border-color: #e2c9aa;
  border-left-color: var(--accent-warm);
  box-shadow: 0 14px 30px rgba(124, 77, 39, 0.11);
}

.message-meta {
  margin-bottom: 7px;
  color: #668060;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.focus-label {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(15, 106, 70, 0.08);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-answer .focus-label {
  background: rgba(201, 119, 44, 0.12);
  color: #8f4f18;
}

.message p {
  line-height: 1.48;
}

.question-text,
.answer-text {
  color: #07111f;
  font-size: clamp(1.16rem, 1.55vw, 1.5rem);
  line-height: 1.45 !important;
  letter-spacing: 0;
}

.question-text {
  font-weight: 700;
}

.answer-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 10px;
}

.answer-actions section {
  padding: 10px;
  border: 1px solid #dbe6d7;
  border-radius: var(--radius);
  background: #f8fbf5;
}

.answer-actions span {
  display: block;
  color: #416441;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.answer-actions p {
  margin-top: 5px;
}

.sources-disclosure {
  margin-top: 12px;
  border-radius: var(--radius);
  border: 1px solid #dbe6d7;
  background: #f9fcf6;
}

.sources-disclosure summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  cursor: pointer;
  color: #375f37;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sources-disclosure summary strong {
  color: var(--accent-blue);
  font-size: 0.82rem;
  text-transform: none;
}

.citations-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 10px;
  display: grid;
  gap: 8px;
}

.citations-list li {
  padding: 9px;
  border: 1px solid #d4dfd0;
  border-radius: var(--radius);
  background: #fff;
}

.citations-list strong {
  display: block;
}

.citations-list span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.document-match {
  padding: 11px;
  border: 1px solid #d6e0d2;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
}

.document-match.used {
  border-color: var(--accent);
  background: #f4fbf6;
  box-shadow: 0 10px 18px rgba(15, 106, 70, 0.1);
}

.document-match header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.document-match header span {
  color: #6f885f;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-match h3 {
  margin-top: 4px;
  font-size: 0.96rem;
}

.document-match header strong {
  min-width: 54px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: #edf7f1;
  color: var(--accent);
  text-align: center;
}

.document-match p {
  margin-top: 7px;
  color: var(--ink-2);
  line-height: 1.42;
}

.document-match footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.source-location {
  color: var(--muted) !important;
  font-size: 0.86rem;
}

.inspector-panel {
  display: grid;
  gap: 12px;
}

.inspector-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef4ef;
  overflow-x: auto;
  scrollbar-width: thin;
}

.inspector-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  min-width: 74px;
  padding: 8px 6px;
  border-radius: 6px;
  background: transparent;
  color: #556374;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.inspector-tabs button.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 5px 12px rgba(15, 106, 70, 0.1);
}

.tab-panels {
  display: grid;
  gap: 12px;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel-header {
  margin-bottom: 10px;
}

.tab-panel-header h3 {
  margin-top: 4px;
}

.knowledge-graph {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.graph-svg {
  width: 100%;
  height: auto;
  display: block;
}

.graph-svg rect {
  fill: #1c2730;
}

.graph-lines line {
  stroke: rgba(203, 229, 216, 0.72);
  stroke-linecap: round;
}

.graph-node circle {
  fill: #25323d;
  stroke: #d8ece2;
  stroke-width: 3;
}

.graph-node.user circle {
  fill: #0f6a46;
}

.graph-node.active circle {
  stroke: #f4c68d;
  stroke-width: 4;
}

.graph-node text {
  fill: #e7efe9;
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
}

.activity-panel {
  padding: 11px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
}

.activity-panel header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.activity-panel header span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.activity-row {
  display: grid;
  grid-template-columns: 72px 1fr 38px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.88rem;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: #e4eae6;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
}

.activity-row.active .bar-track i {
  background: linear-gradient(90deg, var(--accent-warm), var(--accent));
}

.user-breakdown {
  display: grid;
  gap: 9px;
}

.user-stat-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.user-stat-card.active {
  border-color: var(--accent);
  background: #f3fbf5;
  box-shadow: 0 10px 18px rgba(15, 106, 70, 0.1);
}

.user-stat-card header,
.model-usage header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.user-stat-card em,
.model-usage-row em {
  color: var(--accent);
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.user-stat-card p,
.user-stat-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.mini-metrics {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-metrics span {
  padding: 4px 7px;
  border-radius: 6px;
  background: #eef4f7;
  color: var(--ink-2);
  font-size: 0.76rem;
  font-weight: 800;
}

.stats-panel {
  display: grid;
  gap: 12px;
}

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

.stats-grid article {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.stats-grid span,
.model-usage header span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stats-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.model-usage {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.model-usage-row {
  margin-top: 11px;
  display: grid;
  grid-template-columns: minmax(92px, 0.8fr) 1fr 34px;
  align-items: center;
  gap: 8px;
}

.model-usage-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.daily-chart {
  display: grid;
  gap: 10px;
}

.daily-chart-svg {
  width: 100%;
  height: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1c2730;
}

.daily-chart-svg line {
  stroke: rgba(231, 239, 233, 0.26);
}

.message-bars rect {
  fill: url("#dailyBarGradient");
  fill: #2b86b6;
}

.daily-chart-svg polyline {
  fill: none;
  stroke: #f4c68d;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-points circle {
  fill: #f4c68d;
  stroke: #fff6e7;
  stroke-width: 2;
}

.daily-chart-svg text {
  fill: #e7efe9;
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
}

.daily-legend,
.daily-table {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.daily-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.legend-bar,
.legend-line {
  display: inline-block;
  width: 18px;
  height: 8px;
  border-radius: 999px;
  background: #2b86b6;
}

.legend-line {
  height: 3px;
  background: #f4c68d;
}

.daily-table {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.daily-table div {
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-align: center;
}

.daily-table span,
.daily-table em {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.daily-table strong {
  display: block;
  margin: 3px 0;
  color: var(--ink);
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.source-row:last-child {
  border-bottom: 0;
}

.source-row strong {
  font-size: 0.9rem;
}

.source-row span {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.source-row.active strong {
  color: var(--accent);
}

.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 19, 31, 0.68);
  z-index: 40;
}

.tour-card {
  position: fixed;
  z-index: 43;
  border-radius: var(--radius);
  border: 1px solid #d6dfd8;
  background: #fff;
  padding: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.tour-counter {
  color: #617660;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tour-card h3 {
  margin-top: 6px;
}

.tour-card p {
  margin-top: 8px;
  color: #425942;
  line-height: 1.42;
}

.tour-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), #fff 38%);
}

.tour-link {
  background: transparent !important;
  color: #5a6f5a !important;
}

.tour-focus {
  position: relative;
  z-index: 41;
  border-radius: var(--radius);
  box-shadow: 0 0 0 4px rgba(201, 119, 44, 0.82), 0 0 0 9999px rgba(10, 19, 31, 0.34);
}

.tour-open {
  overflow: hidden;
}

@media (max-width: 1240px) {
  .workspace-grid {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  .topbar,
  .workspace-grid,
  .model-panel,
  .right-rail {
    grid-template-columns: 1fr;
  }

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

  .metric-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-left: 0;
  }

  .metric-strip div:last-child {
    border-bottom: 0;
  }

  .model-selector,
  .answer-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: calc(100% - 18px);
    margin-top: 10px;
  }

  .topbar,
  .rail-section,
  .workspace-header,
  .model-panel,
  .conversation-panel,
  .inspector-panel,
  .registry-panel {
    padding: 12px;
  }

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

  .daily-table {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .brand-block {
    padding-top: 28px;
  }

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

  .summary-cell,
  .summary-cell:nth-child(2n),
  .summary-cell:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-cell:last-child {
    border-bottom: 0;
  }

  .tour-card {
    width: calc(100vw - 26px) !important;
    left: 13px !important;
    top: auto !important;
    bottom: 16px;
    max-height: calc(100vh - 32px);
  }
}
