:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --blue: #3498db;
  --red: #e74c3c;
  --green: #27ae60;
  --orange: #f39c12;
  --border: #dce1e8;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 24px;
  color: var(--text);
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* --- Input Section --- */
.input-group {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.field {
  flex: 1;
  min-width: 200px;
}

.field label {
  display: block;
  font-size: .85rem;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="date"],
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .2s;
}

input[type="date"]:focus,
input[type="number"]:focus {
  border-color: var(--blue);
}

select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .2s;
}

select:focus {
  border-color: var(--blue);
}

/* Radio grid — compact buttons in a row */
.radio-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-option {
  position: relative;
  flex: 1 1 auto;
  min-width: 140px;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-option label {
  display: block;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .82rem;
  transition: all .2s;
  margin-bottom: 0 !important;
  text-align: center;
  white-space: nowrap;
}

.radio-option input[type="radio"]:checked + label {
  border-color: var(--blue);
  background: rgba(52,152,219,.08);
  color: var(--blue);
  font-weight: 600;
}


.gender-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gender-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 140px;
  height: 36px;
  background: #ecf0f1;
  border-radius: 18px;
  padding: 3px;
  cursor: pointer;
  transition: background .25s;
}

.toggle-thumb {
  position: absolute;
  left: 3px;
  width: calc(50% - 6px);
  height: 100%;
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: transform .25s ease;
}

.toggle-labels {
  display: flex;
  width: 100%;
  justify-content: space-between;
  padding: 0 16px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-light);
  pointer-events: none;
  z-index: 1;
}

.toggle-labels span:first-child {
  color: var(--blue);
}

.toggle-labels span:last-child {
  color: var(--red);
}

.gender-toggle input#male:checked ~ .toggle-track {
  background: rgba(52,152,219,.15);
}

.gender-toggle input#female:checked ~ .toggle-track {
  background: rgba(231,76,60,.12);
}

.gender-toggle input#female:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(74px);
}

.bmi-display {
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecf0f1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-light);
}

.bmi-display.normal { background: rgba(39,174,96,.12); color: var(--green); }
.bmi-display.overweight { background: rgba(243,156,18,.12); color: var(--orange); }
.bmi-display.obese { background: rgba(231,76,60,.12); color: var(--red); }

/* --- Stats Section --- */
.progress-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 700px;
  margin: 0 auto 16px;
}

.progress-bar-bg {
  width: 100%;
  height: 48px;
  background: #ecf0f1;
  border-radius: 24px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), #5dade2);
  border-radius: 24px;
  transition: width .6s ease;
}

.progress-bar-fill.danger {
  background: linear-gradient(90deg, var(--red), #f1948a);
}

.progress-label {
  text-align: center;
  font-size: .9rem;
  color: var(--text-light);
  margin-top: 6px;
  font-weight: 600;
}

.timers-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  width: 100%;
  max-width: 700px;
  margin: 0 auto 16px;
}

.timer-block {
  flex: 1;
  text-align: center;
  padding: 14px 12px;
  border-radius: 10px;
}

.timer-block.lived {
  background: rgba(52,152,219,.07);
}

.timer-block.remaining {
  background: rgba(39,174,96,.07);
}

.timer-block.expired {
  background: rgba(231,76,60,.08);
}

.timer-label {
  font-size: .75rem;
  color: var(--text-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.timer-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.timer-block.expired .timer-value {
  color: var(--red);
}

/* --- Habits Section --- */
.habits-columns {
  display: flex;
  gap: 24px;
}

.habit-column {
  flex: 1;
}

.habit-column h2 {
  font-size: 1.05rem;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

.habit-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.habit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .2s;
  position: relative;
}

.habit-item:hover {
  background: #f7f9fc;
}

.habit-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.habit-item label {
  font-size: .85rem;
  cursor: pointer;
  flex: 1;
  margin-bottom: 0 !important;
  line-height: 1.3;
}

.habit-item .badge {
  font-size: .72rem;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}

.badge.negative {
  background: rgba(231,76,60,.1);
  color: var(--red);
}

.badge.positive {
  background: rgba(39,174,96,.1);
  color: var(--green);
}

/* Tooltip */
.tooltip-trigger {
  cursor: help;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ecf0f1;
  color: var(--text-light);
  font-size: .65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 400;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  z-index: 100;
  line-height: 1.35;
  pointer-events: none;
}

.tooltip-trigger:hover::before,
.tooltip-trigger:focus::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
  pointer-events: none;
}

/* --- Summary --- */
.summary {
  text-align: center;
  padding: 12px;
  background: rgba(52,152,219,.05);
  border-radius: 8px;
  margin-bottom: 14px;
}

.summary-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue);
}

.summary-label {
  font-size: .82rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* --- Buttons --- */
.btn-reset {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}

.btn-reset:hover {
  opacity: .85;
}

/* --- Error --- */
.error-msg {
  color: var(--red);
  font-size: .85rem;
  margin-top: 6px;
  display: none;
}

.error-msg.visible {
  display: block;
}

/* --- Responsive --- */
@media (max-width: 700px) {
  h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  .timer-value { font-size: 1.1rem; }
  .timers-row { flex-direction: column; max-width: 300px; margin-left: auto; margin-right: auto; }
  .habits-columns { flex-direction: column; gap: 20px; }
  .input-group { flex-wrap: wrap; }
  .field { min-width: unset; flex: 1 1 calc(50% - 8px); }
  .field:nth-child(3) { flex: 1 1 100%; }
}
