:root {
  --primary: #1565c0;
  --primary-light: #e3f2fd;
  --danger: #d32f2f;
  --danger-light: #ffebee;
  --warning: #f57c00;
  --warning-light: #fff3e0;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-600: #757575;
  --gray-800: #424242;
  --gray-900: #212121;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

/* Header */
.header {
  background: var(--primary);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.header h1 { font-size: 20px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 16px; }
.client-selector {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
}
.alert-badge {
  background: var(--danger);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: none;
}
.alert-badge.visible { display: inline-block; }

/* Navigation */
.nav {
  background: white;
  border-bottom: 1px solid var(--gray-300);
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
  min-width: 56px;
  position: relative;
}
.nav button svg { flex-shrink: 0; }
.nav button:hover { background: var(--gray-50); color: var(--gray-800); }
.nav button.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-alert-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
}

/* Main content */
.main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Medication cards */
.med-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border-left: 4px solid var(--primary);
  transition: transform 0.1s;
}
.med-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.med-card.prn { border-left-color: var(--warning); }
.med-card.low-stock { border-left-color: var(--danger); }
.med-card.ok { border-left-color: var(--success); }

.med-card-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  cursor: pointer;
}
.med-card-header h3 { font-size: 15px; font-weight: 600; }
.med-card-header .med-meta {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 4px;
}
.med-card-header .stock-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.stock-badge.ok { background: var(--success-light); color: var(--success); }
.stock-badge.warning { background: var(--warning-light); color: var(--warning); }
.stock-badge.danger { background: var(--danger-light); color: var(--danger); }
.stock-badge.prn { background: #f3e5f5; color: #7b1fa2; }

.med-card-details {
  padding: 0 20px 16px;
  display: none;
  border-top: 1px solid var(--gray-200);
}
.med-card-details.open { display: block; padding-top: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.detail-item label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--gray-600);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.detail-item .value {
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

/* Stock progress bar */
.stock-bar-container {
  margin: 12px 0;
}
.stock-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.stock-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.stock-bar-fill.ok { background: var(--success); }
.stock-bar-fill.warning { background: var(--warning); }
.stock-bar-fill.danger { background: var(--danger); }

/* Action buttons in med cards */
.med-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #0d47a1; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #e65100; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b71c1c; }
.btn-outline {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-600);
  padding: 4px;
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Alert banner */
.alert-banner {
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.alert-banner.danger { background: var(--danger-light); color: var(--danger); border: 1px solid #ef9a9a; }
.alert-banner.warning { background: var(--warning-light); color: var(--warning); border: 1px solid #ffcc02; }
.alert-banner.info { background: var(--primary-light); color: var(--primary); border: 1px solid #90caf9; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
th {
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: var(--gray-50);
}
tr:hover { background: var(--gray-50); }

/* Tab sections */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Section headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 18px; font-weight: 600; }

/* MAR uploads grid */
.mar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.mar-item {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mar-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--gray-200);
}
.mar-item .mar-info {
  padding: 12px;
}
.mar-item .mar-info p { font-size: 13px; color: var(--gray-600); }

/* Approximate level selector */
.level-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.level-option {
  padding: 8px 16px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.level-option:hover { border-color: var(--primary); }
.level-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Summary stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-card .stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 4px;
}
.stat-card.danger .stat-number { color: var(--danger); }
.stat-card.warning .stat-number { color: var(--warning); }

/* File upload area */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-area p { color: var(--gray-600); margin-top: 8px; }
.upload-area input { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .header h1 { font-size: 16px; }
  .main { padding: 12px; }
  .nav button { padding: 10px 16px; font-size: 13px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== eMAR Chart ===== */
.emar-client-header {
  background: white;
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.emar-client-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 14px;
}
.emar-client-info strong {
  font-size: 18px;
  color: var(--primary);
}

.emar-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}
.emar-month-nav h2 {
  font-size: 18px;
  min-width: 200px;
  text-align: center;
}

.emar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  font-size: 12px;
  align-items: center;
}
.emar-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.emar-med-block {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.emar-med-block.prn {
  border-left: 4px solid var(--primary);
}
.emar-med-header {
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Drag handle */
.emar-drag-handle {
  cursor: grab;
  color: var(--gray-600);
  font-size: 18px;
  padding: 4px 8px 4px 0;
  user-select: none;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.emar-drag-handle:hover {
  opacity: 1;
}
.emar-drag-handle:active {
  cursor: grabbing;
}

/* Drag states */
.emar-med-block.dragging {
  opacity: 0.4;
  border: 2px dashed var(--primary);
}
.emar-med-block.drag-over {
  border-top: 3px solid var(--primary);
}
.emar-med-meta {
  font-size: 13px;
  color: var(--gray-600);
  margin-left: 8px;
}

/* Structured medication info header */
.emar-med-info-header {
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.emar-med-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  align-items: baseline;
  margin-bottom: 6px;
}
.emar-med-info-row:last-child { margin-bottom: 0; }
.emar-med-info-item {
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex: 1 1 40%;
  min-width: 180px;
  overflow: hidden;
}
.emar-med-info-item label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-600);
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
  width: 90px;
}
.emar-med-info-item span {
  font-size: 14px;
  color: var(--gray-900);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emar-comments-item {
  grid-column: 1 / -1;
}
.emar-comments-text {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  min-height: 24px;
  display: inline-block;
}
.emar-comments-text:hover {
  background: var(--gray-200);
}
.emar-comments-edit textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.emar-grid-wrapper {
  overflow-x: auto;
  padding: 0;
}

.emar-grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 800px;
  font-size: 12px;
}
.emar-grid th, .emar-grid td {
  border: 1px solid var(--gray-200);
  text-align: center;
  padding: 4px;
}
.emar-grid th {
  background: var(--gray-50);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.emar-time-col {
  width: 60px;
  min-width: 60px;
  position: sticky;
  left: 0;
  background: var(--gray-50) !important;
  z-index: 2;
  font-size: 12px;
}
.emar-time-cell {
  font-weight: 600;
  font-size: 12px;
  position: sticky;
  left: 0;
  background: white;
  z-index: 1;
  color: var(--gray-800);
}
.emar-day-col {
  min-width: 38px;
  width: 38px;
}

/* Today column highlighting */
.emar-today {
  background-color: var(--primary-light) !important;
}

/* Cell styling */
.emar-cell {
  cursor: pointer;
  padding: 3px !important;
  transition: background 0.15s;
}
.emar-cell:hover {
  background-color: var(--gray-200) !important;
}
.emar-overdue-cell {
  background-color: var(--danger-light) !important;
}

/* Grace period warning */
.grace-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #856404;
  line-height: 1.4;
}

/* Circle status indicators */
.emar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}
.emar-circle.given {
  background: var(--success);
  color: white;
}
.emar-circle.refused {
  background: var(--danger);
  color: white;
}
.emar-circle.out_of_stock {
  background: var(--warning);
  color: white;
}
.emar-circle.omitted {
  background: var(--gray-600);
  color: white;
}
.emar-circle.destroyed {
  background: #b71c1c;
  color: white;
}
.emar-circle.hospital {
  background: #1976d2;
  color: white;
}
.emar-circle.school {
  background: #f9a825;
  color: #333;
}
.emar-circle.parent {
  background: #7b1fa2;
  color: white;
}
.emar-circle.other {
  background: var(--gray-600);
  color: white;
}
.emar-circle.pending {
  background: transparent;
  border: 2px solid var(--gray-300);
  width: 24px;
  height: 24px;
}
.emar-circle.overdue {
  background: transparent;
  border: 2px solid var(--danger);
  width: 24px;
  height: 24px;
  animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--danger); opacity: 1; }
  50% { border-color: var(--danger-light); opacity: 0.6; }
}

/* Responsive: week view on mobile */
@media (max-width: 767px) {
  .emar-grid {
    min-width: unset;
  }
  .emar-day-col {
    min-width: 36px;
    width: 36px;
  }
  .emar-circle {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }
  .emar-circle.pending, .emar-circle.overdue {
    width: 20px;
    height: 20px;
  }
  .emar-client-info {
    flex-direction: column;
    gap: 4px;
  }
  .emar-legend {
    gap: 8px;
    font-size: 11px;
  }
  .emar-month-nav h2 {
    font-size: 16px;
    min-width: 160px;
  }
  .nav {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .nav button {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* Correction indicator */
.emar-corrected-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 10px;
  font-weight: 700;
  color: #ff6f00;
  line-height: 1;
}
.emar-cell {
  position: relative;
}
.correction-history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  background: var(--gray-50);
  border-radius: 6px;
  margin-bottom: 6px;
  border-left: 3px solid #ff6f00;
}
.correction-change {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.correction-meta {
  font-size: 12px;
  color: var(--gray-700);
  line-height: 1.4;
}
.correction-meta small {
  color: var(--gray-500);
}

/* Alert severity badges */
.severity-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 6px;
}
.severity-critical { background: var(--danger); color: white; }
.severity-warning  { background: #f9a825; color: #333; }
.severity-info     { background: #1565c0; color: white; }

.alert-severity-heading {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid;
}
.alert-severity-heading.severity-critical { color: var(--danger); border-color: var(--danger); }
.alert-severity-heading.severity-warning  { color: #f57f17; border-color: #f9a825; }
.alert-severity-heading.severity-info     { color: #1565c0; border-color: #1565c0; }
.alert-severity-heading:first-child { margin-top: 0; }

.alert-badge-critical {
  background: var(--danger) !important;
  animation: pulse-critical 2s infinite;
}
@keyframes pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.alert-banner {
  display: flex;
  align-items: center;
}

/* Report download cards */
.report-download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.report-download-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  cursor: pointer;
}
.report-download-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.report-download-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.report-download-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.report-download-desc {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.4;
}
.stat-detail {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Toggle switch */
.feature-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--gray-300);
  border-radius: 28px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(24px); }

/* Med Round Mode overlay */
.med-round-overlay {
  position: fixed;
  inset: 0;
  background: #f5f7fa;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.med-round-container {
  width: 100%;
  max-width: 600px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  box-sizing: border-box;
}
.med-round-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-shrink: 0;
}
.med-round-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--gray-900);
}
.med-round-progress {
  flex: 1;
  text-align: center;
}
.med-round-progress span {
  font-size: 13px;
  color: var(--gray-600);
  display: block;
  margin-bottom: 4px;
}
.med-round-progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}
.med-round-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 6px;
  transition: width 0.3s ease;
}
.med-round-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}
.med-round-time {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 20px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.med-round-drug {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  text-align: center;
  margin-bottom: 20px;
}
.med-round-details {
  display: flex;
  gap: 32px;
  margin-bottom: 28px;
}
.med-round-detail {
  text-align: center;
}
.med-round-detail label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.med-round-detail span {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
}
.med-round-initials {
  margin-bottom: 24px;
  text-align: center;
}
.med-round-initials label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.med-round-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.med-round-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 12px;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.med-round-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.med-round-btn-icon { font-size: 28px; }
.med-round-btn.given { color: var(--success); border-color: #c8e6c9; }
.med-round-btn.given:hover { background: #e8f5e9; border-color: var(--success); }
.med-round-btn.refused { color: var(--danger); border-color: #ffcdd2; }
.med-round-btn.refused:hover { background: #ffebee; border-color: var(--danger); }
.med-round-btn.omitted { color: #ef6c00; border-color: #ffe0b2; }
.med-round-btn.omitted:hover { background: #fff3e0; border-color: #ef6c00; }
.med-round-btn.other { color: var(--gray-600); border-color: var(--gray-200); }
.med-round-btn.other:hover { background: var(--gray-50); border-color: var(--gray-400); }

.med-round-other-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
  width: 100%;
}
.med-round-btn-sm {
  padding: 10px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--gray-700);
  transition: all 0.15s;
}
.med-round-btn-sm:hover { background: var(--gray-50); border-color: var(--gray-400); }

.med-round-notes {
  width: 100%;
  max-width: 400px;
  margin-top: 16px;
}
.med-round-notes label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.med-round-notes textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
}

.med-round-footer {
  margin-top: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* Med round complete screen */
.med-round-complete {
  text-align: center;
  padding: 40px;
}
.med-round-complete-icon {
  font-size: 64px;
  margin-bottom: 16px;
}
.med-round-complete h3 {
  font-size: 24px;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.med-round-complete p {
  font-size: 16px;
  color: var(--gray-600);
  margin-bottom: 24px;
}

/* Login screen */
#loginScreen {
  position: fixed;
  inset: 0;
  z-index: 3000;
}
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #e3f2fd 0%, #f5f7fa 100%);
  padding: 24px;
}
.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

/* Role badges */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.role-badge.admin { background: #e8eaf6; color: #283593; }
.role-badge.manager { background: #e3f2fd; color: #1565c0; }
.role-badge.team_leader { background: #e8f5e9; color: #2e7d32; }
.role-badge.carer { background: #f3e5f5; color: #7b1fa2; }

/* Info tooltip */
.info-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 14px;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}
.info-tooltip-text {
  display: none;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  width: 280px;
  text-align: left;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.info-tooltip:hover .info-tooltip-text,
.info-tooltip:focus .info-tooltip-text {
  display: block;
}

/* Discard date preview */
.discard-date-box {
  background: #fff3e0;
  border: 1px solid #ffcc02;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}
.discard-date-box label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gray-600);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* Disposal modal styles */
.disposal-alert-box {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--danger);
}
.disposal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.disposal-option {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 16px;
}
.disposal-option strong { display: block; margin-bottom: 4px; }
.disposal-option p { font-size: 13px; color: var(--gray-600); margin: 0; }
.disposal-option.recommended {
  border-color: var(--success);
  background: #f1f8e9;
}
.disposal-option-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--success);
  margin-bottom: 4px;
}
.disposal-option.warning {
  border-color: #ef6c00;
  background: #fff8e1;
}
.disposal-never-box {
  background: var(--danger-light);
  border-radius: 8px;
  padding: 12px 16px;
}
.disposal-never-box strong { color: var(--danger); display: block; margin-bottom: 6px; }
.disposal-never-box ul { margin: 0; padding-left: 20px; font-size: 13px; color: var(--gray-700); }
.disposal-never-box li { margin-bottom: 2px; }

/* Titration builder */
.titration-builder {
  background: var(--primary-light);
  border: 1px solid #bbdefb;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}
.titration-step-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  position: relative;
}
.titration-step-card .step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.titration-step-card .step-number {
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
}
.titration-step-card .remove-step {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
}
.titration-step-card .step-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.titration-step-card .step-fields input,
.titration-step-card .step-fields select {
  font-size: 13px;
  padding: 6px 8px;
}
.titration-step-card .step-fields label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  display: block;
  margin-bottom: 2px;
}

/* Titration badge on medication card */
.titration-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--primary-light);
  color: var(--primary);
  margin-left: 8px;
}
.titration-badge.tapering {
  background: #fff3e0;
  color: #ef6c00;
}

/* Titration timeline on medication card */
.titration-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 8px 0;
  padding: 0 8px;
}
.titration-timeline-step {
  flex: 1;
  text-align: center;
  position: relative;
  padding: 6px 4px;
  font-size: 11px;
  color: var(--gray-500);
  border-bottom: 3px solid var(--gray-200);
  transition: all 0.2s;
}
.titration-timeline-step.active {
  color: var(--primary);
  font-weight: 700;
  border-bottom-color: var(--primary);
}
.titration-timeline-step.completed {
  color: var(--success);
  border-bottom-color: var(--success);
}
.titration-timeline-step .step-dose {
  display: block;
  font-size: 12px;
  font-weight: 600;
}
.titration-timeline-step .step-days {
  display: block;
  font-size: 10px;
  color: var(--gray-400);
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrapper {
  position: relative;
}
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 260px;
  overflow-y: auto;
  z-index: 1000;
}
.autocomplete-dropdown.open {
  display: block;
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--gray-100);
}
.autocomplete-item:last-child {
  border-bottom: none;
}
.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--primary-light);
}
.autocomplete-item .med-name {
  font-weight: 500;
}
.autocomplete-item .med-alt {
  color: var(--gray-400);
  font-size: 12px;
}
.autocomplete-item .cd-badge-sm {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
}
.autocomplete-item .cd-badge-sm.cd3,
.autocomplete-item .cd-badge-sm.cd4,
.autocomplete-item .cd-badge-sm.cd5 {
  background: var(--warning);
}

