/* ============================================
   VetCalc — Veterinary Anesthesia Calculator
   Mobile-first CSS
   ============================================ */

/* ---------- Custom Properties ---------- */
:root {
  /* Colors */
  --bg: #F8F8F6;
  --surface: #FFFFFF;
  --primary: #1B6B4A;
  --primary-dark: #144F37;
  --primary-light: #E8F5EE;
  --text-primary: #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-muted: #6E6E6E;
  --border: #E2E2E0;
  --danger: #C62828;
  --danger-light: #FFEBEE;
  --warning: #B45309;
  --warning-light: #FFF8E1;
  --success: #2E7D32;
  --success-light: #E8F5E9;

  /* Spacing (multiples of 4) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;
  --text-5xl: 48px;
  --text-6xl: 60px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);

  /* Layout */
  --tab-bar-height: 64px;
  --header-height: 56px;

  /* Safe areas */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg);
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

/* ---------- App Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: var(--surface);
  height: var(--header-height);
  padding: 0 var(--space-4);
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-header h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.app-header .header-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 6px;
}

.header-version {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 500;
  opacity: 0.6;
}

/* ---------- Disclaimer Banner ---------- */
.disclaimer-banner {
  background: var(--warning-light);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.disclaimer-banner p {
  font-size: var(--text-xs);
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.disclaimer-dismiss {
  background: var(--primary);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
}

/* ---------- Tab Bar ---------- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
  min-height: 44px;
  padding: var(--space-2) 0;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn svg,
.tab-btn .tab-icon {
  width: 24px;
  height: 24px;
  transition: color 0.15s ease;
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
  border-top: 3px solid var(--primary);
}

.tab-btn:active {
  opacity: 0.7;
}

/* ---------- View Panels ---------- */
.view-panel {
  display: none;
  padding: var(--space-4);
  padding-bottom: var(--space-8);
}

.view-panel.active {
  display: block;
}

/* ---------- Species Toggle ---------- */
.species-toggle-wrapper {
  display: flex;
  justify-content: center;
  padding: var(--space-4) 0;
}

.species-toggle {
  display: flex;
  background: var(--border);
  border-radius: var(--radius-pill);
  padding: var(--space-1);
  height: 56px;
  width: 100%;
  max-width: 320px;
  position: relative;
  border: none;
  cursor: pointer;
}

.species-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.species-option.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ---------- Weight Input Section ---------- */
.weight-section {
  padding: var(--space-4) 0;
}

.weight-section label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.weight-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.weight-input-wrapper {
  position: relative;
  flex: 1;
  max-width: 200px;
}

.weight-input-wrapper input {
  width: 100%;
  height: 56px;
  font-family: var(--font-body);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-12) 0 var(--space-4);
  text-align: left;
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.weight-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
}

.weight-input-wrapper input::-webkit-inner-spin-button,
.weight-input-wrapper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.weight-unit {
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.weight-display {
  font-size: var(--text-base);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Weight Quick-Set Buttons */
.weight-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.weight-preset-btn,
.protocol-weight-preset-btn {
  height: 44px;
  min-width: 56px;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.weight-preset-btn:active,
.protocol-weight-preset-btn:active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.weight-preset-btn.active,
.protocol-weight-preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--surface);
}

/* ---------- Drug List ---------- */
.drug-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* Drug Category Section */
.drug-category {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.drug-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  min-height: 56px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

.drug-category-header:active {
  background: var(--bg);
}

.drug-category-header .chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.drug-category.open .drug-category-header .chevron {
  transform: rotate(180deg);
}

.drug-category-count {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  margin-left: auto;
  margin-right: var(--space-3);
}

.drug-category-body {
  display: none;
  border-top: 1px solid var(--border);
}

.drug-category.open .drug-category-body {
  display: block;
}

/* Drug Card */
.drug-card {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.drug-card:last-child {
  border-bottom: none;
}

.drug-card:active {
  background: var(--bg);
}

.drug-card-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.drug-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.drug-dose-badge {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.drug-dose-badge.capped {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.conc-select {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  min-height: 36px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%231B6B4A' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.conc-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.conc-selector-row {
  align-items: center;
}

.drug-card-details {
  display: none;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.drug-card.expanded .drug-card-details {
  display: block;
}

.drug-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-1) 0;
}

.drug-detail-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.drug-detail-value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.drug-route {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg);
  padding: var(--space-1) var(--space-2);
  border-radius: 4px;
  margin-top: var(--space-2);
}

/* Warning Drug Cards */
.drug-card.warning {
  border-left: 4px solid var(--danger);
}

.drug-card.warning .drug-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drug-warning-icon {
  color: var(--danger);
  flex-shrink: 0;
}

.drug-warning-text {
  font-size: var(--text-sm);
  color: var(--danger);
  font-weight: 500;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--danger-light);
  border-radius: var(--radius-sm);
}

/* ---------- Timer View ---------- */
.timer-display-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-8) 0 var(--space-6);
}

.timer-display {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: var(--text-5xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
}

.timer-controls {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-6);
}

.timer-btn {
  height: 64px;
  min-width: 120px;
  padding: 0 var(--space-8);
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.timer-btn:active {
  transform: scale(0.96);
}

.timer-btn-start {
  background: var(--success);
  color: var(--surface);
}

.timer-btn-start:active {
  background: var(--primary-dark);
}

.timer-btn-stop {
  background: var(--danger);
  color: var(--surface);
  display: none;
}

.timer-btn-stop:active {
  background: #A01F1F;
}

.timer-btn-reset {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  min-width: 80px;
}

.timer-btn-reset:active {
  background: var(--border);
}

/* Timer running states (toggled by JS) */
.timer-running .timer-btn-start {
  display: none;
}

.timer-running .timer-btn-stop {
  display: flex;
}

/* Procedure Selector */
.procedure-section {
  margin-top: var(--space-6);
}

.section-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  height: 56px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-12) 0 var(--space-4);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.select-wrapper select:focus {
  outline: none;
  border-color: var(--primary);
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--text-muted);
  pointer-events: none;
}

