/* HealthChat Hub (COROS-Inspired Light Theme Design System) */
:root {
  --bg-main: #F3F4F6;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FAFAFA;
  --border-color: #E5E7EB;
  --border-accent: #0078D4;
  
  --primary: #0078D4;
  --primary-hover: #106EBE;
  --accent-cyan: #0284C7;
  --accent-emerald: #10B981;
  --accent-amber: #F59E0B;
  --accent-rose: #EC4899;
  --accent-purple: #8B5CF6;
  
  --text-main: #1F2937;
  --text-muted: #4B5563;
  --text-dim: #6B7280;
  
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Segoe UI Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --shadow-main: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Modal Overlay & Cards */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 0 0 20px 0;
  overflow: hidden;
}

.modal-header-banner {
  background: #0078D4;
  color: #FFFFFF;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.modal-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-logo h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #FFFFFF;
}

.lang-switcher {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.lang-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 1.1rem;
  line-height: 1.2;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

/* SVG flags: flag emojis do not render on Windows (shown as "SE", "GB", "PL"). */
.lang-flag {
  display: block;
  width: 22px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.lang-btn:hover {
  opacity: 0.85;
}

.lang-btn.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.6);
}

.badge-v {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.modal-subtitle {
  color: #E0F2FE;
  font-size: 0.85rem;
  margin-top: 4px;
}

.modal-body {
  padding: 0 24px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: #F3F4F6;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #FFFFFF;
}

/* Forms & Inputs */
.input-group {
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.input-group input,
.input-group textarea,
.select-input {
  width: 100%;
  padding: 8px 12px;
  background: #FFFFFF;
  border: 1px solid #D1D5DB;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
}

.input-group textarea {
  resize: vertical;
  min-height: 70px;
}

.input-group input:focus,
.input-group textarea:focus,
.select-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row .input-group {
  flex: 1;
}

.consent-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.consent-checkbox-label {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.78rem !important;
  font-weight: 400 !important;
  color: var(--text-muted);
  line-height: 1.4;
  cursor: pointer;
}

.consent-checkbox-label input[type="checkbox"] {
  width: auto;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Remember Login Checkbox */
.login-remember-group {
  margin: -4px 0 16px 0;
}

.login-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.login-remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  border-radius: var(--radius-sm);
  margin: 0;
}

.login-remember-label:hover {
  color: var(--text-main);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

.btn-secondary {
  background: #E5E7EB;
  color: var(--text-main);
  border: 1px solid #D1D5DB;
}

.btn-secondary:hover {
  background: #D1D5DB;
}

.btn-block {
  width: 100%;
  display: block;
}

.error-msg {
  margin-top: 15px;
  padding: 10px;
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  color: #991B1B;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.success-msg {
  margin-top: 15px;
  padding: 10px;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  color: #065F46;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* App Main Container */
.app-container {
  padding: 15px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Header Bar (HealthChat Hub Header) */
.hub-header {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-main);
  margin-bottom: 12px;
}

.hub-title-group h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.hub-sync-status {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--accent-amber);
}

.hub-range-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.range-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin-right: 2px;
}

.btn-range {
  background: #E5E7EB;
  color: var(--text-main);
  border: 1px solid #D1D5DB;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.25;
  transition: all 0.15s ease;
}

.btn-range:hover {
  background: #D1D5DB;
}

.btn-range.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.hub-range-controls .btn {
  padding: 3px 9px;
  font-size: 0.75rem;
  line-height: 1.25;
}

/* Top Navigation Bar (COROS Style) */
.hub-navbar {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-main);
  margin-bottom: 15px;
}

.nav-tabs-left {
  display: flex;
  gap: 6px;
}

.nav-tab-btn {
  background: #E5E7EB;
  color: var(--text-main);
  border: 1px solid #D1D5DB;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-tab-btn:hover {
  background: #D1D5DB;
}

.nav-tab-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.nav-tab-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Navigation Dropdown Menu (Uppdatera / Logga mätningar) */
.nav-dropdown {
  position: relative;
  display: inline-flex;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.dropdown-caret {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  display: inline-block;
}

.nav-dropdown.open .dropdown-caret {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 190px;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.nav-dropdown-menu.hidden {
  display: none !important;
}

.nav-dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.nav-dropdown-menu .dropdown-item:hover {
  background: #F3F4F6;
  color: var(--primary);
}

.nav-tabs-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-tag {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Summary Metric Cards Grid (3 Columns) */
.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 15px;
}

@media (max-width: 1024px) {
  .cards-row {
    grid-template-columns: 1fr;
  }
}

/* 4 Columns Grid (for Training + Weather - strictly 4 compact cards on a single row) */
.cards-row.cards-row-4,
.cards-row-4 {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 10px !important;
  margin-bottom: 15px !important;
  width: 100% !important;
}

/* Nutrition has three cards (Weight, Energy balance, Macros). */
.cards-row.cards-row-4.nutrition-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}
@media (max-width: 768px) {
  .cards-row.cards-row-4.nutrition-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .cards-row.cards-row-4.nutrition-cards > .summary-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 440px) {
  .cards-row.cards-row-4.nutrition-cards { grid-template-columns: 1fr !important; }
}

.cards-row-4 .summary-card {
  padding: 10px 12px !important;
  min-width: 0 !important;
  overflow: hidden !important;
  border-radius: var(--radius-sm) !important;
}

.cards-row-4 .summary-card h3 {
  font-size: 0.8rem !important;
  margin-bottom: 3px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.cards-row-4 .summary-card .summary-value {
  font-size: 1.4rem !important;
  margin-bottom: 2px !important;
  line-height: 1.15 !important;
}

.cards-row-4 .summary-card .summary-status-header {
  font-size: 0.74rem !important;
  margin-bottom: 3px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.cards-row-4 .summary-card .summary-subtext,
.cards-row-4 .summary-card #val-train-status-metrics {
  font-size: 0.72rem !important;
  line-height: 1.35 !important;
}

@media (max-width: 768px) {
  .cards-row.cards-row-4,
  .cards-row-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
}

@media (max-width: 440px) {
  .cards-row.cards-row-4,
  .cards-row-4 {
    grid-template-columns: 1fr !important;
  }
}

.summary-card {
  position: relative;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
}

.summary-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  padding-right: 30px;
}

.summary-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.summary-status-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1F2937;
  margin-bottom: 6px;
}

.summary-trend {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.summary-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 2px;
}

.summary-source {
  font-size: 0.75rem;
  font-style: italic;
  color: #9CA3AF;
  margin-top: 4px;
}

/* AI Recommendation Box in Card 1 */
.ai-advice-box {
  white-space: pre-line;
  font-size: 0.825rem;
  color: #374151;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.45;
  margin-top: 6px;
}

/* Charts Grid (2 Columns x 4 Rows) */
.charts-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 15px;
}

