/* Card Scanner — clinical, uncluttered, arm's-length readable. */

:root {
  --brand: #1e5aa8;
  --brand-dark: #16406f;
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #1b2733;
  --ink-soft: #4a5a6a;
  --line: #d4dee9;
  --green: #1a7f37;
  --green-bg: #e2f2e6;
  --amber: #8a5a00;
  --amber-bg: #fff3cd;
  --amber-border: #d9a400;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --blue-bg: #e3edf9;
  --gray-bg: #eef1f4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  background: var(--brand);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 0;
}
.app-header h1 { margin: 0; font-size: 22px; font-weight: 700; }
.app-header .tagline { margin: 2px 0 0; font-size: 14px; opacity: 0.85; }

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
}
.header-user { text-align: right; font-size: 14px; }
.header-user span { display: block; opacity: 0.9; }
.logout-btn {
  background: none;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 0;
  min-height: 32px;
}

/* Role-aware nav bar */
.nav-bar {
  display: flex;
  gap: 4px;
  max-width: 1100px;
  margin: 10px auto 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-btn {
  background: none;
  border: none;
  border-bottom: 4px solid transparent;
  color: rgba(255, 255, 255, 0.8);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 14px 12px;
  min-height: 48px;
  cursor: pointer;
  white-space: nowrap;
}
.nav-btn.active { color: #fff; border-bottom-color: #fff; }

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

h2 { font-size: 24px; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 20px 0 8px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }

.help-text { color: var(--ink-soft); font-size: 15px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }

/* Buttons — big touch targets */
.big-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  margin: 12px 0;
  font-size: 19px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 12px;
  border: 2px solid var(--brand);
  background: var(--card);
  color: var(--brand);
  cursor: pointer;
}
.big-btn.primary { background: var(--brand); color: #fff; }
.big-btn.primary:active { background: var(--brand-dark); }
.big-btn.secondary { border-style: dashed; color: var(--ink-soft); border-color: var(--line); }
.big-btn:disabled { opacity: 0.45; cursor: default; }

.small-btn {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 16px;
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid var(--brand);
  background: var(--card);
  color: var(--brand);
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: var(--brand);
  font-family: inherit;
  font-size: 17px;
  padding: 10px 4px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
}

/* Forms */
input[type="password"], input[type="text"], input[type="search"] {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font-size: 19px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  margin-bottom: 8px;
}
input:focus { outline: 3px solid rgba(30, 90, 168, 0.4); outline-offset: 1px; }

/* Messages */
.msg { padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.msg-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

/* Capture previews */
.capture-slot { margin-bottom: 4px; }
.preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin: 12px 0;
}
.preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.preview-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.preview-label { font-weight: 700; color: var(--ink-soft); margin-right: auto; }

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.loading-overlay[hidden] { display: none; }
.loading-card {
  background: var(--card);
  border-radius: 14px;
  padding: 28px 36px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}
.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border: 5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result */
.result-head { margin-bottom: 10px; }
.result-head h2 { font-size: 28px; margin: 6px 0 2px; }
.plan-section { margin: 0 0 6px; color: var(--ink-soft); font-weight: 600; letter-spacing: 0.04em; font-size: 14px; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.03em;
}
.badge-high { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.badge-medium { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge-low { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

.staff-message {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 19px;
  font-weight: 600;
}

.flags { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.flag-chip {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 15px;
}

.verify-box {
  background: var(--amber-bg);
  border: 2px solid var(--amber-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
}
.verify-box h3 { margin: 0 0 8px; color: var(--amber); }
.verify-box p { margin: 6px 0; }
.alt-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.alt-chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--brand);
  background: var(--card);
  color: var(--brand);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.alt-chip-plain { border-color: var(--line); color: var(--ink-soft); cursor: default; }

.evidence { margin: 4px 0 0; padding-left: 22px; }
.evidence li { margin-bottom: 4px; }

/* Matrix table */
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 15px;
  margin-top: 8px;
}
.matrix-table th, .matrix-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.matrix-table thead th {
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  position: sticky;
  top: 0;
}
.matrix-table tbody th { font-weight: 600; width: 38%; }
.matrix-table tr:last-child th, .matrix-table tr:last-child td { border-bottom: none; }

.rec-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 700;
  white-space: normal;
}
.rec-obl { background: var(--green-bg); color: var(--green); }
.rec-asc { background: var(--blue-bg); color: var(--brand-dark); }
.rec-neutral { background: var(--gray-bg); color: var(--ink-soft); }
.rec-hosp { background: var(--red-bg); color: var(--red); }
.rec-muted { background: none; color: #93a3b3; }
.rec-plain { background: none; color: var(--ink); font-weight: 400; }

.diff-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.note-row td { font-size: 13.5px; color: var(--ink-soft); background: #f8fafc; }
.note-row th { font-size: 13.5px; color: var(--ink-soft); background: #f8fafc; }

.legend { margin-top: 10px; }
.legend p { margin: 4px 0; font-size: 12.5px; color: var(--ink-soft); }

/* Pre-auth */
.preauth-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 16px 0;
}
.preauth-panel h3 { margin-top: 0; }
.preauth-pending { color: var(--amber); font-weight: 600; }

/* Browse */
.browse-list { margin-top: 8px; }
.browse-group-title {
  margin: 18px 0 6px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.plan-row-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 16px;
  margin-bottom: 8px;
  font-size: 18px;
  font-family: inherit;
  color: var(--ink);
  min-height: 52px;
  cursor: pointer;
}
.plan-row-btn:active { background: var(--blue-bg); }
.browse-empty { color: var(--ink-soft); padding: 12px 4px; }

/* Footer */
.app-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border-top: 1px solid var(--line);
  text-align: center;
}
.app-footer nav { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.built-line { color: var(--ink-soft); font-size: 13px; margin: 4px 0 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* ===================== v2 additions ===================== */

/* Wide desktop layout for queue / detail / admin */
body.wide main { max-width: none; margin-left: 24px; margin-right: 24px; }

.msg-ok { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.saved-banner { margin: 0 0 12px; }
.result-patient { font-weight: 700; font-size: 18px; margin: 0 0 6px; color: var(--ink-soft); }

/* Extra form controls */
select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font-size: 17px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  margin-bottom: 8px;
}
textarea { resize: vertical; }
select:focus, textarea:focus { outline: 3px solid rgba(30, 90, 168, 0.4); outline-offset: 1px; }

/* Patient fields (scan + no-card + admin) */
.patient-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  margin-bottom: 4px;
}
.patient-field { flex: 1 1 180px; min-width: 150px; }
.patient-field-wide { flex: 2 1 280px; }
.patient-field-narrow { flex: 0 1 110px; min-width: 90px; }
input[type="date"] {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font-size: 18px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  margin-bottom: 8px;
  -webkit-appearance: none;
  appearance: none;
}

/* Queue */
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.queue-head h2 { margin: 0; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filter-chip {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.queue-list { margin-top: 4px; }
.queue-row {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}
.queue-row:active, .queue-row:hover { background: var(--blue-bg); }
.queue-row-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.queue-name { font-size: 18px; font-weight: 700; }
.queue-dob { color: var(--ink-soft); font-size: 15px; }
.queue-row-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; }
.queue-plan { font-weight: 600; font-size: 15px; }
.queue-by { color: var(--ink-soft); font-size: 13.5px; margin-left: auto; }
.badge-small { font-size: 12px; padding: 2px 8px; }

.status-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.status-new { background: var(--blue-bg); color: var(--brand-dark); border: 1px solid var(--brand); }
.status-verified { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.status-corrected { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.status-rejected { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

.kind-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.kind-card { background: var(--gray-bg); color: var(--ink-soft); border: 1px solid var(--line); }
.kind-discovery { background: #efe6fb; color: #5b2d91; border: 1px solid #a97fd8; }

/* Queue detail — two-column on desktop, stacked on iPad portrait */
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 8px 0 16px; }
.detail-grid { display: block; }
@media (min-width: 900px) {
  .detail-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
  }
}
.detail-photos { display: flex; flex-direction: column; gap: 12px; }
.detail-photo {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}
.detail-photo img {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: #000;
}
.detail-photo figcaption { margin-top: 6px; font-weight: 700; color: var(--ink-soft); font-size: 14px; }
.detail-plan-name { margin: 6px 0 2px; font-size: 24px; color: var(--ink); text-transform: none; letter-spacing: 0; }

.demo-list { margin: 4px 0 12px; }
.demo-list dt { font-weight: 700; font-size: 13.5px; color: var(--ink-soft); margin-top: 6px; }
.demo-list dd { margin: 0; }

/* Review form */
.review-form, .review-readonly {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
}
.status-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.status-btn {
  flex: 1 1 120px;
  min-height: 52px;
  padding: 10px 16px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  background: var(--card);
}
.status-btn-verified { border: 2px solid var(--green); color: var(--green); }
.status-btn-verified.selected { background: var(--green); color: #fff; }
.status-btn-corrected { border: 2px solid var(--amber-border); color: var(--amber); }
.status-btn-corrected.selected { background: var(--amber-border); color: #fff; }
.status-btn-rejected { border: 2px solid var(--red); color: var(--red); }
.status-btn-rejected.selected { background: var(--red); color: #fff; }

.review-fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px 14px;
  margin: 14px 0;
}
.review-fieldset legend { font-weight: 800; font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 6px; }
.check-inline { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 44px; cursor: pointer; }
.check-inline input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--brand); }
.field-block { margin: 10px 0; }
.picked-plan { font-weight: 700; color: var(--brand-dark); margin: 4px 0 8px; }

/* Plan picker */
.plan-picker { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--bg); }
.plan-picker input[type="search"] { margin-bottom: 6px; min-height: 44px; font-size: 16px; }
.plan-picker-list { max-height: 260px; overflow-y: auto; }
.plan-pick-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 6px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  min-height: 44px;
  cursor: pointer;
}
.plan-pick-btn:hover, .plan-pick-btn:active { background: var(--blue-bg); }
.plan-pick-btn.selected { border-color: var(--brand); background: var(--blue-bg); font-weight: 700; }
.plan-pick-clear { color: var(--ink-soft); font-style: italic; }

/* Discovery checklist (no-card flow) */
.checklist { margin: 8px 0 16px; }
.check-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.check-row.is-done { border-color: var(--green); background: #f4faf5; }
.check-head { display: flex; align-items: flex-start; gap: 10px; }
.check-done-box { flex: 0 0 auto; min-height: 0; }
.check-done-box input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--green); }
.check-num { font-weight: 800; color: var(--ink-soft); }
.check-title { flex: 1 1 auto; font-weight: 700; font-size: 16px; }
.found-toggle {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.found-toggle.on { border-color: var(--green); background: var(--green); color: #fff; }
.check-body { margin-top: 8px; }
.check-portal { margin: 0 0 4px; font-weight: 600; font-size: 14.5px; }
.check-need { margin: 0 0 4px; font-size: 14px; color: var(--ink-soft); }
.check-covers { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-soft); }
.check-notes-input { min-height: 44px; font-size: 16px; }

/* Read-only checklist state in queue detail */
.check-readonly-list { margin: 4px 0 12px; }
.check-readonly {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.check-readonly:last-child { border-bottom: none; }
.check-mark {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: var(--gray-bg);
  border-radius: 6px;
  padding: 2px 8px;
}
.check-found .check-mark { background: var(--green); color: #fff; }
.check-done .check-mark { background: var(--blue-bg); color: var(--brand-dark); }
.check-label { flex: 1 1 240px; }
.check-notes { flex: 1 1 100%; color: var(--ink-soft); font-style: italic; }

/* Admin */
.user-list { margin: 8px 0 20px; }
.user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.user-row.user-inactive { opacity: 0.6; }
.user-info { flex: 1 1 240px; }
.user-meta { color: var(--ink-soft); font-size: 14.5px; }
.user-actions { display: flex; gap: 8px; }
.reset-form { flex: 1 1 100%; display: flex; gap: 8px; align-items: center; }
.reset-form input { flex: 1 1 auto; margin-bottom: 0; min-height: 44px; font-size: 16px; }
.adduser-form { max-width: 720px; }

/* ===================== v3 additions ===================== */

/* Authorization chip in queue rows */
.auth-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.auth-pending { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.auth-approved { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.auth-denied { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.auth-not_required { background: var(--gray-bg); color: var(--ink-soft); border: 1px solid var(--line); }

/* Authorization card (queue detail) */
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
}
.auth-card h3 { margin-top: 0; }
.seg-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 12px; }
.seg-btn {
  flex: 1 1 90px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.seg-btn.selected { border-color: var(--brand); background: var(--brand); color: #fff; }
.auth-updated { color: var(--ink-soft); font-size: 13.5px; margin: 8px 0 0; }

/* Lock screen (shared scan stations) */
.lock-roster { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.lock-user-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 64px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 2px solid var(--brand);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 20px;
  text-align: left;
  cursor: pointer;
}
.lock-user-btn:active { background: var(--blue-bg); }
.lock-username { color: var(--ink-soft); font-size: 14px; }
.lock-selected { font-weight: 700; font-size: 19px; margin: 4px 0 10px; }

/* Change password (forced rotation + self-service) */
#sec-changepw form { max-width: 420px; }
#sec-changepw .field-label { margin-top: 14px; }
#sec-changepw .help-text { margin: 10px 0 0; }
#sec-changepw .big-btn { margin-top: 16px; }
#cpw-help { margin: 0 0 14px; }

/* Footer links (change password, device settings) */
.footer-link {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  min-height: 32px;
}
.device-settings {
  text-align: left;
  max-width: 480px;
  margin: 8px auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.device-settings .help-text { font-size: 13px; margin: 6px 0 0; }

/* ---------- green sheet ---------- */
.gs-fieldset { border: 1px solid var(--border, #ccc); border-radius: 8px; margin: 12px 0; padding: 10px 14px; }
.gs-fieldset legend { font-weight: 600; padding: 0 6px; }
.gs-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 6px 0; }
.gs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 26px; }
.gs-grid > .gs-col { min-width: 0; }
.gs-col h4 { margin: 8px 0 4px; font-size: 0.85em; letter-spacing: 0.04em; }
.gs-col-wide { grid-column: span 2; }
/* one selectable item per row inside its column — cross-column overlap is
   structurally impossible (block-level, min-width:0). Labels wrap at spaces
   only (overflow-wrap:anywhere crushed short labels to one char per line). */
.gs-chip { display: flex; align-items: flex-start; gap: 6px; padding: 2px 4px;
  min-width: 0; white-space: normal; overflow-wrap: normal; word-break: normal;
  line-height: 1.35; }
/* control rows (flags, dates, selects): labels NEVER wrap */
.gs-row .gs-chip { display: inline-flex; white-space: nowrap; }
.gs-chip input { margin: 3px 0 0; flex: none; }
.gs-urgent { color: #b00020; font-weight: 600; }
.gs-imaging-row { display: flex; gap: 8px; align-items: center; margin: 2px 0; flex-wrap: wrap; }
.gs-pick { display: block; margin: 4px 0; text-align: left; }
.gs-chosen { font-weight: 600; }

/* venue panel + soft block */
.gs-venue-panel { border-left: 4px solid #2a5aa8; padding: 6px 10px; margin: 8px 0; background: rgba(42,90,168,0.06); }
.gs-venue-ok { margin: 2px 0; }
.gs-venue-diverge { margin: 2px 0; color: #b00020; font-weight: 600; }
.gs-override { border: 2px solid #b00020; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.gs-override-btn { margin-right: 8px; }

/* payer-ready print replica */
#print-sheet { display: none; }
@media print {
  body.printing > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block; font: 12px/1.5 -apple-system, "Helvetica Neue", Arial, sans-serif; color: #000; padding: 24px; }
  #print-sheet .ps-red { color: #b00020; font-weight: 700; }
  #print-sheet .ps-title { font-size: 16px; font-weight: 700; margin: 8px 0; }
  #print-sheet .ps-strong { font-weight: 700; margin-top: 8px; }
  #print-sheet .ps-attest { margin-top: 24px; border-top: 1px solid #000; padding-top: 6px; font-style: italic; }
  #print-sheet div { margin: 3px 0; }
}

/* schedule status colors */
.sched-date { margin: 14px 0 4px; }
tr.sched-green td { background: rgba(46,125,50,0.10); }
tr.sched-yellow td { background: rgba(245,166,35,0.14); }
tr.sched-red td { background: rgba(176,0,32,0.12); }


/* schedule legend */
.sched-legend { font-size: 0.9em; margin: 4px 0 10px; }
.sched-key { padding: 2px 8px; border-radius: 6px; }
.sched-key-green { background: rgba(46,125,50,0.10); }
.sched-key-yellow { background: rgba(245,166,35,0.14); }
.sched-key-red { background: rgba(176,0,32,0.12); }

/* schedule: spreadsheet behavior — cells NEVER wrap, columns size to content,
   the container scrolls horizontally (Excel-style). */
#schedule-list { overflow-x: auto; }
#schedule-list table { width: max-content; min-width: 100%; border-collapse: collapse; }
#schedule-list td, #schedule-list th { font-size: 0.85em; padding: 4px 8px; white-space: nowrap; text-align: left; }
#schedule-list td.sched-notes { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

/* bilateral units toggle on selected CPT chips */
.gs-x2 { margin-left: 6px; padding: 0 6px; font-size: 0.85em; border-radius: 8px; cursor: pointer; }

/* date inputs inside control chips: fixed width, never crowd their label */
.gs-chip input[type="date"] { width: 160px; flex: none; }
/* Control-row chips (Flags & target date, schedule controls): the date input
   inherits the app's fat touch-target padding (52px tall vs 13px checkboxes),
   which made the "Target DOS" chip tower over its neighbors (user report
   2026-08-06). Compact the inline date/select controls and center the row. */
.gs-row .gs-chip { align-items: center; }
.gs-row .gs-chip input { margin: 0; }
.gs-chip input[type="date"],
.gs-chip select,
.gs-chip input[type="search"] { padding: 3px 6px; font-size: 0.95rem; min-height: 36px; }

/* ---------- orders queue (two-track badges) ---------- */
.sched-scroll { overflow-x: auto; }
.orders-table td { vertical-align: middle; }
.orders-table input[type="date"] { width: 140px; }
.q-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.q-green { background: rgba(46,125,50,0.10); }
.q-yellow { background: rgba(245,166,35,0.14); }
.q-pink { background: rgba(176,0,32,0.12); }
.routing-body { margin: 8px 0; }
.routing-body .primary { margin-top: 8px; }

/* ---------- OBL vs ASC matrix tab ---------- */
.mx-table th, .mx-table td { white-space: nowrap; }
.mx-grid { width: max-content; }
.mx-grid td, .mx-grid th { font-size: 0.85rem; padding: 4px 8px; }
.mx-sticky { position: sticky; left: 0; background: var(--card, #fff); text-align: left; z-index: 1; }
.mx-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; }
.mx-asc, td.mx-asc { background: rgba(46,125,50,0.12); }
.mx-obl, td.mx-obl { background: rgba(21,101,192,0.12); }
.mx-comp, td.mx-comp { background: rgba(120,120,120,0.12); }
.mx-hosp, td.mx-hosp { background: rgba(123,31,162,0.12); }
.mx-split, td.mx-split { background: rgba(245,166,35,0.16); }
.mx-none, td.mx-none { color: #888; }
.mx-legend-line { font-size: 0.85rem; color: var(--muted, #555); }
.mx-methodology p { font-size: 0.85rem; margin: 4px 0; }
#matrix-body details { margin-top: 12px; }

/* practice branding */
.brand-row { display: flex; align-items: center; gap: 12px; }
.hdr-logo { height: 44px; width: auto; }
.login-logo { display: block; margin: 8px auto 4px; height: 140px; width: auto; }
@media print { #print-sheet .ps-logo { display: block; height: 64px; margin-bottom: 6px; } }
.hdr-logo, .login-logo { border-radius: 8px; }
