/* Macro & Workout Tracker — dark, modern, simple */

:root {
  --bg: #0f1117;
  --bg-card: #181b24;
  --bg-input: #22262f;
  --border: #2a2f3a;
  --text: #e8eaef;
  --text-muted: #8b92a8;
  --accent: #5b8cff;
  --accent-hover: #7aa3ff;
  --success: #3ecf8e;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Header */
.header {
  margin-bottom: 1.5rem;
}

.title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  min-width: 5.5rem;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tab-btn.active {
  background: var(--bg-input);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

/* Panels */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-inline .card-title {
  margin: 0;
}

.card-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.card-hint {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Dashboard macro grid */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 500px) {
  .macro-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.macro-stat {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.macro-stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.macro-stat .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}

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

.big-number {
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
  color: var(--success);
}

/* Dashboard: latest bodyweight */
.bw-dash {
  margin: 0;
}

.bw-dash-value {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.bw-dash-value #dash-bw-unit {
  margin-left: 0.35rem;
}

.bw-dash-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.bw-dash-date {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Dashboard: weekly stats */
.week-stats {
  margin: 0;
}

.week-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.week-stat-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.week-stat-row:first-of-type {
  padding-top: 0;
}

.week-stat-row dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.week-stat-row dd {
  margin: 0;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.recent-workout .workout-block {
  font-size: 0.9rem;
}

.recent-workout .workout-meta {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.empty-msg {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-msg.subtle {
  font-size: 0.85rem;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.25);
}

.divider {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

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

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

.btn.secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  border-color: var(--text-muted);
}

/* Pending exercises */
.pending-exercises {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px dashed var(--border);
}

.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mini-list li {
  font-size: 0.85rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.mini-list li:last-child {
  border-bottom: none;
}

.mini-list button.remove {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}

.mini-list button.remove:hover {
  color: #f87171;
  border-color: #f87171;
}

/* Macro current summary */
.macro-current .line {
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.macro-calories-live {
  margin-top: 0.25rem;
}

.macro-calories-preview {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.macro-cal-formula {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* History lists */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-list > li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.6rem;
  background: var(--bg-input);
}

.history-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.btn-delete-history {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.btn-delete-history:hover {
  color: #f87171;
  border-color: #f87171;
}

.history-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.btn-edit-history {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.btn-edit-history:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.history-list .date-tag {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

/* Inside the flex row, date should not add extra bottom gap */
.history-list .history-item-head .date-tag {
  margin-bottom: 0;
}

.history-list .macro-line,
.history-list .ex-line {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.15rem 0;
}

.workout-history .type-tag {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}
