:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f7fb;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
textarea,
.file-button {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 380px;
  min-height: 100vh;
}

.admin-shell {
  min-height: 100vh;
  background: #f5f7fb;
}

.operator-shell {
  background: #f4f7f8;
}

.operator-topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d9e1ea;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 24px;
}

.commerce-switcher {
  display: grid;
  gap: 8px;
  min-width: min(420px, 100%);
}

.commerce-switcher label {
  color: #4c6b5d;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.commerce-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) max-content;
  gap: 8px;
}

.commerce-row select,
.commerce-row input {
  border: 1px solid #b9c6c0;
  border-radius: 8px;
  color: #17211c;
  padding: 10px;
}

.create-business-panel {
  margin: 16px 24px 0;
}

.operator-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
}

.operator-layout {
  align-items: start;
}

.priority-section {
  border-color: #b8dcc8;
}

.split-panel {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  margin-top: 14px;
}

.empty-state {
  border: 1px dashed #b9c6c0;
  border-radius: 8px;
  color: #4c6b5d;
  padding: 14px;
}

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

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid #d8e0dc;
  background: #ffffff;
}

.topbar,
.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid #d9e1ea;
  background: #ffffff;
}

.topbar-subtitle {
  color: #5c6f82;
  line-height: 1.4;
  margin: 8px 0 0;
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #4c6b5d;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
}

.status {
  border: 1px solid #94c7ac;
  border-radius: 8px;
  color: #13643f;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 20px;
}

.bubble {
  max-width: min(720px, 86%);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: #dff5ea;
  border: 1px solid #bde5d1;
}

.bubble.bot {
  align-self: flex-start;
  background: #f2f4f8;
  border: 1px solid #dce2ea;
}

.bubble.system {
  align-self: center;
  color: #5a2f2f;
  background: #fff0f0;
  border: 1px solid #efc8c8;
}

.composer {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid #d8e0dc;
}

textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border: 1px solid #b9c6c0;
  border-radius: 8px;
  padding: 12px;
  color: #17211c;
}

.debug-input {
  width: 100%;
  border: 1px solid #b9c6c0;
  border-radius: 8px;
  padding: 9px 10px;
  color: #17211c;
}

textarea:focus {
  outline: 3px solid #bde5d1;
  border-color: #26845b;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

button,
.file-button {
  border: 1px solid #135f46;
  border-radius: 8px;
  background: #157a56;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
}

button:hover,
.file-button:hover {
  background: #0f6f43;
}

.file-button,
button.secondary {
  background: #ffffff;
  color: #174d78;
  border-color: #98b8d1;
  display: inline-flex;
  align-items: center;
}

.file-button:hover,
button.secondary:hover {
  background: #eef6fb;
}

input[type="file"] {
  display: none;
}

.debug-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: #fbfcfd;
}

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid #d8e0dc;
}

.facts div {
  display: grid;
  gap: 4px;
}

dt {
  color: #4c6b5d;
  font-size: 13px;
  font-weight: 700;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  overflow: auto;
  padding: 20px;
  font-size: 13px;
  line-height: 1.45;
}

.nav-link {
  color: #14527a;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 20px;
  padding: 20px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 24px 28px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 24px 0;
  background: #ffffff;
}

