:root {
  --bg: #8f8f8f;
  --panel: #151515;
  --panel-2: #222323;
  --text: #f7f7ec;
  --muted: #b5b8ad;
  --line: #343634;
  --accent: #d8ff37;
  --accent-2: #49f1b2;
  --accent-3: #bc7cff;
  --danger: #ff5577;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.28);
}

body.theme-dark {
  --bg: #0c111d;
  --panel: #141b2b;
  --panel-2: #101624;
  --text: #f5f7fb;
  --muted: #9ca8bd;
  --line: #273349;
  --accent: #60a5fa;
  --accent-2: #34d399;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

body.theme-light {
  --bg: #f9fafb;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --accent-2: #047857;
}

body.theme-synthwave {
  --bg: #090616;
  --panel: #15102a;
  --panel-2: #21133f;
  --text: #fff7ff;
  --muted: #c6a7ff;
  --line: #44306e;
  --accent: #ff2bd6;
  --accent-2: #19f9ff;
  --shadow: 0 18px 70px rgba(255, 43, 214, 0.18);
}

body.theme-coffee {
  --bg: #f1eadc;
  --panel: #fffaf0;
  --panel-2: #e8dec6;
  --text: #2f2a1f;
  --muted: #756b58;
  --line: #d8c9ad;
  --accent: #5f8f52;
  --accent-2: #9b6b43;
  --shadow: 0 18px 60px rgba(68, 49, 28, 0.14);
}

body.theme-vintage {
  --bg: #ebe3d0;
  --panel: #fbf4df;
  --panel-2: #ded1b2;
  --text: #30291f;
  --muted: #6f6049;
  --line: #c6b58f;
  --accent: #9a3412;
  --accent-2: #315c4c;
  --shadow: 0 18px 60px rgba(60, 42, 22, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

body:not(.authenticated) #appShell {
  display: none !important;
}

body.authenticated #loginScreen {
  display: none !important;
}

body.authenticated.admin #accountsNav {
  display: block !important;
}

body.authenticated:not(.admin) #accountsNav,
body.authenticated:not(.admin) #accountAdminPanel {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 20%, rgba(216, 255, 55, 0.18), transparent 28%),
    var(--bg);
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid #0b0b0b;
  border-radius: 8px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(216, 255, 55, 0.12), transparent 36%),
    #111;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 0.95;
  margin-bottom: 8px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px;
  gap: 18px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  border: 1px solid #0b0b0b;
  border-radius: 8px;
  background: linear-gradient(180deg, #1d1d1d, #101111);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand-block,
.topbar,
.panel-heading,
.button-row,
.top-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 850;
  color: #fff;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #d8ff37;
  color: #111;
  letter-spacing: 0;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.avatar.roman {
  background: #7c3aed;
}

.avatar.karuna {
  background: #059669;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.15rem;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

h3 {
  font-size: 1.05rem;
}

.profile-switcher,
.nav-tabs {
  display: grid;
  gap: 10px;
}

.profile-card,
.nav-tab,
.ghost-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: #242625;
}

.profile-card small,
.metric-card small,
.muted {
  color: var(--muted);
}

.profile-card.active,
.nav-tab.active {
  border-color: var(--accent);
  background: #303421;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent);
}

.nav-tab {
  padding: 11px 12px;
  text-align: left;
  font-weight: 760;
  background: #1f2020;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.field.compact {
  margin-top: auto;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.main-panel {
  min-width: 0;
  padding: 0;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.top-actions,
.button-row {
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  padding: 10px 14px;
  font-weight: 820;
}

.primary-button {
  border: 0;
  color: #111;
  background: var(--accent);
}

.ghost-button {
  background: #242625;
}

.danger-button {
  border: 1px solid rgba(255, 85, 119, 0.55);
  background: rgba(255, 85, 119, 0.10);
  color: var(--danger);
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid,
.daily-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.daily-stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0 0;
}

.person-hero {
  margin-bottom: 16px;
  border: 1px solid #0b0b0b;
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(216, 255, 55, 0.14), transparent 38%),
    linear-gradient(315deg, rgba(188, 124, 255, 0.14), transparent 42%),
    #111;
  box-shadow: var(--shadow);
}

.person-hero > h2 {
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.95;
}

.overage-alert {
  margin-top: 14px;
  border: 1px solid rgba(255, 85, 119, 0.55);
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffe9ee;
  background:
    linear-gradient(90deg, rgba(255, 85, 119, 0.28), rgba(188, 124, 255, 0.16)),
    #26161b;
}

.overage-alert strong {
  display: block;
  margin-bottom: 2px;
  color: #fff;
  font-size: 1.02rem;
}

.ollama-notice {
  margin-bottom: 14px;
  border: 1px solid rgba(216, 255, 55, 0.42);
  border-radius: 8px;
  padding: 12px 14px;
  color: #eef5df;
  background:
    linear-gradient(90deg, rgba(216, 255, 55, 0.16), rgba(73, 241, 178, 0.10)),
    #1d2116;
}

.metric-card,
.panel,
.exercise-card,
.routine-item,
.meal-row,
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  box-shadow: none;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 780;
}

.metric-card strong {
  font-size: clamp(1.45rem, 3vw, 2.3rem);
}

.daily-stat {
  box-shadow: none;
  min-height: 176px;
  align-content: center;
  border: 0;
  color: #111;
}

.daily-stat strong {
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1;
}

.daily-stat span,
.daily-stat small {
  color: rgba(17, 17, 17, 0.72);
}

.calorie-stat {
  background:
    radial-gradient(circle at 86% 18%, rgba(17, 17, 17, 0.16), transparent 24%),
    var(--accent);
}

.protein-stat {
  background:
    radial-gradient(circle at 84% 22%, rgba(17, 17, 17, 0.16), transparent 26%),
    var(--accent-2);
}

.inline-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 8px;
}

