:root {
  --bg: #F6FAF8;
  --surface: #FFFFFF;
  --surface-alt: #FBFDFC;
  --ink: #10201D;
  --muted: #5F7369;
  --primary: #1E9A83; /* buttons, highlights, active states, charts */
  --primary-text: #147D6A; /* links & small text on white — kept darker than
                               --primary so it clears WCAG AA (4.5:1); the
                               lighter --primary would fail as text color */
  --primary-dark: #0B2E2A;
  --primary-tint: #E7F5F0;
  --accent: #C08A3E;
  --accent-tint: #FBF1E0;
  --danger: #C4453A;
  --danger-tint: #FBEAE8;
  --border: #E1EAE6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(11, 46, 42, 0.05);
  --shadow: 0 1px 2px rgba(11, 46, 42, 0.04), 0 10px 28px -14px rgba(11, 46, 42, 0.16);
  --shadow-lg: 0 24px 48px -16px rgba(11, 46, 42, 0.28);
  --font-heading: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--primary-dark);
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.08rem; margin-bottom: 1rem; }
h3 { font-size: 1rem; margin: 0 0 0.35rem; }

.mono { font-family: 'IBM Plex Mono', monospace; letter-spacing: -0.01em; }

a { color: var(--primary-text); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; }

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  background: linear-gradient(180deg, #0D332E 0%, #081F1C 100%);
  color: #EAF2F0;
  display: flex;
  flex-direction: column;
  padding: 1.7rem 1.15rem;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 2.4rem; padding: 0 0.3rem; }
