/* ==========================================
   Airbnb-inspired Design System & Variables
   ========================================== */
:root {
  --color-primary: #ff385c;
  --color-primary-active: #e00b41;
  --color-primary-disabled: #ffd1da;
  --color-error: #c13515;
  --color-error-hover: #b32505;
  --color-ink: #222222;
  --color-body: #3f3f3f;
  --color-muted: #6a6a6a;
  --color-muted-soft: #929292;
  --color-hairline: #dddddd;
  --color-hairline-soft: #ebebeb;
  --color-border-strong: #c1c1c1;
  --color-canvas: #ffffff;
  --color-surface-soft: #f7f7f7;
  --color-surface-strong: #f2f2f2;
  --color-on-primary: #ffffff;
  
  /* Custom health colors */
  --color-glucose: #460479;  /* Luxe purple accent */
  --color-heart: #92174d;    /* Plus magenta accent */
  --color-weight: #008489;
  --color-liver: #e65100;     /* Amber/Orange accent */
  --color-lipid: #166534;     /* Deep Forest Green */
  --color-renal: #0284c7;     /* Sky Blue */
  --color-cbc: #7c2d12;       /* Blood Red-Brown */
  --color-urine: #a21caf;     /* Fuchsia purple */
  
  /* Borders */
  --rounded-xs: 4px;
  --rounded-sm: 8px;
  --rounded-md: 14px;
  --rounded-lg: 20px;
  --rounded-xl: 32px;
  --rounded-full: 9999px;

  /* Spacing */
  --space-xxs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-base: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-section: 64px;

  /* Shadows (Single tier elevation as per Airbnb Spec) */
  --box-shadow: rgba(0, 0, 0, 0.02) 0px 0px 0px 1px, 
                rgba(0, 0, 0, 0.04) 0px 2px 6px 0px, 
                rgba(0, 0, 0, 0.1) 0px 4px 8px 0px;
}

/* ==========================================
   Base Elements & Reset
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--color-canvas);
  color: var(--color-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-ink);
  font-weight: 700;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

button, select, input, textarea {
  font-family: inherit;
  outline: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ==========================================
   Typography Helpers
   ========================================== */
.display-xl {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.43;
  letter-spacing: -0.5px;
}

.display-lg {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}

.display-md {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.43;
}

.display-sm {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.title-md {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.title-sm {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
}

.body-md {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-body);
}

.body-sm {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.43;
}

.caption-sm {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.23;
}

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

.text-rausch { color: var(--color-primary); }
.text-glucose { color: var(--color-glucose); }
.text-heart { color: var(--color-heart); }
.text-weight { color: var(--color-weight); }
.text-liver { color: var(--color-liver); }
.text-lipid { color: var(--color-lipid); }
.text-renal { color: var(--color-renal); }
.text-cbc { color: var(--color-cbc); }
.text-urine { color: var(--color-urine); }

.font-numeric {
  font-feature-settings: "tnum";
}

.uppercase-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-base);
}

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mt-xs { margin-top: var(--space-xs); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.font-bold { font-weight: 700; }
.text-danger { color: var(--color-error); }
.text-success { color: #166534; }

/* ==========================================
   Navigation Header (Airbnb spec)
   ========================================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 80px;
  background-color: var(--color-canvas);
  border-bottom: 1px solid var(--color-hairline-soft);
  display: flex;
  align-items: center;
}

.nav-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: #484848; /* Softer dark gray brand color */
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

.logo-icon {
  font-size: 24px;
}

/* Product Tabs in top nav */
.product-tabs {
  display: flex;
  gap: var(--space-lg);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xxs);
  color: var(--color-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  position: relative;
  transition: color 0.15s ease;
}

.nav-tab i {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.nav-tab:hover {
  color: var(--color-ink);
}

.nav-tab.active {
  color: var(--color-ink);
  font-weight: 600;
}

.nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 12px;
  right: 12px;
  height: 2px;
  background-color: var(--color-ink);
}

/* Multi-User Switcher Container */
.user-switcher-container {
  position: relative;
}

.avatar-menu {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border: 1px solid var(--color-hairline);
  padding: 5px 12px 5px 6px;
  border-radius: var(--rounded-full);
  cursor: pointer;
  background-color: var(--color-canvas);
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
  user-select: none;
}

.avatar-menu:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background-color: var(--color-surface-soft);
}

.avatar-menu #header-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-menu .dropdown-chevron {
  width: 14px;
  height: 14px;
  color: var(--color-muted);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--rounded-full);
  background-color: var(--color-ink);
  color: var(--color-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

/* User Switcher Dropdown popup card */
.user-dropdown-popup {
  position: absolute;
  top: 48px;
  right: 0;
  width: 220px;
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-md);
  box-shadow: var(--box-shadow);
  padding: var(--space-sm);
  z-index: 1000;
  display: none;
  flex-direction: column;
  gap: var(--space-xxs);
}

