:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef2f4;
  --line: #d7dee2;
  --text: #1d252b;
  --muted: #64717a;
  --accent: #2f6f7e;
  --accent-strong: #1d5967;
  --ok: #127a4a;
  --warn: #936112;
  --danger: #b73535;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: var(--accent-strong);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 32px;
  border-radius: 6px;
  background: #26323a;
  color: #ffffff;
  font-size: 13px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-nav a,
.top-nav span,
.workspace-tabs a,
.workspace-tabs span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.top-nav .active,
.workspace-tabs .active {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 600;
}

.app-main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px 28px 42px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

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

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.page-subtitle {
  max-width: 880px;
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.batch-action-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.batch-action-form select,
.batch-action-form input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.batch-action-form select {
  max-width: 210px;
  padding: 0 10px;
}

.batch-action-form input {
  width: 78px;
  padding: 0 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}

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

.button-secondary {
  background: var(--surface);
  color: var(--text);
}

.workspace-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.metric-grid,
.content-grid {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 14px;
}

.content-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  margin-bottom: 14px;
}

.metric-panel,
.diagnostic-panel,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-panel {
  min-height: 114px;
  padding: 16px;
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-panel strong {
  display: block;
  min-height: 28px;
  font-size: 20px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.metric-panel small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.diagnostic-panel {
  padding: 18px;
}

.diagnostic-panel.wide {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-head.compact {
  align-items: center;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.ok {
  color: var(--ok);
}

.warn {
  color: var(--warn);
}

.danger {
  color: var(--danger);
}

.status-pill.ok {
  background: #e7f5ee;
}

.status-pill.warn {
  background: #fff3dc;
}

.status-pill.danger {
  background: #fbe7e7;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(96px, 1fr));
  gap: 10px;
}

.stat-row div {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.stat-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-row strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.diagnostic-list {
  margin: 0;
}

.diagnostic-list div {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(110px, 1fr);
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.diagnostic-list dt {
  color: var(--muted);
  font-weight: 700;
}

.diagnostic-list dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.compact-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
}

.compact-table th,
.compact-table td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.compact-table th {
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.compact-table th:last-child,
.compact-table td:last-child {
  text-align: right;
}

.smoke-table th:last-child,
.smoke-table td:last-child {
  text-align: left;
}

.link-table th,
.link-table td {
  overflow-wrap: anywhere;
}

.link-table th:last-child,
.link-table td:last-child {
  text-align: left;
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
  gap: 14px;
}

.voice-panel {
  min-width: 0;
}

.voice-controls,
.text-probe,
.sample-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.text-probe {
  align-items: stretch;
}

.text-probe input {
  flex: 1 1 260px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

.sample-prompt {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 600;
  text-align: left;
}

.demo-mode-tabs {
  display: inline-grid;
  width: min(360px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.demo-mode-tabs button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.demo-mode-tabs button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.demo-mode-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.internal-demo-grid {
  display: block;
}

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

.demo-tab-panel.active {
  display: block;
}

.demo-tab-panel .phone-chat-shell {
  max-width: 900px;
  margin: 0 auto;
}

.demo-tab-panel .phone-call-panel {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.phone-chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: min(760px, calc(100svh - 172px));
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.phone-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.phone-chat-header div {
  display: grid;
  gap: 2px;
}

.phone-chat-header strong {
  font-size: 18px;
}

.phone-chat-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.phone-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: min(82%, 620px);
}

.chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message.user .chat-bubble {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.chat-message.typing .chat-bubble {
  color: var(--muted);
}

.chat-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-sources a {
  display: inline-flex;
  max-width: 280px;
  min-height: 28px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-suggestions {
  display: flex;
  gap: 8px;
  padding: 10px 14px 0;
  overflow-x: auto;
}

.chat-suggestions button {
  flex: 0 0 auto;
  max-width: 300px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phone-chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 14px 14px;
  background: #f8fafb;
}

.phone-chat-composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 132px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  resize: none;
}

.phone-chat-composer .button {
  min-height: 44px;
}

.phone-call-panel {
  display: grid;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.call-card {
  display: grid;
  justify-items: center;
  min-width: 0;
  gap: 10px;
  padding: 24px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.call-avatar {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #26323a;
  color: #ffffff;
  font-size: 30px;
  font-weight: 800;
}

.call-card h2 {
  font-size: 24px;
}

.call-card p {
  margin: 0;
  color: var(--muted);
}

.call-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.call-button {
  min-width: 96px;
  min-height: 44px;
}

.bogi-demo-page .phone-call-panel .call-card {
  min-height: min(560px, calc(100svh - 196px));
  align-content: center;
}

.call-text-probe,
.call-prompts {
  margin-bottom: 0;
}

.call-transcripts .transcript-box {
  min-height: 144px;
  max-height: 260px;
}

.call-events {
  padding: 14px;
}

.web-answer-grid {
  align-items: start;
}

.web-answer-form {
  display: grid;
  gap: 10px;
}

.web-answer-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.web-answer-form textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.web-answer-form .check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-transform: none;
}

.web-answer-form .check-row input {
  width: 16px;
  height: 16px;
}

.section-subhead {
  margin-top: 18px;
}

.web-answer-text {
  white-space: pre-wrap;
}

.search-progress {
  margin-bottom: 14px;
}

.search-progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-progress-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.search-spinner {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: search-spin 0.9s linear infinite;
}

.search-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.search-steps li {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.search-steps li.active {
  border-color: var(--accent);
  background: #e8f3f5;
  color: var(--accent-strong);
}

.search-steps li.done {
  border-color: #cfe7dc;
  background: #e7f5ee;
  color: var(--ok);
}

@keyframes search-spin {
  to {
    transform: rotate(360deg);
  }
}

.compact-notice {
  margin-top: 16px;
}

.button:disabled,
.sample-prompt:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.voice-transcript-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.voice-transcript-grid h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.transcript-box {
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: #314047;
  white-space: pre-wrap;
}

.muted-box {
  color: var(--muted);
}

.event-panel {
  min-width: 0;
}

.event-log {
  display: grid;
  gap: 8px;
  max-height: 460px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.event-log li {
  padding: 9px 10px;
  border-left: 4px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: #314047;
  overflow-wrap: anywhere;
}

.event-log li.ok {
  border-left-color: var(--ok);
}

.event-log li.warn {
  border-left-color: var(--warn);
}

.event-log li.danger {
  border-left-color: var(--danger);
}

.test-result-list {
  display: grid;
  gap: 12px;
}

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

.test-result {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.test-result.ok {
  border-left-color: var(--ok);
}

.test-result.warn {
  border-left-color: var(--warn);
}

.test-result.danger {
  border-left-color: var(--danger);
}

.test-result header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.test-query {
  margin: 0 0 10px;
  font-weight: 600;
}

.test-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.test-meta span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.answer-preview {
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafb;
  color: #314047;
}

.evaluation-reason {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.inline-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fbe7e7;
  color: var(--danger);
}

.notice {
  padding: 16px;
  margin-top: 14px;
}

.notice strong {
  display: block;
  margin-bottom: 4px;
}

.notice ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.inline-form {
  margin-top: 12px;
}

@media (max-width: 1080px) {
  .metric-grid,
  .content-grid,
  .demo-grid,
  .internal-demo-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-header,
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .top-nav,
  .workspace-tabs,
  .page-actions {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .metric-grid,
  .content-grid,
  .demo-grid,
  .internal-demo-grid,
  .search-steps,
  .route-compare-grid,
  .voice-transcript-grid,
  .stat-row {
    grid-template-columns: 1fr;
  }

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

  .diagnostic-list dd {
    text-align: left;
  }

  .app-main {
    padding: 16px 12px 28px;
  }

  .bogi-demo-page .top-nav,
  .bogi-demo-page .workspace-tabs {
    display: none;
  }

  .bogi-demo-page .app-header {
    min-height: 54px;
    padding: 0 12px;
  }

  .bogi-demo-page .brand-mark {
    width: 34px;
    height: 30px;
  }

  .bogi-demo-page .app-main {
    padding-top: 12px;
  }

  .demo-page-head {
    margin-bottom: 10px;
  }

  .bogi-demo-page .demo-page-head {
    align-items: center;
    gap: 10px;
  }

  .bogi-demo-page .demo-page-head .page-subtitle,
  .bogi-demo-page .demo-page-head .page-actions {
    display: none;
  }

  .bogi-demo-page .demo-mode-tabs {
    width: 100%;
    margin-bottom: 10px;
  }

  .batch-action-form {
    justify-content: flex-start;
  }

  .batch-action-form select {
    max-width: none;
    flex: 1 1 180px;
  }

  .phone-chat-shell {
    height: calc(100svh - 154px);
    min-height: 520px;
  }

  .bogi-demo-page .phone-chat-shell {
    height: calc(100svh - 196px);
    min-height: 0;
  }

  .phone-chat-header {
    padding: 12px;
  }

  .phone-chat-thread {
    padding: 12px;
  }

  .chat-message {
    max-width: 92%;
  }

  .chat-suggestions {
    padding: 8px 12px 0;
  }

  .chat-suggestions button {
    max-width: 260px;
  }

  .phone-chat-composer {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 12px 12px;
  }

  .phone-chat-composer textarea {
    min-height: 46px;
    font-size: 16px;
  }

  .phone-call-panel {
    padding-bottom: 12px;
  }

  .bogi-demo-page .phone-call-panel {
    padding-bottom: 0;
  }

  .bogi-demo-page .phone-call-panel .call-card {
    min-height: calc(100svh - 196px);
    padding: 22px 14px;
  }

  .bogi-demo-page .call-button {
    min-width: 88px;
    flex: 1 1 88px;
  }

  .call-events {
    display: none;
  }

  .call-prompts {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}
