:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-soft: #eef3ec;
  --text: #17201b;
  --muted: #5e6a62;
  --line: #d9ded8;
  --accent: #196b4f;
  --accent-strong: #0d4d3a;
  --warning: #9a5d00;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(23, 32, 27, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand > div,
.chat-topbar > div,
.panel-section,
.bubble {
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.brand p,
.chat-topbar p,
.panel-section p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-controls label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  min-width: 190px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  padding: 0 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.status-ok {
  border-color: rgba(25, 107, 79, 0.28);
  color: var(--accent-strong);
  background: #edf8f3;
}

.status-error {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--danger);
  background: #fff0ee;
}

.status-waiting {
  border-color: rgba(154, 93, 0, 0.25);
  color: var(--warning);
  background: #fff8e8;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  width: min(1240px, calc(100vw - 36px));
  margin: 22px auto;
  align-items: start;
}

.chat-panel,
.side-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chat-panel {
  height: calc(100vh - 130px);
  min-height: 0;
  max-height: calc(100vh - 130px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  position: sticky;
  top: 18px;
}

.chat-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.chat-log {
  min-width: 0;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message {
  display: flex;
  margin-bottom: 14px;
}

.message-user {
  justify-content: flex-end;
}

.message-dispatch,
.message-system {
  justify-content: flex-start;
}

.bubble {
  max-width: min(680px, 88%);
  border-radius: var(--radius);
  padding: 12px 14px;
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-user .bubble {
  background: var(--accent);
  color: white;
}

.message-assistant .bubble {
  background: var(--surface-soft);
  color: var(--text);
}

.message-dispatch .bubble {
  background: #e9f3ff;
  color: #102f4f;
  border: 1px solid #b6d8ff;
}

.message-system .bubble {
  background: #fff8e8;
  color: #4d3412;
  border: 1px solid #f1d38f;
}

.message-error .bubble {
  background: #fff0ee;
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.22);
}

.chat-form {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
  background: white;
  line-height: 1.45;
}

textarea:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(25, 107, 79, 0.22);
  outline-offset: 2px;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-weight: 700;
  min-height: 40px;
  padding: 10px 14px;
}

button:hover {
  background: var(--accent-strong);
}

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

.secondary-button {
  background: white;
  color: var(--accent-strong);
  border: 1px solid rgba(25, 107, 79, 0.35);
}

.secondary-button:hover {
  background: #edf8f3;
}

.side-panel {
  display: grid;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.quick-tests {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quick-tests button {
  width: 100%;
  text-align: left;
  justify-content: start;
  background: #24332c;
}

.quick-tests button:hover {
  background: #17201b;
}

.lead-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 14px;
}

.lead-row {
  display: grid;
  grid-template-columns: 125px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.lead-row dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.lead-row dd {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.full-width {
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .app-header,
  .chat-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-controls {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: min(720px, calc(100vw - 24px));
  }

  .chat-panel {
    height: min(760px, calc(100dvh - 24px));
    max-height: none;
    position: static;
  }

  .side-panel {
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 560px) {
  .app-header {
    width: min(100%, 390px);
    margin: 0;
    padding: 14px;
  }

  .brand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: flex-start;
    width: 100%;
  }

  .brand > div {
    max-width: 100%;
  }

  .header-controls {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  select {
    width: 100%;
    min-width: 0;
  }

  .status {
    justify-self: start;
  }

  .app-shell {
    width: 100%;
    max-width: 390px;
    margin: 12px 0;
    padding: 0 12px;
  }

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

  .bubble {
    max-width: 100%;
  }

  .lead-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.text-link {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.lab-page {
  background: #f4f6f4;
}

.lab-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.lab-shell {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 410px;
  gap: 18px;
  width: min(1600px, calc(100vw - 28px));
  margin: 18px auto;
  align-items: start;
}

.lab-stack {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.lab-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.lab-card-header,
.lab-button-row,
.lab-runtime-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lab-card-header,
.lab-button-row {
  justify-content: space-between;
}

.lab-button-row {
  margin-top: 12px;
}

.lab-button-row button {
  flex: 1;
}

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

.lab-small {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.lab-control-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lab-control-grid label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.lab-control-grid select {
  width: 100%;
  min-width: 0;
}

.toggle-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.lab-prompt-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lab-prompt-grid button {
  width: 100%;
  min-height: 36px;
  background: #24332c;
  text-align: left;
}

.lab-prompt-grid button:hover {
  background: #17201b;
}

.lab-script-input {
  min-height: 190px;
  margin-top: 10px;
  font-size: 13px;
}

.lab-chat-panel {
  height: calc(100vh - 112px);
  max-height: calc(100vh - 112px);
}

.lab-chat-log {
  background:
    linear-gradient(rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.88)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(217, 222, 216, 0.45) 32px);
}

.lab-chat-form textarea {
  min-height: 92px;
}

.lab-inspector {
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lab-summary-grid {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 12px 0 0;
}

.lab-summary-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.lab-summary-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.debug-panel pre {
  max-height: 280px;
  margin: 12px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111a16;
  color: #e7f5ed;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .lab-shell {
    grid-template-columns: 280px minmax(420px, 1fr);
  }

  .lab-inspector {
    grid-column: 1 / -1;
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 900px) {
  .lab-shell {
    grid-template-columns: 1fr;
    width: min(760px, calc(100vw - 24px));
  }

  .lab-chat-panel,
  .lab-inspector {
    height: auto;
    max-height: none;
    overflow-y: visible;
    position: static;
  }
}

@media (max-width: 560px) {
  .lab-shell {
    width: 100%;
    max-width: 390px;
    margin: 12px 0;
    padding: 0 12px;
  }

  .lab-card-header,
  .lab-button-row,
  .lab-runtime-badges {
    align-items: stretch;
    flex-direction: column;
  }

  .lab-summary-grid {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.beta-page {
  min-height: 100vh;
  background: #f4f6f4;
}

.beta-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.beta-thread {
  width: min(760px, 100%);
  height: min(860px, calc(100dvh - 36px));
  min-height: 520px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.beta-thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.beta-thread-header .status {
  max-width: 320px;
  justify-content: center;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.beta-thread-header h1 {
  font-size: 18px;
}

.beta-thread-header p,
.beta-disclaimer {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.beta-chat-log {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fbfcfb;
}

.beta-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.beta-chat-form textarea {
  min-height: 56px;
  max-height: 150px;
  resize: vertical;
}

.beta-disclaimer {
  padding: 0 18px 14px;
  background: #ffffff;
}

html.jtows-chat-embed,
html.jtows-chat-embed body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

html.jtows-chat-embed .beta-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  place-items: stretch;
}

html.jtows-chat-embed .beta-thread {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

html.jtows-chat-embed .beta-thread-header {
  padding: 12px 14px;
}

html.jtows-chat-embed .beta-thread-header h1 {
  font-size: 16px;
}

html.jtows-chat-embed .beta-thread-header p {
  font-size: 12px;
}

html.jtows-chat-embed .beta-chat-log {
  padding: 14px;
}

html.jtows-chat-embed .beta-chat-form {
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  padding: 10px 12px;
}

html.jtows-chat-embed .beta-chat-form textarea,
html.jtows-chat-embed .beta-chat-form button {
  min-height: 48px;
}

html.jtows-chat-embed .beta-disclaimer {
  padding: 0 12px 10px;
  font-size: 11px;
}

.review-page {
  background: #f4f6f4;
}

.review-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.review-shell {
  display: grid;
  grid-template-columns: 300px minmax(320px, 430px) minmax(420px, 1fr);
  gap: 18px;
  width: min(1600px, calc(100vw - 28px));
  margin: 18px auto;
  align-items: start;
}

.review-toolbar {
  display: grid;
  gap: 12px;
}

.review-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text);
  background: white;
  font: inherit;
}

.review-input:focus {
  outline: 3px solid rgba(25, 107, 79, 0.22);
}

.session-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.session-button {
  display: grid;
  gap: 4px;
  width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  text-align: left;
  font-weight: 400;
}

.session-button:hover,
.session-button.active {
  background: #edf8f3;
  border-color: rgba(25, 107, 79, 0.35);
}

.session-button strong,
.session-button span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.session-button strong {
  font-size: 13px;
}

.session-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.review-detail {
  min-width: 0;
}

.dispatch-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
}

.dispatch-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.dispatch-panel h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.dispatch-control-grid,
.dispatch-message-row {
  display: grid;
  gap: 6px;
}

.dispatch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dispatch-actions button,
.dispatch-message-row button {
  width: auto;
}

.dispatch-message-input {
  height: auto;
  min-height: 78px;
  padding-top: 10px;
  resize: vertical;
}

.dispatch-action-error {
  color: #b3261e;
  font-weight: 700;
}

.review-messages {
  display: grid;
  gap: 10px;
  max-height: 46vh;
  margin-top: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.review-message {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #ffffff;
}

.review-message-user {
  border-color: rgba(25, 107, 79, 0.28);
  background: #edf8f3;
}

.review-message-system {
  border-color: rgba(154, 93, 0, 0.25);
  background: #fff8e8;
}

.review-message span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.review-message p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.review-json {
  max-height: 36vh;
  margin: 14px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111a16;
  color: #e7f5ed;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .review-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .review-detail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .beta-shell {
    padding: 0;
  }

  .beta-thread {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  .beta-thread-header {
    align-items: stretch;
    flex-direction: column;
  }

  .beta-thread-header .status {
    max-width: none;
    justify-content: flex-start;
    text-align: left;
  }

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

  .review-shell {
    grid-template-columns: 1fr;
    width: min(760px, calc(100vw - 24px));
  }

  .session-list,
  .review-messages,
  .review-json {
    max-height: none;
  }
}

/* Phone-first live dispatch chat opened from the SMS handoff link. */
body.dispatch-chat-page {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #dce6e1;
  color-scheme: light;
}

.dispatch-phone-app {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(100%, 540px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  border-inline: 1px solid #c7d2cc;
  background: #eef3f0;
  box-shadow: 0 0 40px rgba(17, 46, 37, 0.16);
}

.dispatch-chat-header {
  z-index: 20;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #12372d;
  color: #ffffff;
}

.dispatch-chat-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e5b84a;
  color: #17352c;
  font-size: 14px;
  font-weight: 900;
}

.dispatch-chat-identity {
  min-width: 0;
}

.dispatch-chat-identity h1 {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-chat-identity p {
  margin-top: 3px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 25px;
}

.dispatch-owner-bar {
  z-index: 15;
  display: grid;
  gap: 9px;
  padding: 10px 12px;
  border-bottom: 1px solid #ccd7d1;
  background: #ffffff;
  box-shadow: 0 3px 12px rgba(20, 55, 44, 0.08);
}

.dispatch-owner-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.dispatch-ownership-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.dispatch-ownership-bot {
  background: #e7f1ec;
  color: #245743;
}

.dispatch-ownership-ready {
  background: #fff1c9;
  color: #7a4a00;
}

.dispatch-ownership-human {
  background: #dff4e9;
  color: #075d3c;
}

.dispatch-ownership-waiting {
  background: #edf0ee;
  color: #53635b;
}

.dispatch-connection-label {
  overflow: hidden;
  color: #66736c;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-connection-error {
  color: #a52a22;
  font-weight: 700;
}

.dispatch-employee-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #526159;
  font-size: 12px;
  font-weight: 800;
}

.dispatch-employee-field input {
  width: 100%;
  height: 44px;
  border: 1px solid #c8d3cd;
  border-radius: 12px;
  padding: 0 12px;
  background: #f8faf9;
  color: #17201b;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
}

.dispatch-employee-field input:focus,
.dispatch-chat-composer textarea:focus {
  border-color: #26765b;
  outline: 3px solid rgba(38, 118, 91, 0.18);
}

.dispatch-owner-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dispatch-owner-actions button {
  min-height: 48px;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.15;
}

.dispatch-enter-button {
  border: 1px solid #176a4d;
  background: #176a4d;
  color: #ffffff;
}

.dispatch-resume-button {
  border: 1px solid #d9a832;
  background: #fff4d7;
  color: #694300;
}

.dispatch-owner-actions button:disabled,
.dispatch-chat-composer button:disabled {
  cursor: not-allowed;
  border-color: #d3dad6;
  background: #e8ecea;
  color: #8a958f;
}

.dispatch-owner-help {
  color: #5a6861;
  font-size: 11px;
  line-height: 1.35;
}

.dispatch-chat-messages {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(35, 99, 76, 0.035) 0 2px, transparent 2px 100%),
    #e8efeb;
  background-size: 24px 24px;
  scroll-behavior: smooth;
}

.dispatch-chat-loading,
.dispatch-latest-marker {
  width: fit-content;
  max-width: 92%;
  margin: 5px auto 14px;
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.82);
  color: #627169;
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 1px 2px rgba(18, 55, 45, 0.08);
}

.dispatch-chat-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  margin: 9px 0;
}

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

.dispatch-message-label {
  margin: 0 8px;
  color: #65736c;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.dispatch-message-bubble {
  max-width: 84%;
  border-radius: 18px 18px 18px 5px;
  padding: 9px 11px 6px;
  background: #ffffff;
  color: #17201b;
  box-shadow: 0 1px 2px rgba(22, 48, 39, 0.12);
}

.dispatch-chat-message-bot .dispatch-message-bubble {
  background: #f9fff9;
  border: 1px solid #d2e5da;
}

.dispatch-chat-message-dispatch .dispatch-message-bubble {
  border-radius: 18px 18px 5px 18px;
  background: #d9f5e7;
  color: #103d2e;
}

.dispatch-message-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.38;
}

.dispatch-message-bubble time {
  display: block;
  margin-top: 3px;
  color: #77847d;
  font-size: 10px;
  line-height: 1.1;
  text-align: right;
}

.dispatch-system-message {
  width: fit-content;
  max-width: 90%;
  margin: 10px auto;
  border-radius: 10px;
  padding: 6px 9px;
  background: rgba(255, 247, 220, 0.92);
  color: #765100;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}

.dispatch-chat-composer {
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  gap: 8px;
  align-items: end;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid #ccd7d1;
  background: #ffffff;
  box-shadow: 0 -4px 14px rgba(20, 55, 44, 0.08);
}

.dispatch-chat-composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  border: 1px solid #c8d3cd;
  border-radius: 20px;
  padding: 12px 14px;
  background: #f5f8f6;
  color: #17201b;
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
}

.dispatch-chat-composer button {
  min-width: 64px;
  min-height: 48px;
  border: 1px solid #176a4d;
  border-radius: 16px;
  background: #176a4d;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.dispatch-composer-status {
  grid-column: 1 / -1;
  min-height: 0;
  color: #56655d;
  font-size: 11px;
  line-height: 1.3;
}

.dispatch-composer-status:empty {
  display: none;
}

.dispatch-fatal {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 28px;
  background: #f8faf9;
  color: #17201b;
  text-align: center;
}

.dispatch-fatal[hidden] {
  display: none;
}

.dispatch-fatal h2 {
  font-size: 21px;
}

.dispatch-fatal p {
  color: #59675f;
  font-size: 15px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .dispatch-phone-app {
    width: 100%;
    border: 0;
    box-shadow: none;
  }

  .dispatch-owner-bar {
    gap: 8px;
    padding: 9px 10px;
  }

  .dispatch-chat-messages {
    padding-inline: 10px;
  }
}

@media (max-width: 370px) {
  .dispatch-owner-actions button {
    padding-inline: 7px;
    font-size: 12px;
  }

  .dispatch-owner-help {
    font-size: 10px;
  }
}
