:root {
  --bg0: #f2f6f4;
  --bg1: #e4efe8;
  --ink: #13261c;
  --muted: #5d7266;
  --line: rgba(19, 38, 28, 0.1);
  --green: #1f6b45;
  --green-soft: #d8eee1;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(19, 38, 28, 0.07);
  --radius: 16px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(31, 107, 69, 0.12), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(180, 140, 60, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
}

.login-sub {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font: inherit;
  background: #fafcfb;
}

.login-card button {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.error {
  color: #a32020;
  font-size: 0.85rem;
  margin-top: 10px;
}

.wa-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
}

.wa-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

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

.wa-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1f6b45, #0f5132);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.wa-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
}

.wa-subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.wa-status-pill {
  font-size: 0.68rem;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef3f0;
  color: var(--muted);
  white-space: nowrap;
}

.wa-status-pill.is-ok {
  background: var(--green-soft);
  color: var(--green);
}

.wa-status-pill.is-warn {
  background: #fff3d6;
  color: #8a5a00;
}

.wa-btn-ghost,
.wa-btn-back {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  color: var(--ink);
}

.wa-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 18px 0;
}

.wa-tab {
  border: none;
  background: transparent;
  padding: 10px 16px;
  border-radius: 12px 12px 0 0;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.wa-tab.is-active {
  color: var(--green);
  background: rgba(255, 255, 255, 0.7);
}

.wa-tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}

.wa-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 18px 18px;
}

.wa-panel.hidden,
.hidden { display: none !important; }

.wa-calendar-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.wa-cal-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}

.wa-cal-label input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}

.wa-btn-prim,
.wa-btn-sec {
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.wa-btn-prim {
  border: none;
  background: var(--green);
  color: #fff;
}

.wa-btn-sec {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.wa-cal-result {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.wa-events-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.wa-events-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.wa-doctors-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(280px, 1fr));
  gap: 14px;
  min-height: min(70vh, 720px);
}

@media (max-width: 960px) {
  .wa-doctors-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    min-height: 0;
  }
}

.wa-doc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 280px;
  overflow: hidden;
  border-top: 3px solid var(--doc-accent, var(--green));
}

.wa-doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), #f7faf8);
  border-bottom: 1px solid var(--line);
}

.wa-doc-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
}

.wa-doc-meta {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: #eef3f0;
  padding: 4px 8px;
  border-radius: 999px;
}

.wa-doc-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.wa-doc-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.wa-ev-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wa-ev-card:hover {
  background: #f5faf7;
  border-color: var(--line);
}

.wa-ev-card.is-sent {
  background: rgba(216, 238, 225, 0.35);
}

.wa-ev-card.is-phone-bad {
  background: rgba(253, 232, 232, 0.35);
}

.wa-ev-time {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--doc-accent, var(--green));
  padding-top: 2px;
}

.wa-ev-patient {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
}

.wa-ev-phone {
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--muted);
}

.wa-ev-phone-miss {
  color: #a32020;
  font-size: 0.76rem;
  font-weight: 700;
}

.wa-ev-phone-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.wa-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.wa-badge-sent {
  background: #d8eee1;
  color: #0f5132;
}

.wa-badge-warn {
  background: #fff3d6;
  color: #8a5a00;
}

.wa-badge-bad {
  background: #fde8e8;
  color: #a32020;
}

.wa-ev-patient-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.wa-ev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.wa-btn-link {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--green);
}

.wa-btn-link:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wa-btn-link.wa-btn-danger-link {
  color: #a32020;
  border-color: rgba(163, 32, 32, 0.25);
}

.wa-fc-host {
  min-height: 200px;
}

.wa-fc-host .fc {
  --fc-border-color: transparent;
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: transparent;
  --fc-list-event-hover-bg-color: #f5faf7;
  font-family: var(--font);
  font-size: 0.82rem;
}

.wa-fc-host .fc-list {
  border: none !important;
}

.wa-fc-host .fc-list-day-cushion {
  background: transparent !important;
  font-weight: 700;
  color: var(--muted);
}

.wa-fc-host .fc-list-event td {
  border: none !important;
  padding: 6px 4px !important;
}

.wa-fc-host .fc-event-title {
  font-weight: 650;
}

.wa-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.wa-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 251, 0.95);
}

.wa-search-wrap { padding: 12px; }

.wa-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.wa-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.wa-empty-list {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.wa-conv-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 4px;
  font: inherit;
  color: inherit;
}

.wa-conv-item:hover { background: rgba(31, 107, 69, 0.06); }
.wa-conv-item.is-active { background: var(--green-soft); }

.wa-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #dce8e1;
  color: var(--green);
  font-weight: 800;
  font-size: 0.78rem;
}

.wa-conv-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.wa-conv-name {
  font-weight: 750;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-conv-time {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.wa-conv-preview {
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-unread {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
}

.wa-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(232, 242, 236, 0.55), rgba(244, 248, 246, 0.9));
}

.wa-thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.wa-thread-empty-card {
  text-align: center;
  max-width: 280px;
  color: var(--muted);
}

.wa-thread-empty-title {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--ink);
  font-weight: 700;
}

.wa-thread-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wa-thread-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-thread-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.wa-thread-head-main { min-width: 0; flex: 1; }
.wa-thread-name { font-weight: 750; font-size: 0.98rem; }
.wa-thread-phone { font-size: 0.76rem; color: var(--muted); }

.wa-btn-danger {
  border: 1px solid rgba(163, 32, 32, 0.3);
  background: #fff5f5;
  color: #a32020;
  border-radius: 10px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.wa-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wa-day-sep {
  align-self: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  margin: 6px 0;
}

.wa-bubble {
  max-width: min(78%, 520px);
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(19, 38, 28, 0.05);
  animation: wa-pop 0.18s ease-out;
}

@keyframes wa-pop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.wa-bubble.is-in {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.wa-bubble.is-out {
  align-self: flex-end;
  background: #cfe9d8;
  border-bottom-right-radius: 6px;
}

.wa-bubble-meta {
  display: block;
  margin-top: 4px;
  font-size: 0.64rem;
  color: var(--muted);
  text-align: right;
}

.wa-composer {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  align-items: flex-end;
}

.wa-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  font: inherit;
  min-height: 44px;
  max-height: 120px;
  background: #fafcfb;
}

.wa-send-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.wa-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 30, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.wa-modal {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(19, 38, 28, 0.2);
  overflow: hidden;
}

.wa-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.wa-modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
}

.wa-modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.wa-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wa-modal-body label {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
}

.wa-modal-body input,
.wa-modal-body select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
}

.wa-modal-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 520px) {
  .wa-modal-row { grid-template-columns: 1fr; }
}

.wa-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600 !important;
}

.wa-check input { width: auto !important; margin: 0 !important; }

.wa-phone-edit-patient {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.wa-phone-edit-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.wa-phone-edit-hint.is-bad { color: #a32020; }
.wa-phone-edit-hint.is-warn { color: #8a5a00; }
.wa-phone-edit-hint.is-ok { color: #0f5132; }

.wa-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
