/* TELEVITA member portal — design tokens from the brand book + homepage mockup.
   Palette is fixed: cream, bone, paper, sages, ink. Clay is reserved for
   validation/caution states only. Lora = display, Poppins = UI. */

:root {
  --cream: #F2EEE6;
  --bone: #E8E2D5;
  --paper: #FBFAF6;
  --sage: #8FA08A;
  --sage-light: #A9B6A2;
  --deep-sage: #4A574A;
  --deep-sage-hover: #3C473C;
  --stone: #B0A899;
  --ash: #9C9C95;
  --ink: #1F1F1D;
  --ink-soft: #33332F;
  --clay: #9C5F4E;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(31, 31, 29, 0.04), 0 8px 24px rgba(31, 31, 29, 0.06);
  --nav-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
}
.serif { font-family: 'Lora', serif; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: var(--ink); }
a { color: var(--deep-sage); }
svg { display: block; }
[hidden] { display: none !important; }

.app { max-width: 640px; margin: 0 auto; padding: 0 18px calc(var(--nav-h) + 28px); }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 2px 6px;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--cream) 78%, rgba(242, 238, 230, 0));
}
.topbar .brand-logo { height: 22px; width: auto; color: var(--ink); }
.topbar-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-soft);
  position: relative;
}
.topbar-btn:hover { background: var(--bone); }
.topbar-btn .dot {
  position: absolute; top: 7px; right: 7px; min-width: 16px; height: 16px;
  border-radius: 8px; background: var(--deep-sage); color: var(--paper);
  font-size: 10px; font-weight: 600; display: grid; place-items: center; padding: 0 4px;
}
.topbar .spacer { width: 40px; }

/* ---------- greeting ---------- */
.greet { padding: 18px 2px 4px; }
.greet .hello { font-size: 1.05rem; color: var(--ink-soft); }
.greet .name {
  font-family: 'Lora', serif; font-size: 2.1rem; font-weight: 500;
  color: var(--deep-sage); line-height: 1.15; margin-top: 2px;
}

/* ---------- cards ---------- */
.card {
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-top: 16px;
}
.card-title { font-size: 1.02rem; font-weight: 600; color: var(--ink); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.icon-circle {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--cream); display: grid; place-items: center; color: var(--deep-sage);
}

.row { display: flex; align-items: center; gap: 14px; }
.row + .row { margin-top: 14px; }
.row .meta { flex: 1; min-width: 0; }
.row .label { font-size: 0.78rem; color: var(--ash); }
.row .value { font-weight: 600; font-size: 1.02rem; color: var(--ink); }
.row .sub { font-size: 0.82rem; color: var(--ink-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 10px 20px; font-weight: 500; font-size: 0.9rem;
  transition: background .15s ease;
}
.btn-primary { background: var(--deep-sage); color: var(--paper); }
.btn-primary:hover { background: var(--deep-sage-hover); }
.btn-quiet { color: var(--deep-sage); background: var(--cream); }
.btn-quiet:hover { background: var(--bone); }
.btn[disabled] { opacity: .55; cursor: default; }

.divider { height: 1px; background: var(--bone); margin: 16px 0; }

.status-line { display: flex; align-items: center; gap: 10px; }
.status-line .check {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--deep-sage); color: var(--paper); display: grid; place-items: center;
}
.status-line .value { font-weight: 600; font-size: 0.95rem; }
.status-line .sub { font-size: 0.8rem; color: var(--ash); }