.brand-mark-img { height: 32px; width: auto; display: block; flex-shrink: 0; }
.brand-name { font-family: var(--font-heading); font-weight: 700; font-size: 0.96rem; line-height: 1.2; letter-spacing: -0.005em; color: #fff; }

.nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-link {
  color: #A9C4BD;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: rgba(234, 242, 240, 0.07); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(30, 154, 131, 0.35); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(234, 242, 240, 0.08); }

.sidebar-footer { border-top: 1px solid rgba(234, 242, 240, 0.12); padding-top: 1.1rem; margin-top: 0.5rem; }
.user-chip { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.9rem; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(234, 242, 240, 0.15);
}
.user-name { font-size: 0.87rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.75rem; color: #8CAAA2; text-transform: capitalize; }
.signout { font-size: 0.82rem; color: #8CAAA2; display: block; margin-top: 0.45rem; transition: color 0.15s ease; }
.signout:first-of-type { margin-top: 0; }
.signout:hover { color: #fff; }

.main { flex: 1; padding: 2.6rem 3rem; max-width: 1140px; }

/* ---------- Flash messages ---------- */
.flash-stack { margin-bottom: 1.2rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash-stack-solo { max-width: 420px; margin: 1.5rem auto 0; }
.flash {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
}
.flash-success { background: var(--primary-tint); color: var(--primary-dark); }
.flash-error { background: var(--danger-tint); color: var(--danger); }

/* ---------- Billing reminder banner ---------- */
.billing-alert {
  padding: 0.75rem 1rem; border-radius: 10px; font-size: 0.88rem;
  margin-bottom: 1.2rem; line-height: 1.5;
}
.billing-alert strong { display: inline; margin-right: 0.3rem; }
.billing-alert-due_soon { background: var(--accent-tint); color: var(--accent); }
.billing-alert-overdue { background: var(--danger-tint); color: var(--danger); }

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1.6rem; gap: 1rem; flex-wrap: wrap;
}
.eyebrow {
  text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 600; margin: 0 0 0.3rem;
}
.header-actions { display: flex; gap: 0.6rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(11,46,42,0.08), 0 6px 14px -6px rgba(30,154,131,0.45); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 4px rgba(11,46,42,0.1), 0 10px 20px -8px rgba(30,154,131,0.5); }
.btn-secondary { background: var(--surface); color: var(--primary-dark); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); background: var(--primary-tint); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-alt); }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.link-danger {
  background: none; border: none; padding: 0; color: var(--danger);
  font-size: 0.83rem; cursor: pointer; font-family: inherit; text-decoration: underline;
}
.inline-form { display: inline; }

/* ---------- Stat cards ---------- */
.stat-row { display: flex; gap: 1rem; margin-bottom: 1.6rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; flex: 1; box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-value { display: block; font-family: var(--font-heading); font-weight: 700; font-size: 2rem; letter-spacing: -0.02em; color: var(--primary-dark); }
.stat-label { font-size: 0.85rem; color: var(--muted); }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.6rem 1.7rem; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.grid-detail { display: grid; grid-template-columns: 300px 1fr; gap: 1.2rem; align-items: start; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; padding: 0 0.6rem 0.6rem; border-bottom: 1px solid var(--border);
}
.table td { padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--primary-tint); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- Invoice line items (billing) ---------- */
.invoice-items-table { width: 100%; border-collapse: collapse; }
.invoice-items-table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; padding: 0 0.4rem 0.5rem; border-bottom: 1px solid var(--border);
}
.invoice-items-table td { padding: 0.35rem 0.4rem; vertical-align: top; }
.invoice-items-table input {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; font-family: inherit; box-sizing: border-box;
}
.invoice-items-table .qty-input { width: 4.5rem; }
.invoice-items-table .price-input { width: 6.5rem; }
.invoice-items-table .remove-row {
  padding: 0.4rem 0.6rem; font-size: 1rem; line-height: 1;
}

/* ---------- Mini list (dashboard) ---------- */
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.mini-list li { border-bottom: none; }
/* Scoped to direct-child anchors only (li > a) — the Today's Appointments
   widget nests its link one level deeper (li > div > a) with its own layout,
   so this card treatment doesn't collide with that row's status tag/actions. */
.mini-list > li > a {
  display: block; position: relative; color: var(--ink);
  padding: 0.85rem 2.3rem 0.85rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.mini-list > li > a::after {
  content: '\2192'; color: var(--muted); font-size: 1rem;
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  transition: transform 0.15s ease, color 0.15s ease;
}
.mini-list > li > a:hover {
  text-decoration: none; border-color: var(--primary); background: var(--primary-tint);
  box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.mini-list > li > a:hover::after { transform: translateY(-50%) translateX(3px); color: var(--primary-text); }
.mini-list-title { font-weight: 600; font-size: 0.9rem; display: block; }
.mini-list-sub { font-size: 0.85rem; color: var(--muted); display: block; margin-top: 0.2rem; }

/* ---------- Contact cards (Support page) ---------- */
.contact-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.contact-card {
  display: flex; align-items: flex-start; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.contact-card:hover {
  text-decoration: none; border-color: transparent; box-shadow: var(--shadow-lg); transform: translateY(-2px);
}
.contact-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff;
}
.contact-icon-facebook { background: #1877F2; }
.contact-icon-whatsapp { background: #25D366; }
.contact-card-body { min-width: 0; }
.contact-card-title { font-weight: 700; font-size: 0.98rem; color: var(--ink); display: flex; align-items: center; gap: 0.4rem; }
.contact-card-sub {
  font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-card-arrow { margin-left: auto; color: var(--muted); font-size: 1.1rem; align-self: center; transition: transform 0.15s ease, color 0.15s ease; }
.contact-card:hover .contact-card-arrow { transform: translateX(3px); color: var(--primary-text); }

/* The Support page's logged-out view embeds these cards inside the narrow
   (~480px) auth panel, not the wide main content column — always stack them
   there regardless of viewport width, or a long URL squeezed into half of
   480px wraps letter-by-letter. */
.auth-panel .contact-card-grid { grid-template-columns: 1fr; }

@media (max-width: 860px) {
  .contact-card-grid { grid-template-columns: 1fr; }
}

.empty { color: var(--muted); font-size: 0.9rem; padding: 0.5rem 0; }

/* ---------- Search bar ---------- */
.search-bar { display: flex; gap: 0.6rem; margin-bottom: 1.2rem; }
.search-bar input {
  flex: 1; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 0.9rem; background: var(--surface);
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.2rem; }
.form-grid label {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.82rem; font-weight: 600; color: var(--muted);
}
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 7px;
  font-family: inherit; font-size: 0.92rem; color: var(--ink); background: var(--surface);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.search-bar input:focus, .auth-form input:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }

/* ---------- Patient detail ---------- */
.detail-list { display: flex; flex-direction: column; gap: 0.7rem; margin: 0 0 1.3rem; }
.detail-list div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--border); padding-bottom: 0.5rem; }
.detail-list dt { color: var(--muted); font-size: 0.85rem; }
.detail-list dd { margin: 0; font-weight: 500; text-align: right; }
.detail-alert dd { color: var(--danger); }

/* ---------- Timeline (signature element) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-left: 1.8rem; padding-bottom: 1.6rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
  position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--primary);
}
.timeline-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; }
.timeline-date { font-family: 'IBM Plex Mono', monospace; font-size: 0.78rem; color: var(--muted); }
.tag {
  background: var(--accent-tint); color: var(--accent); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0.15rem 0.5rem; border-radius: 5px;
}
.tag.pay-status-paid { background: var(--primary-tint); color: var(--primary-dark); }
.tag.pay-status-pending { background: var(--accent-tint); color: var(--accent); }
.tag.pay-status-overdue { background: var(--danger-tint); color: var(--danger); }

/* ---------- Help guide ---------- */
.help-toc { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin: 0 0 1.6rem; padding: 0; list-style: none; }
.help-toc a { font-size: 0.85rem; font-weight: 600; }
.help-section { margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid var(--border); }
.help-section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.help-subsection { margin-top: 1.2rem; }
.help-subsection h3 { margin: 0 0 0.4rem; }
.help-callout {
  padding: 0.65rem 0.9rem; border-radius: 8px; font-size: 0.88rem; line-height: 1.5;
  margin: 0.6rem 0 1rem; border-left: 3px solid var(--primary); background: var(--primary-tint);
}
.help-callout.help-callout-tip { border-left-color: var(--accent); background: var(--accent-tint); }
.ui-label {
  display: inline-block; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.05rem 0.4rem; font-size: 0.85em; font-weight: 600; color: var(--primary-dark);
}
.help-code {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; line-height: 1.7;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 0.9rem; margin: 0.5rem 0 1rem; overflow-x: auto; white-space: pre;
  color: var(--primary-dark);
}

/* ---------- Analytics ---------- */
.analytics-controls { display: flex; gap: 0.5rem; margin-bottom: 1.4rem; }
.analytics-group-heading {
  font-size: 1.3rem; font-weight: 700; color: var(--primary-dark);
  margin: 0 0 1rem; padding-top: 1.8rem; border-top: 1px solid var(--border);
}
.analytics-group-heading:first-of-type { padding-top: 0; border-top: none; }
.analytics-section { margin-top: 1.6rem; }
.analytics-section:first-of-type { margin-top: 0; }
.analytics-section h2 { margin-bottom: 0.9rem; }
.chart-wrap { position: relative; height: 260px; margin: 0.6rem 0 1.2rem; }
.chart-wrap.chart-wrap-sm { height: 200px; }
.analytics-note { font-size: 0.85rem; color: var(--muted); margin: -0.4rem 0 1rem; }
.timeline-body p { margin: 0.25rem 0; font-size: 0.88rem; }
.timeline-notes { color: var(--muted); font-style: italic; }
.timeline-meta { display: flex; gap: 0.9rem; margin-top: 0.5rem; font-size: 0.85rem; color: var(--muted); align-items: center; }

/* ---------- Auth screen ---------- */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 2.4rem 2.2rem; width: 340px; box-shadow: var(--shadow); text-align: center;
}
.auth-mark {
  width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem;
  font-family: var(--font-heading); font-weight: 700; font-size: 1.4rem;
}
.auth-mark-img { height: 56px; width: auto; display: block; margin: 0 auto 1rem; }
.auth-panel h1 { font-size: 1.5rem; }
.auth-sub { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0 1.6rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; }
.auth-form label { font-size: 0.82rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 0.35rem; }
.auth-form input { padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; font-size: 0.92rem; }
.auth-form .btn { margin-top: 0.4rem; }
.auth-hint { font-size: 0.75rem; color: var(--muted); margin-top: 1.2rem; line-height: 1.5; }
.auth-hint code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 0.8rem 1rem; }
  .brand { margin-bottom: 0; }
  .nav { flex-direction: row; flex: 1; justify-content: center; }
  .sidebar-footer { display: none; }
  .main { padding: 1.4rem; }
  .grid-2, .grid-detail, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Odontogram (dental chart) ---------- */
.odontogram-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.8rem; margin-bottom: 0.8rem;
}
.odontogram-legend-groups { display: flex; flex-wrap: wrap; gap: 1.6rem; margin-bottom: 0.8rem; }
.odontogram-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; }
.legend-title {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; margin-right: 0.2rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.legend-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.odontogram-hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 1.2rem; max-width: 640px; }

.tooth-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.odontogram-arch-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 600; margin: 0.6rem 0 0.4rem;
}
.odontogram-arch-label:first-child { margin-top: 0; }

