html { height: 100%; }

:root {
  --bg: #f6f8ff;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #6b7280;
  --accent: #4e73df;
  --accent-2: #3a5ccc;
  --accent-soft: #e9efff;
  --border: #e6ebf5;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.10);
  --soft-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body.pbv2 {
  margin: 0;
  min-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: "Manrope", "Plus Jakarta Sans", sans-serif;
  background: linear-gradient(180deg, #f7f9ff 0%, #eef3ff 100%);
  color: var(--ink);
  letter-spacing: 0;
}

.app-shell { padding: 22px 18px 120px; min-height: 100vh; }

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.auth-card { width: min(420px, 90vw); }
.brand { font-weight: 700; color: var(--accent); margin-bottom: 8px; letter-spacing: 0; }
h1 { margin: 8px 0 16px; font-size: 22px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  background: #f6f8ff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:focus,
select:focus {
  border-color: #cdd8f4;
  box-shadow: 0 0 0 4px rgba(78, 115, 223, 0.18);
  background: #ffffff;
}

.btn-primary {
  margin-top: 16px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 18px;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 26px rgba(78, 115, 223, 0.28);
}
.btn-primary:hover { background: var(--accent-2); }
.error { color: #b91c1c; margin-top: 10px; font-size: 13px; }
.error-card { border-color: #f0b4b4; background: #fff7f7; }
.error-list { margin: 8px 0 0; padding-left: 18px; }
.error-list li { color: #b91c1c; font-size: 12px; line-height: 1.4; }

.hint { margin-top: 12px; font-size: 12px; color: var(--muted); }
.field-error { color: #b91c1c; font-size: 12px; margin-top: 6px; display: none; }
.field-error.show { display: block; }

.page { display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; position: relative; }
.topbar-doctor { justify-content: space-between; }
.topbar-doctor .doctor-header { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.topbar-doctor .doctor-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-center .topbar-title { position: absolute; left: 50%; transform: translateX(-50%); text-align: center; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--soft-shadow);
}
.icon-btn .icon { font-size: 18px; line-height: 1; }
.title { font-weight: 700; font-size: 20px; }
.subtitle { color: var(--muted); font-size: 13px; }
.btn-ghost {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
  box-shadow: var(--soft-shadow);
}

.doctor-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: linear-gradient(180deg, #f7f9ff 0%, #eef3ff 100%);
}
.doctor-photo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: #e7efff url('/v2/doctor-photo.jpg') center/cover no-repeat;
  border: 1px solid #d7e3ff;
}
.doctor-name { font-weight: 700; }
.doctor-meta { color: var(--muted); font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--soft-shadow);
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-weight: 700; font-size: 18px; }

.section-title { font-weight: 700; margin-bottom: 12px; font-size: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  font-weight: 600;
}
.chip.muted { background: #f1f5f9; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fcfefd;
  box-shadow: var(--soft-shadow);
}
.list-item.checked-in {
  background: #eaf7f3;
  border-color: #8cc8bb;
}
.name { font-weight: 600; }
.meta { color: var(--muted); font-size: 12px; }
.cta { color: var(--accent); font-weight: 600; }

.empty { color: var(--muted); text-align: center; padding: 20px; }

.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 66px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  padding: 6px 10px;
  z-index: 50;
  box-shadow: 0 20px 40px rgba(31, 41, 55, 0.12);
}
.nav-item {
  display: grid;
  gap: 2px;
  place-items: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  border-radius: 16px;
  padding: 6px 4px;
}
.nav-icon { font-size: 18px; line-height: 1; }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.form-card { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.compact { grid-template-columns: 1.4fr 0.6fr; }
.grid.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: 1.6fr 0.8fr; }
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .grid.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: 1.6fr 0.8fr; }
  .grid.compact { grid-template-columns: 1.4fr 0.6fr; }
}

.section-toggle {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #f8fbfa;
  border-radius: 18px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--soft-shadow);
}
.section-toggle.open { border-color: #cdd8f4; background: #ffffff; }
.section-body { padding: 12px; border: 1px solid var(--border); border-radius: 18px; background: #ffffff; margin-bottom: 6px; }
.hidden { display: none; }

.dob-inputs { display: flex; gap: 8px; align-items: center; }
.calendar-btn { width: 40px; min-width: 40px; height: 40px; border-radius: 14px; }
.input-compact { text-align: center; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

input::placeholder { color: #b0b8c4; }

.list-actions { display: flex; gap: 10px; align-items: center; }
.btn-link { border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 12px; text-decoration: none; padding: 0; cursor: pointer; }
.btn-link:focus { outline: none; }
.profile-card { display: grid; gap: 12px; position: relative; padding-top: 28px; }
.profile-row { display: flex; gap: 12px; align-items: center; padding-left: 112px; }
.profile-photo { width: 90px; height: 90px; border-radius: 28px; background: #e7efff url('/v2/doctor-photo.jpg') center/cover no-repeat; border: 1px solid #d7e3ff; position: absolute; left: 18px; top: -18px; box-shadow: 0 12px 20px rgba(21, 40, 38, 0.15); }
.profile-name { font-weight: 700; font-size: 18px; }
.profile-meta { color: var(--muted); font-size: 13px; }
.rating-row { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.star { color: #f2b01e; }
.chip-row { display: flex; gap: 10px; flex-wrap: wrap; }
.pill { padding: 6px 14px; border-radius: 999px; background: #e9f4f1; color: var(--accent); font-size: 12px; font-weight: 600; }
.pill.warm { background: #f6efe6; color: #8a5a1f; }
.pill.cool { background: #eff3f8; color: #516072; }
.section-head { display: flex; justify-content: space-between; align-items: center; }
.dropdown { color: var(--muted); font-size: 12px; }
.schedule-row { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.day { background: #f4faf7; border: 1px solid var(--border); border-radius: 16px; padding: 10px 0; text-align: center; position: relative; }
.day.active { background: var(--accent); color: #fff; border-color: transparent; }
.day.off { background: #fff1f1; border-color: #f7caca; color: #b42318; }
.day-num { font-weight: 700; font-size: 16px; }
.day-label { font-size: 11px; margin-top: 6px; color: inherit; }
.day-count { position: absolute; top: 6px; right: 6px; background: #fde2e2; color: #b42318; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: #eef6f3; border-radius: 999px; padding: 6px; }
.seg-pill { border: 0; background: transparent; padding: 8px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); font-weight: 600; }
.seg-pill.active { background: var(--accent); color: #fff; }
.time-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.time-pill { padding: 8px 12px; border-radius: 12px; background: #f3f7f6; color: var(--muted); font-size: 12px; font-weight: 600; }
.time-pill.active { background: var(--accent); color: #fff; }
.time-pill.disabled { opacity: 0.45; pointer-events: none; }
.cta-primary { width: 100%; border: 0; background: var(--accent); color: #fff; border-radius: 18px; padding: 14px 16px; font-weight: 700; box-shadow: 0 14px 28px rgba(47, 126, 114, 0.3); text-align: center; text-decoration: none; display: block; }
.status-pill { padding: 6px 10px; border-radius: 999px; background: #eef6f3; color: var(--accent); font-size: 11px; font-weight: 700; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 60; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 23, 0.35); }
.modal-card { position: relative; width: min(360px, 90vw); background: #fff; border-radius: 24px; padding: 16px; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.modal-body { display: grid; gap: 10px; }
.modal-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.modal-row strong { color: var(--ink); font-weight: 700; }

.availability-form .btn-primary { margin-top: 10px; }

.profile-row { justify-content: space-between; }
.profile-info { flex: 1; }
.btn-availability { margin-left: auto; }
.modal-card.wide { width: min(520px, 92vw); }
.calendar-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.calendar-day { border: 1px solid var(--border); border-radius: 16px; padding: 10px; background: #f9fcfb; position: relative; }
.calendar-day.off { background: #fff5f5; border-color: #f7caca; }
.calendar-day.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 126, 114, 0.12); }

.calendar-grid.compact { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-grid.compact .calendar-day { padding: 4px; border-radius: 12px; }
.calendar-grid.compact .day-num { font-size: 12px; }
.calendar-grid.compact .day-label { font-size: 6px; margin-top: 2px; line-height: 1; }
.calendar-grid.compact .day-chips { gap: 4px; }
.calendar-grid.compact .chip-red,
calendar-grid.compact .chip-green,
calendar-grid.compact .chip-muted { font-size: 7px; padding: 1px 5px; }
.calendar-grid.compact .day-count { top: 3px; right: 3px; font-size: 8px; padding: 1px 4px; }
.day-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-red { background: #fde2e2; color: #b42318; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.chip-green { background: #e7f6ee; color: #107c41; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.chip-muted { background: #eef2f7; color: #64748b; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }

.search-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.search-input { flex: 1; }


.form-tight { display: grid; gap: 10px; }
.form-tight .grid { gap: 8px; }
.form-tight label { margin: 6px 0 4px; font-size: 11px; }
.form-tight input,
.form-tight select { padding: 10px 12px; border-radius: 16px; }
.form-tight .segmented { padding: 4px; }
.form-tight .seg-pill { padding: 6px 8px; }

.reason-field input { font-size: 13px; }


.availability-info { margin-top: 10px; font-size: 12px; color: var(--accent); background: #f1faf6; border: 1px solid #d8efe6; padding: 8px 10px; border-radius: 12px; }
.availability-info.off { color: #b42318; background: #fff5f5; border-color: #f7caca; }


.doctor-avatar { position: relative; width: 96px; height: 96px; }
.doctor-avatar .profile-photo { width: 96px; height: 96px; border-radius: 22px; position: static; box-shadow: 0 14px 24px rgba(21, 40, 38, 0.2); }
.photo-upload { position: absolute; right: -6px; bottom: -6px; width: 28px; height: 28px; border-radius: 999px; background: #ffffff; border: 1px solid var(--border); display: grid; place-items: center; box-shadow: var(--soft-shadow); cursor: pointer; font-weight: 700; color: var(--accent); }
.photo-upload input { display: none; }
.btn-schedule { border: 1px solid #cde6dd; background: #eaf7f2; color: var(--accent); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 12px; box-shadow: var(--soft-shadow); }


.status-pill.paid { background: #e7f6ee; color: #107c41; }
.status-pill.checked { background: #e0f2ff; color: #1f5f9c; }

.bmi-gauge { position: relative; height: 190px; display: grid; place-items: center; }
.gauge-arc {
  width: 220px;
  height: 110px;
  border-radius: 220px 220px 0 0;
  background: conic-gradient(
    #38bdf8 0deg 35deg,
    #16a34a 35deg 80deg,
    #facc15 80deg 125deg,
    #f97316 125deg 155deg,
    #ef4444 155deg 180deg
  );
  clip-path: inset(0 0 50% 0);
  box-shadow: inset 0 -6px 0 rgba(255,255,255,0.5);
}
.gauge-inner {
  position: absolute;
  width: 170px;
  height: 85px;
  border-radius: 170px 170px 0 0;
  background: #ffffff;
  top: 36px;
}
.gauge-needle {
  position: absolute;
  width: 6px;
  height: 90px;
  background: #111827;
  bottom: 24px;
  transform-origin: bottom center;
  transform: rotate(0deg);
  transition: transform 0.4s ease;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.gauge-center {
  position: absolute;
  top: 72px;
  display: grid;
  place-items: center;
  gap: 2px;
}
.gauge-title { font-weight: 700; color: #111827; font-size: 13px; letter-spacing: 0; }
.gauge-value { font-weight: 800; font-size: 18px; color: #0f172a; }
.bmi-chart { width: 100%; height: 80px; margin-top: 8px; }


.status-pill.link { text-decoration: none; cursor: pointer; }
.status-pill.link:hover { filter: brightness(0.95); }


.bmi-legend { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.bmi-legend .dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; margin-right: 6px; }
.bmi-legend .blue { background: #38bdf8; }
.bmi-legend .green { background: #16a34a; }
.bmi-legend .yellow { background: #facc15; }
.bmi-legend .orange { background: #f97316; }
.bmi-legend .red { background: #ef4444; }

.table { display: grid; gap: 6px; font-size: 12px; }
.table .row { display: flex; justify-content: space-between; padding: 6px 10px; background: #f6f8ff; border: 1px solid var(--border); border-radius: 12px; }


.bmi-gauge-new { display: grid; place-items: center; padding: 8px 0; }
.gauge-svg { width: 100%; max-width: 320px; height: auto; }
.gauge-seg { fill: none; stroke-width: 16; stroke-linecap: butt; }
.gauge-seg.severe { stroke: #38bdf8; }
.gauge-seg.normal { stroke: #16a34a; }
.gauge-seg.over { stroke: #facc15; }
.gauge-seg.obese { stroke: #f97316; }
.gauge-seg.obese2 { stroke: #ef4444; }
.gauge-needle { stroke: #0f172a; stroke-width: 6; stroke-linecap: round; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.15)); }
.gauge-center-dot { fill: #111827; }
.gauge-title { font-size: 12px; font-weight: 700; fill: #111827; }
.gauge-value { font-size: 18px; font-weight: 800; fill: #0f172a; }
.gauge-tick { font-size: 9px; fill: #475569; }

/* Scroll fix */
html, body { height: auto !important; }
body.pbv2 { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
.app-shell { min-height: 100% !important; overflow: visible; }

.summary-card .summary-top { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.summary-grid { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:10px; margin-top: 12px; }
@media (max-width: 640px) { .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.btn-small { padding: 8px 14px; font-size: 12px; border-radius: 14px; box-shadow: 0 10px 20px rgba(47, 126, 114, 0.18); }
.btn-ghost.btn-small { padding: 6px 12px; font-size: 12px; border-radius: 999px; }
.queue-head-actions { display:flex; align-items:center; gap:10px; }

.queue-item.waiting { background: #eaf7f3; border-color: #8cc8bb; }
.queue-item.progress { background: #e8f1ff; border-color: #b6d4f6; }
.queue-item.skipped { background: #fff7ed; border-color: #f3c891; }
.queue-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.queue-actions form { margin: 0; }

.soap-header { display:flex; flex-direction:column; gap:4px; }
.soap-steps { display:flex; gap:6px; }
.soap-step {
  width:28px;
  height:28px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  background:#e6f2ef;
  color:#4e73df;
  font-size:13px;
}
.soap-step.active { background:#4e73df; color:#fff; }
.soap-title { font-weight:700; font-size:18px; }

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #e7f3ee center/cover no-repeat;
  border: 1px solid #d7e3ff;
  flex: 0 0 auto;
}
.queue-left { display:flex; gap:10px; align-items:flex-start; }
.recall-row { margin-top:4px; font-size:12px; color: var(--muted); }

.photo-row { display:flex; align-items:center; gap:14px; margin-bottom: 10px; }
.patient-photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: #e7f3ee url('/v2/patient-default.svg') center/cover no-repeat;
  border: 1px solid #d7e3ff;
  flex: 0 0 auto;
}
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }


.action-bar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
  padding: 8px 6px;
  background: linear-gradient(180deg, rgba(247,249,255,0.95) 0%, rgba(238,243,255,0.6) 100%);
  backdrop-filter: blur(6px);
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border: 1px solid transparent;
  box-shadow: 0 12px 24px rgba(15,23,42,0.12);
  cursor: pointer;
}
.action-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(78,115,223,0.35);
}
.action-btn.secondary {
  background: #ffffff;
  color: var(--accent);
  border-color: #cdd8f4;
}


.dashboard-page { gap: 12px; }
.dashboard-page .topbar { margin-bottom: 4px; }
.dashboard-page .action-bar { margin-top: 2px; padding: 4px; }
.dashboard-page .action-btn { padding: 12px 14px; }
