/* ==========================================================================
   VitalsFlow Design System & Styling
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
  --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette - Premium Dark Mode */
  --bg-app: #080c14;
  --bg-card: rgba(17, 25, 40, 0.75);
  --bg-card-hover: rgba(26, 37, 59, 0.85);
  --bg-nav: rgba(13, 20, 35, 0.85);
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Interactive Accents */
  --color-primary: #6366f1; /* Indigo */
  --color-primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --color-secondary: #ec4899; /* Pink */
  --color-secondary-gradient: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
  --color-accent-blue: #3b82f6; /* Blue */
  --color-accent-teal: #14b8a6; /* Teal */
  
  /* Health Status Indicators */
  --health-normal: #10b981;    /* Emerald Green */
  --health-elevated: #f59e0b;  /* Amber */
  --health-stage1: #f97316;    /* Orange */
  --health-stage2: #ef4444;    /* Red */
  --health-crisis: #a855f7;    /* Purple */

  /* UI Shadows & Blur */
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --glass-blur: blur(16px);
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  
  /* Safe Area variables for modern smartphones */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  color: var(--text-primary);
  overflow: hidden; /* Main app layout handles scrolling internally */
}

/* Typography Utilities */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

p {
  color: var(--text-secondary);
  line-height: 1.5;
}

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-secondary); }
.text-danger { color: var(--health-stage2); }
.text-sm { font-size: 0.85rem; }
.w-full { width: 100%; }
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Embedded Scrollbar Styling */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 10px;
}

/* App Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg-nav);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 20px;
  padding-right: 20px;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--color-primary);
}

.header-logo h1 {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  -webkit-text-fill-color: var(--text-muted);
  margin-top: 1px;
}

/* Makes brand-sub a tappable link without disrupting the gradient title */
.brand-sub-link {
  text-decoration: none;
  -webkit-text-fill-color: var(--text-muted);
  transition: opacity 0.2s;
}
.brand-sub-link:hover,
.brand-sub-link:active {
  opacity: 0.65;
}

.app-info-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.app-info-link:hover { opacity: 0.75; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--health-normal);
}

.pulse {
  animation: pulse-glow 2s infinite alternate;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 2px rgba(16, 185, 129, 0.2); }
  100% { box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
}

/* Bottom Navigation Bar */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(68px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-nav);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-primary);
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  width: 20%;
  height: 100%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.3s ease, color 0.3s ease;
}

.nav-item:active .nav-icon {
  transform: scale(0.85);
}

.nav-item.active {
  color: var(--color-primary);
}

.nav-item.active .nav-icon {
  color: var(--color-primary);
  transform: translateY(-2px);
}

