/* smartagent.fit — dark fitness-tech theme */
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0b1220;
  --bg-soft: #101a2e;
  --card: #141f33;
  --card-2: #1a2740;
  --border: #24334f;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --grad: linear-gradient(135deg, #34d399, #22d3ee);
  --accent: #34d399;
  --accent-2: #22d3ee;
  --kcal: #fb7185;
  --danger: #f87171;
  --radius: 18px;
  --nav-h: 64px;
}

html { color-scheme: dark; }
body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kcal-accent { color: var(--kcal); }
.error { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
.ok { color: var(--accent); font-size: .9rem; }
.icon { width: 22px; height: 22px; }

/* ---------- buttons & inputs ---------- */
button {
  cursor: pointer; border: none; border-radius: 14px;
  padding: .7rem 1.1rem; font-size: .95rem; font-weight: 700;
  font-family: inherit; color: var(--text); background: var(--card-2);
  transition: transform .08s ease, filter .15s ease;
}
button:active { transform: scale(.97); }
.primary { background: var(--grad); color: #06281f; }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { background: var(--card-2); color: var(--muted); cursor: default; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.block { width: 100%; }
.small-btn { padding: .5rem .8rem; font-size: .85rem; display: inline-flex; align-items: center; gap: .4rem; }

input {
  padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 14px;
  font-size: 1rem; font-family: inherit; width: 100%;
  background: var(--bg-soft); color: var(--text); outline: none;
}
input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(34, 211, 238, .15); }
input::placeholder { color: #5a6b85; }

.input-suffix {
  display: flex; align-items: center; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; flex: 1;
}
.input-suffix input { border: none; background: transparent; box-shadow: none; }
.input-suffix span { padding: 0 .8rem; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.input-suffix:focus-within { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(34, 211, 238, .15); }
.input-suffix.slim { max-width: 130px; }

/* ---------- auth ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-glow {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(500px 300px at 15% 10%, rgba(52, 211, 153, .14), transparent 60%),
    radial-gradient(500px 320px at 85% 85%, rgba(34, 211, 238, .12), transparent 60%);
}
.auth-card {
  position: relative; background: var(--card); border: 1px solid var(--border);
  padding: 2.2rem 1.8rem; border-radius: 24px; width: 100%; max-width: 360px;
  text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.auth-logo { width: 64px; height: 64px; margin-bottom: .6rem; }
.auth-card h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.auth-card > .muted { margin-top: .4rem; font-size: .9rem; line-height: 1.45; }
.auth-card form { margin-top: 1.6rem; display: flex; flex-direction: column; gap: .55rem; text-align: left; }
.auth-card label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.auth-card form .primary { margin-top: .5rem; padding: .85rem; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; position: sticky; top: 0; z-index: 20;
  background: rgba(11, 18, 32, .85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; }
.brand-logo { width: 30px; height: 30px; }
.userbox { display: flex; align-items: center; gap: .6rem; }
.userbox .icon { width: 18px; height: 18px; }

/* ---------- main nav: bottom bar on mobile ---------- */
.mainnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(16, 26, 46, .92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: transparent; border-radius: 0; color: var(--muted);
  font-size: .68rem; font-weight: 700; padding: .4rem;
}
.tab.active { color: var(--accent); }
.tab.active .icon { filter: drop-shadow(0 0 6px rgba(52, 211, 153, .5)); }

/* ---------- layout ---------- */
main { max-width: 720px; margin: 0 auto; padding: 1rem; }
.tabpane { display: none; animation: fade .25s ease; }
.tabpane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem;
}
.card h2 { font-size: 1rem; font-weight: 800; margin: 1.1rem 0 .7rem; display: flex; align-items: center; gap: .5rem; }
.card h2:first-child { margin-top: 0; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 8px; font-size: .8rem;
  background: var(--grad); color: #06281f; flex: none;
}
.row { display: flex; align-items: center; gap: .6rem; margin: .6rem 0; flex-wrap: wrap; }

/* ---------- photo ---------- */
.photo-drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 160px; border: 2px dashed var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .2s; padding: 1rem; width: 100%;
}
.photo-drop:hover { border-color: var(--accent); }
.photo-hint { color: var(--muted); font-size: .95rem; line-height: 1.5; }
.photo-hint small { color: #5a6b85; }
.big-icon { width: 34px; height: 34px; display: block; margin: 0 auto .4rem; color: var(--accent); }
.preview { max-width: 100%; max-height: 300px; border-radius: 12px; }
#analyzeBtn { margin-top: 1rem; padding: .9rem; font-size: 1rem; }
.demo-note {
  margin-top: .7rem; font-size: .82rem; color: #fbbf24;
  background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .25);
  padding: .5rem .8rem; border-radius: 10px;
}

/* ---------- items ---------- */
.items-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .7rem; }
.item-row {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 14px; padding: .6rem;
}
.item-row > input:first-child { grid-column: 1 / -1; }
.item-nums { display: flex; gap: .5rem; align-items: center; flex: 1; }
.item-nums .input-suffix { max-width: 110px; }
.kcal-cell {
  display: flex; align-items: center; color: var(--kcal);
  font-weight: 800; font-size: .95rem; white-space: nowrap; padding: 0 .3rem;
}
.item-del { padding: .4rem .6rem; color: var(--muted); background: transparent; }
.item-del:hover { color: var(--danger); }
.total-row {
  display: flex; justify-content: flex-end; font-size: 1.05rem;
  padding: .8rem 0; border-top: 1px solid var(--border); margin-top: .4rem;
}