.tooth {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  user-select: none; width: 40px;
}
.tooth-svg { width: 32px; height: 40px; transition: transform 0.1s ease; overflow: visible; }
.tooth:hover .tooth-svg { transform: translateY(-3px); }

.tooth-surface {
  fill: #FFFFFF; stroke: var(--border); stroke-width: 0.75;
  cursor: pointer; transition: fill 0.15s ease;
}
.tooth-surface:hover { stroke: var(--primary); stroke-width: 1.25; }

.tooth-root {
  fill: #FFFFFF; stroke: var(--border); stroke-width: 1.5;
  cursor: pointer; transition: stroke 0.15s ease;
}
.tooth-root:hover { stroke: var(--primary); }

.tooth-crown-outline {
  fill: none; stroke: var(--border); stroke-width: 1.5; pointer-events: none;
}
.tooth-whole-marked .tooth-crown-outline { stroke: var(--ink); stroke-width: 2; }

.tooth-whole-overlay {
  fill: none; opacity: 0; pointer-events: none;
  transition: fill 0.15s ease, opacity 0.15s ease;
}

.tooth-num {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem; color: var(--muted);
}

.odontogram-editor {
  display: none; margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
  max-width: 480px;
}
.odontogram-editor.open { display: block; }
.odontogram-editor-title { margin-bottom: 0.15rem; }
.odontogram-editor-surface { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.8rem; font-weight: 600; }
.odontogram-conditions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.odontogram-conditions button {
  padding: 0.4rem 0.7rem; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); font-size: 0.8rem; font-weight: 600; color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.odontogram-conditions button.active { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-tint); }