/* App Main Container Scrollable */
.app-content {
  width: 100%;
  height: 100%;
  padding-top: calc(64px + var(--safe-top));
  padding-bottom: calc(68px + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scroll */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Tab Panes Animation */
.tab-pane {
  display: none;
  /* Fluid padding: tighter on very small screens, comfortable on larger */
  padding: 20px clamp(12px, 4vw, 20px);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-pane.active {
  display: block;
}

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

/* Common Layout Components */
.section-title {
  font-size: 1.6rem;
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* Dashboard / Hoje Tab Styles */
.welcome-container {
  margin-bottom: 24px;
}

.greeting {
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: 4px;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.span-2 {
  grid-column: span 2;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, background 0.2s ease;
  /* Grid items must have min-width: 0 to shrink below content size */
  min-width: 0;
  overflow: hidden;
}

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

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Never shrink the icon */
  flex-shrink: 0;
}

.card-icon .icon {
  width: 22px;
  height: 22px;
}

.weight-bg {
  background: rgba(99, 102, 241, 0.15);
  color: var(--color-primary);
}

.bp-bg {
  background: rgba(236, 72, 153, 0.15);
  color: var(--color-secondary);
}

.steps-bg {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.card-data {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  /* Essential: allows flex/grid child to shrink below its content width */
  min-width: 0;
  overflow: hidden;
}

.card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-value {
  /* clamp: min 0.95rem, fluid, max 1.25rem — prevents overflow on small screens */
  font-size: clamp(0.95rem, 4.5vw, 1.25rem);
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
  /* Prevent long numbers from overflowing */
  word-break: break-all;
}

.card-value-small {
  font-size: clamp(0.85rem, 3.5vw, 1.05rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

.card-trend {
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Progress bar for steps */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Action Banner */
.action-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(236, 72, 153, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.banner-content h3 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.banner-content p {
  font-size: 0.85rem;
}

/* Interactive Cards / List Insights */
.insight-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-lg);
}

.insight-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
}

.insight-header h4 {
  font-size: 1rem;
}

.insight-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insight-list li {
  font-size: 0.85rem;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.insight-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 5px;
  flex-shrink: 0;
}

.loading-state {
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
  font-style: italic;
}

/* ==========================================================================
   Form Components
   ========================================================================== */
.form-container {
  max-width: 500px;
  margin: 0 auto;
}

.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.form-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Custom styled inputs */
input[type="number"], 
input[type="datetime-local"], 
textarea,
select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-primary);
  font-size: 0.95rem;
  width: 100%;
  transition: all 0.2s ease;
  outline: none;
}

input[type="number"]:focus, 
input[type="datetime-local"]:focus, 
textarea:focus,
select:focus {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Custom Incrementor Buttons */
.input-with-controls {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.input-with-controls:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-with-controls input {
  border: none;
  background: transparent;
  text-align: center;
  padding: 12px 4px;
}

.input-with-controls input:focus {
  box-shadow: none;
  background: transparent;
}

.btn-increment {
  background: rgba(255, 255, 255, 0.02);
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 600;
  width: 44px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-increment:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-increment:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.9);
}

/* Textarea customization */
textarea {
  resize: vertical;
}

/* Switch UI */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: relative;
  width: 42px;
  height: 24px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 34px;
  transition: .3s;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
}

input:checked + .slider-toggle {
  background: var(--color-primary-gradient);
}

input:checked + .slider-toggle:before {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.78rem;
  font-weight: 600;
}

/* Form Actions Button Bar */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 30px;
}

/* General Button Styles */
.btn {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: var(--border-radius-md);
  padding: 14px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.btn-primary {
  background: var(--color-primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-secondary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.78rem;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   History Timeline Components
   ========================================================================== */
.history-header {
  margin-bottom: 20px;
}

.filter-controls select {
  padding: 8px 12px;
  font-size: 0.85rem;
  width: auto;
  border-radius: 8px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  padding-left: 10px;
}

.timeline-day-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.timeline-day-group::before {
  content: '';
  position: absolute;
  top: 15px;
  bottom: 0;
  left: 15px;
  width: 2px;
  background: linear-gradient(180deg, var(--color-primary) 0%, rgba(255, 255, 255, 0.03) 100%);
  opacity: 0.3;
}

.timeline-date-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-date-header::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 8px var(--color-primary);
}

.timeline-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 28px;
}

.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 16px;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.timeline-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 8px;
}

.time-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.timeline-actions {
  display: flex;
  gap: 8px;
}

.btn-action-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.btn-action-icon:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-action-icon.delete:hover {
  color: var(--health-stage2);
  background: rgba(239, 68, 68, 0.1);
}

.btn-action-icon.share:hover {
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.1);
}

/* ==========================================================================
   Health Guidance Section (Dashboard)
   ========================================================================== */

.advice-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.advice-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.advice-header h4 {
  font-size: 0.95rem;
  flex: 1;
}

.advice-disclaimer {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 3px 8px;
  white-space: nowrap;
}

.advice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.advice-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--border-radius-md);
  border-left: 3px solid transparent;
}