@media (max-width: 1100px) {
  .charts-grid-2col {
    grid-template-columns: 1fr;
  }
}

.chart-card-box {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-main);
  position: relative;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}

.chart-card-header h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0;
}

.chart-card-box > h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* Info button strictly in the top-right of the chart card */
.chart-info-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: #F3F4F6;
  border: 1px solid #D1D5DB;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #4B5563;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
  outline: none;
  z-index: 20;
}

.chart-info-btn:hover,
.chart-info-btn:focus-visible {
  background: #EFF6FF;
  border-color: #3B82F6;
  color: #1D4ED8;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
  transform: scale(1.08);
}

.chart-regenerate-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.chart-regenerate-btn.spinning svg {
  animation: chartRegenerateSpin 0.9s linear infinite;
}

@keyframes chartRegenerateSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Info Popover / Tooltip Card */
.chart-info-popover {
  position: absolute;
  top: 46px;
  right: 16px;
  width: min(340px, calc(100% - 32px));
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 14px 16px;
  z-index: 100;
  animation: fadeInChartPop 0.18s ease-out forwards;
}

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

.chart-info-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #F1F5F9;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.chart-info-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1E293B;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-info-close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: #94A3B8;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.chart-info-close-btn:hover {
  color: #1E293B;
  background: #F1F5F9;
}

.chart-info-popover-body {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-info-desc strong,
.chart-info-guidance strong {
  color: #1E293B;
}

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

/* Data Table Card */
.table-card-box {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-main);
  margin-bottom: 15px;
}

.table-card-box h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.profile-hr-zones-box {
  margin-top: 16px;
  margin-bottom: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: #F9FAFB;
  font-weight: 600;
  color: var(--text-muted);
}

.data-table tr:hover {
  background: #F3F4F6;
}

/* Floating AI Coach Chat Bubble (Matching Soma Demo design & size) */
.floating-chat-bubble {
  position: fixed;
  right: 20px;
  top: 58%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 9999px;
  background: #10B981;
  color: #000000;
  border: none;
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.35), 0 4px 6px -4px rgba(16, 185, 129, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, background 0.2s ease;
  outline: none;
}

.floating-chat-bubble:hover {
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 14px 20px -3px rgba(16, 185, 129, 0.45), 0 6px 8px -4px rgba(16, 185, 129, 0.3);
  background: #34D399;
}

.floating-chat-bubble:active {
  transform: translateY(-50%) scale(0.95);
}

