/**
 * Healthcare Professional Interface Theme
 * Optimized for clinical environments and mobile devices
 * WCAG AAA compliant with medical color standards
 */

/* ========================================
   DESKTOP-FIRST Medical Workstation Design System
   ======================================== */
:root {
  /* Healthcare Color Palette - Professional Desktop */
  --medical-primary: #1e40af;      /* Professional dark blue */
  --medical-secondary: #3b82f6;    /* Standard blue */
  --medical-success: #047857;      /* Medical green (safe) */
  --medical-warning: #d97706;      /* Amber warning */
  --medical-danger: #dc2626;       /* Medical red (critical) */
  --medical-info: #6366f1;         /* Indigo info */
  
  /* Professional Desktop Palette */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  /* Typography - Desktop optimized */
  --font-family-base: 'Segoe UI', 'Roboto', 'Liberation Sans', sans-serif;
  --font-family-mono: 'Consolas', 'Monaco', 'Liberation Mono', monospace;
  
  /* Dense Desktop Spacing - NO touch targets */
  --space-xs: 0.125rem;   /* 2px */
  --space-sm: 0.25rem;    /* 4px */
  --space-md: 0.375rem;   /* 6px */
  --space-lg: 0.5rem;     /* 8px */
  --space-xl: 0.75rem;    /* 12px */
  --space-2xl: 1rem;      /* 16px */
  --space-3xl: 1.25rem;   /* 20px */
  --space-4xl: 1.5rem;    /* 24px */
  
  /* Desktop Input Targets - Mouse precision */
  --input-height: 28px;             /* Dense desktop inputs */
  --button-height: 32px;            /* Compact buttons */
  --button-height-lg: 40px;         /* Primary actions */
  
  /* Minimal Borders & Radius - Professional look */
  --border-radius-sm: 2px;
  --border-radius-md: 3px;
  --border-radius-lg: 4px;
  --border-width: 1px;
  --border-width-thick: 1px;        /* No thick borders */
  
  /* Subtle Desktop Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-md: 0 2px 4px 0 rgb(0 0 0 / 0.06);
  --shadow-lg: 0 4px 8px 0 rgb(0 0 0 / 0.12);
  
  /* Desktop Focus States */
  --focus-ring: 0 0 0 2px rgb(30 64 175 / 0.2);
  --focus-ring-danger: 0 0 0 2px rgb(220 38 38 / 0.2);
}

/* ========================================
   Base Styles & Reset
   ======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-base);
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ========================================
   Desktop Typography Scale - Dense & Professional
   ======================================== */
.text-xs { font-size: 0.6875rem; line-height: 1rem; }      /* 11px */
.text-sm { font-size: 0.8125rem; line-height: 1.125rem; }  /* 13px */
.text-base { font-size: 0.875rem; line-height: 1.25rem; }  /* 14px - Base */
.text-lg { font-size: 1rem; line-height: 1.375rem; }       /* 16px */
.text-xl { font-size: 1.125rem; line-height: 1.5rem; }     /* 18px */
.text-2xl { font-size: 1.25rem; line-height: 1.625rem; }   /* 20px */
.text-3xl { font-size: 1.375rem; line-height: 1.75rem; }   /* 22px */

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ========================================
   Header & Navigation
   ======================================== */
.healthcare-header {
  background: linear-gradient(135deg, var(--medical-primary) 0%, var(--medical-secondary) 100%);
  color: white;
  padding: var(--space-lg) 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 1000;
}

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

.healthcare-logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  text-decoration: none;
  color: inherit;
}

.healthcare-logo img {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
}

.healthcare-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

/* ========================================
   Desktop-First Layout & Grid System
   ======================================== */
.healthcare-container {
  max-width: 1600px;                    /* Wide desktop support */
  margin: 0 auto;
  padding: 0 var(--space-2xl);
}

/* Desktop-first grid - 3 columns for wide screens */
.healthcare-grid {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;  /* Patient, Values, Results */
  gap: var(--space-2xl);
  margin: var(--space-2xl) 0;
}

/* Form grid for dense desktop layout */
.desktop-form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: var(--space-xl);
  max-width: none;
}