.dashboard-grid,
.nutrition-grid,
.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.nutrition-grid {
  grid-template-columns: minmax(240px, 0.65fr) minmax(320px, 1fr) minmax(260px, 0.8fr);
}

.panel {
  min-width: 0;
  padding: 16px;
  box-shadow: var(--shadow);
  background: #151615;
  border-color: #070707;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.coverage-list,
.timeline,
.exercise-list,
.routine-list,
.meal-log,
.file-grid,
.scheduled-list,
.common-meals {
  display: grid;
  gap: 10px;
}

.coverage-row {
  display: grid;
  grid-template-columns: 120px 1fr 44px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.25fr) minmax(300px, 0.75fr);
  gap: 16px;
}

.filter-row,
.meal-form,
.two-col,
.three-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.search-field,
.meal-form .full {
  grid-column: 1 / -1;
}

.exercise-list {
  max-height: 64vh;
  overflow: auto;
  padding-right: 4px;
}

.exercise-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(216, 255, 55, 0.10), transparent 44%),
    #202220;
}

.exercise-card p,
.routine-item p,
.timeline-item p,
.meal-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: #252625;
  font-size: 0.74rem;
  font-weight: 750;
}

.routine-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #202220;
}

.account-card {
  gap: 14px;
}

.account-card .button-row {
  justify-content: flex-start;
}

.account-form {
  margin-top: 0;
}

.tight-heading {
  margin: 24px 0 12px;
}

.scheduled-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(188, 124, 255, 0.28), transparent 42%),
    #222323;
}

.scheduled-card strong {
  font-size: 1.08rem;
}

.check-button {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-weight: 900;
}

.check-button.done {
  border-color: #41e67d;
  background: #41e67d;
  color: #111;
}

.edit-workout {
  min-height: 34px;
  padding: 8px 10px;
}

.routine-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.routine-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: end;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--danger);
  font-weight: 900;
}

.timeline-item,
.meal-row,
.common-meal-card {
  padding: 12px;
  background: #202220;
}

.meal-row,
.common-meal-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.common-meal-card {
  align-items: center;
}

.coach-output {
  min-height: 360px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.file-grid a,
.file-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  text-decoration: none;
  background: #202220;
}

.compact-list {
  max-height: 420px;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 40px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }

  .sidebar {
    position: relative;
    height: auto;
    top: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }

  .main-panel {
    padding: 16px;
  }

  .profile-switcher,
  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field.compact {
    margin-top: 0;
  }

  .metric-grid,
  .daily-stat-grid,
  .dashboard-grid,
  .nutrition-grid,
  .assistant-layout,
  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-panel,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .meal-row,
  .routine-top {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions > *,
  .button-row > * {
    flex: 1 1 140px;
  }

  .profile-switcher,
  .nav-tabs,
  .filter-row,
  .meal-form,
  .two-col,
  .three-col,
  .routine-controls,
  .inline-edit,
  .daily-stat-grid {
    grid-template-columns: 1fr;
  }

  .scheduled-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .scheduled-card .edit-workout {
    grid-column: 1 / -1;
  }

  .coverage-row {
    grid-template-columns: 86px 1fr 38px;
  }
}
