:root {
  color-scheme: light;
  --ink: #1d252c;
  --muted: #64717d;
  --line: #d9e0e5;
  --surface: #ffffff;
  --band: #f4f7f8;
  --navy: #22384a;
  --teal: #137c72;
  --amber: #b46a10;
  --red: #b13b3f;
  --green: #237653;
  --focus: #2f6fdd;
  --shadow: 0 12px 30px rgba(31, 47, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--band);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
select,
textarea {
  font: inherit;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 22px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 750;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.25;
}

.status-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-strip span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.project-band,
.control-band {
  display: grid;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.project-band {
  grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
  margin-bottom: 12px;
}

.control-band {
  grid-template-columns: minmax(220px, 1.5fr) minmax(130px, 0.7fr) minmax(140px, 0.7fr) auto;
}

.new-project summary {
  min-height: 42px;
  padding: 12px 0 0;
  color: var(--navy);
  cursor: pointer;
  font-weight: 750;
}

.new-project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  margin-top: 10px;
}

#createProjectButton {
  padding: 0 14px;
  color: #fff;
  background: var(--teal);
  font-weight: 750;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button:focus,
select:focus,
input:focus,
textarea:focus {
  outline: 3px solid rgba(47, 111, 221, 0.22);
  outline-offset: 1px;
}

#runButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

.settings-band {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-band summary {
  min-height: 46px;
  padding: 13px 16px;
  color: var(--navy);
  cursor: pointer;
  font-weight: 750;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 14px;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 16px;
}

#saveSettingsButton {
  padding: 0 14px;
  color: #fff;
  background: var(--teal);
  font-weight: 750;
}

#provisionRetellButton {
  padding: 0 14px;
  color: #fff;
  background: var(--navy);
  font-weight: 750;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
}

#runButton[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.button-icon {
  font-size: 13px;
}

.ai-builder {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ai-builder-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 14px;
  padding: 14px 16px 16px;
}

.chat-panel,
.scenario-preview-panel {
  min-width: 0;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  height: 300px;
  overflow: auto;
  padding: 12px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chat-message {
  display: grid;
  gap: 4px;
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chat-message.user {
  justify-self: end;
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.chat-message span {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  opacity: 0.78;
}

.chat-message p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

#sendScenarioChatButton {
  padding: 0 18px;
  color: #fff;
  background: var(--teal);
  font-weight: 750;
}

.scenario-preview-panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}

.scenario-preview {
  height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: var(--ink);
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.scenario-pane,
.runs-pane,
.report-pane {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scenario-pane {
  align-self: start;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.scenario-list,
.run-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.scenario-card,
.run-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scenario-card {
  cursor: pointer;
}

.scenario-card.active,
.run-card.active {
  border-color: var(--focus);
  box-shadow: inset 3px 0 0 var(--focus);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 750;
}

.card-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  text-transform: capitalize;
}

.badge.high,
.badge.fail {
  color: #fff;
  background: var(--red);
}

.badge.medium {
  color: #fff;
  background: var(--amber);
}

.badge.low,
.badge.pass {
  color: #fff;
  background: var(--green);
}

.work-pane {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 86px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.runs-pane,
.report-pane {
  min-height: 420px;
}

.ghost-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--navy);
  background: #eef3f5;
  font-size: 13px;
  font-weight: 700;
}

.report-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  color: var(--navy);
  background: #eef3f5;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.ghost-link.disabled {
  color: #96a2ad;
  pointer-events: none;
  cursor: default;
}

.run-card {
  cursor: pointer;
}

.run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.report-view {
  max-height: calc(100vh - 290px);
  min-height: 360px;
  overflow: auto;
  padding: 16px;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty-state {
  color: var(--muted);
  padding: 20px;
}

@media (max-width: 980px) {
  .control-band,
  .project-band,
  .new-project-grid,
  .settings-grid,
  .ai-builder-grid,
  .layout,
  .split,
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .scenario-pane {
    max-height: none;
  }

  .chat-compose {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 14px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }
}