.admin-tabs a {
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  color: #14527a;
  font-weight: 700;
  padding: 9px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.admin-main {
  display: grid;
  gap: 20px;
}

.admin-section {
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(20, 36, 54, 0.05);
}

.setup-card {
  background: #eef8f2;
  border-color: #b8dcc8;
}

.button-link {
  align-items: center;
  background: #157a56;
  border: 1px solid #135f46;
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
  font-weight: 700;
  margin-top: 8px;
  padding: 10px 14px;
  text-decoration: none;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-form {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.admin-form.two-cols {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.admin-form.three-cols {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.admin-form.four-cols {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.admin-form input,
.admin-form select {
  border: 1px solid #b9c6c0;
  border-radius: 8px;
  padding: 10px;
}

.doctor-list,
.appointments-list,
.calendar-actions {
  display: grid;
  gap: 10px;
}

.calendar-actions {
  grid-template-columns: repeat(3, minmax(0, max-content));
}

.calendar-actions.compact {
  grid-template-columns: 1fr;
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.metric-card {
  border: 1px solid #d8e0dc;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.metric-card strong {
  font-size: 26px;
}

.metric-card span {
  color: #4c6b5d;
  font-size: 13px;
  font-weight: 700;
}

.doctor-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid #d9e1ea;
  background: #fbfcfd;
  color: #17211c;
  text-align: left;
}

.doctor-card:hover {
  border-color: #9bb8ce;
}

.data-card,
.channel-card {
  padding: 14px;
}

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

.pill {
  background: #e9f2fb;
  border: 1px solid #bdd5e8;
  border-radius: 8px;
  color: #14527a;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.pill.ok {
  background: #e5f7ed;
  border-color: #9bd3b4;
  color: #12613e;
}

.pill.warn {
  background: #fff6dd;
  border-color: #e7ca78;
  color: #7a4b00;
}

.profile-presets {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.profile-presets span {
  color: #5c6f82;
  font-size: 13px;
  font-weight: 700;
}

.profile-presets strong {
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  color: #26384a;
  font-size: 13px;
  padding: 6px 8px;
}

.doctor-card.selected {
  border-color: #168653;
  background: #eef8f2;
}

.doctor-card small,
.appointment-item small {
  color: #4c6b5d;
  overflow-wrap: anywhere;
}

.duration-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
}

.duration-row select {
  border: 1px solid #b9c6c0;
  border-radius: 8px;
  padding: 10px;
}

.weekly-schedule {
  display: grid;
  gap: 8px;
}

.day-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 130px 130px;
  gap: 10px;
  align-items: center;
  border: 1px solid #d8e0dc;
  border-radius: 8px;
  padding: 10px;
}

.day-row input[type="time"] {
  border: 1px solid #b9c6c0;
  border-radius: 8px;
  padding: 9px;
}

.day-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.appointment-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #d8e0dc;
  border-radius: 8px;
  padding: 12px;
  width: 100%;
  background: #ffffff;
  color: inherit;
  text-align: left;
}

.appointment-item div {
  display: grid;
  gap: 4px;
}

.conversation-row {
  cursor: pointer;
}

.message-thread {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.message-line {
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.message-line-header,
.message-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message-line-header {
  justify-content: space-between;
}

.error-text {
  color: #9b2f2f;
}

.message-line.inbound {
  background: #f6f9fc;
}

.message-line.outbound {
  background: #eef8f2;
}

button.danger {
  background: #a73535;
  border-color: #8f2a2a;
}

button.danger:hover {
  background: #872424;
}

.status.warning {
  color: #7a4b00;
  border-color: #e1c16e;
}

.admin-item {
  display: grid;
  gap: 6px;
  border-top: 1px solid #d8e0dc;
  padding: 12px 0;
}

.hint {
  color: #4c6b5d;
  line-height: 1.4;
}

.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: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

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

  .commerce-row,
  .split-panel {
    grid-template-columns: 1fr;
  }

  .calendar-actions,
  .admin-form.three-cols,
  .admin-form.four-cols,
  .day-row {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 72vh;
    border-right: 0;
    border-bottom: 1px solid #d8e0dc;
  }

  .actions,
  .topbar,
  .debug-header {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button,
  .actions .file-button {
    width: 100%;
    justify-content: center;
  }

  .bubble {
    max-width: 96%;
  }
}

.dark-theme {
  background: #111821;
  color: #e9eef4;
}

.dark-theme .admin-shell,
.dark-theme .operator-topbar,
.dark-theme .topbar,
.dark-theme .debug-header,
.dark-theme .admin-tabs,
.dark-theme .admin-section,
.dark-theme .appointment-item {
  background: #151f2a;
  color: #e9eef4;
}

.dark-theme .admin-section,
.dark-theme .admin-tabs a,
.dark-theme .doctor-card,
.dark-theme .appointment-item,
.dark-theme .message-line {
  border-color: #2b3a4c;
}

.dark-theme .doctor-card,
.dark-theme .message-line.inbound {
  background: #1b2734;
  color: #e9eef4;
}

.dark-theme .message-line.outbound,
.dark-theme .setup-card {
  background: #143224;
}

.dark-theme input,
.dark-theme select,
.dark-theme .commerce-row select,
.dark-theme .commerce-row input,
.dark-theme textarea,
.dark-theme .debug-input {
  background: #101720;
  border-color: #314357;
  color: #e9eef4;
}

.dark-theme .hint,
.dark-theme .topbar-subtitle,
.dark-theme .doctor-card small,
.dark-theme .appointment-item small {
  color: #a9b7c7;
}
