:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f1f0f8;
  background: #101218;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --page: #101218;
  --panel: #171920;
  --panel-raised: #1c1e28;
  --line: #292b36;
  --muted: #898b9c;
  --soft: #b6b6c4;
  --purple: #a397ff;
  --purple-strong: #8174f7;
  --mint: #73d8b2;
  --orange: #f0ad79;
  --pink: #e89fc5;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 70% -30%, rgba(114, 97, 226, .12), transparent 46%),
    var(--page);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: 238px;
  height: 100vh;
  padding: 31px 18px 22px;
  border-right: 1px solid #252631;
  background: rgba(18, 19, 26, .88);
}
.brand, .mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f5f3ff;
  font: 800 24px/1 system-ui, sans-serif;
  letter-spacing: -1.6px;
  text-decoration: none;
}
.brand { padding: 0 9px; }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #a397ff, #7061e7);
  box-shadow: 0 6px 22px #7667e438;
  color: white;
  font: 800 24px/1 system-ui, sans-serif;
  letter-spacing: -2px;
}
.brand-period, .heading-dot { color: var(--purple); }
.sidebar-caption {
  margin: 47px 11px 12px;
  color: #666877;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.65px;
}
.nav-list { display: grid; gap: 5px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 45px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #9293a1;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  transition: background .18s ease, color .18s ease;
}
.nav-link:hover { background: #1f202a; color: #e8e5ff; }
.nav-link.is-active {
  background: #29263d;
  color: #c4bbff;
  box-shadow: inset 2px 0 #9c8fff;
}
.nav-icon { width: 17px; color: var(--purple); font-size: 17px; text-align: center; }
.sidebar-note {
  margin: auto 3px 20px;
  padding: 17px 15px;
  border: 1px solid #302d46;
  border-radius: 15px;
  background: linear-gradient(145deg, #201e30, #1a1b24);
}
.note-spark { color: #c1b6ff; font-size: 17px; }
.sidebar-note p { margin: 9px 0 0; color: #a7a5b8; font-size: 11px; line-height: 1.8; }
.sidebar-note strong { color: #eeeaff; font-weight: 600; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 0 8px; color: #777987; font-size: 10px; }
.connection-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #8d8e9b; }
.connection-dot[data-status="connected"] { background: #6ed6a9; box-shadow: 0 0 10px #6ed6a955; }
.connection-dot[data-status="error"] { background: #eb817e; }
.connection-dot[data-status="pending"] { background: #d3b86f; }

.workspace { min-height: 100vh; margin-left: 238px; }
.topbar {
  display: flex;
  height: 68px;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  padding: 0 clamp(24px, 5vw, 68px);
  border-bottom: 1px solid #22242d;
}
.mobile-brand { display: none; }
.topbar-date { margin-right: auto; color: #9697a5; font-size: 11px; }
.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid #2c2d37;
  border-radius: 20px;
  background: #171920;
  color: #a8a9b5;
  font-size: 10px;
}
.main-content { width: min(1120px, 100%); margin: 0 auto; padding: 46px clamp(24px, 5vw, 68px) 48px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 29px; }
.eyebrow { margin: 0 0 9px; color: #9290ad; font-size: 9px; font-weight: 700; letter-spacing: 1.6px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
h1 { margin-bottom: 8px; color: #f1eff9; font-size: clamp(26px, 3vw, 34px); font-weight: 700; letter-spacing: -1.45px; line-height: 1.2; }
.heading-subtitle { margin: 0; color: #90919f; font-size: 12px; }
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: progress; opacity: .7; }
.button-primary { background: linear-gradient(120deg, #8b7cf2, #7468e2); box-shadow: 0 6px 20px #7869e32c; color: white; }
.button-primary:hover:not(:disabled) { background: linear-gradient(120deg, #998cfb, #8276ed); }
.button-quiet { border-color: var(--line); background: transparent; color: #b8b8c5; }
.button-quiet:hover { background: #20212b; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card {
  min-height: 130px;
  padding: 17px 17px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, #1a1b23, #16171d);
}
.metric-top { display: flex; align-items: center; justify-content: space-between; }
.metric-label { color: #a4a4b1; font-size: 10px; font-weight: 600; }
.metric-icon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 9px; background: #25232f; color: var(--purple); font-size: 16px; }
.metric-food .metric-icon, .metric-food .metric-value { color: var(--mint); }
.metric-workout .metric-icon, .metric-workout .metric-value { color: var(--orange); }
.metric-protein .metric-icon, .metric-protein .metric-value { color: var(--pink); }
.metric-entries .metric-icon { color: #a9a0ff; }
.metric-value { margin: 12px 0 8px; color: #eeeefa; font: 700 25px/1 system-ui, sans-serif; letter-spacing: -.8px; }
.metric-value small { margin-left: 5px; color: #8c8d9b; font: 500 10px system-ui, sans-serif; letter-spacing: 0; }
.metric-foot { display: flex; align-items: center; gap: 6px; margin: 0; color: #777987; font-size: 9px; }
.metric-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.metric-food .metric-dot { color: var(--mint); }
.metric-workout .metric-dot { color: var(--orange); }
.metric-protein .metric-dot { color: var(--pink); }
.metric-entries .metric-dot { color: var(--purple); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 14px; margin-top: 17px; }
.panel { border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, #191a22, #16171d); }
.trend-panel, .recent-panel { min-height: 303px; padding: 21px 21px 17px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.panel-heading h2, .form-intro h2, .tip-panel h2 { margin: 0; color: #eeedf6; font-size: 16px; font-weight: 650; letter-spacing: -.4px; }
.chart-key { display: flex; align-items: center; gap: 6px; color: #9293a0; font-size: 9px; }
.chart-key i { width: 7px; height: 7px; border-radius: 2px; background: #a195ff; }
.week-chart { display: flex; height: 190px; justify-content: space-around; gap: 8px; padding: 19px 2px 0; }
.chart-column { display: flex; width: min(42px, 13%); flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; }
.chart-value { min-height: 12px; color: #777987; font-size: 8px; white-space: nowrap; }
.chart-track { display: flex; width: 100%; height: 130px; align-items: flex-end; justify-content: center; overflow: hidden; border-radius: 7px 7px 2px 2px; background: #20212a; }
.chart-bar { width: 100%; min-height: 3px; border-radius: 6px 6px 2px 2px; background: linear-gradient(0deg, #7468d8, #aaa0ff); opacity: .7; transition: height .25s ease; }
.chart-bar.is-today { opacity: 1; }
.chart-day { color: #898a98; font-size: 9px; }
.chart-caption { margin: 10px 0 0; color: #777987; font-size: 9px; }
.text-button { padding: 4px; border: 0; background: transparent; color: #b5aaff; cursor: pointer; font-size: 10px; font-weight: 600; }
.text-button:hover { color: #d3ccff; }

.entry-list { display: grid; }
.compact-list { margin-top: 11px; }
.entry-row { display: flex; min-width: 0; align-items: center; gap: 13px; padding: 15px 3px; border-bottom: 1px solid #282932; }
.entry-row:last-child { border-bottom: 0; }
.entry-type-icon { display: grid; width: 39px; height: 39px; flex: none; place-items: center; border: 1px solid #32313f; border-radius: 12px; background: #25232f; color: #b1a7ff; font-size: 18px; }
.entry-type-icon.workout { border-color: #3a302b; background: #29231f; color: #eab28a; }
.entry-main { min-width: 0; flex: 1; }
.entry-main h3 { overflow: hidden; margin: 0 0 4px; color: #e2e1eb; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.entry-detail { overflow: hidden; margin: 0 0 4px; color: #aaaab7; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { margin: 0; color: #777987; font-size: 9px; }
.entry-meta span { margin: 0 3px; color: #555765; }
.entry-side { display: flex; flex: none; align-items: center; gap: 10px; }
.entry-amount { margin: 0; color: #b6afff; font-size: 11px; font-weight: 700; white-space: nowrap; }
.entry-amount small { color: #858694; font-size: 8px; font-weight: 500; }
.entry-actions { display: flex; gap: 3px; }
.icon-button { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #858694; cursor: pointer; font-size: 16px; }
.icon-button:hover { border-color: #363746; background: #22232d; color: #d7d4ee; }
.icon-button.delete-button:hover { color: #ef918f; }
.empty-state { display: grid; min-height: 170px; align-content: center; justify-items: center; text-align: center; }
.empty-state > span { color: #9c90fa; font-size: 21px; }
.empty-state p { margin: 10px 0; color: #999aa8; font-size: 11px; }
.empty-state .text-button { margin-top: 2px; }
.data-note { margin: 16px 3px 0; color: #666875; font-size: 9px; line-height: 1.7; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; align-items: start; gap: 15px; }
.log-panel { padding: 20px; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border: 1px solid #2a2b35; border-radius: 11px; background: #13141a; }
.type-tab { min-height: 37px; border: 0; border-radius: 8px; background: transparent; color: #9697a4; cursor: pointer; font-size: 11px; font-weight: 600; }
.type-tab span { margin-right: 6px; font-size: 15px; }
.type-tab.is-selected { background: #2a273c; color: #c3baff; box-shadow: inset 0 0 0 1px #46405f; }
.form-intro { margin: 25px 0 19px; }
.form-intro h2 { font-size: 17px; }
.form-intro p { margin: 5px 0 0; color: #888a98; font-size: 10px; }
.form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 13px; }
.field { display: grid; min-width: 0; gap: 7px; color: #b9b8c5; font-size: 10px; font-weight: 600; }
.field-wide { grid-column: 1 / -1; }
.field small { color: #777987; font-size: 9px; font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px 11px;
  border: 1px solid #30313b;
  border-radius: 9px;
  background: #13141a;
  color: #e8e7f0;
  font-size: 11px;
}
.field input::placeholder, .field textarea::placeholder { color: #656775; }
.field select { color-scheme: dark; }
.field textarea { resize: vertical; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 19px; padding-top: 15px; border-top: 1px solid #292a34; }
.form-message { margin: 0; color: #777987; font-size: 9px; }
.form-actions { display: flex; gap: 8px; }
.tip-panel { padding: 20px; }
.tip-icon { display: grid; width: 31px; height: 31px; place-items: center; margin-bottom: 20px; border-radius: 10px; background: #2a273c; color: #b7adff; font-size: 15px; }
.tip-panel .eyebrow { margin-bottom: 7px; font-size: 8px; }
.tip-panel h2 { margin-bottom: 10px; font-size: 16px; }
.tip-panel > p:last-child { margin: 0; color: #8e8f9d; font-size: 10px; line-height: 1.8; }
.activity-panel { padding: 20px 22px; }
.activity-heading { padding-bottom: 15px; border-bottom: 1px solid #292a34; }
.filter-group { display: flex; gap: 4px; padding: 3px; border: 1px solid #2b2c36; border-radius: 9px; background: #13141a; }
.filter-button { padding: 7px 11px; border: 0; border-radius: 6px; background: transparent; color: #9293a1; cursor: pointer; font-size: 9px; }
.filter-button.is-selected { background: #2b283d; color: #c5bcff; }
.activity-panel .entry-row { padding: 17px 4px; }
.toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 17px;
  transform: translateY(12px);
  border: 1px solid #45415d;
  border-radius: 11px;
  background: #242233;
  color: #efedff;
  box-shadow: 0 10px 35px #0005;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { border-color: #704547; background: #302124; color: #ffd1d0; }
.mobile-nav { display: none; }

@media (min-width: 1500px) {
  .main-content { padding-top: 57px; }
  .metric-card { min-height: 142px; padding: 19px; }
}

@media (max-width: 1050px) {
  .sidebar { width: 205px; }
  .workspace { margin-left: 205px; }
  .overview-grid { grid-template-columns: 1fr; }
  .trend-panel, .recent-panel { min-height: auto; }
  .form-layout { grid-template-columns: minmax(0, 1fr) 220px; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .topbar { height: 60px; justify-content: space-between; padding: 0 20px; }
  .mobile-brand { display: flex; font-size: 21px; }
  .mobile-brand .brand-mark { width: 29px; height: 29px; border-radius: 10px; font-size: 21px; }
  .topbar-date { margin: 0 0 0 auto; font-size: 9px; }
  .connection-pill { padding: 7px 9px; }
  .connection-pill .connection-dot { width: 6px; height: 6px; }
  #connection-label { font-size: 9px; }
  .main-content { padding: 32px 20px 100px; }
  .page-heading { align-items: flex-start; margin-bottom: 23px; }
  .heading-action { min-height: 36px; padding: 0 11px; font-size: 10px; }
  .heading-subtitle { max-width: 480px; line-height: 1.6; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { min-height: 116px; padding: 14px; }
  .metric-value { font-size: 23px; }
  .overview-grid { gap: 11px; margin-top: 12px; }
  .trend-panel, .recent-panel { padding: 17px 15px; }
  .week-chart { height: 170px; padding-top: 14px; }
  .chart-track { height: 112px; }
  .form-layout { grid-template-columns: 1fr; }
  .tip-panel { display: grid; grid-template-columns: 37px 1fr; column-gap: 10px; padding: 16px; }
  .tip-icon { grid-row: span 2; margin: 0; }
  .tip-panel .eyebrow { align-self: end; }
  .tip-panel h2 { grid-column: 2; }
  .tip-panel > p:last-child { grid-column: 1 / -1; margin-top: 10px; }
  .activity-panel { padding: 16px; }
  .entry-row { gap: 9px; }
  .entry-side { gap: 4px; }
  .mobile-nav {
    position: fixed;
    z-index: 5;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 7px;
    border: 1px solid #34333f;
    border-radius: 15px;
    background: rgba(25, 25, 34, .94);
    box-shadow: 0 10px 34px #0006;
    backdrop-filter: blur(18px);
  }
  .mobile-nav .nav-link { min-height: 48px; flex-direction: column; justify-content: center; gap: 1px; padding: 4px; border-radius: 10px; font-size: 8px; text-align: center; }
  .mobile-nav .nav-icon { width: auto; font-size: 16px; line-height: 1.2; }
  .mobile-nav .nav-link.is-active { box-shadow: none; }
  .toast { right: 16px; bottom: 84px; left: 16px; max-width: none; }
}

@media (max-width: 430px) {
  .topbar { gap: 8px; padding: 0 14px; }
  .mobile-brand { gap: 7px; font-size: 19px; }
  .topbar-date { font-size: 8px; }
  .main-content { padding-right: 14px; padding-left: 14px; }
  .page-heading { gap: 8px; }
  h1 { font-size: 25px; }
  .heading-subtitle { font-size: 10px; }
  .heading-action { min-width: 37px; gap: 3px; font-size: 0; }
  .heading-action span { font-size: 17px; }
  .metric-card { min-height: 108px; padding: 12px; }
  .metric-label { font-size: 9px; }
  .metric-value { font-size: 21px; }
  .metric-foot { font-size: 8px; }
  .panel-heading h2 { font-size: 14px; }
  .chart-key { font-size: 8px; }
  .entry-type-icon { width: 33px; height: 33px; border-radius: 10px; font-size: 16px; }
  .entry-main h3 { max-width: 160px; font-size: 10px; }
  .entry-detail, .entry-meta { font-size: 8px; }
  .entry-amount { font-size: 9px; }
  .entry-amount small { font-size: 7px; }
  .icon-button { width: 25px; height: 26px; font-size: 14px; }
  .activity-heading { align-items: flex-start; flex-direction: column; }
  .filter-button { padding: 6px 12px; }
  .log-panel { padding: 15px; }
  .form-fields { gap: 12px 9px; }
  .field input, .field select { min-height: 39px; }
  .form-footer { align-items: flex-start; flex-direction: column; }
  .form-actions { width: 100%; justify-content: flex-end; }
  .form-message { line-height: 1.5; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
