:root {
  --ink: #1C2B2A;
  --ink-soft: #4B5C5A;
  --paper: #FAF7F1;
  --paper-raised: #FFFFFF;
  --line: #E4DFD3;
  --blue-900: #0A2E5C;
  --blue-700: #0F62C4;
  --blue-500: #2E86EE;
  --blue-100: #E4EFFC;
  --clay: #C96A4A;
  --clay-100: #FBEAE3;
  --amber: #D6A24C;
  --danger: #C0503C;
  --shadow-sm: 0 1px 2px rgba(10, 46, 92, 0.05);
  --shadow-md: 0 10px 28px rgba(10, 46, 92, 0.09);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22220%22%20height%3D%22220%22%20viewBox%3D%220%200%20220%20220%22%3E%0A%3Cg%20fill%3D%22none%22%20stroke%3D%22%230A2E5C%22%20stroke-width%3D%222.2%22%20opacity%3D%220.05%22%3E%0A%20%20%3Cpath%20d%3D%22M40%2020%20h14%20v14%20h14%20v14%20h-14%20v14%20h-14%20v-14%20h-14%20v-14%20h14%20z%22%20/%3E%0A%20%20%3Cpath%20d%3D%22M110%20150%20h18%20l8%20-22%20l12%2040%20l10%20-55%20l9%2037%20h33%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20/%3E%0A%20%20%3Cpath%20d%3D%22M175%2040%20h10%20v10%20h10%20v10%20h-10%20v10%20h-10%20v-10%20h-10%20v-10%20h10%20z%22%20/%3E%0A%20%20%3Ccircle%20cx%3D%2245%22%20cy%3D%22180%22%20r%3D%229%22%20/%3E%0A%20%20%3Cpath%20d%3D%22M45%20171%20v-25%20q0%20-14%2014%20-14%20h6%22%20stroke-linecap%3D%22round%22%20/%3E%0A%3C/g%3E%0A%3C/svg%3E");
  background-repeat: repeat;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand-name { font-family: 'Poppins', 'Inter', sans-serif; }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ AUTH SCREEN ============ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0074E4 0%, #0B5FCB 35%, #0A3D8F 70%, #062559 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  background: var(--blue-700);
  color: white;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.auth-logo.small { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; margin: 0; }
.auth-brand h1 { margin: 0 0 6px; font-size: 24px; color: var(--blue-900); }
.auth-brand p { margin: 0; color: var(--ink-soft); font-size: 14px; }

.auth-tabs {
  display: flex;
  background: var(--blue-100);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-700);
  border-radius: 8px;
  transition: background .15s;
}
.auth-tab.active { background: var(--paper-raised); box-shadow: var(--shadow-sm); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.auth-form input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus, select:focus, textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.auth-note { font-size: 12px; color: var(--ink-soft); text-align: center; margin: 2px 0 0; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }

/* ============ TERMS CHECKBOX & LEGAL LINKS ============ */
.checkbox-label {
  display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 8px;
  font-size: 12px !important; font-weight: 500 !important; color: var(--ink-soft) !important; line-height: 1.5;
}
.checkbox-label input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--blue-700); }
.checkbox-label a { color: var(--blue-700); font-weight: 600; text-decoration: underline; }
.auth-legal-footer { text-align: center; font-size: 11px; color: var(--ink-soft); margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.auth-legal-footer a { color: var(--ink-soft); text-decoration: underline; }
.auth-legal-footer a:hover { color: var(--blue-700); }

.legal-doc-body { max-height: 60vh; overflow-y: auto; padding-right: 6px; }
.legal-picker-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.legal-picker-item {
  text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink);
}
.legal-picker-item:hover { border-color: var(--blue-500); background: var(--blue-100); }

/* ============ ACCOUNT TYPE TOGGLE ============ */
.account-type-toggle { display: flex; gap: 10px; margin-bottom: 4px; }
.account-type-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 10px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--paper); font-family: inherit; font-weight: 600; font-size: 13px; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.account-type-btn.active { border-color: var(--blue-500); background: var(--blue-100); color: var(--blue-900); }
.account-type-icon { font-size: 20px; }
.account-type-hint { font-size: 10.5px; font-weight: 500; color: var(--ink-soft); }
.optional-tag { font-weight: 400; color: var(--ink-soft); font-size: 11.5px; }