/* Lap Buttons */
.lap-section {
  margin-top: var(--space-6);
}

.lap-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.lap-btn {
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.lap-btn:active {
  background: var(--primary);
  color: var(--surface);
}

/* Lap Log */
.lap-log-section {
  margin-top: var(--space-6);
}

.lap-log {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.lap-log-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.lap-time {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  min-width: 72px;
}

.lap-label {
  font-size: var(--text-base);
  color: var(--text-primary);
  font-weight: 500;
}

.lap-log-empty {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-4);
  text-align: center;
}

/* Monitoring Section */
.monitoring-section {
  margin-top: var(--space-6);
}

.monitoring-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.monitoring-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.monitoring-field label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.monitoring-field input {
  height: 48px;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  text-align: center;
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.monitoring-field input:focus {
  outline: none;
  border-color: var(--primary);
}

.monitoring-field input::-webkit-inner-spin-button,
.monitoring-field input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.monitoring-field .unit {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
}

.monitoring-submit {
  grid-column: 1 / -1;
  height: 56px;
  background: var(--primary);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.monitoring-submit:active {
  background: var(--primary-dark);
}

/* Monitoring Log */
.monitoring-log {
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.monitoring-log-entry {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
}

.monitoring-log-time {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: var(--text-xs);
  color: var(--primary);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.monitoring-log-vitals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.monitoring-log-vitals span {
  font-weight: 500;
}

.monitoring-log-vitals strong {
  font-weight: 700;
}

.vital-value.vital-normal strong {
  color: var(--success);
}

.vital-value.vital-warning {
  background: var(--warning-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.vital-value.vital-warning strong {
  color: var(--warning);
}

.vital-value.vital-critical {
  background: var(--danger-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.vital-value.vital-critical strong {
  color: var(--danger);
  font-weight: 800;
}

/* ---------- Checklist View ---------- */
.checklist-header {
  padding: var(--space-4) 0 var(--space-3);
}

/* Checklist Progress Bar */
.checklist-progress {
  margin-bottom: var(--space-4);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

/* Checklist Container */
.checklist-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.checklist-group-header {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  margin-top: var(--space-2);
}

.checklist-group-header:first-child {
  margin-top: 0;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.checklist-item:active {
  background: var(--bg);
}

.checklist-checkbox {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.checklist-item.checked .checklist-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.checklist-checkbox svg {
  width: 16px;
  height: 16px;
  color: var(--surface);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.checklist-item.checked .checklist-checkbox svg {
  opacity: 1;
}

.checklist-item-text {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.checklist-item.checked .checklist-item-text {
  opacity: 0.5;
  text-decoration: line-through;
}

/* ---------- Section Dividers ---------- */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

/* ---------- Protocol View ---------- */
.protocol-patient-section {
  padding: var(--space-4) 0 var(--space-2);
}

.protocol-patient-section label,
.protocol-email-section label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.protocol-input {
  width: 100%;
  height: 56px;
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
}

.protocol-input:focus {
  outline: none;
  border-color: var(--primary);
}

.protocol-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.protocol-results {
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.protocol-empty {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-muted);
  font-size: var(--text-base);
}

.protocol-drug-row {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.protocol-drug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.protocol-drug-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
}

.protocol-drug-route {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg);
  padding: var(--space-1) var(--space-2);
  border-radius: 4px;
}

.protocol-drug-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.protocol-value-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.protocol-value-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.protocol-value-num {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.protocol-value-unit {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.protocol-drug-row.fluid-row .protocol-value-num {
  color: var(--text-primary);
}

.protocol-drug-row.capped-row {
  border-left: 4px solid var(--danger);
}

.protocol-email-section {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.protocol-email-row {
  display: flex;
  gap: var(--space-3);
}

.protocol-email-row .protocol-input {
  flex: 1;
  font-size: var(--text-base);
  font-weight: 500;
  height: 48px;
}

.protocol-send-btn {
  height: 48px;
  padding: 0 var(--space-6);
  background: var(--primary);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.protocol-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.protocol-send-btn:not(:disabled):active {
  background: var(--primary-dark);
  transform: scale(0.96);
}

/* ---------- Empty States ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-3);
}

.empty-state-text {
  font-size: var(--text-base);
}

/* ---------- Focus Styles (Accessibility) ---------- */
.tab-btn:focus-visible,
.species-option:focus-visible,
.weight-preset-btn:focus-visible,
.protocol-weight-preset-btn:focus-visible,
.drug-category-header:focus-visible,
.drug-card:focus-visible,
.timer-btn:focus-visible,
.lap-btn:focus-visible,
.checklist-item:focus-visible,
.monitoring-submit:focus-visible,
.protocol-send-btn:focus-visible,
.checklist-select:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Hover States (desktop PWA) ---------- */
@media (hover: hover) {
  .tab-btn:hover {
    color: var(--primary);
  }

  .drug-card:hover {
    background: var(--bg);
  }

  .drug-category-header:hover {
    background: var(--bg);
  }

  .weight-preset-btn:hover,
  .protocol-weight-preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
  }

  .lap-btn:hover {
    background: var(--primary);
    color: var(--surface);
  }

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

  .timer-btn-start:hover {
    background: var(--primary-dark);
  }

  .timer-btn-stop:hover {
    background: #A01F1F;
  }

  .monitoring-submit:hover {
    background: var(--primary-dark);
  }

  .protocol-send-btn:not(:disabled):hover {
    background: var(--primary-dark);
  }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Utility ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Tablet / Desktop ---------- */
@media (min-width: 768px) {
  body {
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom));
  }

  .tab-bar {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-md);
  }

  .view-panel {
    padding: var(--space-6);
  }

  .timer-display {
    font-size: var(--text-6xl);
  }

  .monitoring-form {
    grid-template-columns: repeat(3, 1fr);
  }

  .weight-presets {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .weight-preset-btn,
.protocol-weight-preset-btn {
    min-width: 64px;
    height: 48px;
    font-size: var(--text-lg);
  }

  .drug-card-summary {
    min-height: 48px;
  }
}

/* ---------- Landscape Safety ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .timer-display {
    font-size: var(--text-4xl);
  }

  .timer-display-wrapper {
    padding: var(--space-4) 0 var(--space-3);
  }

  .timer-btn {
    height: 48px;
  }
}

/* ---------- Dark Mode (optional, respects system) ---------- */
@media (prefers-color-scheme: dark) {
  .protocol-drug-row,
  .drug-card,
  .drug-category,
  .checklist-item,
  .lap-log-item,
  .monitoring-log-entry {
    border: 1px solid #3A3A3E;
  }

  :root {
    --bg: #0F0F0F;
    --surface: #1E1E22;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5);
    --primary: #34D399;
    --primary-dark: #10B981;
    --primary-light: #052E16;
    --text-primary: #F5F5F5;
    --text-secondary: #A1A1AA;
    --text-muted: #9CA3AF;
    --border: #2C2C2E;
    --danger: #F87171;
    --danger-light: #450A0A;
    --warning: #FBBF24;
    --warning-light: #422006;
    --success: #22C55E;
    --success-light: #052E16;
  }
}