.odontogram-editor textarea {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 7px;
  font-family: inherit; font-size: 0.88rem; resize: vertical; margin-bottom: 0.8rem;
}
.odontogram-editor-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

@media (max-width: 860px) {
  .tooth { width: 30px; }
  .tooth-svg { width: 24px; height: 32px; }
  .tooth-num { font-size: 0.6rem; }
}

/* ---------- Appointment booking (public page) ---------- */
.booking-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 2.5rem 1rem; }
.booking-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 2.2rem 2rem; width: 100%; max-width: 560px; box-shadow: var(--shadow);
}
.booking-sub { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 1.4rem; }

.booking-existing-banner {
  background: var(--primary-tint); color: var(--primary-dark); padding: 0.7rem 0.9rem;
  border-radius: 8px; font-size: 0.88rem; margin-bottom: 1.2rem;
}

/* ---------- Appointments (staff queue) ---------- */
.appointment-filters { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; }
.appointment-actions { display: flex; gap: 0.7rem; }
.link-confirm {
  background: none; border: none; padding: 0; color: var(--primary-text);
  font-size: 0.83rem; cursor: pointer; font-family: inherit; text-decoration: underline;
}
.appt-status-pending { background: var(--accent-tint); color: var(--accent); }
.appt-status-confirmed { background: var(--primary-tint); color: var(--primary-dark); }
.appt-status-cancelled { background: var(--danger-tint); color: var(--danger); }

/* ---------- Appointments (weekly calendar) ---------- */
.view-toggle { display: flex; gap: 0.5rem; margin-left: auto; }

.calendar-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; flex-wrap: wrap; gap: 0.6rem;
}
.calendar-range { margin: 0; }
.calendar-nav { display: flex; gap: 0.4rem; }

.calendar-grid-wrap { overflow-x: auto; }
.calendar-grid {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(104px, 1fr));
  min-width: 660px;
}

