:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-2: #edf1eb;
  --ink: #13231d;
  --muted: #6c7872;
  --line: #dce3dd;
  --primary: #1d6a4d;
  --primary-dark: #102a22;
  --primary-soft: #dceee5;
  --accent: #b8e35f;
  --warning: #d99629;
  --danger: #b93b3b;
  --shadow: 0 18px 50px rgba(18, 42, 34, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 28px 20px 22px;
  background: var(--primary-dark);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 40px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 13px;
  background: var(--accent);
  color: var(--primary-dark);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 3.2;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: #aabdb5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 13px;
  color: #b9c8c1;
  font-size: 14px;
  font-weight: 700;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.nav-link span {
  width: 22px;
  color: #8fa59a;
  font-size: 19px;
  text-align: center;
}

.nav-link:hover {
  transform: translateX(2px);
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.nav-link.active {
  background: var(--accent);
  color: var(--primary-dark);
}

.nav-link.active span {
  color: var(--primary-dark);
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
}

.sidebar-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 15px;
}

.sidebar-card p:last-child {
  margin: 0;
  color: #aabdb5;
  font-size: 12px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 7px 0;
  color: #8fa59a;
  font-size: 11px;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(184, 227, 95, 0.11);
}

.main-wrap {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 104px;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(24px, 4vw, 58px);
  border-bottom: 1px solid rgba(220, 227, 221, 0.75);
  background: rgba(244, 246, 241, 0.92);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  margin: 1px 0 0;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.035em;
}

.topbar-actions,
.history-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-button {
  display: none;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

main {
  padding: 34px clamp(24px, 4vw, 58px) 70px;
}

.page-section {
  display: none;
  animation: fade-in 220ms ease;
}

.page-section.active {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  overflow: hidden;
  padding: clamp(28px, 5vw, 52px);
  border-radius: 28px;
  background:
    radial-gradient(circle at 82% 20%, rgba(184, 227, 95, 0.2), transparent 28%),
    linear-gradient(135deg, #102a22, #164934);
  color: white;
  box-shadow: var(--shadow);
}

.hero-card h2 {
  max-width: 680px;
  margin: 10px 0 12px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.04;
  letter-spacing: -0.048em;
}

.hero-card p:last-child {
  max-width: 650px;
  margin: 0;
  color: #b9cec4;
  font-size: 15px;
}

.hero-card .eyebrow {
  color: var(--accent);
}

.hero-ring {
  --progress: 0deg;
  display: grid;
  flex: 0 0 auto;
  width: 148px;
  height: 148px;
  place-items: center;
  border-radius: 999px;
  background: conic-gradient(var(--accent) var(--progress), rgba(255, 255, 255, 0.12) 0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.hero-ring::before {
  position: absolute;
  content: "";
}

.hero-ring > div {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  align-content: center;
  border-radius: inherit;
  background: #133528;
}

.hero-ring strong {
  font-size: 28px;
  line-height: 1;
}

.hero-ring span {
  margin-top: 5px;
  color: #a7beb3;
  font-size: 11px;
  font-weight: 700;
}

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

.metric-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(18, 42, 34, 0.035);
}

.metric-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
}

.metric-card p,
.metric-card span {
  color: var(--muted);
}

.metric-card p {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.metric-card span {
  display: block;
  margin-top: 5px;
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr);
  gap: 18px;
  margin-top: 18px;
}

.lower-grid {
  grid-template-columns: 1.25fr 0.75fr;
}

.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(18, 42, 34, 0.035);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-header h3 {
  margin: 5px 0 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.panel-header select,
.history-toolbar select {
  padding: 9px 32px 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.panel-number {
  color: var(--primary);
  font-size: 22px;
}

.chart-wrap {
  position: relative;
  min-height: 310px;
}

#weightChart {
  display: block;
  width: 100%;
  height: 310px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.score-list {
  display: grid;
  gap: 10px;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.score-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-row strong {
  font-size: 13px;
}

.score-row .goal-met {
  color: var(--primary);
}

.text-link {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.day-cell {
  display: grid;
  min-width: 0;
  min-height: 82px;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.day-cell span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.day-cell strong {
  font-size: 13px;
}

.day-cell.completed {
  border-color: #9fcb80;
  background: var(--primary-soft);
  color: var(--primary);
}

.day-cell.today {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mini-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-metric-grid div {
  padding: 18px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
}

.mini-metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-metric-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 19px;
}

.section-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 26px;
}

.section-intro h2 {
  margin: 7px 0 8px;
  font-size: clamp(29px, 4vw, 43px);
  line-height: 1.06;
  letter-spacing: -0.045em;
}

.section-intro > div > p:last-child {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.date-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.check-in-form,
.settings-form {
  display: grid;
  gap: 18px;
}

.form-card {
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(18, 42, 34, 0.035);
}

.form-card-header {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 24px;
}

.section-number {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

.form-card-header h3 {
  margin: 1px 0 3px;
  font-size: 19px;
}

.form-card-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: #425149;
  font-size: 12px;
  font-weight: 800;
}

.full-width {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fbfcfa;
  color: var(--ink);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

input,
select {
  min-height: 46px;
  padding: 10px 13px;
}

textarea {
  min-height: 90px;
  padding: 13px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(29, 106, 77, 0.09);
}

.toggle-field {
  position: relative;
  display: flex !important;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfa;
}

.toggle-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle {
  position: relative;
  width: 43px;
  height: 24px;
  border-radius: 999px;
  background: #c8d0cb;
  transition: background 160ms ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  content: "";
  transition: transform 160ms ease;
}

.toggle-field input:checked + .toggle {
  background: var(--primary);
}

.toggle-field input:checked + .toggle::after {
  transform: translateX(19px);
}

.form-actions,
.data-actions,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 850;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-button {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 18px rgba(29, 106, 77, 0.18);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #175c42;
  box-shadow: 0 11px 24px rgba(29, 106, 77, 0.22);
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover {
  transform: translateY(-1px);
  border-color: #bdc9c1;
  background: #fbfcfa;
}

.danger-button {
  background: var(--danger);
  color: white;
}

.compact {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 12px;
}

.danger-card {
  border-color: #ead1d1;
}

.danger-card .section-number {
  background: #f5dfdf;
  color: var(--danger);
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.search-field {
  display: flex;
  max-width: 520px;
  flex: 1;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.search-field span {
  color: var(--muted);
}

.search-field input {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.history-list {
  display: grid;
  gap: 13px;
}

.history-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.history-date strong,
.history-date span {
  display: block;
}

.history-date strong {
  font-size: 16px;
}

.history-date span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-chip {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #4f5d56;
  font-size: 11px;
  font-weight: 750;
}

.history-chip.highlight {
  background: var(--primary-soft);
  color: var(--primary);
}

.history-note {
  width: 100%;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-card-actions {
  display: flex;
  gap: 7px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button:hover {
  background: var(--surface-2);
}

.icon-button.delete:hover {
  border-color: #e5b9b9;
  background: #fff1f1;
  color: var(--danger);
}

.empty-history {
  display: none;
  min-height: 330px;
  place-items: center;
  align-content: center;
  border: 1px dashed #cbd5cf;
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.empty-history > div {
  font-size: 34px;
}

.empty-history h3 {
  margin: 14px 0 5px;
  color: var(--ink);
}

.empty-history p {
  margin: 0 0 18px;
  font-size: 13px;
}

.file-button {
  cursor: pointer;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(390px, calc(100vw - 48px));
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--primary-dark);
  color: white;
  box-shadow: 0 18px 48px rgba(10, 29, 23, 0.24);
  font-size: 13px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 24, 19, 0.62);
  backdrop-filter: blur(5px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(480px, 100%);
  padding: 30px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
}

.modal h2 {
  margin: 7px 0 8px;
  letter-spacing: -0.035em;
}

.modal > p:last-of-type {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .today-panel {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 25px 0 70px rgba(0, 0, 0, 0.23);
  }

  .main-wrap {
    margin-left: 0;
  }

  .menu-button {
    display: grid;
    flex: 0 0 auto;
  }

  .topbar {
    min-height: 88px;
    gap: 14px;
    padding: 16px 20px;
  }

  .topbar > div:nth-child(2) {
    flex: 1;
  }

  .topbar-actions .secondary-button {
    display: none;
  }

  main {
    padding: 24px 18px 55px;
  }

  .hero-card {
    align-items: flex-start;
  }

  .hero-ring {
    width: 112px;
    height: 112px;
  }

  .hero-ring > div {
    width: 84px;
    height: 84px;
  }

  .hero-ring strong {
    font-size: 22px;
  }
}

@media (max-width: 620px) {
  .hero-card {
    display: grid;
    padding: 28px 24px;
  }

  .hero-ring {
    justify-self: start;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 14px;
  }

  .metric-icon {
    grid-row: 1 / 4;
    margin: 0;
  }

  .metric-card p,
  .metric-card strong,
  .metric-card span {
    grid-column: 2;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .full-width {
    grid-column: auto;
  }

  .section-intro {
    display: grid;
    align-items: start;
  }

  .history-actions {
    flex-wrap: wrap;
  }

  .history-toolbar {
    display: grid;
  }

  .search-field {
    max-width: none;
  }

  .history-card {
    grid-template-columns: 1fr auto;
    gap: 14px;
  }

  .history-summary {
    grid-column: 1 / -1;
  }

  .week-strip {
    gap: 6px;
  }

  .day-cell {
    min-height: 70px;
  }

  .day-cell strong {
    font-size: 11px;
  }

  .mini-metric-grid {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .data-actions,
  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .form-actions > *,
  .data-actions > *,
  .modal-actions > * {
    width: 100%;
  }
}
