:root {
  color-scheme: light;
  --app-bg: #f0f2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --chat-bg: #efeae2;
  --chat-grid: rgba(17, 27, 33, 0.025);
  --user-bubble: #d9fdd3;
  --bot-bubble: #ffffff;
  --accent: #25d366;
  --accent-dark: #075e54;
  --text: #111b21;
  --text-soft: #667781;
  --line: #d8e0e6;
  --line-soft: #e9edef;
  --shadow-xl: 0 22px 60px rgba(17, 27, 33, 0.08);
  --shadow-lg: 0 10px 30px rgba(17, 27, 33, 0.08);
  --shadow-sm: 0 4px 18px rgba(17, 27, 33, 0.06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 211, 102, 0.08), transparent 18%),
    linear-gradient(180deg, #edf1f4 0%, var(--app-bg) 100%);
}

button,
input,
textarea {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 28px 20px 36px;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.brand-block {
  max-width: 760px;
}

.eyebrow,
.section-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 8px;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
  line-height: 1.15;
}

h3 {
  font-size: 16px;
}

.hero-copy {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 15px;
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(7, 94, 84, 0.08);
  box-shadow: var(--shadow-sm);
  color: var(--text-soft);
}

.status-indicator,
.status-banner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.status-indicator {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(37, 211, 102, 0.12);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.34fr) minmax(320px, 0.76fr);
  gap: 22px;
  align-items: start;
}

.chat-column,
.dashboard-column {
  min-width: 0;
}

.chat-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-surface,
.dashboard-panel,
.chat-panel,
.dashboard-card,
.metric-tile {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-lg);
}

.patient-card,
.payment-card,
.dashboard-panel,
.dashboard-card,
.chat-panel {
  border-radius: var(--radius-xl);
}

.patient-card,
.payment-card,
.dashboard-panel,
.dashboard-card {
  padding: 18px;
}

.card-title-row,
.dashboard-head,
.dashboard-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.patient-fields,
.payment-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.patient-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payment-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.compact-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.compact-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 16px;
  padding: 13px 14px;
  resize: vertical;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

input:focus,
textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: rgba(7, 94, 84, 0.38);
  box-shadow: 0 0 0 4px rgba(7, 94, 84, 0.08);
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.status-banner-neutral {
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-soft);
  border-color: rgba(102, 119, 129, 0.14);
}

.status-banner-neutral .status-banner-dot {
  background: #8fa3ad;
}

.status-banner-success {
  background: rgba(37, 211, 102, 0.12);
  color: #0f5132;
  border-color: rgba(37, 211, 102, 0.2);
}

.status-banner-success .status-banner-dot {
  background: var(--accent);
}

.status-banner-warning {
  background: rgba(255, 193, 7, 0.12);
  color: #6f5600;
  border-color: rgba(255, 193, 7, 0.22);
}

.status-banner-warning .status-banner-dot {
  background: #c48b00;
}

.status-banner-error {
  background: rgba(217, 83, 79, 0.1);
  color: #8a2f2d;
  border-color: rgba(217, 83, 79, 0.18);
}

.status-banner-error .status-banner-dot {
  background: #d9534f;
}

.chat-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 760px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(180deg, #f7f9fa 0%, #ffffff 100%);
  border-bottom: 1px solid var(--line-soft);
}

.chat-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 800;
  background: linear-gradient(180deg, #138a72, var(--accent-dark));
  box-shadow: 0 10px 24px rgba(7, 94, 84, 0.22);
}

.chat-name {
  font-size: 16px;
  font-weight: 700;
}

.chat-presence {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-soft);
}

.chat-tools {
  display: flex;
  gap: 8px;
}

.tool-button,
.attach-button,
.ghost-button,
.ghost-button-strong,
.secondary-action,
.send-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.tool-button,
.attach-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(102, 119, 129, 0.08);
  color: var(--text-soft);
  font-weight: 700;
}

.tool-button:hover,
.attach-button:hover,
.ghost-button:hover,
.ghost-button-strong:hover,
.secondary-action:hover,
.send-button:hover {
  transform: translateY(-1px);
}

.tool-button:disabled,
.attach-button:disabled,
.ghost-button:disabled,
.ghost-button-strong:disabled,
.secondary-action:disabled,
.send-button:disabled {
  opacity: 0.72;
  cursor: wait;
  transform: none;
}

.chat-stream {
  flex: 1;
  min-height: 520px;
  max-height: 760px;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 25px 25px, var(--chat-grid) 1px, transparent 1px),
    radial-gradient(circle at 75px 75px, var(--chat-grid) 1px, transparent 1px);
  background-size: 100px 100px;
}

.message-row {
  display: flex;
  width: 100%;
  animation: message-in 0.18s ease;
}

.message-row-patient {
  justify-content: flex-end;
}

.message-row-bot {
  justify-content: flex-start;
}

.message-row-system {
  justify-content: center;
}

.message {
  width: fit-content;
  max-width: 72%;
  padding: 10px 12px 8px;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(17, 27, 33, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.message:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(17, 27, 33, 0.08);
}

.message-patient {
  background: var(--user-bubble);
  border-top-right-radius: 6px;
}

.message-bot {
  background: var(--bot-bubble);
  border-top-left-radius: 6px;
}

.message-system {
  max-width: 88%;
  background: rgba(255, 255, 255, 0.88);
  color: #8a2f2d;
  border-radius: 12px;
  text-align: center;
}

.message-body {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.message-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-soft);
  text-align: right;
}

.chat-compose-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px 16px 16px;
  background: #f0f2f5;
  border-top: 1px solid var(--line-soft);
}

.composer-field {
  display: block;
}

.composer-field textarea {
  min-height: 52px;
  max-height: 150px;
  resize: none;
  border-radius: 26px;
  padding: 15px 18px;
  background: #ffffff;
}

.send-button {
  min-width: 88px;
  height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(180deg, #0b7a6a, var(--accent-dark));
  box-shadow: 0 10px 25px rgba(7, 94, 84, 0.2);
}

.ghost-button,
.ghost-button-strong,
.secondary-action {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
}

.ghost-button {
  background: rgba(102, 119, 129, 0.08);
  color: var(--text-soft);
}

.ghost-button-strong {
  background: rgba(7, 94, 84, 0.08);
  color: var(--accent-dark);
}

.secondary-action {
  background: #eef7f3;
  color: var(--accent-dark);
}

.payment-card {
  margin-top: 2px;
}

.discreet-field textarea {
  min-height: 82px;
  background: #fafbfc;
}

.file-field input {
  padding: 11px 12px;
  background: #fafbfc;
}

.payment-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.helper-note {
  font-size: 12px;
  color: var(--text-soft);
}

.dashboard-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.metric-tile {
  border-radius: 20px;
  padding: 16px;
}

.metric-tile span {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

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

.dashboard-card {
  padding-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

th {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

td {
  color: var(--text);
}

.empty-row {
  text-align: center;
  color: var(--text-soft);
  padding: 20px 8px;
}

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

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-column {
    order: 2;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 18px 12px 24px;
  }

  .app-topbar,
  .card-title-row,
  .dashboard-head,
  .payment-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .patient-fields,
  .payment-grid,
  .dashboard-metrics {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 680px;
  }

  .chat-stream {
    min-height: 420px;
    max-height: 560px;
    padding: 18px 12px;
  }

  .chat-compose-wrap {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .send-button {
    grid-column: 1 / -1;
    width: 100%;
  }

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