.floating-chat-bubble.active {
  background: #1F2937;
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(31, 41, 55, 0.35);
}

.floating-chat-bubble .bubble-icon-chat,
.floating-chat-bubble .bubble-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  stroke: currentColor;
  transition: transform 0.2s ease;
}

/* Floating Chat Panel */
.floating-chat-panel {
  position: fixed;
  top: 70px;
  bottom: 24px;
  right: 76px;
  width: 440px;
  max-width: calc(100vw - 90px);
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  overflow: hidden;
  animation: floatingChatSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes floatingChatSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.floating-chat-panel.hidden {
  display: none !important;
}

.floating-chat-header {
  padding: 10px 14px;
  background: #F9FAFB;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.floating-chat-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.floating-chat-avatar {
  font-size: 1.4rem;
  line-height: 1;
}

.floating-chat-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.floating-chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.floating-chat-close-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.floating-chat-close-btn:hover {
  color: var(--text-main);
  background: #E5E7EB;
}

.floating-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #FFFFFF;
}

.floating-chat-body .quick-chips-row {
  padding: 8px 12px;
  border-bottom: 1px solid #F3F4F6;
  background: #FAFAFA;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.floating-chat-body .chat-messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.floating-chat-footer {
  padding: 10px 12px;
  background: #FFFFFF;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .floating-chat-panel {
    top: 60px;
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
  .floating-chat-bubble {
    top: auto;
    bottom: 20px;
    right: 16px;
    transform: none;
  }
  .floating-chat-bubble:hover {
    transform: scale(1.08);
  }
  .floating-chat-bubble:active {
    transform: scale(0.95);
  }
}

/* AI Chat Window Modal / Panel */
.ai-chat-card-box {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
  height: 650px;
  overflow: hidden;
}

.chat-controls-bar {
  padding: 12px 16px;
  background: #F9FAFB;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #065F46;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-radius: 999px;
  white-space: nowrap;
  cursor: default;
}

.btn-clear-chat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFFFFF;
  border: 1px solid #FECACA;
  color: #DC2626;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear-chat:hover {
  background: #FEF2F2;
  border-color: #F87171;
  color: #B91C1C;
}

.quick-chips-row {
  display: flex;
  gap: 6px;
}

.chip-btn {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:hover {
  background: #F0F9FF;
  border-color: var(--primary);
  color: var(--primary);
}

.chat-messages-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #FAFAFA;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg-row {
  display: flex;
  gap: 10px;
  max-width: 85%;
}

.chat-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-row.bot {
  align-self: flex-start;
}

.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-section-header {
  margin: 12px 0 4px 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: #1E293B;
  display: block;
}

.chat-msg-row.user .chat-msg-bubble {
  background: var(--primary);
  color: #FFFFFF;
}

.chat-msg-row.bot .chat-msg-bubble {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: #FFFFFF;
  border-top: 1px solid var(--border-color);
}

.key-box {
  font-family: var(--font-mono);
  background: #FFFBEB;
  border: 1px dashed #F59E0B;
  padding: 12px;
  border-radius: var(--radius-sm);
  color: #92400E;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  word-break: break-all;
  margin: 12px 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Danger Zone Card */
.danger-card-box {
  background: #FEF2F2 !important;
  border: 1px solid #FCA5A5 !important;
}

.danger-btn {
  background: #DC2626 !important;
  color: #FFFFFF !important;
  font-weight: 700;
}

.danger-btn:hover {
  background: #B91C1C !important;
}

/* --- DATAKÄLLOR (EXTERNA TJÄNSTER) --- */
.ds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 15px;
}

.ds-card {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-top: 4px solid #9CA3AF;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ds-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ds-logo-lockup {
  display: flex;
  align-items: center;
}

.ds-brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ds-brand-icon {
  flex-shrink: 0;
  display: block;
}

.ds-brand-name {
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.strava-text {
  font-family: 'Montserrat', 'Segoe UI', -apple-system, sans-serif;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: #FC4C02;
}

.garmin-text {
  font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #0078D4;
}

.garmin-text .ds-subbrand {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #64748B;
  text-transform: uppercase;
}

.withings-text {
  font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: #0F172A;
}

.fitbit-text {
  font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: #00B0B9;
  font-size: 1.35rem;
}

.whoop-text {
  font-family: 'Montserrat', 'Segoe UI', -apple-system, sans-serif;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1.5px;
  color: #111827;
}

.hevy-text {
  font-family: 'Montserrat', 'Segoe UI', -apple-system, sans-serif;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #FF4500;
}

.ds-icon {
  font-size: 1.7rem;
  line-height: 1;
}

.ds-card-head h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1F2937;
  margin: 0;
}