.advice-item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.advice-item-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.advice-item-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.advice-item-text {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

/* Level variants */
.advice-critical {
  background: rgba(168, 85, 247, 0.08);
  border-left-color: #a855f7;
}
.advice-critical .advice-item-title { color: #a855f7; }

.advice-warning {
  background: rgba(239, 68, 68, 0.07);
  border-left-color: var(--health-stage2);
}
.advice-warning .advice-item-title { color: var(--health-stage2); }

.advice-info {
  background: rgba(59, 130, 246, 0.07);
  border-left-color: var(--color-accent-blue);
}
.advice-info .advice-item-title { color: var(--color-accent-blue); }

.advice-success {
  background: rgba(16, 185, 129, 0.07);
  border-left-color: var(--health-normal);
}
.advice-success .advice-item-title { color: var(--health-normal); }

/* ==========================================================================
   Share Bottom Sheet
   ========================================================================== */

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.share-sheet {
  width: 100%;
  max-width: 500px;
  background: #1e293b;
  border: 1px solid var(--border-light);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + var(--safe-bottom));
  animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.share-sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  margin: 0 auto 18px;
}

.share-sheet-title {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.share-preview {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-primary);
  font-size: 0.76rem;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.share-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.share-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.share-option-btn svg {
  width: 22px;
  height: 22px;
  stroke: var(--color-primary);
}

.share-option-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
}

.share-option-btn:active {
  transform: scale(0.94);
}

.timeline-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Metric Pill Grid in Timeline */
.metric-pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.metric-pill {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-pill-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-pill-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Blood Pressure Widget inside timeline card */
.bp-widget {
  grid-column: span 2;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bp-widget-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bp-values-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bp-sys-dia {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.bp-pulse {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.bp-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 20px;
}

.bp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* BP Indicator Categories */
.bp-normal { background: rgba(16, 185, 129, 0.1); color: var(--health-normal); }
.bp-normal .bp-dot { background-color: var(--health-normal); }

.bp-elevated { background: rgba(245, 158, 11, 0.1); color: var(--health-elevated); }
.bp-elevated .bp-dot { background-color: var(--health-elevated); }

.bp-stage1 { background: rgba(249, 115, 22, 0.1); color: var(--health-stage1); }
.bp-stage1 .bp-dot { background-color: var(--health-stage1); }

.bp-stage2 { background: rgba(239, 68, 68, 0.1); color: var(--health-stage2); }
.bp-stage2 .bp-dot { background-color: var(--health-stage2); }

.bp-crisis { background: rgba(168, 85, 247, 0.1); color: var(--health-crisis); }
.bp-crisis .bp-dot { background-color: var(--health-crisis); }

.card-notes {
  font-size: 0.8rem;
  padding: 8px 12px;
  border-left: 2.5px solid var(--color-primary);
  background: rgba(99, 102, 241, 0.03);
  border-radius: 0 6px 6px 0;
  margin-top: 4px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border-light);
  border-radius: var(--border-radius-lg);
  color: var(--text-muted);
}

/* ==========================================================================
   Charts Tab Components
   ========================================================================== */
.chart-tab-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 4px;
  margin-bottom: 20px;
}

.chart-tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px;
  border-radius: 8px;
  font-family: var(--font-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-tab-btn.active {
  background: var(--color-primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.chart-card {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-lg);
}

.chart-card.active {
  display: block;
}

.chart-card-header {
  margin-bottom: 16px;
}

.chart-card-header h3 {
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ==========================================================================
   Settings Page Components
   ========================================================================== */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.settings-card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.settings-card p {
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.border-danger {
  border-color: rgba(239, 68, 68, 0.2);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.app-info {
  text-align: center;
  margin: 30px 0 10px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.app-info p {
  margin-bottom: 4px;
}

/* Section divider label inside profile tab */
.section-divider-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 28px 0 12px;
}

/* ==========================================================================
   Profile Tab — Avatar & Summary Header
   ========================================================================== */

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.profile-header-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-header-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary-gradient);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}

/* ==========================================================================
   Computed Health Metrics (BMI / BMR / TDEE)
   ========================================================================== */

.computed-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.computed-stat-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.computed-stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.computed-stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.computed-stat-unit {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* BMI category badges */
.bmi-badge, .bmi-inline-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bmi-under  { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.bmi-normal { background: rgba(16, 185, 129, 0.15); color: var(--health-normal); }
.bmi-over   { background: rgba(245, 158, 11, 0.15); color: var(--health-elevated); }
.bmi-obese  { background: rgba(239, 68, 68, 0.15);  color: var(--health-stage2); }

/* Inline badge in weight card trend row */
.bmi-inline-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.62rem;
  vertical-align: middle;
}

/* ==========================================================================
   Goals Progress — Dashboard Block
   ========================================================================== */

.goals-progress-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.goals-progress-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.goals-progress-header h4 {
  font-size: 0.95rem;
}

.goals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.goal-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.goal-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.goal-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.goal-pct {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.goal-bar-bg {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
}

.goal-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.goal-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Goal colour variants */
.goal-weight   { background: rgba(99, 102, 241, 0.2); color: var(--color-primary); }
.goal-bar.goal-weight   { background: var(--color-primary); }

.goal-steps    { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.goal-bar.goal-steps    { background: #f59e0b; }

.goal-calories { background: rgba(236, 72, 153, 0.2); color: var(--color-secondary); }
.goal-bar.goal-calories { background: var(--color-secondary); }

.goal-reached  { background: rgba(16, 185, 129, 0.2); color: var(--health-normal); }
.goal-bar.goal-reached  { background: var(--health-normal); }

.goal-over     { background: rgba(239, 68, 68, 0.2);  color: var(--health-stage2); }
.goal-bar.goal-over     { background: var(--health-stage2); }

/* Toast System Style */
.toast-container {
  position: fixed;
  top: 24px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(13, 20, 35, 0.95);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(-20px);
  animation: toastFadeIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
             toastFadeOut 0.3s cubic-bezier(0.6, -0.28, 0.735, 0.045) 2.7s forwards;
  pointer-events: auto;
}

.toast.success { border-left-color: var(--health-normal); }
.toast.danger { border-left-color: var(--health-stage2); }
.toast.info { border-left-color: var(--color-accent-blue); }

@keyframes toastFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastFadeOut {
  to { opacity: 0; transform: translateY(-20px); }
}

/* ==========================================================================
   OCR Smart Camera Scanner Styling
   ========================================================================== */
.scanner-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06) 0%, rgba(20, 27, 45, 0.75) 100%);
  border: 1px dashed rgba(99, 102, 241, 0.35);
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

.badge-accent {
  background: var(--color-secondary-gradient);
  color: #fff;
}

.ocr-status-container {
  margin-top: 16px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-light);
}

.ocr-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
}

.ocr-progress-bar {
  height: 100%;
  border-radius: 10px;
  background: var(--color-primary-gradient);
  width: 0%;
  transition: width 0.2s ease;
}

.ocr-results-container {
  margin-top: 16px;
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
}

.ocr-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ocr-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ocr-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.ocr-chip.selected {
  background: var(--color-primary-gradient);
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.ocr-assign-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 14px;
  animation: slideUp 0.3s ease forwards;
}

.ocr-assign-panel p {
  margin-bottom: 10px;
}

.ocr-assign-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.btn-assign {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.btn-assign:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn-assign:active {
  transform: scale(0.95);
}

.flash-success {
  animation: flash-green 0.8s ease;
}

@keyframes flash-green {
  0% { background-color: transparent; }
  30% { background-color: rgba(16, 185, 129, 0.25); border-color: var(--health-normal); }
  100% { background-color: transparent; }
}

/* ==========================================================================
   PIN Protection Overlay
   ========================================================================== */

.pin-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  animation: fadeIn 0.25s ease;
}

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

.pin-container {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.pin-app-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.pin-app-logo svg {
  width: 44px;
  height: 44px;
  color: var(--color-primary);
  stroke: var(--color-primary);
}

.pin-app-logo span {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.pin-title {
  font-size: 1.35rem;
  text-align: center;
  margin: 0;
  color: var(--text-primary);
}

.pin-subtitle {
  font-size: 0.82rem;
  text-align: center;
  color: var(--text-muted);
  margin: -8px 0 0;
  line-height: 1.5;
}

.pin-dots-row {
  display: flex;
  gap: 18px;
  margin: 4px 0;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: transparent;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-dot.filled {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.55);
  transform: scale(1.15);
}

.pin-error-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--health-stage2);
  text-align: center;
  min-height: 18px;
  margin: -6px 0;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}

.pin-key {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  width: 72px;
  height: 72px;
  font-family: var(--font-primary);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  transition: background 0.1s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pin-key:active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--color-primary);
  transform: scale(0.90);
}

.pin-key-action {
  background: transparent;
  border-color: transparent;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pin-key-action:active {
  background: rgba(255, 255, 255, 0.06);
  border-color: transparent;
}

.pin-key-del {
  font-size: 1.15rem;
  color: var(--text-secondary);
}

