/* Test Reports tab (rp-). Mobile first; side-by-side page and values from 900px. */
#page-reports { --rp-amber: #b45309; --rp-amber-bg: #fef3c7; --rp-red-bg: #fee2e2; --rp-green-bg: #dcfce7; --rp-blue-bg: #dbeafe; --rp-purple: #6d28d9; --rp-purple-bg: #ede9fe; }
.nav-item[data-page="reports"] { position: relative; }
#rp-nav-badge { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: #dc2626; color: #fff; border-radius: 999px; font-size: 0.68rem; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; }
#rp-nav-badge[hidden] { display: none; }

.rp-title { margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; color: var(--gray-900, #111827); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rp-help { color: var(--gray-500, #6b7280); font-size: 0.86rem; margin: 4px 0 10px; line-height: 1.45; }
.rp-empty { color: var(--gray-400, #9ca3af); text-align: center; padding: 14px 6px; margin: 0; }
.rp-error, .rp-warn-text { color: var(--rp-amber); font-weight: 600; }
.rp-error { color: var(--red, #dc2626); }
.rp-ok-text { color: var(--green, #16a34a); font-weight: 650; }
.rp-count { background: var(--gray-100, #f3f4f6); border-radius: 999px; padding: 0 9px; font-size: 0.8rem; color: var(--gray-600, #4b5563); }
.rp-section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.rp-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 650; line-height: 1.4; white-space: nowrap; }
.rp-tone-gray { background: var(--gray-100, #f3f4f6); color: var(--gray-600, #4b5563); }
.rp-tone-green { background: var(--rp-green-bg); color: #166534; }
.rp-tone-amber { background: var(--rp-amber-bg); color: #92400e; }
.rp-tone-red { background: var(--rp-red-bg); color: #991b1b; }
.rp-tone-blue { background: var(--rp-blue-bg); color: #1e40af; }
.rp-tone-purple { background: var(--rp-purple-bg); color: var(--rp-purple); }

/* Search and inbox */
.rp-search { display: flex; gap: 8px; margin: 8px 0; }
.rp-search input { flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--gray-300, #d1d5db); border-radius: var(--radius, 10px); font-size: 1rem; }
.rp-results { display: grid; gap: 6px; }
.rp-option, .rp-visit-patient { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; width: 100%; text-align: left; padding: 11px 12px; border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius, 10px); background: #fff; cursor: pointer; font-size: 0.92rem; }
.rp-option:hover, .rp-visit-patient:hover { border-color: var(--primary, #1a56db); background: #f8fafc; }
.rp-visit-patient { background: var(--rp-blue-bg); border-color: #bfdbfe; margin-bottom: 6px; }
.rp-option span, .rp-visit-patient span { color: var(--gray-500, #6b7280); font-size: 0.82rem; }
.rp-list { display: grid; gap: 8px; margin-top: 8px; }
.rp-row, .rp-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius-lg, 14px); background: #fff; }
.rp-row { width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.rp-row:hover { border-color: var(--primary, #1a56db); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06); }
.rp-row-icon { font-size: 1.6rem; line-height: 1; flex: none; width: 34px; text-align: center; }
.rp-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.rp-row-main b { font-size: 0.98rem; overflow-wrap: anywhere; }
.rp-row-main small { color: var(--gray-500, #6b7280); font-size: 0.8rem; line-height: 1.35; }
.rp-urgent-line { color: #b91c1c !important; font-weight: 650; }
.rp-item-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rp-more { margin-top: 12px; }
.rp-more summary { cursor: pointer; color: var(--gray-600, #4b5563); font-weight: 600; padding: 6px 0; }

/* Patient and adding pages */
.rp-patient-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 14px; margin-bottom: 12px; background: #fff; border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius-lg, 14px); }
.rp-patient-name { font-weight: 750; font-size: 1.02rem; }
.rp-patient-bar .btn { margin-left: auto; }
.rp-add { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rp-big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 108px; padding: 14px 10px; border: 2px dashed #93c5fd; border-radius: var(--radius-lg, 14px); background: #f8fbff; cursor: pointer; text-align: center; font: inherit; color: var(--gray-800, #1f2937); }
.rp-big:hover, .rp-big:focus-within { border-color: var(--primary, #1a56db); background: var(--rp-blue-bg); }
.rp-big span { font-size: 1.9rem; line-height: 1; }
.rp-big b { font-size: 1rem; }
.rp-big small { color: var(--gray-500, #6b7280); font-size: 0.78rem; }
.rp-camera { position: relative; margin-top: 12px; }
.rp-camera video { width: 100%; max-height: 62vh; background: #0f172a; border-radius: var(--radius-lg, 14px); display: block; object-fit: contain; }
.rp-frame { position: absolute; inset: 5% 8% auto; height: calc(min(62vh, 100%) * 0.82); border: 2px dashed rgba(255, 255, 255, 0.75); border-radius: 8px; pointer-events: none; }
.rp-tip { font-size: 0.82rem; color: var(--gray-600, #4b5563); margin: 8px 0; }
.rp-camera-actions, .rp-tray-actions, .rp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-camera-actions .btn-primary, .rp-tray-actions .btn-primary { flex: 1; min-width: 200px; }
.rp-tray { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200, #e5e7eb); }
.rp-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.rp-thumb { position: relative; margin: 0; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 10px; overflow: hidden; background: #fff; }
.rp-thumb img, .rp-pdf { display: block; width: 100%; height: 108px; object-fit: cover; }
.rp-pdf { display: grid; place-items: center; background: #fef2f2; color: #b91c1c; font-weight: 800; }
.rp-thumb figcaption { font-size: 0.7rem; padding: 3px 5px; color: var(--gray-600, #4b5563); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-thumb-remove { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(15, 23, 42, 0.75); color: #fff; cursor: pointer; font-size: 0.85rem; }
.rp-progress { display: flex; gap: 14px; align-items: center; }
.rp-spinner { width: 22px; height: 22px; flex: none; border: 3px solid var(--rp-blue-bg); border-top-color: var(--primary, #1a56db); border-radius: 50%; animation: rp-spin 0.9s linear infinite; }
@keyframes rp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rp-spinner { animation-duration: 3s; } }
.rp-cta { border-left: 4px solid var(--primary, #1a56db); }
.rp-cta textarea, .rp-reg input, .rp-change input, .rp-change textarea, .rp-reason input { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300, #d1d5db); border-radius: var(--radius, 10px); font: inherit; font-size: 0.95rem; }
.rp-cta textarea { margin-bottom: 10px; }
.rp-label { display: block; font-size: 0.85rem; font-weight: 650; margin-bottom: 4px; }
.rp-record-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin: 10px 0; border: 1px solid #bfdbfe; background: #f8fbff; border-radius: 10px; font-size: 0.86rem; }

/* One report: check values */
.rp-view-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.rp-view-head .rp-title { margin: 0; flex: 1; min-width: 160px; }
.rp-alert { display: block; padding: 11px 14px; border-radius: var(--radius, 10px); margin-bottom: 10px; line-height: 1.45; font-size: 0.9rem; }
.rp-alert[hidden] { display: none; }
.rp-alert p { margin: 6px 0 0; }
.rp-identity { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.rp-identity input { width: 22px; height: 22px; flex: none; margin-top: 2px; }
.rp-meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; font-size: 0.9rem; }
.rp-meta-line input[type="date"] { padding: 7px 9px; border: 1px solid var(--gray-300, #d1d5db); border-radius: 8px; font: inherit; }
.rp-check { display: grid; gap: 12px; }
.rp-page-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
.rp-page-tabs .btn { margin-left: auto; }
.rp-page-tab { padding: 6px 12px; border: 1px solid var(--gray-300, #d1d5db); border-radius: 999px; background: #fff; cursor: pointer; font-size: 0.8rem; font-weight: 600; }
.rp-page-tab.active { background: var(--primary, #1a56db); color: #fff; border-color: var(--primary, #1a56db); }
.rp-viewer { position: relative; max-height: 46vh; overflow: auto; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 10px; background: #f8fafc; }
.rp-viewer img { display: block; width: 100%; height: auto; min-height: 120px; }
.rp-viewer.rp-zoomed img { width: 200%; max-width: none; }
.rp-viewer.rp-zoomed { max-height: 70vh; }
.rp-mark { position: absolute; border: 3px solid #f59e0b; background: rgba(245, 158, 11, 0.18); border-radius: 4px; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25); pointer-events: none; }
.rp-viewer.rp-zoomed .rp-mark { transform-origin: 0 0; }
.rp-group { margin: 14px 0 6px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500, #6b7280); }
.rp-group:first-child { margin-top: 0; }
.rp-value, .rp-finding { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 4px 10px; padding: 10px; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 10px; margin-bottom: 6px; cursor: pointer; background: #fff; }
.rp-value:hover, .rp-finding:hover { border-color: #93c5fd; }
.rp-value.rp-selected, .rp-finding.rp-selected { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3); }
.rp-value.rp-flagged { border-left: 4px solid #f59e0b; background: #fffbeb; }
.rp-removed { opacity: 0.6; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rp-value-name { font-weight: 650; font-size: 0.92rem; overflow-wrap: anywhere; }
.rp-value-name small { display: block; font-weight: 500; color: var(--gray-500, #6b7280); font-size: 0.76rem; }
.rp-value-number { text-align: right; font-size: 0.92rem; }
.rp-value-number b { font-size: 1.05rem; }
.rp-value-number small { display: block; color: var(--gray-500, #6b7280); font-size: 0.72rem; }
.rp-edit { width: 7.5em; padding: 6px 8px; border: 2px solid var(--primary, #1a56db); border-radius: 8px; font: inherit; text-align: right; }
.rp-value-range { color: var(--gray-500, #6b7280); font-size: 0.8rem; }
.rp-value-tags { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.rp-value-note, .rp-value-actions { grid-column: 1 / -1; margin: 0; font-size: 0.82rem; }
.rp-value-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.rp-value-actions .btn.rp-on { background: var(--rp-green-bg); border-color: #86efac; color: #166534; }
.rp-finding { display: block; }
.rp-finding p { margin: 6px 0; font-size: 0.9rem; line-height: 1.45; }
.rp-hit { padding: 6px 9px; border-radius: 8px; }
.rp-footer { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; margin-top: 12px; background: rgba(255, 255, 255, 0.97); border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius-lg, 14px); box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.08); }
.rp-footer > span { flex: 1; min-width: 180px; font-size: 0.9rem; }
.rp-footer .btn-lg { min-width: 200px; }

/* Treatment update */
.rp-urgency b { font-size: 0.98rem; }
.rp-based { font-size: 0.85rem; color: var(--gray-600, #4b5563); margin: 0 0 12px; line-height: 1.5; }
.rp-summary { margin: 0; line-height: 1.55; }
.rp-problem, .rp-med { border: 1px solid var(--gray-200, #e5e7eb); border-radius: var(--radius-lg, 14px); padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.rp-problem-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.rp-problem-head b { font-size: 1rem; margin-right: 4px; }
.rp-evidence { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 5px; }
.rp-evidence li { display: flex; gap: 8px; font-size: 0.87rem; line-height: 1.45; }
.rp-evidence li > span:first-child { flex: none; width: 1.4em; text-align: center; }
.rp-evidence details { margin-top: 3px; color: var(--gray-600, #4b5563); }
.rp-evidence details p { margin: 3px 0; }
.rp-evidence-off { color: var(--gray-400, #9ca3af); }
.rp-evidence-off small { display: block; }
.rp-link { border: 0; background: none; padding: 0 0 0 4px; color: var(--primary, #1a56db); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.rp-med { border-left-width: 5px; }
.rp-med-ok { border-left-color: #22c55e; }
.rp-med-warn { border-left-color: #f59e0b; }
.rp-med-blocked { border-left-color: #ef4444; background: #fafafa; }
.rp-med header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.rp-med-name { font-size: 1.05rem; }
.rp-med header small { display: block; color: var(--gray-600, #4b5563); font-size: 0.86rem; margin-top: 2px; }
.rp-med p { margin: 6px 0; font-size: 0.9rem; line-height: 1.45; }
.rp-med-for .rp-chip { margin: 2px 2px 2px 0; }
.rp-med-facts { margin: 6px 0; }
.rp-med-facts summary { cursor: pointer; font-weight: 650; font-size: 0.86rem; color: var(--gray-700, #374151); }
.rp-checks { list-style: none; margin: 8px 0; padding: 8px 10px; background: var(--gray-50, #f9fafb); border-radius: 10px; display: grid; gap: 4px; font-size: 0.85rem; }
.rp-check-ok { color: #166534; }
.rp-check-warn { color: #92400e; font-weight: 600; }
.rp-check-block { color: #991b1b; font-weight: 700; }
.rp-med-hi { background: #f0fdf4; padding: 8px 10px; border-radius: 8px; font-size: 0.98rem !important; }
.rp-decide { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.rp-decide-btn { min-height: 46px; padding: 8px; border: 2px solid var(--gray-200, #e5e7eb); border-radius: 10px; background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.rp-decide-btn:hover { border-color: #93c5fd; }
.rp-decide-btn.active[data-decision="approve"] { background: var(--rp-green-bg); border-color: #22c55e; color: #166534; }
.rp-decide-btn.active[data-decision="change"] { background: var(--rp-blue-bg); border-color: #3b82f6; color: #1e40af; }
.rp-decide-btn.active[data-decision="reject"] { background: var(--gray-100, #f3f4f6); border-color: #6b7280; color: #374151; }
.rp-change { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; padding: 10px; background: #f8fbff; border-radius: 10px; }
.rp-change label, .rp-reason, .rp-reg { display: grid; gap: 4px; font-size: 0.8rem; font-weight: 650; color: var(--gray-700, #374151); }
.rp-wide { grid-column: 1 / -1; }
.rp-reason { margin-top: 8px; }
.rp-outcome { margin-top: 8px !important; }
.rp-extras { display: grid; gap: 4px; }
.rp-extra h4 { margin: 6px 0 4px; font-size: 0.9rem; }
.rp-extra ul { margin: 0; padding-left: 20px; font-size: 0.9rem; line-height: 1.5; }
.rp-sign .rp-reg { flex: 1; min-width: 200px; }
/* The doctor signs after reading every medicine, so the sign-off sits at the end instead of floating over them. */
.rp-footer.rp-sign { position: static; box-shadow: none; border-color: #c7d2fe; background: #f8faff; }

/* Hindi first (what the doctor reads), English smaller under it (the record). */
.rp-bi { display: inline; }
.rp-bi .rp-en { display: block; color: var(--gray-500, #6b7280); font-size: 0.82em; font-weight: 400; margin-top: 1px; }
b.rp-bi .rp-hi, .rp-med-title .rp-hi { font-weight: 700; }
.rp-title small, .rp-basis summary small, .rp-again summary small { color: var(--gray-500, #6b7280); font-weight: 500; font-size: 0.8em; }
.rp-summary-card p { margin: 0; line-height: 1.6; font-size: 1rem; }
.rp-med-title { font-size: 1.05rem; }
.rp-med-dose { color: var(--gray-600, #4b5563); font-size: 0.86rem !important; margin: 2px 0 !important; }
.rp-med-why { margin: 6px 0; font-size: 0.9rem; line-height: 1.45; }
.rp-med > .rp-check-warn, .rp-med > .rp-check-block { margin: 4px 0; padding: 6px 10px; border-radius: 8px; font-size: 0.86rem; background: #fffbeb; }
.rp-med > .rp-check-block { background: #fef2f2; }
.rp-med-checks { margin: 6px 0; }
.rp-med-checks summary, .rp-basis > summary, .rp-again > summary { cursor: pointer; font-weight: 650; font-size: 0.86rem; color: var(--gray-700, #374151); }
.rp-basis > summary, .rp-again > summary { font-size: 0.95rem; padding: 2px 0; }
.rp-basis[open] > summary, .rp-again[open] > summary { margin-bottom: 10px; }
.rp-referral { border-left: 5px solid #f59e0b; }
.rp-referral p { margin: 4px 0; }
.rp-again textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300, #d1d5db); border-radius: var(--radius, 10px); font: inherit; margin-bottom: 8px; }

.rp-modal { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, 0.65); display: grid; place-items: center; padding: 16px; }
.rp-modal-box { position: relative; width: min(900px, 100%); max-height: 92vh; background: #fff; border-radius: 14px; padding: 44px 10px 10px; }
.rp-modal-close { position: absolute; top: 6px; right: 6px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--gray-100, #f3f4f6); font-size: 1rem; cursor: pointer; }
.rp-viewer-modal { max-height: calc(92vh - 60px); }

@media (min-width: 900px) {
    .rp-check { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
    .rp-viewer-card { position: sticky; top: 72px; }
    .rp-viewer { max-height: calc(100vh - 230px); }
}
@media (max-width: 720px) {
    .rp-footer { position: static; box-shadow: none; }
}
@media (max-width: 560px) {
    .rp-add { grid-template-columns: 1fr 1fr; gap: 8px; }
    .rp-big { min-height: 96px; }
    .rp-row, .rp-item { flex-wrap: wrap; }
    .rp-item-actions { width: 100%; justify-content: space-between; }
    .rp-patient-bar .btn { margin-left: 0; }
    .rp-change { grid-template-columns: 1fr; }
    .rp-decide-btn { font-size: 0.85rem; padding: 6px 4px; }
    .rp-footer .btn-lg, .rp-camera-actions .btn-primary, .rp-tray-actions .btn-primary { width: 100%; min-width: 0; }
}
@media print { #page-reports .rp-footer, #page-reports .rp-add-card { display: none; } }
