@charset "utf-8";

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, system-ui, Helvetica, Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color)
}

:root {
  --bg-color: #fff;
  --card-bg: #fff;
  --surface-bg: #fafafa;
  --bg-subtle: #f0f0f0;
  --text-color: #333;
  --text-sub: #666;
  --text-muted: #999;
  --text-faint: #777;
  --text-dim: #555;
  --border-color: #e0e0e0;
  --input-border: #ccc;
  --disabled-bg: #f5f5f5;
  --disabled-text: #999;
  --primary-color: #1976d2;
  --primary-hover: #1565c0;
  --success-color: #2e7d32;
  --success-hover: #1b5e20;
  --error-color: #d32f2f;
  --error-hover: #b71c1c;
  --error-bg: #ffebee;
  --warning-color: #f57c00;
  --warning-bg: #fff3e0;
  --success-bg: #e8f5e8;
  --cheat-color: #ffcc80;
  --cheat-hover: #ffb74d;
  --cheat-text: #5d4037;
  --cheat-text-hover: #4e342e;
  --shadow-light: rgba(0, 0, 0, 0.08);
  --shadow-dark: rgba(0, 0, 0, 0.3);
  --chart-weight: #9bb8e0;
  --chart-trend: #9c27b0;
  --chart-predicted: #ff9800;
  --chart-goal: #4caf50;
  --chart-computed: #ff7043;
  --chart-cal-in: #ffb3a3;
  --chart-tdee: #b0bec5;
  --chart-intake-avg: #d32f2f;
  --chart-tdee-avg: #455a64;
  --chart-target: #4caf50;
  --chart-shade-future: rgba(255, 152, 0, 0.06);
  --chart-goal-line: #ff9800;
  --chart-goal-cal-line: #2196f3;
  --tooltip-bg: rgba(0, 0, 0, 0.85);
  --tooltip-text: #fff;
  --tooltip-border: rgba(255, 255, 255, 0.15);
  
  /* Tooltip styles */
  .info-icon {
    position: relative;
    display: inline-block;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    transition: all 0.2s ease;
  }
  
  .info-icon:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
  }
  
  .info-icon:active {
    transform: scale(0.95);
  }
  
  /* Active tooltip state */
  .info-icon.tooltip-active {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  }
  
  /* Mobile-friendly tooltip */
  @media (max-width: 768px) {
    .info-icon {
      width: 20px;
      height: 20px;
      line-height: 20px;
      font-size: 16px;
      /* Prevent text selection on mobile */
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
    }
    
    .info-icon:active {
      background: rgba(0, 0, 0, 0.2);
    }
    
    .info-icon.tooltip-active {
      background: rgba(0, 0, 0, 0.3);
      transform: scale(1.15);
      box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
    }
  }
}

@media (prefers-color-scheme:dark) {
  :root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --surface-bg: #2d2d2d;
    --bg-subtle: #333;
    --text-color: #e0e0e0;
    --text-sub: #e0e0e0;
    --text-muted: #ccc;
    --text-faint: #fff;
    --text-dim: #b3b3b3;
    --border-color: #404040;
    --input-border: #606060;
    --disabled-bg: #2d2d2d;
    --disabled-text: #a0a0a0;
    --shadow-light: rgba(255, 255, 255, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.5);
    --error-hover: #ef5350;
    --tooltip-bg: rgba(255, 255, 255, 0.95);
    --tooltip-text: #111;
    --tooltip-border: rgba(0, 0, 0, 0.25);
  }
  
  /* Dark mode tooltip styles */
  .info-icon:hover {
    background: rgba(255, 255, 255, 0.1);
  }
  
  .info-icon:active {
    background: rgba(255, 255, 255, 0.2);
  }
  
  .info-icon.tooltip-active {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
  }
  
  @media (max-width: 768px) {
    .info-icon:active {
      background: rgba(255, 255, 255, 0.2);
    }
    
    .info-icon.tooltip-active {
      background: rgba(255, 255, 255, 0.3);
      box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
    }
  }
  
  :root {
    --error-bg: rgba(211, 47, 47, 0.15);
    --warning-bg: rgba(245, 124, 0, 0.18);
    --success-bg: rgba(46, 125, 50, 0.18);
    --chart-weight: #80b1dd;
    --chart-trend: #ba68c8;
    --chart-predicted: #ffb74d;
    --chart-goal: #66bb6a;
    --chart-computed: #ff8a65;
    --chart-cal-in: #ff8a80;
    --chart-tdee: #90a4ae;
    --chart-intake-avg: #ef5350;
    --chart-tdee-avg: #607d8b;
    --chart-target: #66bb6a;
    --chart-shade-future: rgba(255, 152, 0, 0.1);
    --chart-goal-line: #ffb74d;
    --chart-goal-cal-line: #64b5f6
  }
}