.user-dropdown-popup.show {
  display: flex;
}

.dropdown-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-muted-soft);
  padding: 6px 12px;
  letter-spacing: 0.5px;
}

.dropdown-users-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
  max-height: 200px;
  overflow-y: auto;
}

.dropdown-user-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 12px;
  border-radius: var(--rounded-sm);
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease;
}

.dropdown-user-item:hover {
  background-color: var(--color-surface-soft);
}

.dropdown-user-item.active {
  background-color: var(--color-surface-strong);
  font-weight: 600;
}

.dropdown-user-item .avatar-tiny {
  width: 24px;
  height: 24px;
  border-radius: var(--rounded-full);
  background-color: var(--color-ink);
  color: var(--color-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.dropdown-user-item .user-name {
  font-size: 13px;
  color: var(--color-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  border-radius: var(--rounded-sm);
  width: 100%;
  transition: background-color 0.15s ease;
  text-align: left;
}

.dropdown-action-btn:hover {
  background-color: var(--color-surface-soft);
}

.dropdown-action-btn i {
  width: 14px;
  height: 14px;
}

/* ==========================================
   Main Content Layout
   ========================================== */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  min-height: calc(100vh - 80px - 200px);
}

.content-view {
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}

.content-view.active {
  display: block;
  opacity: 1;
}

/* ==========================================
   Dashboard Page Layout
   ========================================== */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  gap: var(--space-base);
}

/* Time Filter Segment */
.time-filter-pill {
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-full);
  padding: 4px;
  display: flex;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.filter-btn {
  font-size: 14px;
  font-weight: 500;
  padding: 8px var(--space-base);
  border-radius: var(--rounded-full);
  color: var(--color-muted);
  transition: all 0.2s ease;
}

.filter-btn:hover {
  color: var(--color-ink);
  background-color: var(--color-surface-soft);
}

.filter-btn.active {
  color: var(--color-on-primary);
  background-color: var(--color-ink);
  font-weight: 600;
}

/* Stats Summary Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-base);
  margin-bottom: var(--space-xl);
}

@media (min-width: 600px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.stat-card {
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  padding: var(--space-base);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.stat-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-header i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.1;
}

.stat-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-muted);
}

.stat-meta {
  font-size: 11px;
  color: var(--color-muted);
  border-top: 1px solid var(--color-hairline-soft);
  padding-top: var(--space-xs);
  white-space: nowrap;
}

/* Detailed Age display layout */
.detailed-age-badge {
  display: inline-block;
  background-color: var(--color-surface-soft);
  color: var(--color-muted);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* Dashboard Body: Graph & Last Log card side-by-side */
.dashboard-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  align-items: start;
}

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

.graph-container-card {
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  padding: var(--space-lg);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.graph-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-hairline-soft);
  padding-bottom: var(--space-sm);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.graph-selector-tabs {
  display: flex;
  gap: var(--space-xs);
  background-color: var(--color-surface-soft);
  padding: 4px;
  border-radius: var(--rounded-full);
}

.graph-tab {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--rounded-full);
  color: var(--color-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.graph-tab:hover {
  color: var(--color-ink);
}

.graph-tab.active {
  background-color: var(--color-canvas);
  color: var(--color-ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 320px;
  flex-grow: 1;
}

/* Sidebar Last Log Panel */
.last-log-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.last-log-panel h2 {
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-hairline-soft);
}

/* Last Log Display Card */
.last-log-card {
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-md);
  padding: var(--space-lg);
  box-shadow: var(--box-shadow);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: relative;
  overflow: hidden;
}

.last-log-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 6px;
}