.ds-desc {
  font-size: 0.82rem;
  color: #6B7280;
  margin: 0 0 10px 0;
  line-height: 1.4;
}

.ds-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #F3F4F6;
  color: #6B7280;
  white-space: nowrap;
}

.ds-badge.connected {
  background: #DCFCE7;
  color: #15803D;
}

.ds-steps {
  margin: 14px 0 10px 18px;
  padding: 0;
  font-size: 0.8rem;
  color: #4B5563;
  line-height: 1.6;
}

.ds-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0078D4;
  text-decoration: underline;
  margin-bottom: 12px;
}

.ds-field {
  margin-bottom: 10px;
}

.ds-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}

.ds-copy-row {
  display: flex;
  gap: 6px;
}

.ds-copy-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: 'Consolas', 'Courier New', monospace;
  background: #F9FAFB;
  color: #374151;
}

.ds-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ds-sync-info {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #6B7280;
  font-style: italic;
}

.ds-status {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  min-height: 1.1em;
}

.ds-mfa-row.hidden {
  display: none;
}

/* Readiness breakdown under the recovery score (recovery_model.py) */
.readiness-details { margin: 6px 0 8px; font-size: 0.8rem; line-height: 1.45; color: #4B5563; }
.readiness-line { margin: 1px 0; }
.readiness-meta { color: #6B7280; }
.readiness-stale { color: #9CA3AF; font-style: italic; }
.readiness-flags { color: #B45309; font-weight: 600; }
.readiness-better { color: #047857; }
.readiness-worse { color: #B91C1C; }
.readiness-extra { color: #4B5563; }
.training-form-basis { color: #9CA3AF; font-size: 0.78rem; }

/* Nutrition page (nutrition_model.py) */
.nutrition-subtext { color: #4B5563; margin-top: 4px; }
.nutrition-subtext .nutrition-muted { color: #9CA3AF; }
.nutrition-macros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; margin: 4px 0; font-size: 0.8rem; color: #1F2937; }
.nutrition-macros .nutrition-macro-value { font-weight: 700; }
.nutrition-macros .nutrition-macro-rate { color: #6B7280; font-size: 0.72rem; }
.nutrition-disclaimer { font-size: 0.78rem; color: #6B7280; line-height: 1.5; padding: 10px 12px; border-left: 3px solid #D1D5DB; background: rgba(0, 0, 0, 0.02); border-radius: 4px; }

/* Nutrition: goal, signals and food diary (nutrition_engine.py) */
.nutrition-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 15px; }
.nutrition-row-3 .summary-card { padding: 10px 12px; min-width: 0; }
.nutrition-row-3.nutrition-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nutrition-row-3 .summary-card h3 { font-size: 0.8rem; margin-bottom: 6px; }
.nutrition-goal-form { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.nutrition-goal-form .select-input { flex: 1 1 120px; width: auto; padding: 6px 8px; font-size: 0.8rem; }
.nutrition-goal-form .btn { padding: 6px 12px; font-size: 0.8rem; }
.nutrition-signals { font-size: 0.8rem; line-height: 1.5; color: #374151; }
.nutrition-balance-signals { border-top: 1px solid #E5E7EB; margin-top: 8px; padding-top: 6px; }
.nutrition-balance-signals-title { font-size: 0.75rem; font-weight: 600; color: #4B5563; margin-bottom: 2px; }
.nutrition-info-subtitle { display: block; margin-top: 12px; }
.nutrition-signal { display: flex; gap: 6px; align-items: baseline; margin: 2px 0; }
.nutrition-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; display: inline-block; transform: translateY(-1px); }
.nutrition-note-warn { color: #B45309; }
.nutrition-note-bad { color: #B91C1C; }
.nutrition-diary { margin-bottom: 15px; }
.nutrition-diary-header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.nutrition-diary-header h3 { margin: 0; }
.nutrition-date-nav { display: flex; gap: 6px; align-items: center; }
.nutrition-date-nav .select-input { width: auto; padding: 6px 8px; }
.nutrition-date-nav .btn, .nutrition-diary-actions .btn { padding: 6px 10px; font-size: 0.8rem; }
.nutrition-diary-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.nutrition-coverage { font-size: 0.8rem; color: #4B5563; margin-bottom: 8px; }
.nutrition-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 14px; margin-bottom: 12px; }
.nutrition-bar-label { display: flex; justify-content: space-between; font-size: 0.75rem; color: #374151; margin-bottom: 2px; gap: 6px; }
.nutrition-bar { height: 7px; background: #E5E7EB; border-radius: 4px; overflow: hidden; }
.nutrition-bar > span { display: block; height: 100%; border-radius: 4px; }
.nutrition-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.nutrition-slot { border: 1px solid #E5E7EB; border-radius: 8px; padding: 8px 10px; min-width: 0; background: #FFFFFF; }
.nutrition-slot.skipped { background: #F9FAFB; color: #9CA3AF; }
.nutrition-slot-header { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 0.85rem; margin-bottom: 4px; }
.nutrition-slot-kcal { color: #6B7280; font-size: 0.78rem; white-space: nowrap; }
.nutrition-meal { display: flex; gap: 6px; align-items: flex-start; font-size: 0.78rem; padding: 4px 0; border-top: 1px dashed #E5E7EB; }
.nutrition-meal-body { flex: 1; min-width: 0; }
.nutrition-meal-name { overflow-wrap: anywhere; color: #1F2937; }
.nutrition-meal-macros { color: #6B7280; font-size: 0.72rem; }
.nutrition-icon-btn { background: none; border: none; color: #9CA3AF; cursor: pointer; font-size: 0.95rem; line-height: 1; padding: 0 2px; }
.nutrition-icon-btn:hover { color: #B91C1C; }
.nutrition-slot-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.nutrition-slot-actions .btn { padding: 4px 8px; font-size: 0.75rem; }
.nutrition-add { border: 1px solid #BFDBFE; background: #F8FBFF; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.nutrition-add.hidden { display: none; }
.nutrition-add-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.nutrition-add-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.nutrition-add-buttons .btn { padding: 6px 10px; font-size: 0.8rem; }
.nutrition-add-buttons .select-input { width: auto; flex: 1 1 160px; padding: 6px 8px; font-size: 0.8rem; }
.nutrition-add-status { font-size: 0.78rem; color: #4B5563; min-height: 1em; margin-bottom: 4px; }
.nutrition-items-table input { width: 100%; min-width: 48px; padding: 4px 6px; border: 1px solid #D1D5DB; border-radius: 4px; font-size: 0.8rem; }
.nutrition-items-table td:first-child input { min-width: 120px; }
.nutrition-add-footer { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; font-size: 0.8rem; }
.nutrition-add-total { color: #374151; font-weight: 600; }
.nutrition-checkbox { display: inline-flex; gap: 6px; align-items: center; margin-right: auto; }
.nutrition-drinks, .nutrition-presets { border-top: 1px solid #E5E7EB; padding-top: 8px; margin-top: 8px; font-size: 0.85rem; }
.nutrition-drinks-header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.nutrition-drinks-hint { margin: 4px 0 6px; font-size: 0.8rem; color: var(--text-muted); }
.nutrition-muted-inline { color: #6B7280; font-size: 0.78rem; }
.nutrition-drink-buttons, .nutrition-preset-list, .nutrition-drink-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.nutrition-chip { display: inline-flex; gap: 4px; align-items: center; border: 1px solid #D1D5DB; background: #FFFFFF; border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; cursor: pointer; color: #1F2937; }
.nutrition-chip:hover { border-color: #0078D4; }
.nutrition-chip.static { cursor: default; background: #F3F4F6; }
@media (max-width: 900px) {
  .nutrition-row-3, .nutrition-row-3.nutrition-row-2 { grid-template-columns: 1fr; }
  .nutrition-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .nutrition-slots { grid-template-columns: 1fr; }
}

/* Header and navigation wrap instead of overflowing on narrow screens:
   the range buttons and the seven tabs are wider than a phone. */
.hub-header, .hub-navbar { flex-wrap: wrap; gap: 8px; }
.hub-range-controls { flex-wrap: wrap; }
.nav-tabs-left { flex-wrap: wrap; }
@media (max-width: 768px) {
  .hub-header { padding: 10px 12px; }
  .hub-title-group h1 { font-size: 1.15rem; }
  .hub-range-controls { gap: 4px; width: 100%; }
  .range-label { width: 100%; margin-bottom: 2px; }
  .btn-range { padding: 3px 7px; font-size: 0.75rem; }
  .hub-navbar { padding: 6px 8px; }
  .nav-tabs-left { gap: 4px; width: 100%; }
  .nav-tab-btn { padding: 6px 9px; font-size: 0.78rem; gap: 4px; }
  .nav-tabs-right { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .user-tag { overflow-wrap: anywhere; min-width: 0; }
}

/* Info buttons on data cards (same popover as the charts) */
.has-info { position: relative; }
.has-info > .card-info-btn { position: absolute; top: 12px; right: 12px; z-index: 20; }
.has-info > h3, .has-info > h4, .has-info > .str-card-head, .has-info .nutrition-diary-header { padding-right: 32px; }
.cards-row-4 .summary-card.has-info { overflow: visible !important; }
.cards-row-4 .summary-card.has-info h3 { padding-right: 28px; }
.has-info .chart-info-popover { top: 44px; right: 12px; }
.chart-info-popover { max-height: min(70vh, 560px); overflow-y: auto; }
.chart-info-guidance ul { margin: 6px 0 6px 16px; padding: 0; }
.chart-info-guidance li { margin: 4px 0; line-height: 1.45; }
.chart-info-source { border-top: 1px dashed #E2E8F0; padding-top: 8px; }
.chart-info-source strong { color: #1E293B; }
.chart-info-source ul { margin: 4px 0 0 16px; padding: 0; }
.chart-info-source li { margin: 2px 0; }

/* --- Health sub-pages: Sleep, Stress, Recovery (static/health_pages.js) --- */
.hp-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 15px; }
@media (max-width: 900px) { .hp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hp-value-sm { font-size: 1.35rem; }
.hp-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.4; }
.hp-signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.hp-signal { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); border-left-width: 4px; }
.hp-signal-name { font-size: 0.8rem; color: var(--text-muted); }
.hp-signal-value { font-size: 1.2rem; font-weight: 700; color: var(--text-main); }
.hp-signal-base, .hp-signal-trend { font-size: 0.78rem; color: var(--text-muted); }
.hp-trend-better { border-left-color: #10B981; }
.hp-trend-better .hp-signal-trend { color: #059669; }
.hp-trend-worse { border-left-color: #EF4444; }
.hp-trend-worse .hp-signal-trend { color: #DC2626; }
.hp-trend-normal { border-left-color: #9CA3AF; }
.hp-trend-none { border-left-color: #E5E7EB; }
.hp-flags { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.85rem; color: #92400E; }
.hp-flags li { padding: 2px 0; }

/* --- Data source categories (GAR-3) --- */
.ds-categories { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; margin: 12px 0 6px; }
.ds-categories legend { font-size: 0.85rem; font-weight: 700; color: var(--text-main); padding: 0 4px; }
.ds-cat-help { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 8px; line-height: 1.4; }
.ds-cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
.ds-cat { display: flex; align-items: flex-start; gap: 7px; font-size: 0.84rem; color: var(--text-main); cursor: pointer; line-height: 1.35; }
.ds-cat input { width: auto; margin-top: 2px; }
.ds-cat.required { color: var(--text-muted); cursor: default; }
.ds-cat em { font-style: normal; font-size: 0.75rem; }
.ds-cat-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.ds-cat-updated { font-size: 0.75rem; color: var(--text-muted); }
.ds-cat-single { font-size: 0.8rem; color: var(--text-muted); margin: 10px 0 4px; }

/* --- Training dropdown: current page in the menu --- */
.nav-dropdown-menu .dropdown-item.active { color: var(--primary); font-weight: 700; background: #EFF6FF; }

/* --- Strength training page (static/strength.js) --- */
.str-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 15px; }
@media (max-width: 900px) { .str-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.str-stat-card { width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
.str-stat-card:hover, .str-stat-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15); }
.str-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.str-card-head h3, .str-card-head h4 { margin-bottom: 0; }
.str-hint { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.str-close-btn { position: absolute; top: 10px; right: 14px; }
.str-select { max-width: 260px; font-size: 0.82rem; padding: 4px 8px; }

.str-seg { display: inline-flex; background: #F3F4F6; border-radius: 8px; padding: 2px; }
.str-seg-btn { border: none; background: transparent; padding: 5px 12px; font-size: 0.8rem; border-radius: 6px; cursor: pointer; color: var(--text-muted); }
.str-seg-btn.active { background: #FFFFFF; color: var(--text-main); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.str-muscle-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 10px; }
@media (max-width: 900px) { .str-muscle-grid { grid-template-columns: 1fr; } }
.str-bodies { display: flex; justify-content: center; gap: 10px; }
.str-body { margin: 0; text-align: center; flex: 1; max-width: 190px; }
.str-body figcaption { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.str-body-svg { width: 100%; height: auto; display: block; }
.str-body-svg polygon[data-muscle] { cursor: default; }
.str-muscle-bars { display: flex; flex-direction: column; gap: 10px; }
.str-bar-row, .str-split-row { display: flex; flex-direction: column; gap: 4px; }
.str-split-row { margin-bottom: 10px; }
.str-bar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; }
.str-bar-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.str-bar-value { color: var(--text-muted); white-space: nowrap; }
.str-bar-track { display: flex; height: 7px; background: #F3F4F6; border-radius: 4px; overflow: hidden; }
.str-bar-fill { height: 100%; }
.str-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.str-bar-legend { display: flex; gap: 14px; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.str-legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: #10B981; margin-right: 5px; vertical-align: middle; }
.str-legend-swatch.light { background: rgba(16, 185, 129, 0.4); }

.str-calendar { overflow-x: auto; padding-bottom: 4px; }
.str-cal-grid { display: flex; gap: 3px; min-width: max-content; }
.str-cal-col { display: flex; flex-direction: column; gap: 3px; }
.str-cal-cell { width: 12px; height: 12px; border-radius: 3px; background: #EBEDF0; display: inline-block; }
.str-cal-cell.lvl1 { background: #6EE7B7; }
.str-cal-cell.lvl2 { background: #059669; }
.str-cal-cell.future { background: transparent; }
.str-calendar-legend { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }
.str-calendar-legend span:first-child { margin-right: 4px; }
.str-calendar-legend span:last-child { margin-left: 4px; }

.str-week-details { margin-top: 10px; font-size: 0.85rem; }
.str-week-head { font-weight: 700; margin-bottom: 6px; color: var(--text-main); }
.str-week-row { padding: 4px 0; border-bottom: 1px solid var(--border-color); }

.str-list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 4px; border: none; border-bottom: 1px solid var(--border-color); background: transparent; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.str-list-row:hover { background: #F9FAFB; }
.str-list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.str-list-main strong { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.str-spark { width: 60px; height: 20px; flex-shrink: 0; }
.str-recent { max-height: 520px; overflow-y: auto; }
.str-workout.open .dropdown-caret { transform: rotate(180deg); }
.str-workout-details { padding: 6px 8px 10px; background: #F9FAFB; border-bottom: 1px solid var(--border-color); }
.str-ex { padding: 5px 0; }
.str-ex-title { font-size: 0.84rem; font-weight: 600; margin-bottom: 3px; }
.str-ex-sets { display: flex; flex-wrap: wrap; gap: 4px; }
.str-set { font-size: 0.76rem; background: #FFFFFF; border: 1px solid var(--border-color); border-radius: 10px; padding: 1px 8px; color: #374151; }

/* GAR-5: intensity minutes and the watch's performance figures on the Training page */
.train-garmin-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 15px;
}
.train-garmin-row.hidden { display: none; }
@media (max-width: 1024px) {
  .train-garmin-row { grid-template-columns: 1fr; }
}
.im-progress {
  height: 8px;
  border-radius: 4px;
  background: #E5E7EB;
  overflow: hidden;
  margin: 6px 0 4px;
}
.im-progress-bar {
  height: 100%;
  width: 0;
  background: #F59E0B;
  transition: width 0.3s ease;
}
.im-progress-bar.met { background: #10B981; }
.im-chart { height: 120px; margin-top: 8px; }
.train-perf-list { font-size: 0.88rem; color: #374151; line-height: 1.5; }
.train-perf-list .perf-group { margin-top: 8px; }
.train-perf-list .perf-group:first-child { margin-top: 2px; }
.train-perf-list .perf-label { font-weight: 600; color: #1F2937; }
.train-perf-list .perf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.train-perf-list .perf-cell { background: #F3F4F6; border-radius: 6px; padding: 4px 6px; text-align: center; }
.train-perf-list .perf-cell b { display: block; font-size: 0.95rem; color: #111827; }
.train-perf-list .perf-change.better { color: #10B981; }
.train-perf-list .perf-change.worse { color: #EF4444; }
.source-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
  background: #DBEAFE;
  color: #1D4ED8;
}

/* Charts whose data the user has never synced are hidden - createChart. */
.chart-empty-hidden { display: none !important; }

/* --- Löpning and Cykel pages (static/sport.js) --- */
.sport-empty-text { font-size: 0.9rem; color: #4B5563; line-height: 1.5; }
.sport-records { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.sport-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-bottom: 1px solid #F3F4F6; padding: 4px 0; }
.sport-row:last-child { border-bottom: none; }
.sport-row-label { color: #374151; }
.sport-row-value { font-weight: 700; color: #111827; white-space: nowrap; }
.sport-row-meta { display: block; font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.sport-trend-up { color: #10B981; }
.sport-trend-down { color: #EF4444; }

/* Records and best sessions: list boxes as tall as a chart (canvas 240px), scrolling if longer. */
.sport-list { height: 240px; overflow-y: auto; padding-right: 4px; }
/* The watch's performance figures on the Löpning page, above the charts. */
.sport-perf-card { margin-bottom: 15px; }
.sport-perf-card.hidden { display: none; }

/* Meal photo in the "add meal" panel */
.nutrition-photo-preview { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.nutrition-photo-preview.hidden { display: none; }
.nutrition-photo-preview img { max-width: 160px; max-height: 120px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border-color); }
.nutrition-photo-note { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; margin: 0; }

/* --- Detailed Workout Modal (Passdetaljer) --- */
.clickable-activity-row,
.clickable-sport-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.clickable-activity-row:hover,
.clickable-sport-row:hover {
  background-color: rgba(0, 120, 212, 0.08) !important;
}

.clickable-activity-row:focus-visible,
.clickable-sport-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.activity-modal-card {
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.activity-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background: #FFFFFF;
}

.activity-modal-header-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.activity-modal-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 12px;
  background: rgba(0, 120, 212, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.activity-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.activity-modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.activity-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.activity-modal-media {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* --- AI Workout Analysis & Improvement Tips Card --- */
.activity-modal-ai-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(16, 185, 129, 0.06));
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-lg, 12px);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

[data-theme="dark"] .activity-modal-ai-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.75), rgba(15, 23, 42, 0.85));
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.act-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.act-ai-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.act-ai-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #3B82F6, #10B981);
  color: #FFFFFF;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.act-ai-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.act-ai-subtitle {
  margin: 2px 0 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.act-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: var(--radius-md, 8px);
  background: linear-gradient(135deg, #2563EB, #059669);
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.act-ai-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.act-ai-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.act-ai-btn.spinning .act-ai-btn-icon {
  display: inline-block;
  animation: spin 1s infinite linear;
}

.act-ai-body {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-main);
}

.act-ai-placeholder {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-md, 8px);
  border: 1px dashed rgba(59, 130, 246, 0.3);
  color: var(--text-muted);
  font-size: 0.84rem;
}

[data-theme="dark"] .act-ai-placeholder {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(99, 102, 241, 0.3);
}

.act-ai-placeholder p {
  margin: 0;
}

.act-ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-style: italic;
}

.act-ai-error {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md, 8px);
  color: #EF4444;
  font-size: 0.84rem;
}

.act-ai-result {
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-md, 8px);
  padding: 14px 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="dark"] .act-ai-result {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
}

.act-ai-result strong {
  color: var(--primary-accent, #3B82F6);
  font-weight: 600;
}

[data-theme="dark"] .act-ai-result strong {
  color: #60A5FA;
}

.act-ai-result h3,
.act-ai-result h4,
.act-ai-result .chat-section-header {
  margin: 12px 0 6px 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.act-ai-result h3:first-child,
.act-ai-result h4:first-child {
  margin-top: 0;
}

.act-ai-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .act-ai-footer {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.act-ai-footer .btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 6px;
}

.activity-modal-photos {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0;
  scroll-behavior: smooth;
}

.activity-modal-photos::-webkit-scrollbar {
  height: 6px;
}

.activity-modal-photos::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.activity-modal-photo-img {
  width: 140px;
  height: 95px;
  min-width: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.activity-modal-photo-img:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.activity-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
  background: #F9FAFB;
}

.activity-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 10px;
}

.activity-metric-box {
  background: #F9FAFB;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.activity-metric-box:hover {
  border-color: #CBD5E1;
}

.activity-metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.activity-metric-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 3px;
  line-height: 1.2;
}

.activity-metric-unit {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}

.activity-section {
  border-top: 1px solid #F1F5F9;
  padding-top: 14px;
}

.activity-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Laps & Splits table */
.activity-splits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.activity-splits-table th {
  background: #F3F4F6;
  color: var(--text-muted);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
}

.activity-splits-table td {
  padding: 6px 10px;
  border-top: 1px solid #F3F4F6;
  color: var(--text-main);
}

.activity-splits-table tr:hover td {
  background: #F9FAFB;
}

/* HR zones horizontal bar */
.activity-zones-bar {
  display: flex;
  height: 14px;
  border-radius: 9999px;
  overflow: hidden;
  background: #E5E7EB;
  margin-bottom: 8px;
}

.activity-zone-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.activity-zones-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-zone-tag {
  display: flex;
  align-items: center;
  gap: 5px;
}

.activity-zone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Training effect chips */
.activity-te-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.activity-te-card {
  flex: 1;
  min-width: 130px;
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.activity-te-val {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
}

.activity-te-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Weather & location widget */
.activity-weather-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F0F9FF;
  border: 1px solid #BAE6FD;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #0369A1;
  font-size: 0.88rem;
}

.activity-weather-icon {
  font-size: 1.6rem;
}

/* Exercise sets list */
.activity-sets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.activity-set-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #F9FAFB;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

/* Modal loader */
.activity-modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid #E5E7EB;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