.calendar-corner { border-bottom: 1px solid var(--border); }
.calendar-day-head {
  text-align: center; padding: 0.4rem 0 0.6rem; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.15rem;
}
.calendar-day-head.is-today .calendar-day-num { color: var(--primary-text); font-weight: 700; }
.calendar-day-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.calendar-day-num { font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; color: var(--ink); }

.calendar-unscheduled-label {
  font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; display: flex; align-items: center;
  justify-content: flex-end; padding-right: 6px; border-bottom: 1px solid var(--border);
}
.calendar-unscheduled-cell {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0.35rem;
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--border);
  min-height: 1.6rem;
}
.calendar-chip {
  display: block; width: 100%; font-size: 0.74rem; padding: 0.15rem 0.4rem; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  appearance: none; -webkit-appearance: none; border: none; text-align: left;
  font-family: inherit; cursor: pointer;
}
.calendar-chip:hover { filter: brightness(0.97); }

.calendar-time-axis, .calendar-day-col { position: relative; height: 37rem; }
.calendar-day-col { border-left: 1px solid var(--border); }
.calendar-hour-label {
  position: absolute; left: 0; right: 6px; transform: translateY(-50%);
  font-size: 0.72rem; color: var(--muted); text-align: right;
}
.calendar-hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }

.appt-block {
  position: absolute; left: 3px; right: 3px; min-height: 32px; overflow: hidden;
  border-radius: 6px; border-left: 3px solid currentColor; padding: 2px 6px;
  font-size: 0.7rem; line-height: 1.15; display: flex; flex-direction: column;
  justify-content: center; color: inherit; box-shadow: var(--shadow);
  appearance: none; -webkit-appearance: none; border-top: none; border-right: none;
  border-bottom: none; text-align: left; font-family: inherit; cursor: pointer;
}
.appt-block:hover { filter: brightness(0.97); text-decoration: none; }
.appt-block-time { font-weight: 600; font-size: 0.68rem; }
.appt-block-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-block-clinic { font-size: 0.65rem; opacity: 0.8; }

.calendar-popover-backdrop { position: fixed; inset: 0; background: transparent; z-index: 40; }
.calendar-popover {
  position: absolute; z-index: 41; width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.9rem 1rem;
}
.calendar-popover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.3rem; }
.calendar-popover-time { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.calendar-popover-close {
  background: none; border: none; padding: 0; color: var(--muted); font-size: 1.2rem;
  line-height: 1; cursor: pointer;
}
.calendar-popover-close:hover { color: var(--ink); }
.calendar-popover h3 { margin: 0 0 0.15rem; }
.calendar-popover-meta { margin: 0 0 0.2rem; font-size: 0.85rem; color: var(--muted); }
.calendar-popover-reason { margin: 0.3rem 0; font-size: 0.85rem; }
.calendar-popover-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.calendar-popover-actions .btn { padding: 0.4rem 0.75rem; font-size: 0.82rem; }

/* ---------- Dashboard: today's appointments ---------- */
.todays-appt-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.6rem 0.2rem;
}
.todays-appt-row .todays-appt-link {
  flex: 1; min-width: 0; padding: 0; display: flex !important; flex-direction: column;
}
.todays-appt-time { font-size: 0.78rem; color: var(--primary-text); font-weight: 700; }
.todays-appt-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

/* ---------- Freehand chart notes ---------- */
.freehand-toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.freehand-colors { display: flex; gap: 0.4rem; margin-right: 0.4rem; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--border);
}
.color-swatch.active { border-color: var(--surface); box-shadow: 0 0 0 2px var(--primary); }
#freehand-erase.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.freehand-canvas-wrap { position: relative; touch-action: none; }
.freehand-canvas-wrap canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.freehand-canvas-wrap.editing canvas { pointer-events: auto; cursor: crosshair; }

/* Reuse the interactive tooth shapes as a plain, non-clickable outline background */
.freehand-bg-image {
  display: block; width: 100%; height: auto; user-select: none; pointer-events: none;
  border-radius: 8px;
}
.chart-attribution {
  font-size: 0.75rem; color: var(--muted); margin-top: 0.6rem;
}