.last-log-card.bp-normal-glucose-normal::before { background-color: #22c55e; }
.last-log-card.bp-warning-or-glucose-warning::before { background-color: #f59e0b; }
.last-log-card.bp-danger-or-glucose-danger::before { background-color: var(--color-error); }

.last-log-placeholder {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  color: var(--color-muted);
  border: 2px dashed var(--color-hairline);
  border-radius: var(--rounded-md);
  font-size: 14px;
}

.last-log-time {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 500;
}

.status-badge {
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--rounded-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.normal {
  background-color: #f0fdf4;
  color: #166534;
}

.status-badge.warning {
  background-color: #fffbeb;
  color: #92400e;
}

.status-badge.danger {
  background-color: #fef2f2;
  color: #991b1b;
}

.last-log-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 11px;
  color: var(--color-muted);
}

.metric-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-ink);
}

.metric-val-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-muted);
}

.last-log-note {
  font-size: 13px;
  color: var(--color-body);
  background-color: var(--color-surface-soft);
  padding: 8px 12px;
  border-radius: var(--rounded-sm);
  border-left: 2px solid var(--color-border-strong);
}

/* Guideline Widget card */
.guidelines-card {
  background-color: var(--color-surface-soft);
  border-radius: var(--rounded-md);
  padding: var(--space-lg);
  border: 1px solid var(--color-hairline-soft);
}

.guidelines-card h3 {
  margin-bottom: var(--space-md);
}

.guidelines-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.guidelines-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.guide-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--rounded-full);
  text-align: center;
}

.guide-tag.bp-normal { background-color: #e8f5e9; color: #2e7d32; }
.guide-tag.bp-high { background-color: #ffebee; color: #c62828; }
.guide-tag.glucose-normal { background-color: #f3e5f5; color: #6a1b9a; }
.guide-tag.liver-normal { background-color: #ffe8d6; color: #d05b00; }

/* ==========================================
   Log Entry Form Page (Flexible Sub-records)
   ========================================== */
.form-container {
  max-width: 680px;
  margin: 0 auto;
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  padding: var(--space-xl);
  box-shadow: var(--box-shadow);
}

.form-header {
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-hairline-soft);
  padding-bottom: var(--space-md);
}

/* Preset buttons layout */
.preset-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-base);
  flex-wrap: wrap;
}

.preset-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

.preset-buttons {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.preset-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--rounded-full);
  background-color: var(--color-surface-soft);
  color: var(--color-muted);
  border: 1px solid var(--color-hairline-soft);
  transition: all 0.15s ease;
}

.preset-btn:hover {
  color: var(--color-ink);
  border-color: var(--color-border-strong);
}

.preset-btn.active {
  background-color: var(--color-ink);
  color: var(--color-on-primary);
  border-color: var(--color-ink);
}

form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

.alert-banner-error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--color-error);
  padding: var(--space-md) var(--space-base);
  border-radius: var(--rounded-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 14px;
}

.alert-banner-error i {
  width: 18px;
  height: 18px;
}

.metric-form-section {
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  padding: var(--space-base);
  background-color: var(--color-canvas);
  transition: all 0.2s ease;
}

.metric-form-section:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  border-color: var(--color-border-strong);
}

.section-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-sm);
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.section-inputs-wrapper {
  margin-top: var(--space-base);
  padding-top: var(--space-base);
  border-top: 1px dashed var(--color-hairline-soft);
  display: block;
}

.section-inputs-wrapper.hidden-inputs {
  display: none;
}

/* Rounded IOS-like Switch style */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-border-strong);
  transition: .2s;
  border-radius: var(--rounded-full);
}

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