/* ============ PASSWORD VISIBILITY TOGGLE ============ */
.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 40px !important; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 16px; padding: 6px 8px;
  border-radius: 8px; opacity: .55; line-height: 1;
}
.password-toggle:hover { opacity: 1; background: var(--blue-100); }

.btn {
  border: none; border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px; font-weight: 600;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn-primary { background: var(--blue-700); color: white; }
.btn-primary:hover { background: var(--blue-900); }
.btn-secondary { background: var(--blue-100); color: var(--blue-900); }
.btn-secondary:hover { background: #d3ebe4; }
.btn-danger { background: var(--clay-100); color: var(--danger); }
.btn-danger:hover { background: #f6dcd1; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:active { transform: scale(0.98); }

/* ============ APP SHELL ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  background: linear-gradient(160deg, #0B5FCB 0%, #0A3D8F 55%, #062559 100%);
  color: #EAF3F0;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 26px; }
.brand-name { font-weight: 700; font-size: 16px; color: white; }
.brand-clinic { font-size: 11.5px; color: #9FC6BC; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  color: #C9E3DC;
  transition: background .15s, color .15s;
}
.nav-icon { font-size: 16px; width: 18px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-link.active { background: var(--blue-500); color: white; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 10px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue-500); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #9FC6BC; text-transform: capitalize; }
.icon-btn {
  background: none; border: none; color: #9FC6BC; font-size: 16px;
  padding: 6px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: white; }

.mobile-menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 60;
  width: 40px; height: 40px;
  background: var(--blue-900); color: white;
  border: none; border-radius: 10px; font-size: 18px;
  box-shadow: var(--shadow-md);
}

.main-content { flex: 1; padding: 32px 40px; max-width: 1180px; }

/* ============ SHARED UI ============ */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h2 { margin: 0 0 4px; font-size: 24px; color: var(--blue-900); }
.page-header p { margin: 0; color: var(--ink-soft); font-size: 14px; }

.card {
  background: var(--paper-raised);
  border: 1px solid rgba(228, 223, 211, 0.7);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-value { font-family: 'Poppins'; font-size: 30px; font-weight: 700; color: var(--blue-700); }
.stat-label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

.section-title { font-size: 15px; font-weight: 700; color: var(--blue-900); margin: 0 0 14px; }

.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 6px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }

.search-bar {
  display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap;
}
.search-bar input[type="text"] {
  flex: 1; min-width: 200px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: var(--paper-raised);
}
.search-bar input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }

.patient-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
  background: var(--paper-raised);
  transition: border-color .15s, box-shadow .15s;
}
.patient-card:hover { border-color: var(--blue-500); box-shadow: var(--shadow-sm); }
.patient-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--blue-100); color: var(--blue-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.patient-meta { flex: 1; min-width: 0; }
.patient-name { font-weight: 600; font-size: 15px; }
.patient-sub { font-size: 12.5px; color: var(--ink-soft); }

.empty-state {
  text-align: center; padding: 50px 20px; color: var(--ink-soft);
}
.empty-state .empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .5; }

/* Tag / badge */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600;
}
.badge-teal { background: var(--blue-100); color: var(--blue-700); }
.badge-clay { background: var(--clay-100); color: var(--clay); }
.badge-amber { background: #FBF0DC; color: #9C7523; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(14,61,54,0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--paper-raised);
  border-radius: 18px;
  width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
  padding: 26px 28px 24px;
  box-shadow: var(--shadow-md);
}
.modal h3 { margin: 0 0 4px; font-size: 19px; color: var(--blue-900); }
.modal .modal-sub { margin: 0 0 18px; font-size: 13px; color: var(--ink-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

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

/* ============ PATIENT DETAIL ============ */
.detail-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.detail-avatar {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--blue-700); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
}
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px 22px; }
.info-item .info-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 600; margin-bottom: 3px; }
.info-item .info-value { font-size: 14.5px; font-weight: 500; }