main {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 24px;
  background: var(--bg-color);
  min-height: 100vh;
  box-sizing: border-box
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  margin: 0
}

.dashboard-top {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 20px 0 12px;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid var(--border-color)
}

.dashboard-top section {
  margin: 0
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: nowrap
}

.top-nav .nav-link {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color .2s ease
}

.top-nav .nav-link:hover,
.top-nav .nav-link:focus-visible {
  color: var(--primary-hover);
  outline: 0
}

.nav-action {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary-color);
  color: #fff;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
  white-space: nowrap
}

.nav-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.12)
}

.nav-action:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px
}

.nav-action--danger {
  background: var(--error-color)
}

.nav-action--danger:hover {
  background: var(--error-hover)
}

h1 {
  font-size: 18px;
  margin: 0;
  color: var(--text-color);
  flex: 0 1 auto;
  min-width: 0
}

.neon-text {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 0 0 5px rgba(59, 130, 246, 0.8), 0 0 10px rgba(59, 130, 246, 0.6), 0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2);
  animation: neon-glow 2.5s ease-in-out infinite alternate
}

@keyframes neon-glow {
  0% {
    text-shadow: 0 0 5px rgba(59, 130, 246, 0.8), 0 0 10px rgba(59, 130, 246, 0.6), 0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2)
  }

  100% {
    text-shadow: 0 0 8px rgba(236, 72, 153, 0.9), 0 0 16px rgba(236, 72, 153, 0.7), 0 0 30px rgba(236, 72, 153, 0.5), 0 0 50px rgba(236, 72, 153, 0.3), 0 0 70px rgba(236, 72, 153, 0.1)
  }
}

@media (prefers-color-scheme:light) {
  .neon-text {
    color: var(--primary-color);
    text-shadow: 0 0 3px rgba(59, 130, 246, 0.4), 0 0 6px rgba(59, 130, 246, 0.3), 0 0 12px rgba(59, 130, 246, 0.2)
  }

  @keyframes neon-glow {
    0% {
      text-shadow: 0 0 3px rgba(59, 130, 246, 0.4), 0 0 6px rgba(59, 130, 246, 0.3), 0 0 12px rgba(59, 130, 246, 0.2)
    }

    100% {
      text-shadow: 0 0 5px rgba(236, 72, 153, 0.5), 0 0 10px rgba(236, 72, 153, 0.4), 0 0 20px rgba(236, 72, 153, 0.3)
    }
  }
}

section {
  margin: 12px 0
}

#summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px
}

.sticky-summary {
  padding: 0
}

.sticky-summary .card {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 16px;
  margin-bottom: 0
}

.js-dashboard-swiper {
  overflow: hidden;
  padding: 0 0 32px;
  touch-action: pan-x
}

.js-dashboard-swiper .swiper-wrapper {
  align-items: stretch
}

.js-dashboard-swiper .swiper-slide {
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  box-sizing: border-box
}

.js-dashboard-swiper .swiper-slide>.card,
.js-dashboard-swiper .swiper-slide>section.card {
  width: 100%;
  box-sizing: border-box;
  margin: 0
}

.js-dashboard-swiper .swiper-slide>section#charts.card {
  padding: 16px 14px
}

.js-dashboard-swiper .swiper-pagination-bullet {
  background: var(--primary-color);
  opacity: .25
}

.js-dashboard-swiper .swiper-pagination-bullet-active {
  opacity: 1
}


.today-hero {
  text-align: center;
  padding: 12px 8px 8px;
  background: var(--card-bg)
}

.today-hero .hero-title {
  color: var(--text-color);
  font-size: 1.0em;
  font-weight: 600
}

.today-hero .hero-value {
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--text-color);
  line-height: 1.1;
  margin-top: 6px
}

.today-hero .hero-unit {
  color: var(--text-sub);
  margin-top: -2px
}

.today-hero .hero-mode {
  color: var(--text-muted);
  font-size: .95em;
  margin-top: 4px
}

.today-hero .hero-sub {
  color: var(--text-sub);
  font-size: .9em;
  margin-top: 6px
}

.today-hero .hero-meta {
  color: var(--text-sub);
  font-size: .9em;
  margin-top: 6px
}

