/* AM EYES web app — base stylesheet */

* { box-sizing: border-box; }

:root {
  --color-primary: #1F4E79;
  --color-primary-dark: #163961;
  --color-primary-light: #E8F0FE;
  --color-text: #1a1a1a;
  --color-text-muted: #666;
  --color-text-faint: #999;
  --color-border: #e1e4e8;
  --color-bg: #f6f8fa;
  --color-card-bg: #ffffff;
  --color-urgent: #d62828;
  --color-urgent-bg: #ffe5e5;
  --color-review: #f9a825;
  --color-review-bg: #fff8e1;
  --color-success: #2e7d32;
  --color-error: #c62828;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top nav ---------- */
.topnav {
  background: var(--color-primary);
  color: white;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.nav-brand a {
  color: white;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
}
.nav-brand a:hover { text-decoration: none; opacity: 0.9; }
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-links a {
  color: rgba(255,255,255,0.85);
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 14px;
}
.nav-links a:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  text-decoration: none;
}
.nav-links a.active {
  background: rgba(255,255,255,0.15);
  color: white;
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}
.nav-user .user-name { font-weight: 500; }
.logout-link {
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 4px 12px;
  border-radius: 4px;
}
.logout-link:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  text-decoration: none;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
}
.page-title {
  margin: 0 0 8px 0;
  font-size: 26px;
  font-weight: 600;
  color: var(--color-text);
}
.page-subtitle {
  margin: 0 0 24px 0;
  color: var(--color-text-muted);
  font-size: 14px;
}
.section {
  margin-top: 32px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.section h2 {
  margin: 0 0 16px 0;
  font-size: 17px;
  font-weight: 600;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 { margin: 0; }
footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--color-text-faint);
  font-size: 12px;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-num {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-primary);
}
.card-label {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.card-link {
  font-size: 13px;
  display: inline-block;
  margin-top: 8px;
}

.card-row {
  display: flex;
  gap: 16px;
  margin: 24px 0;
}
.mini-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  flex: 1;
  min-width: 140px;
}
.mini-card.mini-urgent { border-left: 3px solid var(--color-urgent); }
.mini-card.mini-review { border-left: 3px solid var(--color-review); }
.mini-num { font-size: 24px; font-weight: 700; color: var(--color-primary); }
.mini-label { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  background: white;
  color: var(--color-text);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover {
  background: var(--color-bg);
  text-decoration: none;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  color: white;
}
.btn-primary:disabled {
  background: #b0b8c4;
  border-color: #b0b8c4;
  color: white;
  cursor: not-allowed;
}
.btn-danger {
  color: var(--color-urgent);
  border-color: #f5c6c6;
}
.btn-danger:hover {
  background: #fff0f0;
  border-color: var(--color-urgent);
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; font-weight: 600; }
.btn-group { display: inline-flex; gap: 8px; align-items: center; }

/* ---------- Preferences UI ---------- */
.prefs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.prefs-card {
  display: block;
  padding: 18px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.prefs-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.prefs-card-wide { max-width: 100%; }
.prefs-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.prefs-card-head h3 { margin: 0; font-size: 16px; }
.prefs-card-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 8px;
}
.prefs-card-stats div { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 22px; font-weight: 600; }
.stat-nb { color: var(--color-urgent); }
.stat-lbl { font-size: 11px; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.prefs-card-foot {
  font-size: 12px;
  color: var(--color-text-faint);
  margin: 8px 0 0 0;
}
.prefs-form { margin-top: 16px; }
.prefs-meta-block {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.prefs-meta-block label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
}
.prefs-meta-block input[type="number"] { width: 100px; padding: 6px 8px; }
.prefs-meta-block .hint { display: block; margin-top: 6px; font-size: 12px; }
.prefs-table-wrapper { overflow-x: auto; }
.prefs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.prefs-table th {
  background: #f5f5f5;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-faint);
  border-bottom: 1px solid var(--color-border);
}
.prefs-table td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); }
.prefs-table tr:last-child td { border-bottom: none; }
.prefs-cat-label { font-weight: 500; }
.prefs-row-nb { background: #fafafa; opacity: 0.65; }
.prefs-row-nb .prefs-cat-label { text-decoration: line-through; }
.prefs-tests-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
}
.prefs-tests-input:focus { outline: none; border-color: var(--color-primary); }
.prefs-tests-input:disabled { background: #f5f5f5; color: #999; }
.prefs-nb-checkbox { width: 18px; height: 18px; cursor: pointer; }
.prefs-urgent-textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  resize: vertical;
}
.prefs-save-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  padding: 16px 0;
  margin-top: 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 12px;
  z-index: 10;
}

