/* Theme tokens converted 1:1 from the Claude Design prototype / iOS AppTheme */
:root {
  --teal: #004e4e;
  --gold: #ca9d33;
  --red: #cf4040;
  --green: #439458;

  --text-primary: #141c21;
  --text-secondary: #646a6e;
  --text-tertiary: #7b8186;
  --text-muted-40: #43494d;
  --text-muted-30: #292f32;

  --screen-bg: #f9f8f5;
  --card-border: #dfdeda;
  --input-border: #d9d7d3;
  --progress-track: #eae8e2;
  --segment-bg: #edebe5;

  --gold-card-text: #281e06;
  --qa-teal-icon-bg: #ddf0ef;
  --qa-gold-icon-bg: #f6eed8;
  --qa-gold-icon-fg: #7d5e07;

  --badge-overdue-bg: #ffe5e1;
  --badge-new-bg: #f6eed8;
  --badge-new-fg: #673e00;
  --badge-active-bg: #def1e1;

  --error-bg: #ffe8e4;
  --error-fg: #972527;

  --allergy-bg: rgba(255, 239, 230, 0.5);
  --allergy-border: #f1c1b1;
  --allergy-header: #8a3819;
  --allergy-body: #4e1c0a;

  --status-completed-bg: #def1e1;
  --status-inprogress-bg: #f6eed8;
  --status-inprogress-fg: #6e5000;
  --status-planned-bg: #edebe5;
  --status-planned-fg: #5e6468;

  --teal-card-sub: #d0e2e2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #eceae5;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--screen-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.06);
}