.remaining-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px
}

.remaining-card .rem-label {
  color: var(--text-dim);
  font-size: .95em
}

.remaining-card .rem-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text-color)
}

.remaining-card .rem-mode {
  color: var(--text-muted);
  font-size: .9em;
  margin-top: 2px
}

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

.today-actions .cheat-toggle {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--cheat-color);
  color: var(--cheat-text)
}

.today-actions .cheat-toggle.active {
  background: var(--cheat-hover);
  color: var(--cheat-text-hover)
}

.today-actions .cheat-toggle:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed
}

.today-actions .mark-btn {
  flex: 1
}

.details-bubble {
  margin-top: 10px
}

.details-bubble>summary {
  cursor: pointer;
  color: var(--primary-color)
}

.details-bubble dl {
  margin: 8px 0 0 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 12px;
  justify-content: space-between;
  width: 100%;
}

.details-bubble dt {
  color: var(--text-sub)
}

.details-bubble dd {
  margin: 0;
  font-weight: 600;
  color: var(--text-color);
  text-align: right;
  justify-self: end;
}

/* Smart summary under Today's Recommendation */
.smart-summary {
  margin-top: 8px;
  color: var(--text-sub);
  font-size: 0.9em;
  line-height: 1.35;
}
.smart-summary .good { color: #2e7d32; }
.smart-summary .warn { color: #c62828; }
.smart-summary .info { color: #555; }
.smart-summary b { font-weight: 600; }

.smart-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-subtle);
  color: var(--text-sub);
}
.smart-badge--good {
  background: rgba(46, 125, 50, 0.12);
  color: #2e7d32;
}
.smart-badge--warn {
  background: rgba(198, 40, 40, 0.12);
  color: #c62828;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.7em;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-sub);
}
.confidence-badge--low { color: #fb8c00; background: rgba(251, 140, 0, 0.14); }
.confidence-badge--moderate { color: #2e7d32; background: rgba(46, 125, 50, 0.14); }
.confidence-badge--high { color: #1e88e5; background: rgba(30, 136, 229, 0.14); }
.confidence-badge--custom { color: var(--primary-color); }

.intake-progress {
  margin-top: 14px;
}
.intake-progress__track {
  position: relative;
  height: 14px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}
.intake-progress__bar {
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s ease;
}
.intake-progress__bar--green { background: linear-gradient(90deg, #43a047 0%, #66bb6a 100%); }
.intake-progress__bar--amber { background: linear-gradient(90deg, #f9a825 0%, #fbc02d 100%); }
.intake-progress__bar--amber-critical { background: linear-gradient(90deg, #f57c00 0%, #ff9800 100%); }
.intake-progress__bar--red { background: linear-gradient(90deg, #c62828 0%, #e53935 100%); }

.intake-progress__marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(0,0,0,0.2);
}

.intake-progress__caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 0.85em;
  color: var(--text-sub);
}
.intake-progress__caption--alert span:last-child {
  color: #c62828;
  font-weight: 600;
  animation: pulseAlert 1.2s ease-in-out infinite;
}

@keyframes pulseAlert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.quick-remaining {
  color: var(--text-dim);
  font-size: .95em;
  margin-top: 8px
}

.chart-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px
}

.chart-controls h2 {
  margin: 0;
  font-size: 1.2em;
  color: var(--text-color)
}

.period-selector {
  display: flex;
  background: var(--bg-subtle);
  border-radius: 6px;
  overflow: hidden
}

.period-btn {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color .2s ease;
  color: var(--text-sub)
}

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

.period-btn:hover:not(.active) {
  background: var(--border-color)
}

.chart-container {
  margin: 16px 0;
  padding: 0 12px
}

.chart-container h3 {
  margin: 0 0 12px 0;
  font-size: 1em;
  color: var(--text-sub);
  text-align: center
}

.chart-container canvas {
  width: 100%;
  max-height: 260px
}

.chart-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  color: var(--text-muted)
}

@media (max-width:480px) {
  .dashboard-top {
    padding: 14px 0 8px;
    gap: 8px
  }

  header {
    gap: 8px
  }

  .top-nav {
    gap: 8px
  }

  .top-nav .nav-link {
    font-size: 13px
  }

  .nav-action {
    padding: 6px 12px;
    font-size: 13px
  }

  h1 {
    font-size: 17px
  }

  .neon-text {
    font-size: 22px;
    letter-spacing: 1.0px
  }

  .chart-controls {
    flex-direction: column;
    align-items: stretch
  }

  .period-selector {
    width: 100%
  }

  .period-btn {
    flex: 1;
    text-align: center
  }

  .js-dashboard-swiper .swiper-slide>section#charts.card {
    padding: 14px 12px
  }

  .chart-container {
    margin: 12px 0;
    padding: 0 8px
  }

  .chart-container canvas {
    max-height: 220px
  }

  /* Fix birthdate input field width in mobile view - match height input exactly */
  .form-group input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    box-sizing: border-box;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-color);
    min-height: 44px;
    /* Remove iOS default styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  /* Also ensure height input has consistent styling in mobile */
  .form-group input[type="number"] {
    padding: 10px 12px;
    font-size: 16px;
    min-height: 44px;
  }
}

.session-btn {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  margin: 4px 8px 4px 0;
  min-height: 44px
}

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

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

.session-btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-color)
}

.session-btn.secondary:hover {
  background: var(--border-color)
}

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

.session-form {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface-bg);
  border-radius: 6px;
  border: 1px solid var(--border-color)
}

.session-form h3 {
  margin: 0 0 16px 0;
  font-size: 1.1em;
  color: var(--text-color)
}

.form-group {
  margin-bottom: 16px
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-sub);
  font-size: 14px
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 16px;
  box-sizing: border-box;
  background: var(--card-bg);
  color: var(--text-color)
}

.form-group input:focus {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2)
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px
}

.form-actions .session-btn {
  flex: 1;
  margin: 0
}

.history-toggle {
  background: transparent;
  border: 0;
  color: var(--primary-color);
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 0;
  font-size: 14px;
  margin-top: 12px
}

.history-toggle:hover {
  color: var(--primary-hover)
}

.history-content {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-bg);
  border-radius: 6px;
  border: 1px solid var(--border-color)
}

