/* ══ Patient Detail Full-Page View — EMR Clinical Review ═════════ */

#page-patient-detail {
  --pd-primary: #4F46E5;
  --pd-primary-soft: #EEF2FF;
  --pd-primary-border: #C7D2FE;
  --pd-success: #10B981;
  --pd-success-bg: #ECFDF5;
  --pd-success-border: #A7F3D0;
  --pd-warning: #F59E0B;
  --pd-warning-bg: #FFFBEB;
  --pd-warning-border: #FDE68A;
  --pd-danger: #EF4444;
  --pd-danger-bg: #FEF2F2;
  --pd-danger-border: #FECACA;
  --pd-info-bg: #EFF6FF;
  --pd-info-border: #BFDBFE;
  --pd-bg: #F8FAFC;
  --pd-card: #FFFFFF;
  padding: 0 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--pd-bg);
}

.pd-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 80px);
}

body.pd-has-save-bar #page-patient-detail {
  padding-bottom: 88px;
}

/* ── Topbar ── */
.pd-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.pd-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--rule, #e8e4f4);
  background: #fff;
  color: var(--ink2, #3d2a6b);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.pd-back-btn:hover {
  background: var(--pd-primary-soft);
  border-color: var(--pd-primary-border);
}

.pd-breadcrumb {
  font-size: 13px;
  color: var(--ink3, #7c6e9a);
}

.pd-bc-sep {
  margin: 0 6px;
  opacity: .5;
}

.pd-bc-current {
  color: var(--ink, #1a0938);
  font-weight: 600;
}

/* ── Patient header ── */
.pd-patient-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "identity actions"
    "metrics metrics";
  gap: 16px 20px;
  align-items: start;
  background: var(--pd-card);
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
}

.pd-header-left {
  grid-area: identity;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}

.pd-identity {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.pd-metrics {
  grid-area: metrics;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.pd-header-actions {
  grid-area: actions;
  align-self: start;
  justify-self: end;
  max-width: 100%;
  display: flex;
  align-items: flex-start;
}

.pd-avatar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pd-primary), #6366F1);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .5px;
}

.pd-avatar.status-default { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.pd-avatar.status-xfer { background: linear-gradient(135deg, #7c3aed, #5b21b6); }

.pd-name {
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  color: #0F172A;
  letter-spacing: .2px;
  line-height: 1.25;
  text-transform: uppercase;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
}

.pd-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink3, #7c6e9a);
}

.pd-tag {
  font-weight: 700;
  color: var(--pd-primary);
}

.pd-ic-row {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink3, #7c6e9a);
  font-family: var(--mono, 'DM Mono', monospace);
  word-break: break-all;
  overflow-wrap: anywhere;
}

.pd-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pd-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
}

.pd-badge-aktif {
  background: var(--green-bg, #ecfdf5);
  color: var(--green, #059669);
  border: 1px solid var(--green-b, #6ee7b7);
}

.pd-badge-cicir {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.pd-badge-xfer {
  background: var(--purple-bg, #f5f3ff);
  color: var(--purple, #7c3aed);
  border: 1px solid var(--purple-b, #c4b5fd);
}

.pd-badge-cat {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.pd-metric {
  background: var(--pd-bg);
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}

.pd-metric-icon {
  font-size: 14px;
  margin-bottom: 4px;
  opacity: .85;
}

.pd-metric-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink3, #7c6e9a);
  margin-bottom: 2px;
}

.pd-metric-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #1a0938);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pd-metric-val.positive { color: var(--pd-success); }
.pd-metric-val.negative { color: var(--pd-danger); }
.pd-metric-val.warn { color: var(--pd-warning); }

/* ── Quick actions ── */
.pd-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.pd-qa-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1.5px solid #E2E8F0;
  background: var(--pd-card);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.pd-qa-btn:hover {
  background: var(--pd-bg);
  border-color: #CBD5E1;
}

.pd-qa-primary {
  background: var(--pd-primary);
  border-color: var(--pd-primary);
  color: #fff;
}

.pd-qa-primary:hover {
  background: #4338CA;
  border-color: #4338CA;
  color: #fff;
}

.pd-qa-more {
  min-width: 130px;
}

.pd-tindakan-wrap {
  position: relative;
}

.pd-tindakan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--ink, #1a0938);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.pd-tindakan-btn:hover {
  background: #2d1654;
}

.pd-tindakan-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--rule, #e8e4f4);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(26, 9, 56, .12);
  z-index: 50;
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.pd-tindakan-menu[hidden] {
  display: none !important;
}

.pd-tindakan-menu button {
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2, #3d2a6b);
  cursor: pointer;
}

.pd-tindakan-menu button:hover {
  background: var(--purple-bg, #f5f3ff);
}

/* ── Alerts — horizontal chip bar ── */
.pd-alerts {
  display: block;
}

.pd-alerts:empty {
  display: none;
}

.pd-alert-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--pd-card);
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.pd-alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pd-alert-chip .pd-alert-icon {
  font-size: 13px;
}

.pd-alert-danger,
.pd-alert-chip.pd-alert-danger {
  background: var(--pd-danger-bg);
  border-color: var(--pd-danger-border);
  color: #B91C1C;
}

.pd-alert-warn,
.pd-alert-chip.pd-alert-warn {
  background: var(--pd-warning-bg);
  border-color: var(--pd-warning-border);
  color: #B45309;
}

.pd-alert-info,
.pd-alert-chip.pd-alert-info {
  background: var(--pd-info-bg);
  border-color: var(--pd-info-border);
  color: #1D4ED8;
}

.pd-alert-stable,
.pd-alert-chip.pd-alert-stable {
  background: var(--pd-success-bg);
  border-color: var(--pd-success-border);
  color: #047857;
}

/* legacy single alert rows (fallback) */
.pd-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid transparent;
}

.pd-alert-icon {
  flex-shrink: 0;
  font-size: 15px;
}

.pd-alert-danger {
  background: var(--pd-danger-bg);
  border-color: var(--pd-danger-border);
  color: #991b1b;
}

.pd-alert-warn {
  background: var(--pd-warning-bg);
  border-color: var(--pd-warning-border);
  color: #92400e;
}

.pd-alert-info {
  background: var(--pd-info-bg);
  border-color: var(--pd-info-border);
  color: #1e40af;
}

/* ── 3-column grid ── */
.pd-grid {
  display: grid;
  grid-template-columns: minmax(240px, 22%) minmax(320px, 1fr) minmax(280px, 28%);
  gap: 16px;
  align-items: start;
  flex: 1;
}

.pd-col-left,
.pd-col-center,
.pd-col-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.pd-col-right {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

/* ── Cards ── */
.pd-card {
  background: var(--pd-card);
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}

.pd-clinical-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pd-card-last-review {
  border-color: var(--pd-primary-border);
  box-shadow: 0 2px 12px rgba(79, 70, 229, .08);
}

.pd-card-head--highlight {
  background: linear-gradient(135deg, var(--pd-primary-soft) 0%, var(--pd-card) 100%);
  border-bottom-color: var(--pd-primary-border);
}

.pd-last-review-body {
  background: linear-gradient(180deg, #FAFAFF 0%, var(--pd-card) 100%);
}

.pd-card-foot--split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pd-btn-sm {
  padding: 6px 12px !important;
  font-size: 11px !important;
  min-width: 0 !important;
  flex: 0 0 auto !important;
}

.pd-card-flat {
  box-shadow: none;
}

.pd-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #E2E8F0;
  background: var(--pd-bg);
}

.pd-card-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink3, #7c6e9a);
}

.pd-card-sub {
  font-size: 11px;
  color: var(--ink3, #7c6e9a);
}

.pd-card-body {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--ink2, #3d2a6b);
}

.pd-card-foot {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--rule, #e8e4f4);
}

.pd-phase-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--purple-bg, #f5f3ff);
  color: var(--purple, #7c3aed);
  border: 1px solid var(--purple-b, #c4b5fd);
}

.pd-clinical-edit-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--rule, #e8e4f4);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink2, #3d2a6b);
  cursor: pointer;
}

.pd-clinical-edit-btn:hover {
  background: var(--purple-bg, #f5f3ff);
  border-color: var(--purple-b, #c4b5fd);
}

.pd-clinical-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pd-clinical-form .pd-field label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .35px;
  color: var(--ink3, #7c6e9a);
  margin-bottom: 4px;
  display: block;
}

.pd-clinical-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.pd-clinical-form-actions .pd-btn-primary {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
}

.pd-clinical-err {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
}

.pd-clinical-updated {
  font-size: 10px;
  color: var(--ink3, #7c6e9a);
  margin-top: 8px;
}

/* ── Clinical Notes tab (Phase 4) ───────────────────────────────── */
.pd-clinical-notes-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pd-cn-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pd-cn-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.pd-cn-timeline-wrap {
  padding-top: 4px;
}

.pd-cn-item {
  position: relative;
  padding: 12px 0 12px 18px;
  border-bottom: 1px solid var(--rule, #e8e4f4);
}

.pd-cn-item:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}

.pd-cn-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple, #7c3aed);
  box-shadow: 0 0 0 3px var(--purple-bg, #f5f3ff);
}

.pd-cn-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.pd-cn-item-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink, #1a0938);
}

.pd-cn-item-type {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.pd-cn-type-progress {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

.pd-cn-type-counselling {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #6ee7b7;
}

.pd-cn-type-incident {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.pd-cn-type-other {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.pd-cn-item-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink2, #3d2a6b);
  word-break: break-word;
}

.pd-cn-item-meta {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink3, #7c6e9a);
}

.pd-risk-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}

.pd-risk-low {
  background: var(--green-bg, #ecfdf5);
  color: var(--green, #059669);
  border: 1px solid var(--green-b, #6ee7b7);
}

.pd-risk-medium {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.pd-risk-high {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.pd-risk-none {
  background: var(--bg, #faf9fc);
  color: var(--ink3, #7c6e9a);
  border: 1px solid var(--rule, #e8e4f4);
}

.pd-phase-note {
  font-size: 12px;
  color: var(--ink3, #7c6e9a);
  margin: 0 0 12px;
}

.pd-dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pd-clin-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pd-clin-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #64748B;
}

.pd-clin-val {
  font-size: 13px;
  font-weight: 600;
  color: #0F172A;
  line-height: 1.5;
}

.pd-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pd-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #E2E8F0;
  background: var(--pd-bg);
  color: #334155;
}

.pd-chip--dx {
  background: var(--pd-primary-soft);
  border-color: var(--pd-primary-border);
  color: #4338CA;
}

.pd-chip--comorb {
  background: #F0FDFA;
  border-color: #99F6E4;
  color: #0F766E;
}

.pd-chip--psych {
  background: #FDF4FF;
  border-color: #F5D0FE;
  color: #86198F;
}

.pd-dl dt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .35px;
  color: var(--ink3, #7c6e9a);
}

.pd-dl dd {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #1a0938);
}

.pd-meth-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 6px;
}

.pd-meth-row span:first-child {
  color: var(--ink3, #7c6e9a);
}

.pd-meth-row strong {
  color: var(--ink, #1a0938);
  text-align: right;
}

.pd-adherence-bar {
  height: 8px;
  background: #eef0f6;
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.pd-adherence-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #22c55e, #059669);
  transition: width .4s ease;
}

.pd-adherence-fill.low {
  background: linear-gradient(90deg, #fbbf24, #d97706);
}

.pd-adherence-fill.critical {
  background: linear-gradient(90deg, #f87171, #dc2626);
}

.pd-adherence-lbl {
  font-size: 11px;
  color: var(--ink3, #7c6e9a);
  text-align: right;
}

.pd-quick-notes {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink2, #3d2a6b);
  white-space: pre-wrap;
  margin-bottom: 8px;
}

.pd-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--pd-primary);
  cursor: pointer;
}

.pd-link-btn:hover {
  text-decoration: underline;
}

/* ── Tabs ── */
.pd-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--rule, #e8e4f4);
  border-radius: 12px;
  flex-wrap: wrap;
}

.pd-tab {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink3, #7c6e9a);
  cursor: pointer;
  white-space: nowrap;
}

.pd-tab:hover {
  color: var(--ink2, #3d2a6b);
  background: var(--bg, #faf9fc);
}

.pd-tab-active {
  background: var(--purple-bg, #f5f3ff);
  color: var(--purple, #7c3aed);
  box-shadow: inset 0 0 0 1px var(--purple-b, #c4b5fd);
}

.pd-tab-panels {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pd-tab-panel[hidden] {
  display: none !important;
}

#pd-clinical-view[hidden],
#pd-clinical-form[hidden] {
  display: none !important;
}

/* ── Urine timeline ── */
.pd-urine-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 4px;
}

.pd-urine-tl-item {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #F1F5F9;
  position: relative;
}

.pd-urine-tl-item:last-child {
  border-bottom: none;
}

.pd-urine-tl-item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 24px;
  bottom: -2px;
  width: 2px;
  background: #E2E8F0;
}

.pd-urine-tl-item:last-child::before {
  display: none;
}

.pd-urine-tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pd-success);
  box-shadow: 0 0 0 3px var(--pd-success-bg);
  justify-self: center;
}

.pd-urine-tl-item--pos .pd-urine-tl-dot {
  background: var(--pd-danger);
  box-shadow: 0 0 0 3px var(--pd-danger-bg);
}

.pd-urine-tl-month {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
}

.pd-urine-tl-result {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.pd-urine-tl-result.neg {
  background: var(--pd-success-bg);
  color: var(--pd-success);
  border: 1px solid var(--pd-success-border);
}

.pd-urine-tl-result.pos {
  background: var(--pd-danger-bg);
  color: var(--pd-danger);
  border: 1px solid var(--pd-danger-border);
}

.pd-urine-tl-result.pending {
  background: var(--pd-info-bg);
  color: #1D4ED8;
  border: 1px solid var(--pd-info-border);
}

.pd-urine-tl-item--pending .pd-urine-tl-dot {
  background: var(--pd-warning);
  box-shadow: 0 0 0 3px var(--pd-warning-bg);
}

.pd-urine-tl-item--pending {
  background: linear-gradient(90deg, var(--pd-warning-bg) 0%, transparent 100%);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: 8px;
}

.pd-urine-tl-item--pos {
  background: linear-gradient(90deg, var(--pd-danger-bg) 0%, transparent 100%);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: 8px;
}

.pd-urine-full-wrap {
  border-top: 1px solid #E2E8F0;
  background: var(--pd-bg);
}

/* ── Review timeline ── */
.pd-review-timeline {
  display: flex;
  flex-direction: column;
}

.pd-rt-item {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #F1F5F9;
}

.pd-rt-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pd-rt-date {
  font-size: 12px;
  font-weight: 800;
  color: #64748B;
  line-height: 1.35;
}

.pd-rt-body {
  min-width: 0;
}

.pd-rt-status {
  display: inline-flex;
  margin-bottom: 4px;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.pd-rt-status--stable {
  background: var(--pd-success-bg);
  color: #047857;
  border: 1px solid var(--pd-success-border);
}

.pd-rt-status--improving {
  background: var(--pd-info-bg);
  color: #1D4ED8;
  border: 1px solid var(--pd-info-border);
}

.pd-rt-status--warn {
  background: var(--pd-warning-bg);
  color: #B45309;
  border: 1px solid var(--pd-warning-border);
}

.pd-rt-plan {
  font-size: 13px;
  font-weight: 600;
  color: #0F172A;
  line-height: 1.45;
}

/* ── Documents grid ── */
.pd-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.pd-doc-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
  background: var(--pd-bg);
  min-height: 72px;
}

.pd-doc-item--active {
  border-color: var(--pd-success-border);
  background: var(--pd-success-bg);
}

.pd-doc-item--warn {
  border-color: var(--pd-warning-border);
  background: var(--pd-warning-bg);
}

.pd-doc-item--muted {
  opacity: .85;
}

.pd-doc-icon {
  font-size: 18px;
  line-height: 1;
}

.pd-doc-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #64748B;
}

.pd-doc-val {
  font-size: 12px;
  font-weight: 700;
  color: #0F172A;
  line-height: 1.35;
}

.pd-doc-action {
  margin-top: auto;
  padding: 0;
  border: none;
  background: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--pd-primary);
  cursor: pointer;
  text-align: left;
}

.pd-doc-action:hover {
  text-decoration: underline;
}

/* ── Sticky save bar ── */
.pd-save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid #E2E8F0;
  box-shadow: 0 -4px 24px rgba(15, 23, 42, .08);
  padding: 12px 20px;
}

.pd-save-bar[hidden] {
  display: none !important;
}

.pd-save-bar-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pd-save-bar-msg {
  font-size: 13px;
  font-weight: 700;
  color: #B45309;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pd-save-bar-msg::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pd-warning);
}

.pd-save-bar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pd-save-bar-actions .pd-btn-primary {
  flex: 0 0 auto;
  min-width: 140px;
}

.pd-textarea--clinical {
  min-height: 96px;
  font-size: 13px;
  line-height: 1.55;
}

/* ── Urine history list ── */
.pd-urine-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule, #e8e4f4);
}

.pd-urine-item:last-child {
  border-bottom: none;
}

.pd-urine-month {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink3, #7c6e9a);
  min-width: 36px;
}

.pd-urine-date {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #1a0938);
}

.pd-urine-result {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.pd-urine-result.neg {
  background: var(--green-bg, #ecfdf5);
  color: var(--green, #059669);
}

.pd-urine-result.pos {
  background: #fef2f2;
  color: #dc2626;
}

.pd-urine-empty {
  font-size: 13px;
  color: var(--ink3, #7c6e9a);
  text-align: center;
  padding: 20px 0;
}

/* ── Last review ── */
.pd-review-summary dt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink3, #7c6e9a);
  margin-top: 8px;
}

.pd-review-summary dt:first-child {
  margin-top: 0;
}

.pd-review-summary dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #1a0938);
}

.pd-review-summary dd.pd-review-multiline {
  white-space: normal !important;
  word-break: break-word;
  line-height: 1.55;
  font-weight: 500;
}

.pd-review-text {
  display: block;
}

.pd-review-badge-row {
  margin-top: 8px;
}

.pd-review-stable {
  display: inline-block;
  margin-top: 0;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--green-bg, #ecfdf5);
  color: var(--green, #059669);
}

.pd-review-stable--warn {
  background: #fffbeb;
  color: #b45309;
}

/* ── Empty state ── */
.pd-empty-state {
  text-align: center;
  padding: 40px 24px;
  background: #fff;
  border: 1px dashed var(--rule, #e8e4f4);
  border-radius: 14px;
}

.pd-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.pd-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #1a0938);
  margin-bottom: 6px;
}

.pd-empty-text {
  font-size: 13px;
  color: var(--ink3, #7c6e9a);
  margin: 0 0 16px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Doctor review form ── */
.pd-review-card {
  background: #fff;
  border: 1px solid var(--rule, #e8e4f4);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(26, 9, 56, .05);
}

.pd-review-head {
  padding: 14px 16px;
  border-bottom: 1px solid #E2E8F0;
  background: linear-gradient(135deg, var(--pd-primary-soft) 0%, var(--pd-card) 100%);
}

.pd-review-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink3, #7c6e9a);
}

.pd-review-sub {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink, #1a0938);
  margin-top: 2px;
}

.pd-review-form {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pd-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .35px;
  color: var(--ink3, #7c6e9a);
  margin-bottom: 5px;
}

.pd-opt {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.pd-inp,
.pd-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1.5px solid var(--rule, #e8e4f4);
  border-radius: 9px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink, #1a0938);
  background: #fff;
  transition: border-color .15s;
}

.pd-inp:focus,
.pd-textarea:focus {
  outline: none;
  border-color: var(--pd-primary-border);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.pd-textarea {
  resize: vertical;
  min-height: 72px;
}

.pd-char-count {
  font-size: 11px;
  color: var(--ink3, #7c6e9a);
  text-align: right;
  margin-top: 3px;
}

.pd-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.pd-review-err {
  flex: 1 1 100%;
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
}

.pd-review-err:empty,
.pd-review-err[style*="display: none"] {
  display: none !important;
}

.pd-btn-primary,
.pd-btn-outline,
.pd-btn-ghost,
.pd-btn-primary-soft {
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.pd-btn-primary {
  background: var(--pd-primary);
  color: #fff;
  flex: 1;
  min-width: 120px;
}

.pd-btn-primary:hover {
  background: #4338CA;
}

.pd-btn-primary-soft {
  background: var(--purple-bg, #f5f3ff);
  color: var(--purple, #7c3aed);
  border: 1px solid var(--purple-b, #c4b5fd);
}

.pd-btn-outline {
  background: #fff;
  color: var(--ink2, #3d2a6b);
  border: 1.5px solid var(--rule, #e8e4f4);
}

.pd-btn-outline:hover:not(:disabled) {
  border-color: var(--purple-b, #c4b5fd);
  background: var(--purple-bg, #f5f3ff);
}

.pd-btn-outline:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.pd-btn-ghost {
  background: transparent;
  color: var(--ink3, #7c6e9a);
}

.pd-btn-ghost:hover {
  color: var(--ink, #1a0938);
}

/* ── Footer ── */
.pd-footer {
  font-size: 11px;
  color: var(--ink3, #7c6e9a);
  padding: 8px 4px 0;
  border-top: 1px solid var(--rule, #e8e4f4);
  margin-top: 8px;
}

/* ── Responsive ─────────────────────────────────────────────────── */

/* Large tablet / small desktop — 2-col: sidebar cards | tabs + review */
@media (min-width: 1024px) and (max-width: 1180px) {
  #page-patient-detail {
    padding: 0 16px 24px;
  }

  .pd-grid {
    grid-template-columns: minmax(260px, 32%) 1fr;
    grid-template-rows: auto auto;
    align-items: start;
  }

  .pd-col-left {
    grid-column: 1;
    grid-row: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .pd-col-center {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .pd-col-right {
    grid-column: 2;
    grid-row: 2;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .pd-patient-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "identity actions"
      "metrics metrics";
    gap: 14px 16px;
  }

  .pd-header-left {
    grid-area: identity;
  }

  .pd-metrics {
    grid-area: metrics;
    grid-template-columns: repeat(5, 1fr);
  }

  .pd-header-actions {
    grid-area: actions;
    align-self: start;
  }
}

/* iPad Pro portrait at 1024px — force single column (not 2-col landscape) */
@media (min-width: 1024px) and (max-width: 1180px) and (orientation: portrait) {
  .pd-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .pd-col-left,
  .pd-col-center,
  .pd-col-right {
    grid-column: auto;
    grid-row: auto;
  }

  .pd-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .pd-tindakan-btn {
    width: 100%;
    justify-content: center;
  }
}

/* iPad portrait & medium tablets — single column stack */
@media (max-width: 1023px) {
  #page-patient-detail {
    padding: 0 14px 22px;
    overflow-x: hidden;
    max-width: 100%;
  }

  .pd-wrap {
    min-height: 0;
    gap: 14px;
  }

  .pd-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .pd-col-left,
  .pd-col-center,
  .pd-col-right {
    grid-column: auto;
    grid-row: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    width: 100%;
  }

  .pd-col-right {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .pd-patient-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "identity"
      "metrics"
      "actions";
    padding: 16px;
    gap: 14px;
  }

  .pd-header-left {
    width: 100%;
    grid-area: identity;
  }

  .pd-identity {
    min-width: 0;
    flex: 1;
  }

  .pd-name {
    font-size: 16px;
    word-break: break-word;
  }

  .pd-metrics {
    grid-area: metrics;
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .pd-metric {
    padding: 10px;
  }

  .pd-header-actions {
    grid-area: actions;
    width: 100%;
    justify-self: stretch;
  }

  .pd-quick-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .pd-qa-btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    min-height: 44px;
  }

  .pd-qa-more {
    flex: 1 1 100%;
  }

  .pd-tindakan-wrap {
    flex: 1 1 100%;
  }

  .pd-tindakan-menu {
    left: 0;
    right: 0;
    min-width: 0;
  }

  .pd-doc-grid {
    grid-template-columns: 1fr;
  }

  .pd-topbar {
    gap: 10px;
  }

  .pd-breadcrumb {
    min-width: 0;
    flex: 1;
  }

  .pd-bc-current {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }

  .pd-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .pd-tabs::-webkit-scrollbar {
    display: none;
  }

  .pd-tab {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 14px;
  }

  .pd-clinical-form .pd-inp,
  .pd-clinical-form .pd-textarea,
  .pd-cn-form .pd-inp,
  .pd-cn-form .pd-textarea {
    font-size: 16px; /* elak zoom iOS pada focus */
  }

  .pd-clinical-form-actions {
    flex-direction: column;
  }

  .pd-clinical-form-actions .pd-btn-primary,
  .pd-clinical-form-actions .pd-btn-ghost {
    width: 100%;
    min-height: 44px;
  }

  .pd-cn-form-actions {
    flex-direction: column;
  }

  .pd-cn-form-actions .pd-btn-primary,
  .pd-cn-form-actions .pd-btn-ghost {
    width: 100%;
    min-height: 44px;
  }

  .pd-cn-form-row {
    grid-template-columns: 1fr;
  }

  .pd-review-actions {
    flex-direction: column;
  }

  .pd-review-actions .pd-btn-primary,
  .pd-review-actions .pd-btn-outline,
  .pd-review-actions .pd-btn-ghost {
    width: 100%;
    min-height: 44px;
    flex: none;
  }

  .pd-card-body {
    padding: 12px 14px;
  }

  .pd-clinical-summary .pd-dl {
    gap: 10px;
  }
}

/* Mobile phones */
@media (max-width: 768px) {
  #page-patient-detail {
    padding: 0 12px 20px;
  }

  .pd-patient-header {
    padding: 14px;
  }

  .pd-avatar {
    width: 48px;
    height: 48px;
    font-size: 16px;
    border-radius: 12px;
  }

  .pd-name {
    font-size: 14px;
  }

  .pd-meta,
  .pd-ic-row {
    font-size: 11px;
  }

  .pd-metric-lbl {
    font-size: 9px;
  }

  .pd-metric-val {
    font-size: 12px;
  }

  .pd-back-btn {
    min-height: 44px;
    padding: 8px 12px;
  }

  .pd-clinical-edit-btn {
    min-height: 36px;
    padding: 6px 12px;
  }

  .pd-empty-state {
    padding: 28px 16px;
  }

  .pd-review-form {
    padding: 12px 14px 14px;
  }

  .pd-footer {
    font-size: 10px;
    line-height: 1.45;
  }
}

/* Narrow phones */
@media (max-width: 400px) {
  .pd-metrics {
    grid-template-columns: 1fr;
  }

  .pd-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pd-back-btn {
    width: 100%;
    justify-content: center;
  }

  .pd-breadcrumb {
    text-align: center;
    font-size: 12px;
  }

  .pd-tab {
    font-size: 11px;
    padding: 10px 12px;
  }
}