/* Vertical measurements layout */
.measurements-desktop-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* Force form-groups inside measurements to stack vertically */
.measurements-desktop-grid .form-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Keep input and button side by side, but stack the measurement fields vertically */
.measurements-desktop-grid .input-group-desktop {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
}

/* Hydric Balance Section - Third Column */
.hydric-balance-section-desktop {
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-md);
  background: white;
  padding: var(--space-2xl);
  min-height: 500px;
}

/* Values grid - inputs/outputs side by side */
.values-desktop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
}

/* Scale down for smaller desktop screens */
@media (max-width: 1400px) {
  .healthcare-grid {
    grid-template-columns: 1fr 1fr;     /* 2 columns */
  }
  
  .measurements-desktop-grid {
    display: flex;
    flex-direction: column;
  }
}

/* Tablet fallback (still desktop-focused) */
@media (max-width: 1024px) {
  .healthcare-grid {
    grid-template-columns: 1fr;
  }
  
  .measurements-desktop-grid {
    display: flex;
    flex-direction: column;
  }
  
  .values-desktop-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   Cards & Sections
   ======================================== */
.healthcare-card {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  border: var(--border-width) solid var(--gray-200);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.healthcare-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.healthcare-card-header {
  background: var(--gray-100);
  padding: var(--space-xl);
  border-bottom: var(--border-width) solid var(--gray-200);
}

.healthcare-card-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.healthcare-card-body {
  padding: var(--space-xl);
}

/* ========================================
   Progressive Form Design
   ======================================== */
.healthcare-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.healthcare-section {
  background: white;
  border-radius: var(--border-radius-lg);
  border: var(--border-width-thick) solid var(--gray-200);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.healthcare-section.active {
  border-color: var(--medical-primary);
  box-shadow: var(--focus-ring);
}

.healthcare-section-header {
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-50) 100%);
  padding: var(--space-lg) var(--space-xl);
  border-bottom: var(--border-width) solid var(--gray-200);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.healthcare-section-header:hover {
  background: var(--gray-100);
}

.healthcare-section-header.completed {
  background: linear-gradient(135deg, var(--medical-success) 0%, #10b981 100%);
  color: white;
}

.healthcare-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.healthcare-section-step {
  background: var(--medical-primary);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
}

.healthcare-section-step.completed {
  background: var(--medical-success);
}

.healthcare-section-content {
  padding: var(--space-xl);
  display: none;
}

.healthcare-section.active .healthcare-section-content {
  display: block;
}

/* ========================================
   Desktop Form Controls - Mouse/Keyboard Optimized
   ======================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.form-label.required::after {
  content: '*';
  color: var(--medical-danger);
  font-weight: var(--font-bold);
}

/* Dense desktop inputs */
.form-control {
  height: var(--input-height);
  padding: var(--space-sm) var(--space-lg);
  border: var(--border-width) solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  background: white;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--medical-primary);
  box-shadow: var(--focus-ring);
}

.form-control:hover {
  border-color: var(--gray-400);
}

.form-control.is-invalid {
  border-color: var(--medical-danger);
  box-shadow: var(--focus-ring-danger);
}

.form-control.success {
  border-color: var(--medical-success);
}

/* Desktop number inputs - right-aligned with monospace */
.form-control[type="number"] {
  font-family: var(--font-family-mono);
  font-size: var(--text-sm);
  text-align: right;
  padding-right: var(--space-md);
}

/* Compact desktop inputs for measurements */
.form-control.compact {
  height: 24px;
  padding: var(--space-xs) var(--space-md);
  font-size: 0.75rem;
}

/* Desktop-specific input groups */
.input-group-desktop {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.input-group-desktop .form-control {
  flex: 1;
  margin: 0;
}

.input-group-desktop .input-unit {
  font-size: var(--text-xs);
  color: var(--gray-500);
  font-weight: var(--font-medium);
  min-width: 2rem;
  text-align: left;
}

/* ========================================
   Calculation Fields with Visual Feedback
   ======================================== */
.calculation-field {
  background: var(--gray-50);
  border: var(--border-width-thick) solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl);
  transition: all 0.3s ease;
}

.calculation-field.has-value {
  background: white;
  border-color: var(--medical-success);
  box-shadow: 0 0 0 1px var(--medical-success);
}

.calculation-input-group {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.calculation-input {
  flex: 1;
  min-height: var(--touch-target-optimal);
  padding: var(--space-md);
  border: var(--border-width) solid var(--gray-300);
  border-radius: var(--border-radius-md);
  font-size: var(--text-base);
  font-family: var(--font-family-mono);
}

.calculation-button {
  min-width: var(--touch-target-optimal);
  min-height: var(--touch-target-optimal);
  padding: 0 var(--space-lg);
  border: none;
  border-radius: var(--border-radius-md);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.calculation-button.primary {
  background: var(--medical-primary);
  color: white;
}

.calculation-button.primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.calculation-button.danger {
  background: var(--medical-danger);
  color: white;
}

.calculation-button.danger:hover {
  background: #b91c1c;
}

.calculation-list {
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-md);
  max-height: 200px;
  overflow-y: auto;
}

.calculation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: var(--border-width) solid var(--gray-100);
}

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

.calculation-total {
  background: var(--medical-primary);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--border-radius-md);
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  text-align: center;
  margin-top: var(--space-lg);
}

/* ========================================
   Desktop Action Buttons - Mouse Optimized
   ======================================== */
.healthcare-button {
  height: var(--button-height);
  padding: 0 var(--space-2xl);
  border: var(--border-width) solid transparent;
  border-radius: var(--border-radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.healthcare-button:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}

.healthcare-button.primary {
  background: var(--medical-primary);
  color: white;
  border-color: var(--medical-primary);
}

.healthcare-button.primary:hover {
  background: #1e3a8a;
  border-color: #1e3a8a;
}

.healthcare-button.secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.healthcare-button.secondary:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

.healthcare-button.success {
  background: var(--medical-success);
  color: white;
  border-color: var(--medical-success);
}

.healthcare-button.danger {
  background: var(--medical-danger);
  color: white;
  border-color: var(--medical-danger);
}

/* Compact button variant */
.healthcare-button.compact {
  height: 24px;
  padding: 0 var(--space-lg);
  font-size: 0.75rem;
  gap: var(--space-sm);
}

/* Large button for primary actions */
.healthcare-button.lg {
  height: var(--button-height-lg);
  padding: 0 var(--space-3xl);
  font-size: var(--text-base);
}

/* Desktop-specific button groups */
.button-group-desktop {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.button-group-desktop .healthcare-button {
  margin: 0;
}

/* Icon-only buttons for desktop */
.healthcare-button.icon-only {
  width: var(--button-height);
  padding: 0;
}

.healthcare-button.icon-only.compact {
  width: 24px;
}

/* ========================================
   Results Display - Clinical Format
   ======================================== */
.results-container, #results-container {
  display: none !important; /* Ocultar sistema antigo - usando apenas modal */
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-top: var(--space-2xl);
}

.results-header {
  background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-700) 100%);
  color: white;
  padding: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.results-actions {
  display: flex;
  gap: var(--space-md);
}

.results-body {
  padding: var(--space-2xl);
}

.patient-info {
  background: var(--gray-50);
  border-radius: var(--border-radius-md);
  padding: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

.patient-name {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--gray-800);
  margin: 0 0 var(--space-md) 0;
}

.patient-details {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.patient-badge {
  background: var(--medical-info);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.measurements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.measurement-item {
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  text-align: center;
}

.measurement-label {
  font-size: var(--text-sm);
  color: var(--gray-600);
  margin-bottom: var(--space-sm);
}

.measurement-value {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--gray-800);
  font-family: var(--font-family-mono);
}

/* ========================================
   Balance Display - Clinical Priority
   ======================================== */
.balance-section {
  background: var(--gray-900);
  color: white;
  padding: var(--space-2xl);
  border-radius: var(--border-radius-lg);
  text-align: center;
  margin: var(--space-2xl) 0;
}

.balance-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-xl);
  opacity: 0.9;
}