.session-item {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--card-bg);
  border-radius: 4px;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center
}

.session-item:last-child {
  margin-bottom: 0
}

.session-info {
  flex: 1
}

.session-info .session-title {
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 4px
}

.session-info .session-details {
  font-size: 12px;
  color: var(--text-sub)
}

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

.session-actions button {
  padding: 6px 12px;
  font-size: 12px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-subtle);
  color: var(--text-color)
}

.session-actions button:hover {
  background: var(--border-color)
}

.session-actions .view-btn {
  background: var(--primary-color);
  color: white
}

.session-actions .view-btn:hover {
  background: var(--primary-hover)
}

@media (max-width:480px) {
  .form-actions {
    flex-direction: column
  }

  .form-actions .session-btn {
    width: 100%
  }

  .session-item {
    flex-direction: column;
    align-items: stretch
  }

  .session-actions {
    margin-top: 12px;
    justify-content: stretch
  }

  .session-actions button {
    flex: 1
  }
}

@media (pointer:coarse) {
  .session-btn {
    padding: 12px 20px;
    font-size: 16px
  }

  .form-group input {
    padding: 14px 16px
  }

  .history-toggle {
    padding: 12px 0;
    font-size: 16px
  }
}

.data-entry-btn {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  min-height: 40px
}

.data-entry-btn.primary {
  background: var(--success-color);
  color: #fff
}

.data-entry-btn.primary:hover {
  background: var(--success-hover)
}

.data-entry-btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-color)
}

.data-entry-btn.secondary:hover {
  background: var(--border-color)
}

.data-entry-btn:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed
}

.data-manager-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px
}

.data-mode-toggle {
  display: inline-flex;
  background: var(--surface-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 4px;
  gap: 4px
}

.data-mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-color);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 120px;
  transition: background .2s ease, color .2s ease
}

.data-mode-btn.active {
  background: var(--primary-color);
  color: #fff
}

.data-mode-btn:focus-visible {
  outline: 2px solid var(--primary-hover);
  outline-offset: 2px
}

.custom-range-controls {
  display: none;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap
}

.custom-range-controls label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--text-sub);
  gap: 6px
}

.custom-range-controls input[type=date] {
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--text-color);
  min-height: 38px
}

.custom-range-controls input[type=date]:focus {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2)
}

.data-action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap
}

.data-manager-status {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px
}

.status-line {
  font-size: 13px;
  color: var(--text-sub)
}

.data-loading {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px
}

.data-table-wrapper {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
  position: relative
}

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

.data-entry-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  transition: all .2s ease
}

.data-entry-card.missing {
  background: var(--surface-bg);
  opacity: .8
}