.record-entry {
  border-left: 3px solid var(--blue-500);
  padding: 4px 0 18px 18px;
  margin-left: 4px;
  position: relative;
}
.record-entry::before {
  content: ''; position: absolute; left: -7px; top: 6px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--blue-500); border: 2px solid var(--paper-raised);
}
.record-date { font-size: 12.5px; color: var(--blue-700); font-weight: 700; margin-bottom: 3px; }
.record-reason { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.record-body { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; }
.record-body strong { color: var(--ink); }
.record-vitals { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.vital-chip { font-size: 12px; background: var(--paper); border: 1px solid var(--line); padding: 4px 10px; border-radius: 100px; color: var(--ink-soft); }
.record-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ============ CALENDAR ============ */
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.calendar-nav { display: flex; align-items: center; gap: 10px; }
.calendar-title { font-family: 'Poppins'; font-weight: 700; font-size: 17px; color: var(--blue-900); min-width: 180px; text-align: center; text-transform: capitalize; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-dow { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); text-align: center; padding-bottom: 6px; text-transform: uppercase; }
.calendar-day {
  min-height: 96px; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; background: var(--paper-raised); cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s;
}
.calendar-day:hover { border-color: var(--blue-500); }
.calendar-day.other-month { opacity: .35; }
.calendar-day.today { border-color: var(--blue-700); box-shadow: inset 0 0 0 1px var(--blue-700); }
.day-number { font-size: 12.5px; font-weight: 700; }
.day-appt { font-size: 10.5px; background: var(--blue-100); color: var(--blue-700); padding: 2px 6px; border-radius: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-appt.more { background: transparent; color: var(--ink-soft); font-weight: 600; }

.agenda-list { margin-top: 26px; }
.appt-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.appt-time { font-weight: 700; color: var(--blue-700); font-size: 13.5px; width: 92px; flex-shrink: 0; }
.appt-info { flex: 1; }
.appt-title { font-weight: 600; font-size: 14px; }
.appt-sub { font-size: 12.5px; color: var(--ink-soft); }

/* ============ TOAST ============ */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--blue-900); color: white;
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ SOAP FORM ============ */
.soap-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.soap-section:first-of-type { margin-top: 14px; }
.soap-label {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
  font-size: 13.5px; font-weight: 700; color: var(--blue-900);
}
.soap-hint { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); }
.soap-tag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--blue-700); color: white; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.plan-sublabel { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .02em; }
.soap-section textarea, .soap-section input[type="text"] {
  width: 100%; font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.soap-section textarea:focus, .soap-section input:focus {
  outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100);
}