.balance-value {
  font-size: 3rem;
  font-weight: var(--font-bold);
  font-family: var(--font-family-mono);
  margin-bottom: var(--space-md);
}

.balance-value.positive { color: var(--medical-success); }
.balance-value.negative { color: var(--medical-danger); }
.balance-value.neutral { color: var(--gray-300); }

.balance-subtitle {
  font-size: var(--text-base);
  opacity: 0.8;
}

/* ========================================
   Mobile Responsive Design
   ======================================== */
@media (max-width: 768px) {
  :root {
    --space-lg: 0.875rem;
    --space-xl: 1.25rem;
    --space-2xl: 1.75rem;
  }
  
  .healthcare-container {
    padding: 0 var(--space-md);
  }
  
  .healthcare-header .container {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
  
  .healthcare-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
  
  .calculation-input-group {
    flex-direction: column;
  }
  
  .patient-details {
    justify-content: center;
  }
  
  .measurements-grid {
    grid-template-columns: 1fr;
  }
  
  .balance-value {
    font-size: 2.5rem;
  }
}

/* ========================================
   Dark Mode Support
   ======================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
  }
  
  body {
    background-color: var(--gray-50);
    color: var(--gray-800);
  }
  
  .healthcare-card,
  .form-control,
  .calculation-field {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-800);
  }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
  .healthcare-header,
  .healthcare-button,
  .results-actions {
    display: none !important;
  }
  
  .results-container {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  * {
    color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* ========================================
   Accessibility Enhancements
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  .healthcare-button,
  .form-control,
  .healthcare-card {
    border-width: 2px;
  }
}

/* Focus visible for better keyboard navigation */
.healthcare-button:focus-visible,
.form-control:focus-visible,
.healthcare-section-header:focus-visible {
  outline: 3px solid var(--medical-primary);
  outline-offset: 2px;
}

/* ========================================
   Loading Screen
   ======================================== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-left: 4px solid var(--medical-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-lg);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   Progress Indicator
   ======================================== */
.progress-container {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-md);
  border: var(--border-width) solid var(--gray-200);
}

