/* FitTrack — zero external CSS deps. Mobile-first, dark sleek UI. */

:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-card: #161e29;
  --border: #243041;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --accent: #3dd6c6;
  --accent-dim: #2a9d8f;
  --warn: #f4a261;
  --danger: #e76f51;
  --ok: #6bcb77;
  --purple: #9b8cff;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  --nav-h: 64px;
  --max: 920px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2740 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #132a28 0%, transparent 50%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--nav-h) + 1.5rem);
}

/* Top brand bar (desktop) / compact header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid;
  place-items: center;
  color: #041016;
  font-size: 0.95rem;
  font-weight: 800;
}

.brand span {
  font-size: 1.1rem;
}

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

.small {
  font-size: 0.85rem;
}

/* Cards */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 40%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
}

.card h2,
.card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

@media (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Stat chips */
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

.stat .label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.stat .value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat .sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.delta-pos {
  color: var(--ok);
}
.delta-neg {
  color: var(--warn);
}

/* Forms */
label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.75rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(61, 214, 198, 0.15);
}

/* Large touch targets for phone */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  font-weight: 650;
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.05s ease, opacity 0.15s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #041016;
  width: 100%;
}

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

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  min-height: 36px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.flash {
  background: rgba(61, 214, 198, 0.12);
  border: 1px solid rgba(61, 214, 198, 0.35);
  color: var(--accent);
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
}

.flash-error {
  background: rgba(231, 111, 81, 0.12);
  border-color: rgba(231, 111, 81, 0.4);
  color: #ffb4a2;
}

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

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

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

.list .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Forecast horizon chips */
.horizons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  min-height: 40px;
}

.chip.active {
  background: rgba(61, 214, 198, 0.15);
  border-color: var(--accent-dim);
  color: var(--accent);
  font-weight: 650;
}

.forecast-grid .stat .value {
  font-size: 1.2rem;
}

/* Simple SVG chart container */
.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.disclaimer {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* Bottom navigation — primary mobile UX */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 50;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.bottom-nav a.active {
  color: var(--accent);
}

.bottom-nav .ico {
  font-size: 1.15rem;
  line-height: 1;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(400px, 100%);
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}

/* Desktop: slightly larger type, show side padding */
@media (min-width: 768px) {
  .app-shell {
    padding-top: 1.5rem;
    padding-bottom: calc(var(--nav-h) + 2rem);
  }
  .stat .value {
    font-size: 1.5rem;
  }
}

/* Hide number spinners on some browsers for cleaner phone UX */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.25rem 0 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
}

.tab.active {
  color: var(--text);
  border-color: var(--accent-dim);
  background: rgba(61, 214, 198, 0.1);
}

.hidden {
  display: none !important;
}

/* Ingredient adder on Log page */
.ingredient-builder {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 1rem;
}

.ing-row {
  display: grid;
  grid-template-columns: 1fr 100px auto;
  gap: 0.45rem;
  align-items: start;
}

.ing-row input {
  margin-bottom: 0.35rem;
}

@media (max-width: 520px) {
  .ing-row {
    grid-template-columns: 1fr;
  }
  .ing-row .btn {
    width: 100%;
  }
}

#ing-sum-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
}

/* Split date + time (mobile-friendly; datetime-local hour editing is flaky on phones) */
.dt-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dt-row input {
  margin-bottom: 0;
  min-height: 48px;
}

/* Visually hidden but available to screen readers / labels */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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