* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, 'Segoe UI', Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, [onclick] { touch-action: manipulation; }
html, body { height: 100%; background: #f3f4f6; overscroll-behavior-y: contain; }

.screen { min-height: 100vh; }

/* ==== Đăng nhập / Tra cứu ==== */
#phoneScreen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 32px 24px; width: 100%; max-width: 360px;
  text-align: center; box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}
.login-card .brand { margin-bottom: 4px; }
.login-card .brand-logo { width: 64px; height: 64px; }
.switch-mode-link { margin-top: 16px; font-size: 13px; color: #ea580c; cursor: pointer; text-decoration: underline; }
.login-card .brand-icon { width: 48px; height: 48px; margin: 0 auto; color: #ea580c; }
.login-card .brand-icon svg { width: 100%; height: 100%; }
.login-card .brand-title { font-size: 20px; color: #ea580c; font-weight: 700; margin-bottom: 2px; }
.tab-icon { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 5px; }
.tab-icon svg { width: 100%; height: 100%; }
.login-card .sub { color: #6b7280; font-size: 13px; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 13px 14px; margin-bottom: 12px; border: 1px solid #d1d5db;
  border-radius: 10px; font-size: 15px; -webkit-appearance: none;
}
.btn-primary {
  width: 100%; padding: 13px; background: #ea580c; color: #fff; border: none;
  border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-secondary {
  width: 100%; padding: 13px; background: #e5e7eb; color: #111827; border: none;
  border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card .link { color: #ea580c; font-size: 13px; margin-top: 14px; cursor: pointer; text-decoration: underline; }
.login-card .error { color: #dc2626; font-size: 13px; margin-top: 10px; min-height: 16px; }
.login-card .hint { color: #6b7280; font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ==== Ứng dụng chính (khung kết quả) - giống hệt .login-card: canh giữa, bo góc, đổ bóng ==== */
#mainScreen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 20px;
}
.app-card {
  background: #fff; border-radius: 16px; width: 100%; max-width: 420px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
  overflow: hidden;
}
.app-header {
  background: #ea580c; color: #fff; padding: 16px 18px; display: flex;
  justify-content: space-between; align-items: center; flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}
.doctor-name { font-weight: 700; font-size: 16px; }
.doctor-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.icon-btn { background: rgba(255,255,255,0.15); color: #fff; border: none; padding: 8px 12px; border-radius: 8px; font-size: 12px; }

.app-content { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }

.rec-card {
  background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); display: flex; justify-content: space-between; align-items: center;
}
.rec-info .rec-code { font-weight: 700; font-size: 14px; color: #111827; }
.rec-info .rec-patient { font-size: 13px; color: #374151; margin-top: 2px; }
.rec-info .rec-date { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.rec-status { font-size: 11px; padding: 4px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.rec-status.ready { background: #ffedd5; color: #9a3412; }
.rec-status.pending { background: #fef9c3; color: #854d0e; }
.rec-status.abnormal { background: #fee2e2; color: #991b1b; }

.detail-card { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.detail-card h4 { color: #ea580c; font-size: 14px; margin-bottom: 8px; }
table.result-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.result-table th, table.result-table td { padding: 7px 6px; border-bottom: 1px solid #f0f0f0; text-align: left; }
table.result-table tr.abnormal td { color: #b91c1c; font-weight: 700; background: #fef2f2; }
.back-link {
  display: inline-block; margin-bottom: 12px; color: #fff; font-size: 13px; cursor: pointer; font-weight: 600;
  background: #ea580c; padding: 6px 14px; border-radius: 20px;
}
.pdf-btn { display: block; text-align: center; background: #ea580c; color: #fff; padding: 12px; border-radius: 10px; margin-top: 10px; text-decoration: none; font-weight: 600; font-size: 14px; }

.summary-row { display: flex; gap: 10px; margin-bottom: 14px; }
.summary-box { flex: 1; background: #fff; border-radius: 12px; padding: 14px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.summary-box .num { font-size: 18px; font-weight: 700; color: #ea580c; }
.summary-box .label { font-size: 11px; color: #6b7280; margin-top: 4px; }

.empty-state {
  text-align: center; color: #fff; padding: 40px 20px; font-size: 14px;
  background: linear-gradient(160deg, #fb923c, #ea580c); border-radius: 12px; margin: 10px 0;
}
.install-banner {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; color: #92400e; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.install-banner button { background: #d97706; color: #fff; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; flex-shrink: 0; }

/* ==== Safe-area cho điện thoại có notch/thanh cử chỉ ==== */
.app-header { padding-top: calc(16px + env(safe-area-inset-top)); }
.app-content { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.login-screen, #loginScreen, #otpScreen, #phoneScreen {
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

/* input tối thiểu 16px để tránh iOS tự phóng to khi focus */
input, select, textarea { font-size: 16px; }