.data-entry-card.dirty {
  border-left: 4px solid var(--primary-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1)
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color)
}

.date-section {
  display: flex;
  flex-direction: column;
  gap: 4px
}

.date-primary {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-color)
}

.date-secondary {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace
}

.actions-dropdown {
  position: relative
}

.dropdown-trigger {
  background: 0;
  border: 0;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: background-color .2s
}

.dropdown-trigger:hover {
  background: var(--surface-bg);
  color: var(--text-color)
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 120px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all .2s ease
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0)
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: 0;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-color);
  transition: background-color .2s
}

.dropdown-item:hover {
  background: var(--surface-bg)
}

.dropdown-item.primary {
  color: var(--primary-color)
}

.dropdown-item.danger {
  color: var(--danger-color)
}

.dropdown-item:disabled {
  opacity: .5;
  cursor: not-allowed
}

.data-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px
}

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

.input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px
}

.compact-input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 14px;
  transition: all .2s ease
}

.compact-input:focus {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2)
}

.compact-input::placeholder {
  color: var(--text-muted);
  opacity: .7
}

.manual-row-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--text-color);
  min-height: 34px
}

.manual-row-input:focus {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2)
}

.manual-row-input::placeholder {
  color: var(--text-muted)
}

.manual-row-input.invalid {
  border-color: var(--error-color);
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.2)
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap
}

.row-action {
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
  background: var(--bg-subtle);
  color: var(--text-color)
}

.row-action:hover {
  background: var(--border-color)
}

.row-action.primary {
  background: var(--primary-color);
  color: #fff
}

.row-action.primary:hover {
  background: var(--primary-hover)
}

.row-action.danger {
  background: var(--error-color);
  color: #fff
}

.row-action.danger:hover {
  background: var(--error-hover)
}

.row-action:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed
}

.empty-state {
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted)
}

.data-feedback {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-sub)
}

.data-feedback.success {
  color: var(--success-color)
}

.data-feedback.error {
  color: var(--error-color)
}

@media (max-width:768px) {
  .data-inputs {
    grid-template-columns: 1fr;
    gap: 12px
  }

  .card-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch
  }

  .date-section {
    order: 1
  }

  .actions-dropdown {
    order: 2;
    align-self: flex-end
  }

  .dropdown-menu {
    right: auto;
    left: 0
  }
}

@media (max-width:480px) {
  .data-manager-controls {
    flex-direction: column;
    align-items: stretch
  }

  .data-entry-card {
    padding: 12px
  }

  .data-mode-toggle {
    width: 100%
  }

  .data-mode-btn {
    flex: 1
  }

  .custom-range-controls {
    width: 100%;
    justify-content: space-between
  }

  .custom-range-controls input[type=date] {
    width: 100%
  }

  .data-action-buttons {
    width: 100%;
    justify-content: space-between
  }

  .data-action-buttons .data-entry-btn {
    flex: 1
  }

  .row-actions {
    flex-direction: column
  }

  .row-action {
    width: 100%;
    text-align: center
  }
}

@media (pointer:coarse) {
  .data-entry-btn {
    padding: 12px 20px;
    font-size: 16px
  }

  .manual-row-input {
    padding: 10px 14px;
    font-size: 16px
  }

  .row-action {
    padding: 10px 14px;
    font-size: 15px
  }
}

.form-group input.invalid {
  border-color: var(--error-color);
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.2)
}

.form-group .error-message {
  color: var(--error-color);
  font-size: 12px;
  margin-top: 4px;
  display: block
}

.metric-separator {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
  border: 0
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px var(--shadow-light)
}

.card h2 {
  margin-top: 0;
  color: var(--text-color);
  font-size: 1.2em
}

.card.collapsible {
  padding: 0;
  overflow: hidden
}

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

.card.collapsible .card-collapsible-header h2 {
  margin: 0;
  font-size: 1.2em
}

.card-collapse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: 0;
  color: var(--text-muted);
  font-size: .95em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color .2s ease, background-color .2s ease
}

.card-collapse-toggle:hover,
.card-collapse-toggle:focus-visible {
  color: var(--text-color);
  outline: 0
}

.card-collapse-toggle .toggle-icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .2s ease;
  margin-top: -2px
}

.card.collapsible.is-collapsed .card-collapse-toggle .toggle-icon {
  transform: rotate(45deg)
}

.collapsible-content {
  padding: 0 20px 20px
}

.card.collapsible.is-collapsed .collapsible-content {
  display: none
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color)
}