/* ---------- dashboard hero ---------- */
.hero-card { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.ring-wrap { position: relative; width: 150px; height: 150px; flex: none; margin: 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--card-2); stroke-width: 11; }
.ring-fg {
  fill: none; stroke-width: 11; stroke-linecap: round;
  stroke: var(--accent); stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .8s ease;
}
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-kcal { font-size: 2rem; font-weight: 800; color: var(--kcal); line-height: 1; }
.hero-side { flex: 1; min-width: 180px; }
.kcal-left { font-size: 1.25rem; font-weight: 800; }
.goal-edit { margin-top: .8rem; display: flex; align-items: center; gap: .6rem; }
.goal-edit label { white-space: nowrap; }

/* ---------- chart ---------- */
.chart { display: flex; align-items: flex-end; gap: .5rem; height: 150px; margin-top: .4rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; min-width: 0; }
.bar { width: 72%; max-width: 34px; background: var(--card-2); border-radius: 7px 7px 0 0; min-height: 4px; transition: height .5s ease; }
.bar.today { background: var(--grad); box-shadow: 0 0 14px rgba(52, 211, 153, .35); }
.bar-val { font-size: .68rem; color: var(--muted); margin-top: .3rem; }
.bar-label { font-size: .68rem; color: #5a6b85; }

/* ---------- meals & favorites ---------- */
.meal-row {
  display: flex; gap: .8rem; align-items: center; padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.meal-row:last-child { border-bottom: none; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; flex: none; }
.meal-main { flex: 1; min-width: 0; font-size: .92rem; }
.meal-main .muted.small { margin-top: .15rem; line-height: 1.4; }
.meal-actions { display: flex; gap: .35rem; flex: none; }
.meal-actions button { padding: .45rem .7rem; font-size: .8rem; }
.fav-form { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0; }
.fav-form input:first-child { flex: 1 1 140px; }

/* ---------- desktop ---------- */
@media (min-width: 720px) {
  body { padding-bottom: 0; }
  .mainnav {
    position: static; height: auto; padding: 0 1rem;
    background: transparent; backdrop-filter: none; border: none;
    max-width: 720px; margin: 1rem auto 0; gap: .5rem;
  }
  .tab {
    flex: none; flex-direction: row; gap: .5rem; font-size: .9rem;
    padding: .6rem 1.1rem; border-radius: 12px;
  }
  .tab.active { background: rgba(52, 211, 153, .12); }
  .tab .icon { width: 18px; height: 18px; }
}

/* ---------- notifications ---------- */
.bell { position: relative; padding: .5rem .6rem; }
.badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--kcal); color: #fff; font-size: .65rem; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(360px, 92vw); background: var(--bg-soft);
  border-left: 1px solid var(--border); padding: 1rem;
  overflow-y: auto; box-shadow: -12px 0 40px rgba(0, 0, 0, .4);
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.notif {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: .8rem .9rem; margin-bottom: .6rem;
}
.notif.unread { border-color: var(--accent); box-shadow: 0 0 12px rgba(52, 211, 153, .15); }
.notif b { display: block; margin-bottom: .1rem; }
.notif p { margin-top: .35rem; font-size: .9rem; line-height: 1.45; color: var(--text); }

/* ---------- register ---------- */
.reg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.reg-grid > div { display: flex; flex-direction: column; gap: .55rem; }
select {
  padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 14px;
  font-size: 1rem; font-family: inherit; width: 100%;
  background: var(--bg-soft); color: var(--text); outline: none;
}
select:focus { border-color: var(--accent-2); }
.switch-auth { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .4rem; }
.switch-auth a { color: var(--accent-2); text-decoration: none; font-weight: 700; }

/* ---------- admin ---------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem;
}
.stat-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 14px; padding: .9rem; text-align: center;
}
.stat-val {
  font-size: 1.5rem; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.broadcast-form { display: flex; flex-direction: column; gap: .6rem; }
textarea {
  padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 14px;
  font-size: 1rem; font-family: inherit; width: 100%; resize: vertical;
  background: var(--bg-soft); color: var(--text); outline: none;
}
textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(34, 211, 238, .15); }

.user-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 14px; padding: .9rem; margin-bottom: .7rem;
}
.user-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.admin-badge {
  background: var(--grad); color: #06281f; font-size: .68rem; font-weight: 800;
  padding: .15rem .5rem; border-radius: 8px;
}
.user-rows { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.user-rows > div { display: flex; gap: .6rem; font-size: .87rem; }
.user-rows span { color: var(--muted); min-width: 130px; flex: none; }
.ghost.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- weight tracking ---------- */
.reg-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.weight-row { display: flex; align-items: baseline; gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.weight-now { font-size: 2rem; font-weight: 800; }
.weight-now .muted { font-size: 1rem; font-weight: 400; }
#weightHistory { line-height: 1.8; }

/* ---------- profile ---------- */
.profile-form { display: flex; flex-direction: column; gap: .8rem; }
.profile-form label { display: block; margin-bottom: .35rem; }