/* CD Warning Banner */
.cd-warning-banner {
  background: var(--danger-light);
  border: 2px solid var(--danger);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.cd-warning-banner.schedule-3,
.cd-warning-banner.schedule-4,
.cd-warning-banner.schedule-5 {
  background: var(--warning-light);
  border-color: var(--warning);
}
.cd-warning-icon {
  background: var(--danger);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.cd-warning-banner.schedule-3 .cd-warning-icon,
.cd-warning-banner.schedule-4 .cd-warning-icon,
.cd-warning-banner.schedule-5 .cd-warning-icon {
  background: var(--warning);
}
.cd-warning-content {
  font-size: 13px;
  line-height: 1.5;
}
.cd-warning-content strong {
  font-size: 14px;
}
.cd-warning-content p {
  margin: 4px 0;
}
.cd-warning-content ul {
  margin: 4px 0 0;
  padding-left: 20px;
}
.cd-warning-content li {
  margin-bottom: 2px;
}

/* Did you mean? bar */
.did-you-mean-bar {
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 6px;
  padding: 6px 12px;
  margin-top: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.did-you-mean-bar .dym-text {
  flex: 1;
}
.did-you-mean-bar .dym-name {
  font-weight: 600;
}
.did-you-mean-bar button {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid #90caf9;
  background: #fff;
}
.did-you-mean-bar button.dym-yes {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* CD Badge on medication cards */
.cd-card-badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  cursor: help;
}
.cd-card-badge.cd3,
.cd-card-badge.cd4,
.cd-card-badge.cd5 {
  background: var(--warning);
}

/* Manual CD checkbox */
#newMedManualCD {
  margin-right: 6px;
}

/* ===== INCIDENT REPORTING ===== */
.severity-radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.severity-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}
.severity-radio small {
  color: var(--gray-400);
  font-size: 12px;
  margin-left: 4px;
}
.severity-radio input[type="radio"] {
  margin-right: 4px;
}
.severity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.severity-dot.minor { background: var(--primary); }
.severity-dot.moderate { background: var(--warning); }
.severity-dot.severe { background: var(--danger); }
.severity-dot.critical { background: #7b1fa2; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover {
  background: #c62828;
}

/* Incident cards */
.incident-card {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  transition: box-shadow 0.15s;
}
.incident-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.incident-severity-bar {
  width: 4px;
  min-height: 48px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
}
.incident-severity-bar.minor { background: var(--primary); }
.incident-severity-bar.moderate { background: var(--warning); }
.incident-severity-bar.severe { background: var(--danger); }
.incident-severity-bar.critical { background: #7b1fa2; }

.incident-card-body {
  flex: 1;
  min-width: 0;
}
.incident-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.incident-type-label {
  font-weight: 600;
  font-size: 14px;
}
.incident-severity-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  color: #fff;
}
.incident-severity-badge.minor { background: var(--primary); }
.incident-severity-badge.moderate { background: var(--warning); }
.incident-severity-badge.severe { background: var(--danger); }
.incident-severity-badge.critical { background: #7b1fa2; }

.incident-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.incident-status-badge.open { background: var(--danger-light); color: var(--danger); }
.incident-status-badge.under_investigation { background: var(--warning-light); color: var(--warning); }
.incident-status-badge.resolved { background: var(--success-light); color: var(--success); }

.incident-card-meta {
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 4px;
}
.incident-card-desc {
  font-size: 13px;
  color: var(--gray-600);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.incident-count-badge {
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
}

/* Incident detail modal */
.incident-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.incident-detail-item label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--gray-400);
  font-weight: 600;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 2px;
}
.incident-detail-item .value {
  font-size: 14px;
}
.incident-detail-full {
  grid-column: 1 / -1;
}

/* Five Rights verification */
.five-rights-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s;
}
.five-rights-item:hover {
  background: var(--gray-50);
}
.five-rights-item:last-of-type {
  border-bottom: none;
}
.five-rights-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--success);
}