/* ---------- Freehand chart accordion (adult / pediatric) ---------- */
.freehand-accordion-summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; color: var(--primary-dark);
}
.freehand-accordion-summary::-webkit-details-marker { display: none; }
.freehand-accordion-summary::marker { content: ""; }
.freehand-accordion-summary:hover { color: var(--primary-text); }
.accordion-chevron {
  color: var(--muted); font-size: 0.75rem; transition: transform 0.15s ease; flex-shrink: 0; margin-left: 0.8rem;
}
.freehand-accordion[open] .accordion-chevron { transform: rotate(180deg); }
.freehand-accordion-body { margin-top: 1rem; }
.chart-attribution a { color: var(--muted); text-decoration: underline; }

/* ---------- Patient intake form ---------- */
.intake-panel { max-width: 720px; text-align: left; }
.intake-panel .booking-form { text-align: left; }
.intake-section-title {
  margin: 1.8rem 0 0.9rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.intake-panel form > .intake-section-title:first-of-type,
.intake-section-title:first-child { margin-top: 0.6rem; padding-top: 0; border-top: none; }
.intake-subhead {
  font-weight: 700; font-size: 0.92rem; color: var(--primary-dark);
  margin: 1.2rem 0 0.6rem;
}
.intake-checkbox-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem 1rem; margin-bottom: 0.6rem;
}
.intake-checkbox-grid-3col { grid-template-columns: repeat(3, 1fr); }
.checkbox-item {
  display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--ink);
  font-weight: 400; cursor: pointer;
}
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.inline-text-input {
  flex: 1; padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 5px;
  font-family: inherit; font-size: 0.82rem; margin-left: 0.3rem;
}

.signature-pad-wrap {
  border: 1px dashed var(--border); border-radius: 8px; background: #FAFBFA;
  height: 160px; position: relative; touch-action: none; margin-bottom: 0.6rem;
}
.signature-pad-wrap canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: crosshair; }
.signature-actions { display: flex; justify-content: flex-end; margin-bottom: 0.4rem; }

@media (max-width: 860px) {
  .intake-checkbox-grid, .intake-checkbox-grid-3col { grid-template-columns: 1fr; }
}

/* ---------- Multi-tenant clinic context ---------- */
.clinic-context {
  font-size: 0.72rem; color: #9FBAB5; margin: -0.15rem 0 1.5rem 0.3rem;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}

.clinic-badge {
  display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700; color: var(--primary-dark); background: var(--primary-tint);
  padding: 0.15rem 0.55rem; border-radius: 5px;
}

.reset-form { display: flex; gap: 0.6rem; align-items: center; padding: 0.5rem 0; }
.reset-form input { flex: 1; max-width: 280px; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; }

/* ---------- Document upload ---------- */
.upload-form {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.upload-form input[type="file"] {
  flex: 1; min-width: 200px; font-size: 0.85rem; color: var(--muted);
  padding: 0.4rem 0; font-family: inherit;
}

/* ---------- Consent modals ---------- */
.consent-checkbox-row { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.7rem; font-size: 0.88rem; flex-wrap: wrap; }
.consent-checkbox-row .checkbox-item { margin: 0; }
.consent-link { color: var(--primary-text); font-weight: 600; }
.consent-modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(28, 38, 36, 0.55);
  z-index: 1000; align-items: center; justify-content: center; padding: 1.5rem;
}
.consent-modal-overlay.open { display: flex; }
.consent-modal {
  background: var(--surface); border-radius: 12px; max-width: 640px; width: 100%;
  max-height: 85vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.consent-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.consent-modal-header h3 { margin: 0; font-family: var(--font-heading); font-weight: 700; color: var(--primary-dark); }
.consent-modal-close {
  background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted);
  padding: 0 0.3rem;
}
.consent-modal-close:hover { color: var(--ink); }
.consent-modal-body { padding: 1.1rem 1.3rem; overflow-y: auto; font-size: 0.86rem; color: var(--ink); line-height: 1.5; }
.consent-modal-body h4 { font-size: 0.92rem; margin: 1rem 0 0.3rem; color: var(--primary-dark); }
.consent-modal-body h4:first-child { margin-top: 0; }
.consent-modal-body p { margin: 0.3rem 0; }
.consent-modal-body ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.consent-modal-body li { margin-bottom: 0.3rem; }