input:checked + .slider {
  background-color: var(--color-ink);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

@media (min-width: 600px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  position: relative;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.empty-flex-group {
  display: none;
}

@media (min-width: 600px) {
  .empty-flex-group {
    display: block;
  }
}

.input-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
}

/* Inputs */
.text-input {
  height: 56px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--rounded-sm);
  padding: 0 var(--space-base);
  font-size: 16px;
  color: var(--color-ink);
  background-color: var(--color-canvas);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.text-input::placeholder {
  color: var(--color-muted-soft);
}

.text-input:focus {
  border-color: var(--color-ink);
  border-width: 2px;
  box-shadow: 0 0 0 4px rgba(34,34,34,0.05);
}

/* Select */
.select-input {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23222222' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  padding-right: var(--space-xxl);
  cursor: pointer;
}

/* Textarea */
.textarea-input {
  height: 120px;
  padding: var(--space-md) var(--space-base);
  resize: vertical;
}

.hint-text {
  font-size: 12px;
  color: var(--color-muted);
}

.error-message {
  font-size: 12px;
  color: var(--color-error);
  font-weight: 500;
  min-height: 18px;
  margin-top: 2px;
}

.character-counter {
  position: absolute;
  right: 4px;
  bottom: -22px;
  font-size: 12px;
  color: var(--color-muted);
}

/* ==========================================
   Buttons (Airbnb Spec)
   ========================================== */
.btn {
  height: 48px;
  padding: 0 var(--space-lg);
  border-radius: var(--rounded-sm);
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-on-primary);
}

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

.btn-primary:disabled {
  background-color: var(--color-primary-disabled);
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--color-canvas);
  color: var(--color-ink);
  border: 1px solid var(--color-ink);
}

.btn-secondary:hover {
  background-color: var(--color-surface-soft);
}

.btn-pill-rausch {
  border-radius: var(--rounded-full);
  height: 44px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-base);
  margin-top: var(--space-md);
  border-top: 1px solid var(--color-hairline-soft);
  padding-top: var(--space-lg);
}

.form-actions-clean {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-base);
  margin-top: var(--space-lg);
  border-top: 1px solid var(--color-hairline-soft);
  padding-top: var(--space-lg);
}

/* ==========================================
   History Logs View
   ========================================== */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  gap: var(--space-base);
}

.history-list-wrapper {
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.history-table-container {
  width: 100%;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.history-table th {
  background-color: var(--color-surface-soft);
  color: var(--color-ink);
  font-weight: 600;
  padding: 12px var(--space-sm);
  border-bottom: 1px solid var(--color-hairline);
  white-space: nowrap;
}

.history-table td {
  padding: 12px var(--space-sm);
  border-bottom: 1px solid var(--color-hairline-soft);
  vertical-align: middle;
  color: var(--color-body);
}

.history-table tbody tr:hover {
  background-color: var(--color-surface-soft);
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-date {
  font-weight: 500;
  color: var(--color-ink);
  min-width: 90px;
}

.history-bp {
  font-weight: 700;
}
.history-bp.high { color: var(--color-error); }
.history-bp.normal { color: #166534; }

.history-glucose {
  font-weight: 700;
}
.history-glucose.high { color: var(--color-error); }
.history-glucose.normal { color: #166534; }

.history-glucose-type {
  display: inline-block;
  font-size: 10px;
  background-color: var(--color-surface-soft);
  color: var(--color-muted);
  padding: 1px 4px;
  border-radius: var(--rounded-xs);
  text-transform: capitalize;
}

.history-note {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-actions-cell {
  display: flex;
  gap: var(--space-xs);
  justify-content: center;
}

.action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--rounded-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  background-color: var(--color-surface-soft);
  color: var(--color-ink);
}

.action-btn:hover {
  background-color: var(--color-surface-strong);
}

.action-btn-edit:hover {
  color: var(--color-primary-active);
}

.action-btn-delete:hover {
  color: var(--color-error);
  background-color: #fef2f2;
}

.action-btn i {
  width: 14px;
  height: 14px;
}

.text-center { text-align: center; }
.py-8 { padding-top: var(--space-xxl); padding-bottom: var(--space-xxl); }

/* ==========================================
   Settings View Style
   ========================================== */
.settings-container-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  min-height: 520px;
}

@media (min-width: 768px) {
  .settings-container-card {
    grid-template-columns: 240px 1fr;
  }
}

.settings-sidebar {
  border-bottom: 1px solid var(--color-hairline-soft);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

@media (min-width: 768px) {
  .settings-sidebar {
    border-bottom: none;
    border-right: 1px solid var(--color-hairline-soft);
    padding: var(--space-xl) var(--space-lg);
  }
}

.settings-cat-btn {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--rounded-sm);
  transition: all 0.15s ease;
}

.settings-cat-btn:hover {
  color: var(--color-ink);
  background-color: var(--color-surface-soft);
}

.settings-cat-btn.active {
  color: var(--color-ink);
  background-color: var(--color-surface-strong);
  font-weight: 600;
}

.settings-main-panel {
  padding: var(--space-lg);
}

@media (min-width: 768px) {
  .settings-main-panel {
    padding: var(--space-xl);
  }
}

.settings-pane {
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease-in;
}

.settings-pane.active {
  display: block;
  opacity: 1;
}

/* Family Members profiles layout cards */
.family-profile-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-base);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  background-color: var(--color-canvas);
  margin-bottom: var(--space-sm);
}

.family-profile-info {
  display: flex;
  align-items: center;
  gap: var(--space-base);
}

.family-profile-info .avatar-mid {
  width: 40px;
  height: 40px;
  border-radius: var(--rounded-full);
  background-color: var(--color-ink);
  color: var(--color-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.family-profile-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.family-profile-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-ink);
}

.family-profile-meta {
  font-size: 12px;
  color: var(--color-muted);
}

.family-profile-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.family-btn-switch {
  height: 32px;
  padding: 0 var(--space-md);
  font-size: 12px;
  border-radius: var(--rounded-full);
  background-color: var(--color-ink);
  color: var(--color-on-primary);
  font-weight: 600;
  border: 1px solid var(--color-ink);
  transition: all 0.15s ease;
}

.family-btn-switch:hover {
  background-color: var(--color-surface-soft);
  color: var(--color-ink);
}

.family-btn-switch.active {
  background-color: var(--color-surface-soft);
  color: var(--color-muted-soft);
  border-color: var(--color-hairline);
  cursor: default;
}

.family-btn-delete {
  width: 32px;
  height: 32px;
  border-radius: var(--rounded-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fef2f2;
  color: var(--color-error);
  border: 1px solid #fee2e2;
  transition: all 0.15s ease;
}

.family-btn-delete:hover {
  background-color: var(--color-error);
  color: var(--color-on-primary);
  border-color: var(--color-error);
}

.security-status-card {
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-md);
  padding: var(--space-lg);
  background-color: var(--color-surface-soft);
}

.backup-box {
  padding: var(--space-base);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--rounded-md);
  background-color: var(--color-canvas);
}

.import-controls {
  display: flex;
  align-items: center;
  gap: var(--space-base);
  flex-wrap: wrap;
}

/* Spinner Loader style */
.spinner-loader {
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-hairline);
  border-top: 3px solid var(--color-primary);
  border-radius: 50%;
  animation: spin-loader-anim 1s linear infinite;
  display: inline-block;
}

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