/* v10.23 — restore-from-defaults section + broken-seed indicator on cards */
.prefs-danger-zone {
  margin-top: 40px;
  padding: 16px 20px;
  border: 1px solid #f0c04a;
  border-radius: var(--radius);
  background: #fffaf0;
}
.prefs-danger-zone h3 {
  margin: 0 0 6px 0;
  color: #855e10;
  font-size: 15px;
}
.prefs-danger-zone p {
  margin: 0 0 12px 0;
  font-size: 13px;
}
.btn-warn {
  background: #fff4e0;
  border-color: #e0c08a;
  color: #855e10;
}
.btn-warn:hover {
  background: #ffe9c2;
  border-color: #c89a55;
}
.stat-num.stat-warn {
  color: #c4730d;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ---------- Roster / metadata strip / alerts ---------- */
.prefs-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 10px 0 18px 0;
  padding: 10px 14px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
}
.prefs-card-meta {
  margin: -6px 0 10px 0;
  font-size: 12px;
}
.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 13px;
  line-height: 1.5;
}
.alert-warn {
  background: #fff8e6;
  border: 1px solid #f0c04a;
  color: #6b4f0b;
}
.alert ul { margin: 8px 0 0 18px; padding: 0; }
.row-inactive { opacity: 0.55; background: #fafafa; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge-success { background: #e6f4ea; color: #1d6e3a; }
.badge-warn { background: #fff5cf; color: #6b4f0b; }
.inline-edit-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.inline-edit-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.inline-edit-form input, .inline-edit-form select {
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}
.add-doctor-form .add-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.add-doctor-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
}
.add-doctor-form input, .add-doctor-form select {
  padding: 6px 9px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
}
/* Modal */
.modal-hidden { display: none; }
[data-modal].modal-hidden { display: none; }    /* beat [data-modal]'s display: flex */
[data-modal] {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: #fff;
  padding: 24px 28px;
  border-radius: var(--radius);
  max-width: 460px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-card h3 { margin: 0 0 12px 0; }
.modal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin: 12px 0;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ---------- Audit log viewer ---------- */
.audit-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  padding: 14px 16px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.audit-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
}
.audit-filters input, .audit-filters select {
  padding: 6px 9px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  min-width: 150px;
}
.audit-table .ts { font-size: 11px; color: var(--color-text-faint); }
.audit-entity { font-size: 12px; color: var(--color-text-faint); margin-bottom: 4px; }
.audit-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--color-primary);
  user-select: none;
}
.audit-details pre {
  background: #f9f9f9;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
  margin: 8px 0 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.pagination {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}

/* ---------- User/role chips + user-menu + modal labels ---------- */
.role-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}
.role-admin  { background: #fef0e2; color: #a64500; }
.role-editor { background: #e1efff; color: #1a5fb4; }
.role-viewer { background: #ececec; color: #555; }
.user-menu-link {
  text-decoration: none;
  padding: 2px 8px;
  margin: 0 4px;
  color: var(--color-text-faint);
  font-size: 15px;
}
.user-menu-link:hover { color: var(--color-primary); }
.modal-label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 4px;
}

/* ---------- AI preferences editor ---------- */
.prefs-card-ai {
  background: linear-gradient(135deg, #f3f0ff 0%, #fff 60%);
  border: 1px solid #d4caff;
}
.prefs-card-ai:hover {
  border-color: #9b87f5;
}
.ai-examples {
  margin: 14px 0 20px 0;
  padding: 12px 16px;
  background: #f8f7ff;
  border: 1px solid #e6e0ff;
  border-radius: var(--radius);
  font-size: 13px;
}
.ai-examples ul {
  margin: 4px 0 0 18px;
  padding: 0;
  color: var(--color-text-faint);
}
.ai-examples li {
  margin: 4px 0;
  font-style: italic;
}
.ai-status-area:not(:empty),
.ai-result-area:not(:empty) {
  margin: 16px 0;
}
.ai-plan-area {
  margin-top: 24px;
}
.ai-plan-table td {
  vertical-align: top;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}
.ai-plan-table tr:hover {
  background: #fafafa;
}
.action-toggle {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin-top: 2px;
}
.old-val {
  display: inline-block;
  padding: 1px 6px;
  background: #fde8e8;
  color: #8a3d3d;
  border-radius: 3px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  text-decoration: line-through;
}
.new-val {
  display: inline-block;
  padding: 1px 6px;
  background: #e8f5e9;
  color: #2e5d34;
  border-radius: 3px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 500;
}
.flash-warn {
  background: #fff8e6;
  color: #6b4f0b;
  border: 1px solid #f0c04a;
}
.flash-info {
  background: #e8f1ff;
  color: #1a5fb4;
  border: 1px solid #b8d4ff;
}

/* ---------- SRFax integration ---------- */
.srfax-status-block {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 16px 0;
}
.srfax-status-block h2 { margin-top: 0; font-size: 16px; }
.srfax-panel {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 12px 0;
}
.srfax-panel.hidden { display: none; }
.srfax-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.srfax-result {
  margin-top: 12px;
}
.srfax-result.hidden { display: none; }

/* ---------- SRFax history view ---------- */
.srfax-run-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.srfax-run-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 6px;
}
.srfax-run-counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.count-chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.count-saved   { background: #e6f4ea; color: #1d6e3a; }
.count-dup     { background: #ececec; color: #555; }
.count-err     { background: #fde8e8; color: #8a3d3d; }
.count-fetched { background: #e8f1ff; color: #1a5fb4; }
.srfax-empty-run {
  margin: 8px 0 0 0;
  font-style: italic;
  font-size: 13px;
}
.srfax-error-summary { color: #8a3d3d; cursor: pointer; }
.srfax-error-list {
  margin: 6px 0 0 18px;
  color: #8a3d3d;
  font-size: 13px;
}
.srfax-error-list li { margin: 2px 0; }
.srfax-run-card details {
  margin-top: 6px;
}
.srfax-run-card summary {
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
}

/* ---------- Batch receiving-date displays ---------- */
.batch-receiving-summary {
  background: #f8f9fa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 10px 0 16px 0;
  font-size: 13px;
  color: var(--color-text-faint);
}
.batch-receiving-summary code {
  background: transparent;
  padding: 0;
  font-size: 13px;
  color: inherit;
  font-weight: 500;
}
.per-date-list {
  margin: 6px 0 0 18px;
  padding: 0;
}
.per-date-list li {
  margin: 2px 0;
  font-size: 12px;
}
.received-range {
  font-size: 12px;
  background: transparent;
  padding: 0;
  color: var(--color-text-faint);
}

/* ---------- SRFax preview page ---------- */
.srfax-panel-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.srfax-since-label {
  font-size: 13px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.srfax-since-label select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
}
.srfax-counts-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.srfax-count-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 120px;
  text-align: center;
}
.srfax-count-num {
  font-size: 22px;
  font-weight: 600;
}
.srfax-count-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-faint);
  margin-top: 2px;
}
.srfax-count-recent  .srfax-count-num { color: #1d6e3a; }
.srfax-count-medium  .srfax-count-num { color: #1a5fb4; }
.srfax-count-old     .srfax-count-num { color: #8a3d3d; }
.srfax-count-undated .srfax-count-num { color: #777; }

.srfax-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 0;
  gap: 12px;
  flex-wrap: wrap;
}
.srfax-actions-left, .srfax-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.srfax-actions-left label {
  font-weight: 500;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
#selected-count {
  min-width: 80px;
}
.srfax-preview-table .small {
  font-size: 11px;
  word-break: break-all;
}
.age-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.age-recent { background: #e6f4ea; color: #1d6e3a; }
.age-medium { background: #e8f1ff; color: #1a5fb4; }
.age-old    { background: #fde8e8; color: #8a3d3d; }

/* ---------- Batch progress checklist (v10.18) ---------- */
.batch-progress-section {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 14px 0 22px 0;
}
.progress-header {
  margin-bottom: 12px;
}
.progress-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.batch-complete-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 11px;
  background: #ececec;
  color: #555;
  letter-spacing: 0.3px;
}
.batch-complete-badge.is-complete {
  background: #e6f4ea;
  color: #1d6e3a;
}
.progress-bar-wrap {
  background: #ececec;
  border-radius: 6px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  background: linear-gradient(to right, #2d7d4d, #1d6e3a);
  height: 100%;
  width: 0;
  transition: width 0.3s ease;
}

.progress-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
@media (min-width: 800px) {
  .progress-checklist {
    grid-template-columns: 1fr 1fr;
    gap: 4px 24px;
  }
}
.progress-step {
  position: relative;
  border-radius: 4px;
}
.progress-step.is-checked {
  background: #f0f8f1;
}
.progress-step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}
.progress-step-label:hover {
  background: #f5f7f9;
}
.progress-step.is-checked .progress-step-label:hover {
  background: #e6f0e8;
}
.progress-step-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.progress-step-check:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.progress-step-text {
  font-size: 14px;
  flex: 1;
}
.progress-step.is-checked .progress-step-text {
  color: #1d6e3a;
  font-weight: 500;
}
.progress-step-meta {
  font-size: 11px;
  color: #1d6e3a;
  font-weight: 600;
  white-space: nowrap;
}
.progress-step-time {
  color: #4a7558;
  font-weight: 400;
  margin-left: 4px;
}

/* batches list row indicators */
.batch-row-complete {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9px;
  background: #e6f4ea;
  color: #1d6e3a;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}
.batch-row-progress {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  color: var(--color-text-faint);
  background: #f0f0f0;
  padding: 1px 7px;
  border-radius: 9px;
  vertical-align: middle;
}

/* ---------- Record filter bar (v10.19) ---------- */
.record-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  margin: 8px 0 16px 0;
  background: #f7f8fa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-group-search {
  flex: 1 1 240px;
  min-width: 200px;
  gap: 8px;
}
.filter-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-right: 4px;
}
.filter-pill {
  background: white;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-pill:hover {
  background: #eef2f7;
}
.filter-pill.is-active {
  background: #1a5fb4;
  border-color: #1a5fb4;
  color: white;
}
.filter-pill .pill-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  font-weight: 600;
}
.filter-pill.is-active .pill-count {
  background: rgba(255, 255, 255, 0.25);
}
.filter-input {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  flex: 1;
  font-size: 13px;
  min-width: 180px;
}
.filter-clear-btn {
  font-size: 12px;
  background: white;
}
.filter-counter {
  font-size: 13px;
  font-weight: 500;
}
.filter-counter.is-filtered {
  color: #1a5fb4;
  font-weight: 600;
}

/* ---------- Batches list: tabs, expandable progress, archive (v10.20) ---------- */
.batches-view-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin: 12px 0 18px 0;
}
.view-tab {
  padding: 8px 16px;
  text-decoration: none;
  color: var(--color-text-faint);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.view-tab:hover {
  color: var(--color-text);
  background: #f5f7f9;
}
.view-tab.is-active {
  color: #1a5fb4;
  border-bottom-color: #1a5fb4;
}
.view-tab-count {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 9px;
  background: #ececec;
  color: var(--color-text-faint);
  font-weight: 600;
}
.view-tab.is-active .view-tab-count {
  background: #e8f1ff;
  color: #1a5fb4;
}

/* Page title with archive button */
.page-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.page-title-actions {
  margin-left: auto;
}
.batch-archived-banner {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  background: #fff4e0;
  color: #855e10;
  border: 1px solid #f0c04a;
}
.batch-row.is-archived {
  background: #fafafa;
  opacity: 0.78;
}
.batch-row.is-archived td {
  color: #777;
}
.batch-archived-chip {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9px;
  background: #fff4e0;
  color: #855e10;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}

/* Expand button */
.expand-cell {
  text-align: center;
  padding: 4px;
}
.expand-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-faint);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 10px;
  transition: background 0.15s;
}
.expand-btn:hover {
  background: #eef2f7;
  color: var(--color-text);
}
.expand-chevron {
  display: inline-block;
  transition: transform 0.15s;
}
.expand-btn[aria-expanded="true"] {
  background: #eef2f7;
  color: var(--color-text);
}

/* Per-row progress bar */
.progress-cell {
  min-width: 140px;
}
.row-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.row-progress-bar {
  background: #ececec;
  border-radius: 5px;
  height: 6px;
  overflow: hidden;
  cursor: help;
}
.row-progress-fill {
  background: #6b9fd6;
  height: 100%;
  transition: width 0.25s ease;
  border-radius: 5px;
}
.row-progress-fill.is-complete {
  background: linear-gradient(to right, #2d7d4d, #1d6e3a);
}
.row-progress-text {
  font-size: 11px;
  color: var(--color-text-faint);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.row-progress-text.is-complete {
  color: #1d6e3a;
}

/* Expanded inline checklist row */
.batch-progress-row {
  background: #fafbfc;
}
.batch-progress-cell {
  padding: 12px 16px 16px 50px;
  border-top: 1px solid #e6e9ee;
}
.row-progress-checklist {
  max-width: 700px;
}
.row-progress-steplist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}
@media (min-width: 700px) {
  .row-progress-steplist {
    grid-template-columns: 1fr 1fr;
    gap: 2px 20px;
  }
}
.row-step {
  border-radius: 3px;
}
.row-step.is-checked {
  background: #f0f8f1;
}
.row-step-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  cursor: pointer;
  user-select: none;
  border-radius: 3px;
  font-size: 13px;
}
.row-step-label:hover {
  background: #eef2f7;
}
.row-step.is-checked .row-step-label:hover {
  background: #e6f0e8;
}
.row-step-check {
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.row-step-check:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.row-step-text {
  flex: 1;
}
.row-step.is-checked .row-step-text {
  color: #1d6e3a;
  font-weight: 500;
}
.row-step-meta {
  font-size: 10px;
  color: #1d6e3a;
  font-weight: 600;
  white-space: nowrap;
}
.row-step-time {
  color: #4a7558;
  font-weight: 400;
  margin-left: 3px;
}
.row-progress-placeholder {
  padding: 10px;
}
.row-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.archive-btn {
  background: white;
  color: #855e10;
  border-color: #e0c08a;
}
.archive-btn:hover {
  background: #fff4e0;
}

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--color-border);
  background: #fafbfc;
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.data-table tbody tr:hover {
  background: var(--color-primary-light);
}
.records-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.records-table { font-size: 12px; }
.records-table tbody td { padding: 8px 10px; }
.row-urgent { background: var(--color-urgent-bg) !important; }
.row-urgent:hover { background: #ffd5d5 !important; }
.row-review { background: var(--color-review-bg) !important; }
.row-review:hover { background: #fff0c4 !important; }

.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.empty-state {
  color: var(--color-text-muted);
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-info {
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin-right: 4px;
}
.badge-urgent {
  background: var(--color-urgent);
  color: white;
}
.badge-semi {
  background: #f59e0b;     /* amber — v11.23 semi-urgent */
  color: #3f2a00;
  font-weight: 700;
}
.badge-dryeye {
  background: #0d9488;     /* teal — v11.23 dry-eye triage */
  color: #ffffff;
}
.badge-review {
  background: var(--color-review);
  color: white;
}
.count-pill {
  display: inline-block;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

/* ---------- Drag-drop zone ---------- */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  background: var(--color-card-bg);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 24px;
}
.dropzone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.dropzone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  border-style: solid;
}
.dropzone-icon { font-size: 48px; margin-bottom: 12px; }
.dropzone-text strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}
.dropzone-text span {
  display: block;
  color: var(--color-text-muted);
  font-size: 13px;
}
.upload-progress {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}

/* ---------- Progress bar ---------- */
.progress-bar {
  background: var(--color-border);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  background: var(--color-primary);
  height: 100%;
  transition: width 0.3s ease;
}
.status-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.progress-pct { font-weight: 600; color: var(--color-primary); }

.pipeline-status {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.pipeline-status.hidden { display: none; }
.status-log {
  max-height: 280px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
}
.log-line { color: var(--color-text-muted); }
.log-time {
  color: var(--color-text-faint);
  margin-right: 8px;
}

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-error { background: #ffebee; color: var(--color-error); border-left: 3px solid var(--color-error); }
.flash-success { background: #e8f5e9; color: var(--color-success); border-left: 3px solid var(--color-success); }
.flash-info { background: var(--color-primary-light); color: var(--color-primary); border-left: 3px solid var(--color-primary); }

/* ---------- Login ---------- */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}
.login-card {
  background: var(--color-card-bg);
  padding: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand h1 {
  margin: 0 0 4px 0;
  color: var(--color-primary);
  font-size: 28px;
}
.login-brand .subtitle {
  color: var(--color-text-muted);
  font-size: 13px;
  margin: 0;
}
.login-card label {
  display: block;
  margin-bottom: 16px;
}
.login-card label span {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.login-card .btn-primary {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
}
.login-note {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-faint);
  margin-top: 24px;
  margin-bottom: 0;
}

/* ---------- Misc ---------- */
.breadcrumb { margin-bottom: 8px; }
.breadcrumb a { color: var(--color-text-muted); font-size: 13px; }
.batch-link { font-weight: 500; }
.download-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.download-row-urgent {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
  align-items: center;
}
.urgent-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--color-urgent-bg);
  color: var(--color-urgent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-urgent {
  background: var(--color-urgent);
  color: #fff;
  border-color: var(--color-urgent);
}
.btn-urgent:hover {
  background: #b81f1f;
  border-color: #b81f1f;
  color: #fff;
}
.filter-input {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  width: 280px;
  max-width: 100%;
}
.filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.hidden { display: none !important; }
.muted { color: var(--color-text-faint); font-size: 11px; }

/* ---------- Editable records (batch detail) ---------- */
.hint {
  color: var(--color-text-muted);
  font-size: 13px;
  margin: 8px 0 16px 0;
}
.hint strong { color: var(--color-text); }

.editable-records {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.record-card:hover { border-color: #c5cde0; }
.record-card.record-urgent {
  border-left: 4px solid var(--color-urgent);
  background: linear-gradient(to right, var(--color-urgent-bg) 0%, var(--color-card-bg) 4%);
}
.record-card.record-semi {
  border-left: 4px solid #f59e0b;     /* amber — v11.23 semi-urgent */
  background: linear-gradient(to right, #fff7e6 0%, var(--color-card-bg) 4%);
}
.record-card.record-review {
  border-left: 4px solid var(--color-review);
  background: linear-gradient(to right, var(--color-review-bg) 0%, var(--color-card-bg) 4%);
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #fafbfc;
  border-bottom: 1px solid var(--color-border);
}
.record-id { display: flex; align-items: baseline; gap: 12px; }
.doc-number {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-primary);
}
.source-pdf {
  font-size: 11px;
  color: var(--color-text-faint);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.record-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.record-body { padding: 12px 16px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 14px;
}
.field-grid-detail {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--color-border);
}
.record-card.record-expanded .field-grid-detail { display: grid; }

.field-cell {
  display: flex;
  flex-direction: column;
  position: relative;
}
.field-cell.field-wide { grid-column: span 2; }
.field-cell.field-fullwide { grid-column: 1 / -1; }
.field-cell label {
  font-size: 10px;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 3px;
}
.field-cell input,
.field-cell select,
.field-cell textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid transparent;
  background: #f6f8fa;
  border-radius: 4px;
  width: 100%;
  transition: all 0.12s;
  color: var(--color-text);
}
.field-cell input:hover,
.field-cell select:hover,
.field-cell textarea:hover {
  background: #eef1f5;
}
.field-cell input:focus,
.field-cell select:focus,
.field-cell textarea:focus {
  outline: none;
  background: white;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}
.field-cell textarea {
  resize: vertical;
  min-height: 36px;
  font-family: inherit;
  line-height: 1.4;
}

.field-section-title {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
  margin-top: 8px;
  margin-bottom: 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
}
.field-section-title:first-child { margin-top: 0; }

.field-status {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  pointer-events: none;
}
.field-status-saving { background: #fff3cd; color: #856404; }
.field-status-saved { background: #d4edda; color: var(--color-success); animation: fadeIn 0.2s; }
.field-status-error { background: #f8d7da; color: var(--color-error); }
@keyframes fadeIn { from {opacity:0;} to {opacity:1;} }

.toggle-detail {
  background: white;
  border: 1px solid var(--color-border);
}

.field-cell input.field-missing,
.field-cell select.field-missing {
  background: #fff4e5;
  border-color: #ffb74d;
}
.field-cell input.field-missing:focus,
.field-cell select.field-missing:focus {
  background: white;
  border-color: var(--color-primary);
}
.field-warn {
  color: #d84315;
  margin-left: 4px;
  font-size: 12px;
}

.mini-card.mini-edited { border-left: 3px solid var(--color-primary); }

/* ---------- Two-clinic downloads layout ---------- */
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.downloads-clinic {
  background: #f6f8fa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.downloads-clinic.downloads-clinic-le {
  background: #f0f7ff;
  border-color: #bcd6f3;
}
.downloads-clinic-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
}
.downloads-count {
  font-size: 12px;
  font-weight: 500;
  background: white;
  color: var(--color-text-muted);
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}
.downloads-clinic-sub {
  margin: 0 0 12px 0;
  font-size: 12px;
  color: var(--color-text-muted);
}
.downloads-clinic .download-row {
  flex-wrap: wrap;
}
.legacy-files {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fafbfc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.legacy-files summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.legacy-files .download-row { margin-top: 10px; }

/* ---------- Clickable source PDF filename ---------- */
.source-pdf-link {
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  border: 1px solid transparent;
}
.source-pdf-link:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  text-decoration: none;
}
.source-pdf-link.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.source-pdf-link.active .pdf-icon { filter: brightness(0) invert(1); }
.pdf-icon { font-size: 12px; }

/* ---------- PDF preview side panel ---------- */
.pdf-preview-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(50vw, 720px);
  height: 100vh;
  background: white;
  box-shadow: -4px 0 16px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.pdf-preview-panel.open { transform: translateX(0); }

.pdf-preview-header {
  padding: 10px 14px;
  background: var(--color-primary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}
.pdf-preview-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.pdf-preview-icon { font-size: 16px; }
#pdf-preview-title {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.pdf-preview-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.pdf-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s;
}
.pdf-preview-btn:hover {
  background: rgba(255,255,255,0.25);
  text-decoration: none;
  color: white;
}

#pdf-preview-iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #525659;
}
/* v11.84 — viewer footer: record nav + inline doctor/urgency */
.pdf-preview-footer { border-top:1px solid var(--color-border); background:#fff; padding:10px 14px; display:flex; flex-direction:column; gap:8px; }
.pdf-nav { display:flex; align-items:center; gap:12px; }
.pdf-nav-btn { border:1px solid var(--color-border); background:#f6f8fa; border-radius:6px; padding:6px 12px; font-size:13px; font-weight:600; cursor:pointer; color:var(--color-text); }
.pdf-nav-btn:hover:not(:disabled) { background:#eef1f4; }
.pdf-nav-btn:disabled { opacity:.45; cursor:default; }
.pdf-pos { font-size:12px; color:var(--color-text-muted); font-variant-numeric:tabular-nums; min-width:64px; text-align:center; }
.pdf-fields { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.pdf-field { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--color-text-muted); }
.pdf-field select { font-size:13px; padding:5px 8px; border:1px solid var(--color-border); border-radius:6px; max-width:200px; }
.pdf-field-status { font-size:12px; color:var(--color-success); font-weight:600; }

/* When panel is open, shift main content over so it doesn't get covered */
body.preview-open .container {
  margin-right: min(50vw, 720px);
  max-width: none;
  transition: margin-right 0.3s ease;
}
body.preview-open .topnav {
  padding-right: calc(24px + min(50vw, 720px));
  transition: padding-right 0.3s ease;
}

/* Narrow screens (mobile/tablet) — overlay instead of pushing content */
@media (max-width: 900px) {
  .pdf-preview-panel { width: 100vw; }
  body.preview-open .container { margin-right: 0; }
  body.preview-open .topnav { padding-right: 24px; }
}


/* ---------- Duplicate-detection report (upload page) ---------- */
.duplicate-report {
  margin-top: 16px;
  padding: 18px 22px;
  background: #fffbea;
  border: 2px solid #f0c040;
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(240, 192, 64, 0.15);
}
.duplicate-report .dup-header h3 {
  margin: 0 0 6px 0;
  color: #8b6900;
  font-size: 17px;
}
.duplicate-report .dup-header .hint {
  margin: 0 0 14px 0;
  color: #6b5300;
  font-size: 13px;
}
.dup-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: white;
  border: 1px solid #f0c040;
  border-radius: 6px;
  opacity: 1;
  transition: opacity 0.15s ease;
}
.dup-info { flex: 1; }
.dup-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}
.dup-match {
  margin-top: 6px;
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}
.dup-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.dup-bulk {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #d4ae50;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.upload-stat {
  margin-left: 8px;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 10px;
}
.upload-stat-dup { background: #fff3cd; color: #8b6900; }
.upload-stat-err { background: #ffd6d6; color: #c62828; }

/* =====================================================================
   RESPONSIVE STYLES — iPad (1024px) + iPhone (640px)
   ===================================================================== */

/* Hamburger button (hidden on desktop, shown on mobile) */
.nav-burger {
  display: none;
  background: transparent;
  border: 0;
  padding: 10px 8px;
  cursor: pointer;
  margin-right: 8px;
}
.nav-burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: white;
  margin: 4px 0;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ---------- iPad / tablet (≤ 1024px) ---------- */
@media (max-width: 1024px) {
  .container {
    padding: 16px;
  }
  .nav-links { gap: 2px; }
  .nav-links a { padding: 8px 12px; font-size: 13px; }
  .nav-user .user-name { display: none; }

  /* Editable records: 2-column field grid instead of 4 */
  .field-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Downloads grid: still side-by-side but tighter min-width */
  .downloads-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }

  /* Page title spacing */
  .page-title { font-size: 22px; }
  .page-subtitle { font-size: 13px; }

  /* PDF preview: existing 900px rule already makes it full-width on phones,
     but on iPad portrait we still want a usable side panel */
  .pdf-preview-panel { width: 60vw; }
}

/* ---------- Tablet + phone: collapse nav to hamburger (≤ 1024px) ---------- */
@media (max-width: 1024px) {
  .topnav { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .nav-brand { flex: 1; }
  .nav-brand a { font-size: 17px; }
  .nav-burger { display: block; order: 2; }
  .nav-links {
    display: none; width: 100%; order: 4;
    flex-direction: column; gap: 2px;
    background: rgba(0,0,0,0.15); border-radius: 6px; padding: 8px;
    max-height: calc(100vh - 110px); overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 14px; border-radius: 4px; font-size: 15px; }
  .nav-user { order: 3; font-size: 13px; gap: 8px; }
  .nav-user .user-name { display: none; }
  .logout-link { padding: 6px 12px; background: rgba(255,255,255,0.1); border-radius: 4px; }
}

/* ---------- iPhone / phone (≤ 640px) ---------- */
@media (max-width: 640px) {
  body {
    font-size: 15px; /* slightly bigger for legibility */
  }
  .container {
    padding: 12px;
  }

  /* ---- Larger touch targets ---- */
  .btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 15px;
  }
  .btn-sm {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 14px;
  }
  .btn-block-mobile {
    display: block;
    width: 100%;
    text-align: center;
  }

  /* ---- Inputs / selects: bigger, full-width ---- */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    padding: 12px 14px;
    min-height: 44px;
  }
  textarea { min-height: 80px; }

  /* ---- Page titles ---- */
  .page-title { font-size: 20px; }
  .page-subtitle { font-size: 13px; line-height: 1.5; }

  /* ---- Cards ---- */
  .card-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .card { padding: 16px; }

  /* ---- Sections ---- */
  .section { padding: 14px; margin-bottom: 14px; }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .section-header h2 { font-size: 17px; }

  /* ---- Editable records: 1-column grid, full-width fields ---- */
  .field-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .record-card { padding: 0; }
  .record-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }
  .record-header .doc-number {
    font-size: 15px;
    font-weight: 700;
  }
  .record-card .field-grid {
    padding: 14px;
  }
  .field-cell label {
    font-size: 11px;
    margin-bottom: 4px;
  }
  .editable-records { gap: 14px; }
  .expand-toggle {
    width: 100%;
    text-align: center;
    margin-top: 8px;
  }

  /* ---- Downloads grid: stack vertically ---- */
  .downloads-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .downloads-clinic { padding: 14px; }
  .download-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .download-row .btn { width: 100%; }

  /* ---- Data tables: convert to stacked cards on phone ---- */
  .data-table thead {
    /* Hide the column headers — each cell will show its own label */
    display: none;
  }
  .data-table tbody tr {
    display: block;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  .data-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--color-border);
  }
  .data-table tbody td:last-child { border-bottom: none; padding-bottom: 0; }
  .data-table tbody td:first-child { padding-top: 0; }
  .data-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 70px;
  }
  .data-table tbody td[data-label=""]::before { display: none; }
  .data-table tbody td[data-label=""] {
    justify-content: stretch;
  }

  /* ---- Dropzone: more tap-friendly ---- */
  .dropzone {
    padding: 30px 16px;
    min-height: 140px;
  }
  .dropzone-icon { font-size: 36px; }
  .dropzone-text { font-size: 14px; }

  /* ---- Duplicate report rows: stack info above buttons ---- */
  .dup-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .dup-actions { width: 100%; }
  .dup-actions .btn { flex: 1; }
  .dup-bulk { flex-direction: column; }
  .dup-bulk .btn { width: 100%; }

  /* ---- PDF preview: full-screen modal on phone ---- */
  .pdf-preview-panel {
    width: 100vw !important;
    height: 100vh;
    top: 0;
    border-left: none;
  }
  body.preview-open .container { margin-right: 0 !important; }
  body.preview-open footer { display: none; }

  /* ---- Pipeline status log: smaller, scrollable ---- */
  .status-log {
    max-height: 220px;
    font-size: 12px;
  }
  .log-line { padding: 4px 0; }
  .log-time { font-size: 11px; }

  /* ---- Login form: vertical padding ---- */
  .login-container { padding: 30px 18px; max-width: 100%; }

  /* ---- Flash messages: full width ---- */
  .flash { padding: 12px 14px; font-size: 14px; }

  /* ---- Footer: smaller ---- */
  footer { padding: 16px 12px; font-size: 11px; }
}

/* ---------- Phone landscape / small tablet (641–900px) ---------- */
@media (min-width: 641px) and (max-width: 900px) {
  .field-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .downloads-grid {
    grid-template-columns: 1fr;
  }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 8px 6px; }
}

/* ---------- High-density displays (iPad Pro retina) ---------- */
@media (min-resolution: 2dppx) {
  .badge, .btn { -webkit-font-smoothing: antialiased; }
}

/* ---------- Print (in case anyone prints a record) ---------- */
@media print {
  .topnav, footer, .download-row, #regenerate-btn, .delete-btn,
  .expand-toggle, .dup-actions, .nav-burger {
    display: none !important;
  }
  body { background: white; font-size: 11pt; }
  .container { padding: 0; max-width: 100%; }
  .record-card { break-inside: avoid; border: 1px solid #888 !important; box-shadow: none !important; }
  .field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  input, select, textarea {
    border: none !important; background: transparent !important;
    padding: 0 !important; font-size: 10pt !important; min-height: 0 !important;
  }
}

/* ---------- v10 workflow additions ---------- */
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.card-warn { border-color: #f59e0b; background: #fffbeb; }
.card-warn .card-num { color: #b45309; }
@media (max-width: 640px) {
  .header-actions { width: 100%; margin-top: 0.5rem; }
  .header-actions .btn { flex: 1; min-width: 0; }
}

/* v11.27 — nav dropdowns (Manage Faxes / Todos / APIs) -------------------- */
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-drop-toggle {
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: rgba(255,255,255,0.85);
  padding: 8px 14px; border-radius: 4px;
  font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-drop-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-drop-toggle.active { background: rgba(255,255,255,0.15); color: #fff; }
.nav-caret { font-size: 10px; opacity: 0.8; transition: transform .15s ease; }
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-drop-menu {
  display: none;
  position: absolute; top: 100%; left: 0; margin-top: 4px;
  min-width: 184px; z-index: 200;
  background: var(--color-primary);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px; padding: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.nav-dropdown.open .nav-drop-menu { display: block; }
/* Bridge the 4px gap between the toggle and the menu so moving the mouse down
   into the menu doesn't cross a non-hover zone and close it (v11.80). */
.nav-drop-menu::before {
  content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px;
}
.nav-drop-menu a {
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 9px 12px; border-radius: 4px;
  color: rgba(255,255,255,0.9); font-size: 14px; font-weight: 500;
}
.nav-drop-menu a:hover { background: rgba(255,255,255,0.12); color: #fff; text-decoration: none; }
.nav-drop-menu a.active { background: rgba(255,255,255,0.15); color: #fff; }
/* Desktop convenience: hover also opens (on top of click-to-toggle). */
@media (min-width: 1025px) {
  .nav-dropdown:hover .nav-drop-menu { display: block; }
}
/* Mobile / burger panel: dropdowns stack inline, click-toggle only. */
@media (max-width: 1024px) {
  .nav-dropdown { display: block; width: 100%; }
  .nav-drop-toggle { width: 100%; justify-content: space-between; padding: 12px 14px; font-size: 15px; }
  .nav-drop-menu {
    position: static; box-shadow: none; border: none; min-width: 0;
    margin: 0 0 4px 0; padding: 4px 4px 4px 12px; background: rgba(0,0,0,0.18);
  }
}