/* Dashboard incident stat */
.stat-card.incidents {
  border-left: 4px solid var(--danger);
}

/* ===== Document Scan ===== */
.scan-section {
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}
.scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--primary);
  border-color: var(--primary);
}
.scan-btn:hover {
  background: var(--primary);
  color: white;
}
.scan-hint {
  display: block;
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 6px;
}
.scan-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  color: var(--primary);
  font-weight: 500;
}
.scan-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: scanSpin 0.8s linear infinite;
}
@keyframes scanSpin {
  to { transform: rotate(360deg); }
}
.scan-review-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}
.scan-review-card.removed {
  opacity: 0.4;
  text-decoration: line-through;
}
.scan-review-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.scan-review-header strong {
  flex: 1;
  font-size: 15px;
}
.scan-confidence {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.scan-confidence.high { background: var(--success); }
.scan-confidence.medium { background: var(--warning); }
.scan-confidence.low { background: var(--danger); }
.scan-review-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 4px 12px;
  font-size: 13px;
  color: var(--gray-600);
}
.scan-review-details span {
  color: var(--gray-900);
}
.scan-review-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.scan-patient-info {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.scan-patient-info h4 {
  font-size: 14px;
  color: var(--warning);
  margin-bottom: 8px;
}
.scan-patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 4px 16px;
  font-size: 13px;
}
.scan-patient-grid label {
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  font-size: 11px;
}
.scan-doc-info {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--gray-600);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 0.9rem;
  max-width: 400px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.2s forwards;
  line-height: 1.4;
}
.toast.toast-error {
  background: var(--danger);
}
.toast.toast-success {
  background: var(--success);
}
.toast.toast-warning {
  background: var(--warning);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ===== Connectivity Bar ===== */
.connectivity-bar {
  background: var(--warning-light);
  color: var(--warning);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid var(--warning);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 950;
}
.connectivity-bar.offline {
  background: var(--danger-light);
  color: var(--danger);
  border-bottom-color: var(--danger);
}

/* ===== Bottom Navigation (Mobile) ===== */
.bottom-nav {
  display: none;
}
.more-menu {
  display: none;
}
.more-menu-overlay {
  display: none;
}

/* ===== eMAR Mobile Daily View ===== */
.emar-mobile-day-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  margin-bottom: 12px;
}
.emar-mobile-day-nav span {
  font-weight: 600;
  font-size: 16px;
}
.emar-mobile-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.emar-mobile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.15s;
}
.emar-mobile-card:active {
  background: var(--gray-50);
}
.emar-mobile-card-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  min-width: 50px;
}
.emar-mobile-card-info {
  flex: 1;
  min-width: 0;
}
.emar-mobile-card-info strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emar-mobile-card-info span {
  font-size: 12px;
  color: var(--gray-600);
}
.emar-mobile-section {
  margin-bottom: 20px;
}
.emar-mobile-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--gray-600);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-left: 4px;
}
.emar-legend-toggle {
  display: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 767px) {
  /* Mobile top nav adjustments */
  .nav button {
    padding: 6px 10px;
    min-width: 48px;
    min-height: 48px;
    font-size: 10px;
  }

  /* Header mobile */
  .header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header h1 { display: none; }
  #userInfo { display: none; }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .client-selector {
    flex: 1;
    min-height: 40px;
    font-size: 15px;
  }

  /* Main content mobile padding */
  .main {
    padding: 12px;
  }

  /* Touch targets */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }
  .btn-sm {
    min-height: 40px;
    padding: 8px 14px;
  }
  input, select, textarea {
    min-height: 44px;
    font-size: 16px;
  }
  .modal-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 28px;
  }

  /* Stats grid */
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }

  /* Section headers */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* eMAR legend toggle */
  .emar-legend-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-600);
    width: 100%;
  }
  .emar-legend {
    display: none;
    margin-bottom: 12px;
  }
  .emar-legend.open {
    display: flex;
  }

  /* Connectivity bar above bottom nav */
  .connectivity-bar {
    bottom: 64px;
  }

  /* Toast position on mobile */
  .toast-container {
    top: auto;
    bottom: 76px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: none;
  }

  /* Responsive tables */
  .responsive-table thead { display: none; }
  .responsive-table,
  .responsive-table tbody {
    display: block;
  }
  .responsive-table tr {
    display: block;
    margin-bottom: 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
  }
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
    gap: 8px;
  }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 11px;
    text-transform: uppercase;
    flex-shrink: 0;
    min-width: 80px;
  }
  .responsive-table td:last-child {
    padding-bottom: 0;
  }

  /* Modal full-screen on mobile */
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: 28px; }
}