/* ==========================================
   App Lock Screen Overlay
   ========================================== */
.lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.lock-card {
  background-color: var(--color-canvas);
  border: 1px solid var(--color-hairline-soft);
  border-radius: var(--rounded-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 360px;
  box-shadow: var(--box-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.lock-header {
  text-align: center;
}

.lock-icon-shield {
  font-size: 48px;
  display: inline-block;
  margin-bottom: var(--space-sm);
}

.pin-dots-container {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin: var(--space-sm) 0;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--rounded-full);
  border: 2px solid var(--color-border-strong);
  background-color: transparent;
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background-color: var(--color-ink);
  border-color: var(--color-ink);
}

.lock-error-msg {
  color: var(--color-error);
  font-size: 13px;
  font-weight: 600;
  min-height: 20px;
  text-align: center;
}

.pinpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  width: 100%;
}

.pin-btn {
  height: 60px;
  border-radius: var(--rounded-md);
  background-color: var(--color-surface-soft);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.pin-btn:hover {
  background-color: var(--color-surface-strong);
}

.pin-btn:active {
  background-color: var(--color-border-strong);
  transform: scale(0.96);
}

.pin-btn.text-danger {
  font-size: 13px;
  color: var(--color-error);
}

.pin-btn.text-success {
  font-size: 16px;
  color: #166534;
}

/* ==========================================
   Footer Component
   ========================================== */
.footer-simple {
  background-color: var(--color-canvas);
  border-top: 1px solid var(--color-hairline);
  padding: var(--space-lg) 0;
}

.footer-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ==========================================
   Mobile Responsive Support (iPhone / Safari)
   ========================================== */
.history-mobile-cards {
  display: none;
}

@media (max-width: 768px) {
  body, html {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .top-nav {
    height: auto;
    padding: var(--space-sm) 0;
  }

  .nav-container {
    flex-direction: column;
    gap: var(--space-sm);
    padding: 0 var(--space-md);
  }

  .product-tabs {
    width: 100%;
    justify-content: space-between;
    gap: 0;
    border-top: 1px solid var(--color-hairline-soft);
    padding-top: var(--space-sm);
  }

  .nav-tab {
    font-size: 11px;
    padding: 6px 2px;
    flex-grow: 1;
    text-align: center;
  }

  .nav-tab.active::after {
    bottom: -8px;
    left: 4px;
    right: 4px;
  }

  .nav-profile {
    width: 100%;
    border-top: 1px solid var(--color-hairline-soft);
    padding-top: var(--space-sm);
    display: flex;
    justify-content: center;
  }

  .user-switcher-container {
    width: 100%;
    max-width: 280px;
  }

  .avatar-menu {
    width: 100%;
    justify-content: space-between;
  }

  .user-dropdown-popup {
    width: 100%;
    top: 44px;
  }

  .main-content {
    padding: var(--space-md) var(--space-sm);
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .time-filter-pill {
    width: 100%;
    justify-content: space-between;
  }

  .time-filter-pill .filter-btn {
    flex-grow: 1;
    text-align: center;
    padding: 6px 2px;
    font-size: 11px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
  }

  .stat-card {
    padding: var(--space-xs);
    gap: 2px;
    min-height: auto;
  }

  .stat-title {
    font-size: 9px;
  }

  .stat-value {
    font-size: 15px;
  }

  .stat-unit {
    font-size: 9px;
  }

  .stat-meta {
    font-size: 8px;
  }

  .dashboard-body {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .graph-container-card {
    padding: var(--space-xs);
    min-height: auto;
  }

  .graph-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .graph-selector-tabs {
    width: 100%;
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    background-color: var(--color-surface-soft);
    padding: 2px;
    border-radius: var(--rounded-full);
    -webkit-overflow-scrolling: touch;
  }

  .graph-tab {
    flex-grow: 1;
    text-align: center;
    font-size: 10px;
    padding: 6px 6px;
  }

  .canvas-wrapper {
    height: 220px;
  }

  .form-container {
    padding: var(--space-base);
  }

  .form-row {
    grid-template-columns: 1fr !important;
    gap: var(--space-sm);
  }

  .text-input, .select-input, .textarea-input {
    font-size: 16px !important;
    height: 48px;
  }

  .textarea-input {
    height: 100px;
  }

  .history-table-container {
    display: none;
  }

  .history-mobile-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-base);
    padding: var(--space-base) 0;
  }

  .history-mobile-card {
    background-color: var(--color-canvas);
    border: 1px solid var(--color-hairline-soft);
    border-radius: var(--rounded-md);
    padding: var(--space-base);
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-hairline-soft);
    padding-bottom: var(--space-xs);
  }

  .mobile-card-header .date-time {
    display: flex;
    flex-direction: column;
  }

  .mobile-card-header .date {
    font-size: 14px;
    color: var(--color-ink);
  }

  .mobile-card-header .time {
    font-size: 11px;
  }

  .mobile-actions {
    display: flex;
    gap: var(--space-sm);
  }

  .mobile-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
  }

  .mobile-card-row .label {
    color: var(--color-muted);
    font-weight: 500;
  }

  .mobile-card-row .val {
    color: var(--color-ink);
  }

  .mobile-card-row.note-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background-color: var(--color-surface-soft);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--rounded-sm);
    border-left: 2px solid var(--color-border-strong);
    margin-top: 4px;
  }

  .italic-text {
    font-style: italic;
    font-size: 12px;
    color: var(--color-body);
  }

  .settings-container-card {
    grid-template-columns: 1fr !important;
  }

  .settings-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--color-hairline-soft);
    flex-direction: row !important;
    overflow-x: auto;
    white-space: nowrap;
    padding: var(--space-sm);
    -webkit-overflow-scrolling: touch;
    gap: var(--space-xs);
  }

  .settings-sidebar h2 {
    display: none;
  }

  .settings-cat-btn {
    padding: 8px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .settings-main-panel {
    padding: var(--space-base);
  }

  .lock-card {
    max-width: 320px;
    padding: var(--space-lg);
    gap: var(--space-md);
  }

  .pin-btn {
    height: 52px;
    font-size: 18px;
  }
}