.med-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.med-row-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.med-row-fields input, .med-row-fields textarea {
  width: 100%; font-family: inherit; font-size: 13.5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper); resize: vertical;
}
.med-row-fields input:focus, .med-row-fields textarea:focus {
  outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100);
}
.med-remove-btn {
  background: var(--clay-100); color: var(--danger); border: none; border-radius: 8px;
  width: 32px; height: 32px; flex-shrink: 0; font-size: 13px; margin-top: 2px;
}
.med-remove-btn:hover { background: #f6dcd1; }
@media (max-width: 640px) { .med-row-fields { grid-template-columns: 1fr; } }

/* SOAP display in the timeline */
.soap-line { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.soap-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0; margin-top: 1px;
  background: var(--blue-100); color: var(--blue-700); font-size: 11px; font-weight: 700;
}
.soap-chip.soap-chip-wide { width: auto; padding: 0 6px; font-size: 9.5px; }
.med-list { margin: 0; padding-left: 18px; }
.med-list li { margin-bottom: 6px; }
.med-instructions { color: var(--ink-soft); font-size: 13px; }

/* ============ EDI (Evaluación del Desarrollo Infantil) ============ */
.edi-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.edi-btn {
  flex: 1; min-width: 140px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--paper); font-family: inherit; font-weight: 600; font-size: 13px; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.edi-btn span { font-weight: 400; font-size: 11px; color: var(--ink-soft); }
.edi-btn.edi-verde.active { border-color: #2E8B57; background: #E7F5EC; }
.edi-btn.edi-amarillo.active { border-color: #D6A24C; background: #FBF0DC; }
.edi-btn.edi-rojo.active { border-color: var(--danger); background: var(--clay-100); }
.edi-result-badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 100px; display: inline-flex; align-items: center; gap: 4px; }
.edi-result-badge.verde { background: #E7F5EC; color: #1E6B41; }
.edi-result-badge.amarillo { background: #FBF0DC; color: #9C7523; }
.edi-result-badge.rojo { background: var(--clay-100); color: var(--danger); }

/* ============ PEDIATRIC GROWTH PERCENTILES ============ */
.growth-card { margin-bottom: 22px; }
.growth-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; flex-wrap: wrap; gap: 8px; }
.growth-subtitle { font-size: 12px; color: var(--ink-soft); margin: 0 0 16px; }
.growth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.growth-metric {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: var(--paper);
}
.growth-metric-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.growth-metric-value { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.growth-percentile { font-family: 'Poppins'; font-size: 26px; font-weight: 700; color: var(--blue-700); }
.growth-raw { font-size: 12.5px; color: var(--ink-soft); }
.growth-bar-track { height: 6px; border-radius: 100px; background: var(--line); overflow: hidden; margin-bottom: 8px; }
.growth-bar-fill { height: 100%; border-radius: 100px; background: var(--blue-500); }
.growth-status { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 100px; display: inline-block; }
.growth-status.ok { background: var(--blue-100); color: var(--blue-700); }
.growth-status.warn { background: #FBF0DC; color: #9C7523; }
.growth-status.danger { background: var(--clay-100); color: var(--danger); }
.growth-history { margin-top: 4px; }
.growth-history-row {
  display: grid; grid-template-columns: 90px 1fr 1fr 1fr; gap: 8px;
  padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 12px;
}
.growth-history-row:last-child { border-bottom: none; }
.growth-history-row.head { font-weight: 700; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.growth-note { font-size: 11.5px; color: var(--ink-soft); margin-top: 10px; line-height: 1.5; }
.growth-charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 18px 0; }
.growth-chart-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--paper); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.growth-chart-box:hover { border-color: var(--blue-500); box-shadow: var(--shadow-sm); }
.growth-chart-title { font-size: 12.5px; font-weight: 700; color: var(--blue-900); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.growth-chart-zoom { font-size: 13px; opacity: .5; }
.growth-chart-box svg { width: 100%; height: auto; display: block; }

/* ============ QUICK SEARCH (dashboard) ============ */
.quick-search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-raised);
  border: 1px solid rgba(228, 223, 211, 0.8);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.quick-search-box:focus-within {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px var(--blue-100);
}
.quick-search-icon { font-size: 17px; color: var(--ink-soft); flex-shrink: 0; }
.quick-search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; font-family: inherit; color: var(--ink);
}
.quick-search-box input::placeholder { color: #9CA8A6; }
.quick-search-kbd {
  font-size: 11px; color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px;
  flex-shrink: 0;
}
.quick-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; z-index: 40;
  padding: 6px;
}
.quick-search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; transition: background .12s;
}
.quick-search-item:hover { background: var(--blue-100); }
.quick-search-empty { padding: 14px; text-align: center; font-size: 13px; color: var(--ink-soft); }

.quick-actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.quick-action-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-raised); border: 1px solid rgba(228, 223, 211, 0.8);
  border-radius: 11px; padding: 10px 16px;
  font-size: 13.5px; font-weight: 600; color: var(--blue-900);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.quick-action-btn span { font-size: 15px; }
.quick-action-btn:hover { border-color: var(--blue-500); box-shadow: var(--shadow-md); }
.quick-action-btn:active { transform: scale(0.97); }

/* ============ CIE-10 AUTOCOMPLETE ============ */
.cie10-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; z-index: 50;
}
.cie10-option { padding: 8px 12px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.cie10-option:hover, .cie10-option.active { background: var(--blue-100); }
.cie10-code { font-weight: 700; color: var(--blue-700); font-size: 12px; flex-shrink: 0; }
.cie10-desc { color: var(--ink); }

/* ============ PROFILE / IMAGE UPLOAD ============ */
.upload-field { border-top: 1px solid var(--line); padding-top: 16px; }
.upload-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.upload-preview {
  width: 120px; height: 76px; border-radius: 10px; border: 1px dashed var(--line);
  background: var(--paper); display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-empty { font-size: 11px; color: var(--ink-soft); text-align: center; padding: 0 8px; }

.modal.modal-wide { max-width: 940px; }
.growth-chart-enlarged { display: flex; justify-content: center; }
.growth-chart-enlarged svg { width: 100%; height: auto; max-width: 880px; }

/* ============ CLINICAL ATTACHMENTS ============ */
.attachments-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.attachment-card { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper-raised); }
.attachment-thumb { width: 100%; height: 100px; object-fit: cover; display: block; cursor: pointer; background: var(--paper); }
.attachment-file-icon { display: flex; align-items: center; justify-content: center; font-size: 34px; }
.attachment-meta { padding: 8px 10px; }
.attachment-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-date { font-size: 10.5px; color: var(--ink-soft); }
.attachment-delete {
  position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,0.9); color: var(--danger);
  width: 24px; height: 24px; border-radius: 50%; font-size: 11px;
}
.attachment-delete:hover { background: white; }