.progress-bar {
  height: 8px;
  background: linear-gradient(90deg, var(--medical-primary), var(--medical-secondary));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  text-align: center;
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--gray-600);
}

/* ========================================
   Period Selection
   ======================================== */
.period-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.period-option {
  background: white;
  border: var(--border-width-thick) solid var(--gray-300);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.period-option:hover {
  border-color: var(--medical-primary);
  transform: translateY(-2px);
}

.period-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.period-option input[type="radio"]:checked + .period-label {
  color: var(--medical-primary);
}

.period-option:has(input:checked) {
  border-color: var(--medical-primary);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(14, 165, 233, 0.05));
  box-shadow: var(--focus-ring);
}

.period-label {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-sm);
  transition: color 0.2s ease;
}

.period-description {
  font-size: var(--text-sm);
  color: var(--gray-500);
}

/* ========================================
   Form Grid & Layout
   ======================================== */
.form-grid {
  display: grid;
  gap: var(--space-xl);
}

@media (min-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .form-grid .form-group:first-child {
    grid-column: 1 / -1;
  }
}

.measurements-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.values-grid {
  display: grid;
  gap: var(--space-2xl);
}

@media (min-width: 1024px) {
  .values-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.values-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  padding-bottom: var(--space-md);
  border-bottom: var(--border-width-thick) solid var(--gray-200);
}

.values-section-title.success {
  color: var(--medical-success);
  border-color: var(--medical-success);
}

.values-section-title.danger {
  color: var(--medical-danger);
  border-color: var(--medical-danger);
}

/* ========================================
   Input with Unit
   ======================================== */
.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input {
  padding-right: 4rem;
}

.input-unit {
  position: absolute;
  right: var(--space-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--gray-500);
  pointer-events: none;
}

/* ========================================
   Section Actions
   ======================================== */
.section-actions {
  display: flex;
  gap: var(--space-lg);
  justify-content: space-between;
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: var(--border-width) solid var(--gray-200);
}

@media (max-width: 768px) {
  .section-actions {
    flex-direction: column;
  }
  
  .section-actions .healthcare-button {
    width: 100%;
  }
}

/* ========================================
   Form Help Text
   ======================================== */
.form-help {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: var(--space-sm);
}

.form-help i {
  color: var(--medical-info);
}

/* ========================================
   Calculation Labels
   ======================================== */
.calculation-label {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--gray-700);
  margin-bottom: var(--space-lg);
}

.calculation-label i {
  color: var(--medical-primary);
  font-size: 1.25rem;
}

