:root {
  --bg: #f5f2ec;
  --ink: #171614;
  --muted: #686057;
  --line: #d9d0c2;
  --panel: #fffdfa;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --wa: #1f8f5f;
  --bot: #ece5d8;
  --client: #d8f3dc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  color: var(--accent-ink);
  background: var(--accent);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 130px;
  padding: 10px 12px;
  line-height: 1.4;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 0.98;
  font-weight: 780;
}

h2 {
  font-size: 16px;
  line-height: 1.1;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 30px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--panel);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.app-view {
  display: grid;
  gap: 18px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.control-band,
.workspace-grid {
  display: grid;
  gap: 14px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.topbar-actions,
.button-row,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-band {
  grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1fr);
}

.workspace-grid {
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 420px);
  align-items: start;
}

.qr-panel,
.test-panel,
.conversation-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.qr-panel,
.test-panel,
.history-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.conversation-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  min-height: 520px;
}

.qr-box {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #faf7f1;
}

.qr-box img {
  width: min(220px, 100%);
  height: auto;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 440px;
  max-height: 62vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9f5ec;
}

.message {
  max-width: min(76%, 620px);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.36;
  font-size: 14px;
}

.message.inbound {
  align-self: flex-start;
  background: var(--bot);
}

.message.outbound {
  align-self: flex-end;
  background: var(--client);
}

.message small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.tests-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.test-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.test-item strong {
  font-size: 13px;
}

.test-item span,
.test-detail,
.muted-line {
  color: var(--muted);
  font-size: 12px;
}

.test-detail {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  line-height: 1.4;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.notes-field {
  margin-top: 6px;
}

.status-pill,
.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 750;
}

.status-pill.ready {
  border-color: rgba(31, 143, 95, 0.4);
  color: var(--wa);
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.danger-button {
  background: var(--danger);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.error-text {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar,
  .control-band,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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