/* appointment ledger rows (Date | Overview | Time) */
.ledger { display: grid; grid-template-columns: 84px 1fr; row-gap: 14px; }
.ledger .lkey {
  font-size: 0.8rem; color: var(--ash);
  border-right: 2px solid var(--bone); margin-right: 16px; padding: 2px 0;
}
.ledger .lval { font-size: 0.92rem; color: var(--ink-soft); padding: 2px 0; }
.ledger .lval .big { font-weight: 600; font-size: 1.15rem; color: var(--ink); }
.ledger .lval .big .day { font-family: 'Lora', serif; }
.link-edit {
  display: inline-block; margin-top: 4px; font-size: 0.88rem; font-weight: 500;
  color: var(--ink); text-decoration: underline; text-underline-offset: 3px;
}

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: .02em;
  background: var(--cream); color: var(--deep-sage);
}
.chip.warn { background: #F3E9E5; color: var(--clay); }

.empty { text-align: center; padding: 26px 12px; color: var(--ink-soft); }
.empty .empty-icon { margin: 0 auto 10px; width: 44px; height: 44px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; color: var(--sage); }
.empty p { font-size: 0.9rem; max-width: 34ch; margin: 0 auto; }

.section-title { font-family: 'Lora', serif; font-size: 1.45rem; color: var(--ink); padding: 20px 2px 2px; }
.muted { color: var(--ash); font-size: 0.85rem; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--paper); border-top: 1px solid var(--bone);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav .inner {
  max-width: 640px; margin: 0 auto; height: var(--nav-h);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.navitem {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 0.68rem; color: var(--ash); position: relative;
}
.navitem.active { color: var(--deep-sage); font-weight: 600; }
.navitem .dot {
  position: absolute; top: 12px; right: calc(50% - 20px); min-width: 15px; height: 15px;
  border-radius: 8px; background: var(--deep-sage); color: var(--paper);
  font-size: 9px; font-weight: 600; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- auth ---------- */
.auth-wrap { max-width: 400px; margin: 0 auto; padding: 12vh 22px 40px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-logo .brand-logo { height: 26px; width: auto; color: var(--ink); }
.auth-sub { text-align: center; color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 30px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--bone); background: var(--paper); outline: none;
}
.field input:focus { border-color: var(--sage); }
.field input[aria-invalid="true"] { border-color: var(--clay); }
.auth-wrap .btn { width: 100%; padding: 13px 20px; }
.auth-links { text-align: center; margin-top: 18px; display: grid; gap: 10px; }
.auth-links button, .auth-links a { font-size: 0.86rem; color: var(--deep-sage); text-decoration: none; }
.auth-links button:hover, .auth-links a:hover { text-decoration: underline; }
.form-error { color: var(--clay); font-size: 0.85rem; margin: 4px 0 10px; min-height: 1em; }
.notice {
  background: var(--paper); border: 1px solid var(--bone); border-radius: 12px;
  padding: 14px 16px; font-size: 0.87rem; color: var(--ink-soft); margin-top: 16px;
}

/* ---------- messages ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 0.92rem; }
.bubble.patient { align-self: flex-end; background: var(--deep-sage); color: var(--paper); border-bottom-right-radius: 6px; }
.bubble.staff { align-self: flex-start; background: var(--paper); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.bubble .who { font-size: 0.7rem; opacity: .75; margin-bottom: 2px; }
.bubble .when { font-size: 0.66rem; opacity: .6; margin-top: 4px; text-align: right; }
.composer {
  position: fixed; bottom: var(--nav-h); left: 0; right: 0; z-index: 25;
  background: var(--cream); padding: 10px 18px calc(10px + env(safe-area-inset-bottom) * 0);
}
.composer .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--bone); background: var(--paper);
  border-radius: 22px; padding: 11px 16px; max-height: 120px; outline: none;
}
.composer textarea:focus { border-color: var(--sage); }
.composer .send {
  width: 44px; height: 44px; border-radius: 50%; flex: none; align-self: flex-end;
  background: var(--deep-sage); color: var(--paper); display: grid; place-items: center;
}
.page-messages .app { padding-bottom: calc(var(--nav-h) + 84px); }

/* ---------- profile ---------- */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 0.92rem; }
.kv dt { color: var(--ash); font-size: 0.8rem; padding-top: 2px; }
.kv dd { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 18px); z-index: 60;
  background: var(--ink); color: var(--paper); font-size: 0.85rem;
  border-radius: 999px; padding: 10px 20px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--clay); }

.loading { display: grid; place-items: center; padding: 60px 0; color: var(--ash); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--bone); border-top-color: var(--sage);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

@media (min-width: 700px) {
  .greet .name { font-size: 2.4rem; }
  .app { padding-top: 8px; }
}