/* ========================================
   Field Errors
   ======================================== */
.field-error {
  color: var(--medical-danger);
  font-size: var(--text-xs);
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.field-error::before {
  content: '⚠';
  font-weight: bold;
}

.form-control.error {
  border-color: var(--medical-danger);
  box-shadow: var(--focus-ring-danger);
}

/* ========================================
   Connection Status
   ======================================== */
.healthcare-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.status-indicator.online {
  background: var(--medical-success);
  color: var(--medical-success);
}

.status-indicator.offline {
  background: var(--medical-danger);
  color: var(--medical-danger);
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--medical-info);
  min-width: 300px;
  z-index: 1050;
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  border-left-color: var(--medical-danger);
}

.toast.success {
  border-left-color: var(--medical-success);
}

.toast-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: var(--border-width) solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: var(--font-semibold);
}

.toast.error .toast-header {
  color: var(--medical-danger);
}

.toast.success .toast-header {
  color: var(--medical-success);
}

.toast-body {
  padding: var(--space-md) var(--space-lg);
  color: var(--gray-700);
}

/* ========================================
   Footer
   ======================================== */
.healthcare-footer {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: var(--space-2xl) 0;
  margin-top: var(--space-3xl);
  text-align: center;
  font-size: var(--text-sm);
}

.footer-link {
  color: var(--medical-primary);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* ========================================
   Button Variants
   ======================================== */
.healthcare-button.secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.healthcare-button.secondary:hover {
  background: var(--gray-300);
  transform: translateY(-1px);
}

/* ========================================
   Animation Classes
   ======================================== */
.spin {
  animation: spin 1s linear infinite;
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

/* ========================================
   Mobile Optimizations
   ======================================== */
@media (max-width: 768px) {
  .period-options {
    grid-template-columns: 1fr;
  }
  
  .measurements-grid {
    grid-template-columns: 1fr;
  }
  
  .toast {
    right: var(--space-md);
    left: var(--space-md);
    min-width: auto;
  }
  
  .healthcare-header .healthcare-container {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .calculation-input-group {
    flex-direction: column;
  }
  
  .calculation-button {
    width: 100%;
  }
}

/* ========================================
   Report Modal
   ======================================== */

.modal-xl {
  max-width: 1200px;
}

#report-modal .modal-content {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
}

#report-modal.modal {
  display: none;
}

#report-modal.modal.show {
  display: block !important;
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 1050 !important;
  width: auto !important;
  height: auto !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
}

/* Backdrop opaco para o modal */
.modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  z-index: 1040 !important;
}

/* ========================================
   Validação de Peso Pediátrico
   ======================================== */
.weight-warning {
  border-color: #f59e0b !important;
  background-color: #fef3c7 !important;
  box-shadow: 0 0 0 0.2rem rgba(245, 158, 11, 0.25) !important;
}

.form-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background-color: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 0.375rem;
  color: #92400e;
  font-size: 0.875rem;
  font-weight: 500;
}

.form-warning i {
  color: #f59e0b;
  font-size: 1rem;
}

/* ========================================
   Campos de Balanço Hídrico
   ======================================== */
.hydric-field {
  position: relative;
  background: white;
  border-radius: 6px;
  padding: 6px;
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
  margin-bottom: 6px;
}

.hydric-field:hover {
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hydric-input-container {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.hydric-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.hydric-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.hydric-input.hydric-error {
  border-color: #dc2626;
  background-color: #fef2f2;
}

.hydric-input.hydric-warning {
  border-color: #f59e0b;
  background-color: #fefbf3;
}

.hydric-total {
  color: #1f2937;
  font-weight: 600;
  margin-top: 2px;
  padding: 1px 3px;
  background: #f8fafc;
  border-radius: 3px;
  display: inline-block;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  font-size: 11px;
}

.hydric-total:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.hydric-total:active {
  transform: translateY(0);
}

.hydric-history {
  margin-top: 4px;
  padding: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  max-height: 80px;
  overflow-y: auto;
  transition: all 0.3s ease;
}

.hydric-history.detailed-view {
  background: #fff;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
  animation: fadeIn 0.3s ease;
}

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

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 10px;
}

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

.history-expression {
  color: #6b7280;
  font-family: monospace;
  flex: 1;
}

.history-value {
  color: #1f2937;
  font-weight: 500;
  margin-right: 8px;
}

.history-remove {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.history-remove:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.hydric-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

.hydric-feedback.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.hydric-feedback.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.hydric-feedback.preview {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}


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

/* Estados de entrada */
.hydric-field.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.hydric-field.has-values {
  border-left: 4px solid #059669;
}

.hydric-field.has-values .hydric-total {
  background: #ecfdf5;
  color: #059669;
}

#report-modal .modal-dialog {
  margin: 0 !important;
  width: 100% !important;
  max-width: 1200px !important;
}

#report-modal .modal-header {
  background: var(--primary-color);
  color: white;
  border-bottom: none;
  padding: var(--space-lg) var(--space-xl);
}

