:root {
  --wa-bg: #0b141a;
  --wa-panel: #111b21;
  --wa-header: #202c33;
  --wa-in: #202c33;
  --wa-out: #005c4b;
  --wa-text: #e9edef;
  --wa-dim: #8696a0;
  --wa-teal: #00a884;
  --wa-line: #2a3942;
  --side-bg: #0f1a20;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #060c10;
  color: var(--wa-text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(340px, 480px) minmax(280px, 380px);
  gap: 18px;
  justify-content: center;
  padding: 18px;
  height: 100vh;
}

/* ---------------- phone ---------------- */
.phone {
  display: flex;
  flex-direction: column;
  background: var(--wa-bg);
  border: 1px solid var(--wa-line);
  border-radius: 14px;
  overflow: hidden;
  min-height: 0;
}

.wa-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--wa-header);
  border-bottom: 1px solid var(--wa-line);
}

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #1fa855;
  color: #fff;
  font-size: 18px;
  display: grid; place-items: center;
  font-weight: 700;
}

.who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.who span { color: var(--wa-dim); font-size: 12px; }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image: radial-gradient(circle at 20% 10%, #12222b 0%, #0b141a 60%);
}

.bubble {
  max-width: 85%;
  padding: 7px 10px 8px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  font-size: 14.5px;
}