.metric:last-child {
  border-bottom: 0
}

.metric-label {
  color: var(--text-sub)
}

.metric-value {
  font-weight: 700;
  color: var(--text-color)
}

.metric-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #fff;
  background: var(--warning-color)
}

.metric-tag--warn {
  background: var(--warning-color)
}

.recommendation-display {
  text-align: center;
  padding: 20px
}

.kcal-target {
  font-size: 3em;
  font-weight: 700;
  color: var(--primary-color);
  margin: 10px 0
}

.kcal-bounds {
  color: var(--text-sub);
  font-size: .9em
}

.progress-bar {
  width: 100%;
  height: 20px;
  background: var(--bg-subtle);
  border-radius: 10px;
  margin: 15px 0;
  position: relative;
  overflow: hidden
}

.progress-fill {
  height: 100%;
  background: var(--success-color);
  border-radius: 10px;
  transition: width .3s ease
}

.no-data {
  text-align: center;
  color: var(--text-muted);
  padding: 20px
}

.form-section {
  margin-bottom: 32px
}

.form-section h3 {
  margin: 0 0 16px 0;
  color: var(--text-dim);
  font-size: 1.1em;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px
}

.field-help {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
  line-height: 1.4
}

@media (prefers-color-scheme:dark) {
  .field-help {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 0;
    border-radius: 2px
  }
}

.field-error {
  font-size: 12px;
  color: var(--error-color);
  margin-top: 4px;
  display: none
}

.form-group input.error {
  border-color: var(--error-color);
  background-color: var(--card-bg);
  box-shadow: 0 0 0 2px var(--error-bg)
}

.form-group input.valid {
  border-color: var(--success-color);
  background-color: var(--card-bg);
  box-shadow: 0 0 0 2px var(--success-bg)
}

.settings-help {
  background: rgba(25, 118, 210, 0.08);
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-sub)
}

@media (prefers-color-scheme:dark) {
  .settings-help {
    border-width: 2px;
    color: #fff
  }

  .settings-help h3 {
    color: var(--primary-color);
    font-weight: 600
  }
}

.notification {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 14px;
  display: none;
  border: 1px solid
}

.notification.success {
  background: rgba(46, 125, 50, 0.1);
  color: var(--success-color);
  border-color: var(--success-color)
}

.notification.error {
  background: rgba(211, 47, 47, 0.1);
  color: var(--error-color);
  border-color: var(--error-color)
}

.loading {
  display: none;
  text-align: center;
  padding: 20px;
  color: var(--text-muted)
}

.btn {
  border: 0;
  border-radius: 6px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  min-height: 44px;
  flex: 1
}

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

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

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

.btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-color)
}

.btn.secondary:hover {
  background: var(--border-color)
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 24px
}

.metrics-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  padding: 10px 0
}

.sticky-summary .metrics-container {
  gap: 8px;
  padding: 4px 0
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 0;
  cursor: help
}

.sticky-summary .metric-item {
  padding: 0 4px
}

.metric-icon {
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px
}

.sticky-summary .metric-icon {
  margin-bottom: 2px
}

.metric-icon svg {
  width: 36px;
  height: 36px;
  opacity: .8
}

.metric-item .metric-value {
  font-weight: 700;
  color: var(--text-color);
  font-size: 1.1em;
  text-align: center;
  white-space: nowrap
}

.metric-item .metric-value.calculated-weight {
  background: var(--warning-color);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  font-size: 1em
}

.metric-item:hover .metric-icon {
  opacity: 1
}

.metric-item:hover .metric-icon svg {
  transform: scale(1.1);
  transition: transform .2s ease
}

.metric-date {
  font-size: .75em;
  color: var(--text-sub);
  text-align: center;
  margin-top: 2px;
  font-weight: 400
}

.sticky-summary .metric-date {
  margin-top: 0;
  font-size: .7em
}

@media (max-width:480px) {
  .button-group {
    flex-direction: column
  }

  .btn {
    width: 100%
  }
}

#manualDataTable .date-cell {
  display: flex;
  flex-direction: column;
  gap: 2px
}

#manualDataTable .date-cell .date-primary {
  font-weight: 600;
  color: var(--text-color)
}

#manualDataTable .date-cell .date-secondary {
  font-size: 12px;
  color: var(--text-muted)
}

#manualDataTable tbody tr.missing .date-secondary::after {
  content: ' · missing';
  color: var(--warning-color);
  font-weight: 500
}
