/* ============================================
   PDX Design System
   ============================================ */

:root {
  --primary: #0D7377;
  --primary-light: #14A3A8;
  --primary-dark: #0A5C5F;
  --accent: #E8634F;
  --accent-gold: #F0A500;
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6C757D;
  --text-muted: #9CA3AF;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --success: #28A745;
  --error: #EF4444;
  --warning: #F59E0B;
  --sidebar-bg: #0D7377;
  --sidebar-width: 240px;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: 0.15s ease;
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar.hidden {
  display: none;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-brand h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.125rem;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  opacity: 0.7;
  font-weight: 400;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-section {
  margin-bottom: 1.25rem;
}

.nav-label {
  display: block;
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.5;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-left-color: #fff;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.sidebar-user {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-logout:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ============================================
   Main Content
   ============================================ */

.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.main.full-width {
  margin-left: 0;
}

.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Page Header
   ============================================ */

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  color: var(--text-muted);
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  transition: box-shadow var(--transition);
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  transition: all var(--transition);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.card-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ============================================
   Dashboard Grid
   ============================================ */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.dashboard-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  cursor: pointer;
  min-height: 120px;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-left-color: var(--primary-light);
}

.dashboard-card svg {
  color: var(--primary);
}

.dashboard-card .card-label {
  font-size: 0.8rem;
  font-weight: 500;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover {
  background: #DC2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #22913D;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
  letter-spacing: 0.25px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.form-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.form-inline {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

/* ============================================
   Tables
   ============================================ */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: var(--bg);
}

/* ============================================
   Patient List
   ============================================ */

.patient-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.patient-row:last-child {
  border-bottom: none;
}

.patient-row:hover {
  background: var(--bg);
}

.patient-name {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.patient-name:hover {
  color: var(--primary);
}

.patient-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.patient-row:hover .patient-actions {
  opacity: 1;
}

.action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}

.action-icon:hover {
  background: var(--primary);
  color: #fff;
}

/* ============================================
   Reactions (Severity Colors)
   ============================================ */

.reaction-3plus {
  background: #FECACA;
  border-left: 4px solid #DC2626;
}

.reaction-2plus {
  background: #FED7AA;
  border-left: 4px solid #EA580C;
}

.reaction-1plus {
  background: #FEF08A;
  border-left: 4px solid #CA8A04;
}

.reaction-plusminus {
  background: #E2E8F0;
  border-left: 4px solid #94A3B8;
}

.reaction-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.reaction-strength {
  font-weight: 600;
  width: 50px;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
}

.reaction-allergen {
  flex: 1;
}

/* ============================================
   Strength Buttons (Patch Test)
   ============================================ */

.strength-buttons {
  display: flex;
  gap: 0.25rem;
}

.strength-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}

.strength-btn:hover {
  transform: scale(1.05);
}

.strength-btn.s-plusminus { border-color: #94A3B8; color: #64748B; }
.strength-btn.s-plusminus:hover { background: #E2E8F0; }
.strength-btn.s-1plus { border-color: #CA8A04; color: #CA8A04; }
.strength-btn.s-1plus:hover { background: #FEF08A; }
.strength-btn.s-2plus { border-color: #EA580C; color: #EA580C; }
.strength-btn.s-2plus:hover { background: #FED7AA; }
.strength-btn.s-3plus { border-color: #DC2626; color: #DC2626; }
.strength-btn.s-3plus:hover { background: #FECACA; }

/* ============================================
   Collapsible Sections
   ============================================ */

.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.collapsible-header:hover {
  background: var(--border-light);
}

.collapsible-header h2,
.collapsible-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}

.collapsible-toggle {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.collapsible-toggle.open {
  transform: rotate(180deg);
}

.collapsible-body {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-light);
}

.collapsible-body.hidden {
  display: none;
}

.date-section > .collapsible-header {
  background: var(--primary);
  color: #fff;
}

.date-section > .collapsible-header:hover {
  background: var(--primary-light);
}

.date-section > .collapsible-header h2 {
  color: #fff;
}

.date-section > .collapsible-toggle {
  color: rgba(255,255,255,0.7);
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 500;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
  animation-delay: 0s, 2.7s;
  max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ============================================
   Loading Spinner
   ============================================ */

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

.spinner-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Login Page
   ============================================ */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -1px;
}

.login-brand p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.login-error {
  background: #FEE2E2;
  color: var(--error);
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  margin-bottom: 1rem;
  display: none;
}

/* ============================================
   Letter Editor
   ============================================ */

.letter-editor {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  background: #FAFBFC;
}

.letter-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.1);
}

.letter-content {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.85rem;
  padding: 0.75rem;
  background: #FAFBFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  max-height: 250px;
  overflow-y: auto;
}

.letter-view {
  padding: 2rem;
  line-height: 1.7;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.95rem;
  background: #fff;
  color: #222;
}

.letter-view p {
  margin: 0 0 0.75rem 0;
}

.letter-view strong {
  font-weight: 700;
}

/* ============================================
   Filter Chips
   ============================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-chip {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================
   Allergen Search
   ============================================ */

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg);
}

.search-result-name {
  font-size: 0.875rem;
  font-weight: 500;
}

/* ============================================
   Stepper (Education Wizard)
   ============================================ */

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
}

.step.active .step-number {
  background: var(--primary);
  color: #fff;
}

.step.completed .step-number {
  background: var(--success);
  color: #fff;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.step.active .step-label {
  color: var(--text);
}

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 0.75rem;
}

.step-connector.completed {
  background: var(--success);
}

/* ============================================
   Checkbox Table
   ============================================ */

.checkbox-table {
  width: 100%;
  border-collapse: collapse;
}

.checkbox-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
  vertical-align: middle;
}

.checkbox-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================
   Copy Button
   ============================================ */

.copy-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.copy-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* ============================================
   Allergens List (Two Column)
   ============================================ */

.allergens-list {
  column-count: 2;
  column-gap: 1.5rem;
  padding-left: 1.5rem;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
}

.allergens-list li {
  break-inside: avoid;
  margin-bottom: 0.25rem;
  padding: 0;
  border: none;
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ============================================
   Saved Reactions List
   ============================================ */

.saved-reactions {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-top: 1rem;
}

.saved-reactions h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.saved-reactions ul {
  list-style: none;
  padding: 0;
}

.saved-reactions li {
  padding: 0.375rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.saved-reactions li:last-child {
  border-bottom: none;
}

/* ============================================
   Survey Builder
   ============================================ */

.question-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

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

.question-text {
  flex: 1;
  font-size: 0.875rem;
}

.question-remove {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.question-remove:hover {
  opacity: 1;
}

/* ============================================
   Utilities
   ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .sidebar, .toast-container, .btn, .no-print {
    display: none !important;
  }
  .main {
    margin-left: 0;
  }
  .collapsible-body {
    display: block !important;
  }
}

/* ============================================
   Search Bar
   ============================================ */

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  box-shadow: var(--shadow);
}

.search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar .form-input {
  border: none;
  box-shadow: none;
  padding: 0.375rem 0;
}

.search-bar .form-input:focus {
  box-shadow: none;
}

/* ============================================
   Status Dots (Patient List)
   ============================================ */

.patient-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.patient-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stage-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-dots {
  display: flex;
  gap: 3px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--transition);
}

.status-dot.active {
  background: var(--success);
}

/* ============================================
   Pipeline (Patient Dashboard)
   ============================================ */

.pipeline {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  overflow-x: auto;
}

.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.pipeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
  transition: all var(--transition);
}

.pipeline-stage.done .pipeline-dot {
  background: var(--success);
  color: #fff;
}

.pipeline-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.pipeline-stage.done .pipeline-label {
  color: var(--text);
}

.pipeline-connector {
  flex: 1;
  height: 2px;
  min-width: 20px;
  background: var(--border);
  margin: 0 0.25rem;
  margin-bottom: 1rem;
}

/* ============================================
   Dashboard Card Badges
   ============================================ */

.card-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-badge.done {
  background: #E0F4EA;
  color: #059669;
}

.card-badge.pending {
  background: #F3F4F6;
  color: #9CA3AF;
}

.card-badge.interim {
  background: #FEF3C7;
  color: #D97706;
}

/* ============================================
   Read Type Toggle
   ============================================ */

.read-type-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.read-type-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.read-type-btn:first-child {
  border-right: 1px solid var(--border);
}

.read-type-btn.active {
  background: var(--primary);
  color: #fff;
}

.read-type-btn:hover:not(.active) {
  background: var(--bg);
}

/* ============================================
   Read Sections (Review Results)
   ============================================ */

.read-section {
  margin-bottom: 0.25rem;
}

.read-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}

/* ============================================
   Comparison Summary
   ============================================ */

.comparison-summary {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.comparison-summary h4 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.comparison-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8rem;
}

.comparison-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.comparison-escalated .comparison-badge { background: #EF4444; }
.comparison-deescalated .comparison-badge { background: #28A745; }
.comparison-new .comparison-badge { background: #D97706; }
.comparison-resolved .comparison-badge { background: #6366F1; }

/* ============================================
   Type Badge (Build Survey)
   ============================================ */

.type-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: #fff;
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ============================================
   Radio Group (Survey)
   ============================================ */

.radio-group {
  display: flex;
  gap: 1.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--primary);
}

/* ============================================
   Public Survey Page
   ============================================ */

.survey-public-container {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: var(--bg);
}

.survey-public-card {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  align-self: flex-start;
}

.survey-public-brand {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.survey-public-brand h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -1px;
}

.survey-public-brand p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main {
    margin-left: 0;
  }
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .content {
    padding: 1rem;
  }
  .pipeline {
    gap: 0;
  }
  .pipeline-label {
    font-size: 0.55rem;
  }
}

/* ============================================
   Patch Panel Catalog
   ============================================ */

.ascii-output {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre;
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  max-height: 400px;
  overflow-y: auto;
}

.catalog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  gap: 0.5rem;
  transition: background var(--transition);
}

.catalog-row:hover {
  background: var(--bg);
}

.catalog-row-toggle {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.65rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
  user-select: none;
  transition: color var(--transition);
}

.catalog-row-toggle:hover {
  color: var(--primary);
}

.catalog-row-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 1.75rem;
  padding: 0.1rem 0.4rem;
}

.catalog-group-selected {
  background: #E0F4EA;
  border-left: 3px solid var(--success);
}

.catalog-group-selected .catalog-row-count {
  background: #C6F6D5;
  border-color: var(--success);
  color: #166534;
}

.copy-btn.copied {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  margin: 0.25rem;
}

.selected-tag .tag-type {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.selected-tag .tag-type.group {
  background: #DBEAFE;
  color: #1D4ED8;
}

.selected-tag .tag-type.indiv {
  background: #FEF3C7;
  color: #92400E;
}

.selected-tag .remove-tag {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.selected-tag .remove-tag:hover {
  color: var(--danger);
}

.allergen-list-cols {
  column-count: 2;
  column-gap: 1rem;
  font-size: 0.8rem;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .allergen-list-cols {
    column-count: 1;
  }
}