/* ============ TRIAL BANNER ============ */
.trial-banner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  background: var(--blue-100); border: 1px solid #B8D6F5; border-radius: 12px;
  padding: 12px 16px; margin-bottom: 20px; font-size: 13.5px; color: var(--blue-900);
}
.trial-banner button {
  background: var(--blue-700); color: white; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; font-family: inherit; flex-shrink: 0;
}
.trial-banner button:hover { background: var(--blue-900); }

/* ============ BILLING PAYWALL ============ */
.paywall-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(135deg, #0A2E5C 0%, #0B5FCB 60%, #2E86EE 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.paywall-card {
  background: var(--paper-raised); border-radius: 20px; width: 100%; max-width: 440px;
  padding: 34px 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.paywall-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.paywall-title { font-size: 21px; color: var(--blue-900); margin: 0 0 8px; }
.paywall-sub { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 20px; }

.billing-toggle { display: flex; background: var(--paper); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.billing-toggle-btn {
  flex: 1; border: none; background: transparent; padding: 9px 6px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.billing-toggle-btn.active { background: var(--paper-raised); color: var(--blue-900); box-shadow: var(--shadow-sm); }
.billing-save-tag { background: #E7F5EC; color: #1E6B41; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 100px; }

.paywall-price-box {
  background: var(--blue-100); border-radius: 14px; padding: 18px; text-align: center; margin-bottom: 16px;
}
.paywall-price { font-family: 'Poppins'; font-size: 30px; font-weight: 700; color: var(--blue-900); }
.paywall-price span { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.paywall-price-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.paywall-logout { display: block; margin: 16px auto 0; background: none; border: none; font-size: 12.5px; color: var(--ink-soft); text-decoration: underline; font-family: inherit; }

/* ============ RESPONSIVE ============ */
@media (max-width: 880px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: block; }
  .main-content { padding: 72px 16px 40px; }
  .calendar-day { min-height: 60px; padding: 6px 5px; }
  .calendar-grid { gap: 5px; }
  .day-appt { display: none; } /* keep the day cell tappable + clean; details live in the agenda list below */
  .day-appt:first-of-type { display: block; font-size: 9px; }
}

@media (max-width: 640px) {
  .page-header { gap: 10px; }
  .page-header h2 { font-size: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 24px; }
  .quick-actions-row { gap: 8px; }
  .quick-action-btn { flex: 1 1 calc(50% - 8px); justify-content: center; padding: 12px 10px; }
  .quick-search-kbd { display: none; }
  .detail-header { gap: 10px; }
  .detail-header > button { flex: 1 1 auto; }
  .growth-history-row {
    grid-template-columns: 1fr; gap: 2px;
    padding: 10px 8px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px;
  }
  .growth-history-row.head { display: none; }
  .growth-history-row div::before { content: attr(data-label) ": "; font-weight: 700; color: var(--ink-soft); }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .appt-row { flex-wrap: wrap; }
  .appt-time { width: auto; }
}

/* Comfortable tap targets on touch devices */
@media (pointer: coarse) {
  .btn, .icon-btn, .nav-link, .patient-card, .quick-action-btn { min-height: 42px; }
  .cie10-option, .quick-search-item { padding-top: 11px; padding-bottom: 11px; }
}