.bubble.in  { background: var(--wa-in);  align-self: flex-start; border-top-left-radius: 2px; }
.bubble.out { background: var(--wa-out); align-self: flex-end;   border-top-right-radius: 2px; }
.bubble .footer-note { color: var(--wa-dim); font-size: 12px; margin-top: 6px; }
.bubble .header-note { color: var(--wa-teal); font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.bubble b { font-weight: 700; }

/* Eva's buttons sit under her message, one per row, as in the design. */
.actions { display: flex; flex-direction: column; gap: 5px; align-self: flex-start; width: min(85%, 340px); }
.actions button {
  width: 100%;
  min-height: 42px;
  background: var(--wa-in);
  color: var(--wa-text);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.actions button.flow, .actions button.attach { color: #53bdeb; }
.actions button.flow::before { content: '☰  '; }
.actions button.attach::before { content: '📎 '; }
.actions button:hover { background: #2a3942; }

/* the customer's documents, one card per file */
.docs { display: flex; flex-direction: column; gap: 5px; }
.doc { display: flex; gap: 8px; align-items: center; background: rgba(0, 0, 0, .18); border-radius: 8px; padding: 6px 9px; }
.doc > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.doc-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 11px; color: #a6d8cb; }

/* the design's progress bar under the chat header */
.steps { padding: 8px 14px 10px; background: var(--wa-panel); border-bottom: 1px solid var(--wa-line); }
.steps-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; margin-bottom: 6px; }
.steps-top span { color: var(--wa-dim); font: 600 11px ui-monospace, Consolas, monospace; }
.step-bars { display: flex; gap: 4px; }
.step-bars div { flex: 1; height: 4px; border-radius: 2px; background: #2a3942; }
.step-bars div.done { background: #1fa855; }
.step-bars div.active { background: #6e68f0; }

.panel-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 14px 0 4px; }
.panel-buttons button { font-size: 12.5px; font-weight: 600; }
.panel-buttons button.on { background: #b4501e; border-color: transparent; color: #fff; }

.sys {
  align-self: center;
  background: #1d282f;
  color: var(--wa-dim);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 10px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--wa-header);
  border-top: 1px solid var(--wa-line);
}

.composer input {
  flex: 1;
  background: #2a3942;
  border: none;
  border-radius: 18px;
  padding: 9px 14px;
  color: var(--wa-text);
  font: inherit;
}

.composer input:focus { outline: 1px solid var(--wa-teal); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--wa-line);
  background: #2a3942;
  color: var(--wa-text);
  padding: 8px 12px;
}

button:hover { background: #33444f; }
button.primary { background: var(--wa-teal); color: #04231c; border-color: transparent; font-weight: 600; }
button.primary:hover { background: #06c397; }
button.primary:disabled { background: #2a3942; color: var(--wa-dim); cursor: not-allowed; }
button.ghost { background: transparent; border-color: transparent; color: var(--wa-dim); }
button.ghost:hover { background: #2a3942; color: var(--wa-text); }

/* ---------------- inspector ---------------- */
.side {
  background: var(--side-bg);
  border: 1px solid var(--wa-line);
  border-radius: 14px;
  padding: 14px 16px;
  overflow-y: auto;
  min-height: 0;
}

.side h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--wa-dim);
  margin: 18px 0 8px;
}

.side h2:first-child { margin-top: 0; }

.state { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
.state dt { color: var(--wa-dim); }
.state dd { margin: 0; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 5px 10px; font-size: 12.5px; }

.hint { color: var(--wa-dim); font-size: 12px; line-height: 1.5; }

.composer.locked { opacity: .4; pointer-events: none; }

.number-card {
  align-self: center;
  width: min(320px, 100%);
  margin: 24px auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--wa-in);
  border: 1px solid var(--wa-line);
  border-radius: 12px;
  color: var(--wa-text);
}
.number-card span { color: var(--wa-dim); font-size: 12.5px; line-height: 1.45; }
.number-card input {
  padding: 8px 10px;
  background: var(--wa-bg);
  color: var(--wa-text);
  border: 1px solid var(--wa-line);
  border-radius: 8px;
  font: inherit;
}
.number-card button { background: var(--wa-teal); color: #fff; border: none; border-radius: 8px; padding: 8px; font: inherit; }
.number-card button:disabled { opacity: .5; }
.number-error { color: #f15c6d; font-size: 12.5px; }

#testCustomer {
  width: 100%;
  padding: 6px 8px;
  background: var(--wa-header);
  color: var(--wa-text);
  border: 1px solid var(--wa-line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
code { background: #1d282f; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.log {
  font: 11.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--wa-dim);
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  max-height: 34vh;
  overflow-y: auto;
}

.log .err { color: #f2707a; }
.log .ok { color: var(--wa-teal); }

/* ---------------- flow sheet ---------------- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.sheet.hidden, .hidden { display: none; }

.sheet-card {
  width: min(420px, 100%);
  max-height: 92vh;
  background: #f0f2f5;
  color: #111b21;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 10px 6px;
  background: #fff;
  border-bottom: 1px solid #e0e3e7;
}

.sheet-header button { color: #54656f; font-size: 16px; }
.sheet-header button:hover { background: #e9edef; }
.sheet-titles { flex: 1; min-width: 0; }
.sheet-titles strong { display: block; font-size: 16px; font-weight: 600; }
.sheet-header .meta { display: block; color: #667781; font-size: 11.5px; }
.sheet-tag { color: #667781; font: 600 11px ui-monospace, Consolas, monospace; }
.sheet-caption { text-align: center; color: #667781; font-size: 12.5px; }

.sheet-body { padding: 14px; overflow-y: auto; background: #f0f2f5; }

.sheet-error {
  margin: 10px 14px 0;
  padding: 8px 10px;
  background: #fdeaea;
  color: #b4232c;
  border-radius: 8px;
  font-size: 13px;
}

.sheet-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e0e3e7;
}

.sheet-footer .primary { width: 100%; border-radius: 22px; padding: 11px; background: #008069; color: #fff; }
.sheet-footer .primary:disabled { background: #d5d9dd; color: #8696a0; }
.sheet-footer .ghost { color: #54656f; }
.sheet-footer .ghost:hover { background: #e9edef; }

.sheet-debug {
  margin: 0;
  padding: 12px 14px;
  background: #111b21;
  color: #8fd8c4;
  font: 11px/1.5 ui-monospace, Consolas, monospace;
  max-height: 30vh;
  overflow: auto;
  white-space: pre-wrap;
}

/* flow components */
.f-heading { font-size: 20px; font-weight: 700; margin: 4px 0 10px; }
.f-subheading { font-size: 16px; font-weight: 600; margin: 16px 0 6px; }
.f-body { margin: 8px 0; font-size: 14.5px; }
.f-caption { margin: 6px 0; font-size: 12.5px; color: #667781; }
.f-body ul, .f-caption ul { margin: 6px 0; padding-left: 18px; }
.f-body li { margin: 2px 0; }
.f-link { display: inline-block; margin: 10px 0; color: #027eb5; background: none; border: none; padding: 0; text-decoration: underline; }

.f-field { margin: 12px 0; }
.f-field > label { display: block; font-size: 12.5px; color: #54656f; margin-bottom: 4px; }
.f-field .req { color: #b4232c; }

.f-field input[type=text],
.f-field input[type=number],
.f-field input[type=email],
.f-field input[type=tel],
.f-field input[type=date],
.f-field select,
.f-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c9ced3;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: #111b21;
}

.f-field textarea { min-height: 62px; resize: vertical; }
.f-field input:focus, .f-field select:focus, .f-field textarea:focus { outline: 2px solid var(--wa-teal); border-color: var(--wa-teal); }
.f-helper { font-size: 11.5px; color: #667781; margin-top: 4px; }
.f-invalid input, .f-invalid select, .f-invalid textarea { border-color: #b4232c; }

.f-options { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid #c9ced3; border-radius: 8px; padding: 4px 6px; }
.f-option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; cursor: pointer; }
.f-option + .f-option { border-top: 1px solid #eceff1; }
.f-option input { margin-top: 3px; accent-color: var(--wa-teal); }
.f-option .t { font-size: 14px; }
.f-option .d { display: block; font-size: 12px; color: #667781; }

.f-optin { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 14px; }
.f-optin input { margin-top: 3px; accent-color: var(--wa-teal); }

.f-docs { background: #fff; border: 1px dashed #c9ced3; border-radius: 8px; padding: 12px; }
.f-docs .row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.f-docs ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: #54656f; }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .phone { height: 80vh; }
}