#report-modal .modal-header .modal-title {
  font-weight: 600;
  font-size: 1.25rem;
}

#report-modal .modal-header .btn-close {
  filter: brightness(0) invert(1);
}

#report-modal .modal-body {
  padding: var(--space-xl);
  max-height: 70vh;
  overflow-y: auto;
}

#report-modal .modal-footer {
  border-top: var(--border-width) solid var(--gray-200);
  padding: var(--space-lg) var(--space-xl);
}

.report-section {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--gray-50);
  border-radius: var(--border-radius);
  border: var(--border-width) solid var(--gray-200);
}

.report-section h3 {
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.report-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--gray-200);
}

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

.report-item-label {
  font-weight: 500;
  color: var(--text-color);
}

.report-item-value {
  color: var(--primary-color);
  font-weight: 600;
}

.report-vital-sign {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  background: white;
  border-radius: var(--border-radius-sm);
  border: var(--border-width) solid var(--gray-200);
}

.report-vital-sign-name {
  font-weight: 500;
  color: var(--text-color);
}

.report-vital-sign-value {
  color: var(--primary-color);
  font-weight: 600;
}

.report-vital-sign-detail {
  font-size: 0.9rem;
  color: var(--gray-600);
  margin-top: var(--space-xs);
}

/* ========================================
   Desktop-First Components
   ======================================== */

/* Desktop Toolbar */
.desktop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  padding: var(--space-lg) var(--space-2xl);
  margin-bottom: var(--space-2xl);
  box-shadow: var(--shadow-sm);
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.toolbar-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--gray-700);
}

/* Compact Period Selector */
.period-selector-compact {
  display: flex;
  gap: var(--space-md);
}

.radio-compact {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--gray-700);
  user-select: none;
}

.radio-compact input[type="radio"] {
  margin: 0;
  width: 14px;
  height: 14px;
}

.radio-compact:hover {
  color: var(--medical-primary);
}

/* Compact Progress Bar */
.progress-compact {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 200px;
}

.progress-bar-compact {
  height: 6px;
  background: linear-gradient(90deg, var(--medical-primary), var(--medical-secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
  flex: 1;
}

.progress-text-compact {
  font-size: var(--text-xs);
  color: var(--gray-500);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

/* Desktop Form Panels */
.form-panel {
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.panel-header {
  background: var(--gray-50);
  border-bottom: var(--border-width) solid var(--gray-200);
  padding: var(--space-lg) var(--space-2xl);
}

.panel-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.panel-content {
  padding: var(--space-2xl);
}

.section-subtitle {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--gray-700);
  margin: var(--space-2xl) 0 var(--space-lg) 0;
  border-bottom: var(--border-width) solid var(--gray-200);
  padding-bottom: var(--space-sm);
}

/* Desktop Measurements Grid */
.measurements-section {
  margin-top: var(--space-2xl);
}

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

.measurement-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.measurement-total {
  font-size: var(--text-xs);
  color: var(--medical-primary);
  font-weight: var(--font-semibold);
  text-align: center;
  background: var(--gray-50);
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  border: var(--border-width) solid var(--gray-200);
}

/* Desktop Values Grid */
.values-section-desktop {
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-md);
  padding: var(--space-2xl);
}

.values-header-desktop {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: var(--border-width) solid var(--gray-200);
}

.values-title-desktop {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin: 0;
}

.values-grid-desktop {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-xl);
}

/* Calculation Field Desktop */
.calculation-field-desktop {
  background: var(--gray-50);
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  padding: var(--space-lg);
}

.calculation-field-desktop.has-value {
  background: white;
  border-color: var(--medical-success);
}

.calculation-label-desktop {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--gray-700);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.calculation-input-desktop {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.calculation-input-desktop input {
  flex: 1;
}

.calculation-list-desktop {
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
}

.calculation-item-desktop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--border-width) solid var(--gray-100);
  font-size: var(--text-sm);
  font-family: var(--font-family-mono);
}

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