.screen {
  flex: 1;
  padding: 16px 20px 24px;
  padding-bottom: calc(24px + 68px + env(safe-area-inset-bottom));
}
.screen.no-tabbar {
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* ── Typography helpers ─────────────────────────────────────────── */

.screen-title { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.section-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.overline {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}

/* ── Header rows ────────────────────────────────────────────────── */

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

.add-btn {
  width: 34px; height: 34px;
  background: var(--teal);
  color: #fff;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ── Avatars ────────────────────────────────────────────────────── */

.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 13px;
  font-size: 15px; font-weight: 700;
  flex-shrink: 0;
}
.avatar.lg { width: 60px; height: 60px; border-radius: 16px; font-size: 19px; }

/* ── Cards ──────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
}

.card-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}
.card-row:active { background: #f4f3ef; }

.card-list { display: flex; flex-direction: column; gap: 8px; }

.item-title { font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
.item-sub { font-size: 12.5px; color: var(--text-secondary); }
.item-sub.sm { font-size: 12px; }

.empty-state {
  font-size: 13.5px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 26px 0;
}

/* ── Home ───────────────────────────────────────────────────────── */

.home-greeting { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.home-name { font-size: 24px; font-weight: 700; }

.stat-cards { display: flex; gap: 10px; margin: 8px 0 22px; }
.stat-card { flex: 1; border-radius: 16px; padding: 14px; }
.stat-card .stat-num { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { font-size: 12.5px; font-weight: 500; }
.stat-card.teal { background: var(--teal); }
.stat-card.teal .stat-num { color: #fff; }
.stat-card.teal .stat-label { color: var(--teal-card-sub); }
.stat-card.gold { background: var(--gold); }
.stat-card.gold .stat-num { color: var(--gold-card-text); }
.stat-card.gold .stat-label { color: #392c0c; font-weight: 600; }

.quick-actions { display: flex; gap: 10px; margin-bottom: 24px; }
.quick-action {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-primary);
}
.quick-action .qa-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700;
  flex-shrink: 0;
}

.see-all { font-size: 13px; font-weight: 600; color: var(--teal); }

.appt-time {
  font-size: 14px; font-weight: 700;
  color: var(--teal);
  width: 68px; flex-shrink: 0;
}
.appt-divider { width: 1px; align-self: stretch; background: var(--card-border); margin-right: 12px; }

/* ── Search + filter chips ──────────────────────────────────────── */

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 12px;
}
.search-box input {
  flex: 1;
  border: none; outline: none;
  font-size: 14.5px;
  color: var(--text-primary);
  background: transparent;
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-box svg { flex-shrink: 0; }

.filter-chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  font-size: 12.5px; font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
}
.chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }

.badge {
  font-size: 11px; font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ── Appointments (week strip) ──────────────────────────────────── */

.week-strip {
  display: flex; gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.week-strip::-webkit-scrollbar { display: none; }
.day-cell {
  flex-shrink: 0;
  width: 46px;
  padding: 8px 0;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--input-border);
  color: var(--text-muted-30);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.day-cell .dow { font-size: 10.5px; font-weight: 600; opacity: 0.75; }
.day-cell .dom { font-size: 16px; font-weight: 700; }
.day-cell .dot { width: 4px; height: 4px; border-radius: 999px; background: var(--teal); margin-top: 2px; }
.day-cell.selected { background: var(--teal); border-color: var(--teal); color: #fff; }
.day-cell.selected .dot { background: #fff; }

.date-label { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

/* ── Billing ────────────────────────────────────────────────────── */

.balance-card {
  background: var(--teal);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}
.balance-card .bal-label { font-size: 12.5px; font-weight: 500; color: var(--teal-card-sub); }
.balance-card .bal-amount { font-size: 28px; font-weight: 700; color: #fff; }

.amount-due { font-size: 14.5px; font-weight: 700; color: var(--red); }

/* ── Patient detail ─────────────────────────────────────────────── */

.back-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14.5px; font-weight: 600;
  color: var(--teal);
  margin-bottom: 14px;
}

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-name { font-size: 19px; font-weight: 700; }
.detail-sub { font-size: 13px; color: var(--text-secondary); }

.segment {
  display: flex; gap: 6px;
  background: var(--segment-bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.segment button {
  flex: 1;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
  border-radius: 9px;
}
.segment button.active {
  background: #fff;
  color: var(--teal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

.info-card-title {
  text-transform: uppercase;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.info-card-body { font-size: 13.5px; line-height: 1.55; color: var(--text-primary); white-space: pre-line; }

.allergy-card {
  background: var(--allergy-bg);
  border: 1px solid var(--allergy-border);
  border-radius: 14px;
  padding: 14px;
}
.allergy-card .info-card-title { color: var(--allergy-header); }
.allergy-card .info-card-body { color: var(--allergy-body); }

.status-pill {
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px;
  border-radius: 7px;
  white-space: nowrap;
}
.status-pill.completed { background: var(--status-completed-bg); color: var(--green); }
.status-pill.inprogress { background: var(--status-inprogress-bg); color: var(--status-inprogress-fg); }
.status-pill.planned { background: var(--status-planned-bg); color: var(--status-planned-fg); }

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--progress-track);
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill { height: 100%; border-radius: 3px; background: var(--teal); }
.progress-fill.completed { background: var(--green); }

.balance-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--teal);
  border-radius: 14px;
  padding: 14px;
}
.balance-row .bal-label { font-size: 12.5px; font-weight: 500; color: var(--teal-card-sub); }
.balance-row .bal-amount { font-size: 20px; font-weight: 700; color: #fff; }

.pay-btn {
  font-size: 11px; font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  white-space: nowrap;
}
.pay-btn.paid { background: var(--status-completed-bg); color: var(--green); }

.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-tile {
  aspect-ratio: 1;
  background: var(--progress-track);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted-40);
  text-align: center;
  padding: 8px;
}

/* ── Forms ──────────────────────────────────────────────────────── */

.form-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.form-header .cancel { font-size: 15px; color: var(--text-secondary); }
.form-header .form-title { font-size: 15px; font-weight: 700; }
.form-header .save { font-size: 15px; font-weight: 700; color: var(--teal); }
.form-header .save:disabled { opacity: 0.5; }

.error-banner {
  background: var(--error-bg);
  color: var(--error-fg);
  font-size: 13px; font-weight: 500;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.form-stack { display: flex; flex-direction: column; gap: 12px; padding-bottom: 32px; }
.form-cols { display: flex; gap: 10px; }
.form-cols > * { flex: 1; min-width: 0; }

.field label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--input-border);
  border-radius: 11px;
  padding: 11px 12px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); }
.field textarea { resize: vertical; min-height: 84px; }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23646a6e' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Tab bar ────────────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--card-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar[hidden] { display: none; }
.tabbar button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-tertiary);
}
.tabbar button.active { color: var(--teal); }
.tabbar svg { width: 22px; height: 22px; }

/* ── Login ──────────────────────────────────────────────────────── */

.login-screen {
  min-height: 80dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
}
.login-logo {
  width: 84px;
  height: 84px;
  background: var(--teal);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.login-logo svg { width: 46px; height: 46px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.login-sub { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 18px; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.login-btn {
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--teal);
  border-radius: 12px;
  padding: 13px 0;
}
.login-btn:disabled { opacity: 0.6; }

/* ── Loading / error ────────────────────────────────────────────── */

.center-fill {
  min-height: 60dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--progress-track);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.retry-btn {
  font-size: 13.5px; font-weight: 600;
  color: #fff;
  background: var(--teal);
  border-radius: 10px;
  padding: 10px 20px;
}
