:root {
  --bg: #f6f4ef;
  --surface: #fffdf6;
  --surface-strong: #fff6d5;
  --ink: #14243d;
  --muted: #4a5870;
  --line: #d5d0be;
  --brand: #006b5f;
  --brand-strong: #005046;
  --warn: #a0400f;
  --danger: #b22026;
  --urgent-bg: #ffe3dc;
  --ok: #2e7d32;
  --shadow: 0 14px 40px rgba(26, 34, 56, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Nunito", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, #fff3ce 0%, rgba(255, 243, 206, 0.3) 35%, transparent 60%),
    radial-gradient(circle at 90% 10%, #d6ece8 0%, rgba(214, 236, 232, 0.2) 30%, transparent 65%),
    var(--bg);
  min-height: 100vh;
}

a {
  color: inherit;
}

input,
select,
textarea,
button {
  font: inherit;
}

button {
  cursor: pointer;
}

.landing {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem;
}

.hero-card {
  max-width: 720px;
  background: linear-gradient(145deg, #fffdf8, #fff6dc);
  border: 1px solid #f0e6c6;
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 2rem;
}

.hero-card h1 {
  margin-top: 0.2rem;
  margin-bottom: 0.6rem;
  font-family: "Iowan Old Style", "Georgia", serif;
  font-size: clamp(2rem, 3vw, 3rem);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0;
}

.hero-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 1.2rem;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.ghost {
  background: transparent;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 252, 240, 0.85);
  backdrop-filter: blur(6px);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand-title {
  margin: 0;
  font-family: "Iowan Old Style", "Georgia", serif;
  font-size: 1.45rem;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.filters {
  display: grid;
  gap: 0.5rem;
}

.filters input,
.filters select,
.filters textarea,
.panel-card input,
.panel-card select,
.panel-card textarea,
.auth-card input,
.auth-card select,
.auth-card textarea,
.family-onboarding input,
.family-onboarding select,
.family-onboarding textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.conversation-list {
  overflow: auto;
  display: grid;
  gap: 0.55rem;
  padding-right: 0.2rem;
}

.conversation-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  background: #fff;
  cursor: pointer;
}

.conversation-row:hover {
  border-color: var(--brand);
}

.conversation-row.active {
  border-color: var(--brand);
  background: #ecfbf8;
}

.conversation-row.urgent {
  border-color: #ec9a83;
  background: var(--urgent-bg);
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.badge {
  border-radius: 999px;
  padding: 0.2rem 0.52rem;
  font-size: 0.72rem;
  border: 1px solid var(--line);
  background: #fff;
}

.badge.admin {
  color: #0d4f8a;
  border-color: #99bde0;
  background: #f0f7ff;
}

.badge.clinical {
  color: #6b4f00;
  border-color: #dec382;
  background: #fff9e8;
}

.badge.urgent {
  color: #7f1015;
  border-color: #e89a9f;
  background: #ffe8ea;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.topbar nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
}

.tab-btn.active {
  border-color: var(--brand);
  background: #ecfbf8;
}

.content {
  overflow: auto;
  padding: 1rem;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.chat-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0.9rem;
  min-height: calc(100vh - 160px);
}

.chat-card,
.panel-card,
.auth-card,
.family-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.chat-messages {
  height: 56vh;
  overflow: auto;
  padding: 1rem;
  display: grid;
  gap: 0.55rem;
}

.msg {
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  max-width: 88%;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: pre-wrap;
}

.msg.family {
  margin-left: auto;
  background: #f4f8ff;
  border-color: #c4d5ef;
}

.msg.pediatrician,
.msg.assistant {
  background: #ecfbf8;
  border-color: #9ed4ca;
}

.msg.system {
  background: #fff8e8;
  border-color: #e9d4a2;
}

.msg.system.urgent {
  background: #ffe9e6;
  border-color: #ebb5aa;
}

.msg-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.chat-compose {
  border-top: 1px solid var(--line);
  padding: 0.8rem;
  display: grid;
  gap: 0.55rem;
}

.chat-compose textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  resize: vertical;
}

.row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.panel-card {
  padding: 0.9rem;
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.panel-card h3,
.panel-card h4,
.chat-card h3,
.auth-card h2,
.family-card h2 {
  margin: 0;
}

.kv {
  display: grid;
  gap: 0.25rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.5rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  border: 1px solid #a3c4d8;
  background: #f0f7ff;
  border-radius: 999px;
  padding: 0.22rem 0.5rem;
  font-size: 0.72rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
}

.metric strong {
  display: block;
  font-size: 1.5rem;
  margin-top: 0.35rem;
}

.auth-wrap,
.family-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card,
.family-card {
  width: min(760px, 100%);
  padding: 1rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.auth-form,
.family-onboarding,
.family-chat {
  display: grid;
  gap: 0.6rem;
}

.family-chat {
  display: none;
}

.family-chat.active {
  display: grid;
}

.family-header {
  border: 1px solid #e4dcbc;
  background: linear-gradient(145deg, #fffbef, #fff2cf);
  border-radius: 14px;
  padding: 0.8rem;
}

.non-urgency-banner {
  border: 1px solid #ebbc99;
  color: #6e2f11;
  background: #fff0e7;
  border-radius: 12px;
  padding: 0.65rem;
  font-weight: 700;
}

.quick-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-actions .btn {
  border-radius: 10px;
}

.struct-form {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  display: none;
  gap: 0.45rem;
}

.struct-form.active {
  display: grid;
}

.notice {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid #f0d5a8;
  background: #fff8ea;
  color: #674100;
}

.notice.error {
  border-color: #e6a3a7;
  background: #ffe8ea;
  color: #79191f;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
}

.list-table th,
.list-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.45rem;
  vertical-align: top;
}

.pediatrician-ui {
  background: #f4f6f8;
}

.pediatrician-ui .sidebar,
.pediatrician-ui .topbar,
.pediatrician-ui .chat-card,
.pediatrician-ui .panel-card {
  background: #fff;
  backdrop-filter: none;
}

.pediatrician-ui .sidebar,
.pediatrician-ui .topbar {
  border-color: #dde3ea;
}

.pediatrician-ui .chat-card,
.pediatrician-ui .panel-card {
  border-color: #dde3ea;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.pediatrician-ui .btn {
  border-radius: 10px;
}

.pediatrician-ui .tab-btn {
  border-radius: 8px;
}

.pediatrician-ui .conversation-row {
  border-color: #dde3ea;
  border-radius: 10px;
  padding: 0.6rem;
}

.pediatrician-ui .conversation-row.active {
  background: #f2f8ff;
}

.pediatrician-ui .conversation-row.urgent {
  background: #fff2ef;
}

.pediatrician-ui .badge {
  background: #f8fafc;
  border-color: #dbe4ee;
  color: #334155;
}

.pediatrician-ui .badge.admin,
.pediatrician-ui .badge.clinical {
  background: #f8fafc;
  color: #334155;
  border-color: #dbe4ee;
}

.pediatrician-ui .badge.urgent {
  background: #fff1ee;
  border-color: #f5c4ba;
  color: #9f2c19;
}

.pediatrician-ui .chat-messages {
  background: #fbfcfd;
  border-top: 1px solid #eef2f6;
  border-bottom: 1px solid #eef2f6;
}

@media (max-width: 1060px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 720px) {
  .chat-messages {
    height: 46vh;
  }

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

.demo-wa-page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 211, 102, 0.12), transparent 38%),
    radial-gradient(circle at 85% 80%, rgba(7, 94, 84, 0.2), transparent 34%),
    linear-gradient(160deg, #e7efe9 0%, #dce9df 48%, #cddfd3 100%);
}

.demo-wa-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.demo-wa-actions {
  width: min(1180px, 100%);
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.9rem;
}

.demo-wa-split {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 420px));
  justify-content: center;
  gap: 1.5rem;
}

.phone-frame {
  position: relative;
  background: #1d1f23;
  border-radius: 36px;
  padding: 14px;
  box-shadow:
    0 18px 34px rgba(21, 35, 31, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.phone-notch {
  width: 42%;
  height: 24px;
  border-radius: 0 0 16px 16px;
  background: #15171a;
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.wa-screen {
  border-radius: 24px;
  overflow: hidden;
  height: 720px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #efeae2;
}

.wa-header {
  background: #075e54;
  color: #fff;
  padding: 2.1rem 1rem 0.8rem;
}

.wa-title,
.wa-subtitle {
  margin: 0;
}

.wa-title {
  font-weight: 700;
}

.wa-subtitle {
  opacity: 0.92;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.wa-chat {
  padding: 0.95rem 0.8rem;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.55rem;
  background:
    linear-gradient(rgba(239, 234, 226, 0.96), rgba(239, 234, 226, 0.96)),
    repeating-linear-gradient(
      45deg,
      rgba(18, 140, 126, 0.05) 0px,
      rgba(18, 140, 126, 0.05) 1px,
      transparent 1px,
      transparent 14px
    );
}

.wa-day {
  justify-self: center;
  font-size: 0.75rem;
  color: #5b6865;
  background: #d4ebe8;
  border: 1px solid #bcdeda;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

.wa-msg {
  max-width: 85%;
  border-radius: 10px;
  padding: 0.45rem 0.55rem 0.35rem;
  line-height: 1.35;
  font-size: 0.93rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.wa-msg span {
  display: block;
  text-align: right;
  font-size: 0.7rem;
  opacity: 0.76;
  margin-top: 0.2rem;
}

.wa-msg.incoming {
  justify-self: start;
  background: #fff;
}

.wa-msg.outgoing {
  justify-self: end;
  background: #d9fdd3;
}

.wa-msg.system {
  justify-self: center;
  max-width: 92%;
  background: #fff6d8;
  border: 1px solid #e2c98d;
  color: #5f470b;
}

.wa-compose {
  border-top: 1px solid #d9ddd3;
  background: #f0f2f5;
  padding: 0.65rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: center;
}

.wa-input {
  background: #fff;
  color: #25312d;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  border: 1px solid #d8dde1;
  width: 100%;
  min-width: 0;
}

.wa-input::placeholder {
  color: #8b8f92;
}

.wa-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #25d366;
  color: #fff;
  font-weight: 700;
  border: 0;
}

.wa-empty {
  margin: 0.3rem auto 0;
  width: fit-content;
  max-width: 92%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #d8ddd2;
  border-radius: 10px;
  color: #5f6967;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  text-align: center;
}

.wa-structured {
  display: none;
  gap: 0.4rem;
  padding: 0.65rem;
  border-top: 1px dashed #c7d2c6;
  background: #eef4ef;
}

.wa-structured.active {
  display: grid;
}

.wa-structured-title {
  margin: 0;
  font-size: 0.8rem;
  color: #4f5d58;
  font-weight: 600;
}

@media (max-width: 920px) {
  .demo-wa-split {
    grid-template-columns: 1fr;
  }

  .wa-screen {
    height: 620px;
  }
}