.calculation-total-desktop {
  background: var(--medical-primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-sm);
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  text-align: center;
  font-family: var(--font-family-mono);
}

/* Keyboard Shortcut Indicators */
kbd {
  background: var(--gray-800);
  color: white;
  font-size: 0.625rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family-mono);
  margin-left: var(--space-md);
}

/* Desktop Results Panel */
.results-panel-desktop {
  background: white;
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-md);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.results-header-desktop {
  background: var(--gray-800);
  color: white;
  padding: var(--space-lg) var(--space-2xl);
  border-bottom: var(--border-width) solid var(--gray-700);
}

.results-content-desktop {
  padding: var(--space-2xl);
}

.results-summary-desktop {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

.summary-card-desktop {
  background: var(--gray-50);
  border: var(--border-width) solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  padding: var(--space-lg);
  text-align: center;
}

.summary-value-desktop {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  font-family: var(--font-family-mono);
  margin: var(--space-sm) 0;
}

.summary-label-desktop {
  font-size: var(--text-xs);
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   Compact Mode for Medical Efficiency
   ======================================== */
.compact {
  font-size: 0.8rem !important;
  line-height: 1.2 !important;
  padding: var(--space-sm) var(--space-md) !important;
}

.compact.calculation-input-group {
  margin-bottom: var(--space-md) !important;
}

.compact.calculation-input {
  min-height: 36px !important;
  font-size: 0.75rem !important;
  padding: var(--space-sm) !important;
}

.compact.calculation-button {
  min-width: 36px !important;
  min-height: 36px !important;
  padding: 0 var(--space-md) !important;
  font-size: 0.75rem !important;
}

.compact.calculation-list {
  max-height: 150px !important;
  margin-top: var(--space-sm) !important;
}

.compact.calculation-total {
  font-size: 0.875rem !important;
  padding: var(--space-sm) var(--space-md) !important;
  margin-top: var(--space-md) !important;
}

.compact .form-label {
  font-size: 0.75rem !important;
  margin-bottom: var(--space-sm) !important;
}

.compact .calculation-label {
  font-size: 0.875rem !important;
  margin-bottom: var(--space-md) !important;
}

.compact .calculation-label i {
  font-size: 1rem !important;
}

/* Medical measurements compact styling */
.measurements-grid .form-group.compact .form-label {
  font-size: 0.75rem !important;
  font-weight: 500 !important;
}

.measurements-grid .compact .calculation-total {
  background: var(--medical-primary);
  color: white;
  text-align: center;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
}

/* Compact calculation field in measurements */
.measurements-grid .calculation-input-group.compact {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.measurements-grid .calculation-input.compact {
  flex: 1;
  font-family: var(--font-family-mono);
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
}

.measurements-grid .calculation-button.compact {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.measurements-grid .calculation-button.compact:hover {
  transform: translateY(-1px);
}

/* Unit displays for compact measurements */
.measurements-grid .compact::after {
  content: attr(data-unit);
  font-size: 0.625rem;
  color: var(--gray-500);
  margin-left: var(--space-sm);
}

/* Responsive compact adjustments */
@media (max-width: 768px) {
  .compact {
    font-size: 0.75rem !important;
  }
  
  .compact.calculation-input {
    min-height: 32px !important;
    font-size: 0.7rem !important;
  }
  
  .compact.calculation-button {
    min-width: 32px !important;
    min-height: 32px !important;
    font-size: 0.7rem !important;
  }
  
  .measurements-grid .calculation-input-group.compact {
    flex-direction: column;
    gap: var(--space-xs);
  }
  
  .measurements-grid .calculation-button.compact {
    width: 100%;
  }
}

/* ========================================
   High DPI / Retina Support
   ======================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .healthcare-logo img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}