:root {
  --forest: #2e6f57;
  --forest-dark: #245a47;
  --sage: #6fa67a;
  --mint: #ddeedf;
  --cream: #fafaf7;
  --surface: #ffffff;
  --charcoal: #24322a;
  --stone: #708070;
  --sand: #e8d8b5;
  --border: #e3ece3;
  --error: #b64040;
  --shadow: 0 18px 45px rgba(36, 50, 42, 0.09);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--charcoal);
  background: var(--cream);
  font-family: Inter, Manrope, 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; }

.hidden { display: none !important; }
.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; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 12px 18px; border-radius: 999px; color: white; background: var(--forest); }
.skip-link:focus { top: 16px; }

.background-shape { position: fixed; border-radius: 50%; pointer-events: none; z-index: -1; }
.shape-one { width: 420px; height: 420px; right: -180px; top: -190px; background: var(--mint); }
.shape-two { width: 320px; height: 320px; left: -205px; bottom: 2%; background: #edf4ee; }

.app-header {
  width: min(1240px, calc(100% - 36px));
  margin: 0 auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { border-radius: 16px; }
.brand span { display: grid; line-height: 1.15; }
.brand strong { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--forest); }
.brand small { margin-top: 4px; color: var(--stone); }
.header-link { color: var(--forest); font-weight: 750; text-decoration: none; }
.header-link:hover { text-decoration: underline; }

main { width: min(1240px, calc(100% - 36px)); margin: 0 auto; min-height: calc(100vh - 160px); }
.center-view { min-height: 70vh; display: grid; place-content: center; justify-items: center; color: var(--stone); }
.loader { width: 42px; height: 42px; border: 4px solid var(--mint); border-top-color: var(--forest); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-layout { display: grid; grid-template-columns: .95fr 1.05fr; gap: 28px; align-items: stretch; padding: 26px 0 64px; }
.brand-panel, .surface { border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.brand-panel { padding: 52px; background: linear-gradient(145deg, var(--mint), #edf4ee); border-color: #9ccaa7; display: flex; flex-direction: column; justify-content: center; }
.large-logo { border-radius: 28px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 9px; color: var(--forest); font-size: .76rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.brand-panel h1, .workspace-heading h1, .detail-heading h1 { margin: 0; font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.04; letter-spacing: -.045em; }
.brand-panel > p:not(.eyebrow) { max-width: 540px; color: var(--stone); font-size: 1.08rem; }
.benefit-list { display: grid; gap: 14px; margin: 28px 0 0; padding: 0; list-style: none; }
.benefit-list li { display: flex; gap: 13px; align-items: center; font-weight: 680; }
.benefit-list li span { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 12px; color: var(--forest); background: rgba(255,255,255,.62); }

.auth-card { padding: 38px; }
.auth-heading h2 { margin: 0; font-size: 2rem; line-height: 1.15; }
.auth-heading > p:last-child { margin: 8px 0 0; color: var(--stone); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 28px 0; padding: 4px; border-radius: 999px; background: #edf4ee; }
.segmented button { min-height: 48px; border: 0; border-radius: 999px; color: var(--stone); background: transparent; font-weight: 800; cursor: pointer; }
.segmented button.active { color: var(--forest); background: white; box-shadow: 0 7px 20px rgba(36,50,42,.08); }

fieldset { margin: 0 0 24px; padding: 0; border: 0; }
legend { margin-bottom: 10px; font-weight: 800; }
.mode-card { position: relative; display: grid; grid-template-columns: 52px 1fr 26px; gap: 13px; align-items: center; margin-top: 9px; padding: 15px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; transition: .18s ease; }
.mode-card:hover, .mode-card.selected { border-color: var(--forest); background: #f1f8f3; }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; color: var(--forest); background: var(--mint); font-size: 1.5rem; font-weight: 900; }
.mode-card.selected .mode-icon { color: white; background: var(--forest); }
.mode-card > span:nth-of-type(2) { display: grid; }
.mode-card strong { font-size: .96rem; }
.mode-card small { margin-top: 3px; color: var(--stone); }
.mode-check { color: var(--forest); font-weight: 900; opacity: 0; }
.mode-card.selected .mode-check { opacity: 1; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: .87rem; font-weight: 760; color: var(--charcoal); }
input, select, textarea { width: 100%; border: 1px solid #d9e5dc; border-radius: 15px; color: var(--charcoal); background: white; outline: none; transition: border .15s ease, box-shadow .15s ease; }
input, select { min-height: 52px; padding: 0 15px; }
textarea { resize: vertical; padding: 14px 15px; }
input:focus, select:focus, textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(46,111,87,.12); }

.button { min-height: 48px; padding: 0 21px; border: 1px solid transparent; border-radius: 999px; font-weight: 800; cursor: pointer; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .58; cursor: wait; transform: none; }
.button.primary { color: white; background: var(--forest); }
.button.primary:hover { background: var(--forest-dark); }
.button.secondary { color: var(--forest); border-color: #9ccaa7; background: white; }
.button.ghost { color: var(--forest); border-color: var(--border); background: transparent; }
.button.wide { width: 100%; min-height: 56px; }
.privacy-note { margin: 19px 8px 0; color: var(--stone); font-size: .78rem; text-align: center; }
.form-message { margin: 10px 0; padding: 11px 13px; border-radius: 12px; color: var(--forest); background: var(--mint); font-weight: 650; }
.form-message.error { color: var(--error); background: #fff0f0; }

.workspace { padding: 38px 0 76px; }
.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.workspace-heading h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
.workspace-heading > div:first-child > p:last-child { margin: 10px 0 0; color: var(--stone); }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.form-grid { max-width: 920px; margin: 0 auto; padding: 34px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; }
.span-two { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 10px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.summary-card { min-height: 142px; padding: 24px; display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-content: center; }
.summary-icon { grid-row: 1 / span 2; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 17px; color: var(--forest); background: var(--mint); font-size: 1.25rem; }
.summary-card small { color: var(--stone); }
.summary-card strong { font-size: 1.26rem; }
.client-grid, .professional-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.client-grid > .surface, .professional-detail-grid > .surface, .history-card { padding: 28px; }
.section-title h2 { margin: 0; font-size: 1.45rem; }
.section-copy { margin: 9px 0 20px; color: var(--stone); }
.meal-form { margin-top: 22px; }
.nutrition-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.empty-state { color: var(--stone); padding: 22px 0; }
.meal-row, .history-row, .note-row { display: grid; gap: 4px; padding: 15px 0; border-bottom: 1px solid var(--border); }
.meal-row:last-child, .history-row:last-child, .note-row:last-child { border-bottom: 0; }
.meal-row-head, .history-row-head { display: flex; justify-content: space-between; gap: 16px; }
.meal-row strong, .history-row strong { font-size: .96rem; }
.meal-row small, .history-row small, .note-row small { color: var(--stone); }
.history-card { margin-top: 20px; }
.progress-grid { display: grid; grid-template-columns: .82fr 1.18fr; gap: 20px; margin-top: 20px; }
.progress-entry-card, .progress-chart-card, .professional-progress-card { padding: 28px; }
.measurement-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 13px; }
.progress-summary { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; margin: 20px 0 12px; }
.progress-metric { padding: 12px; border: 1px solid var(--border); border-radius: 15px; background: #fbfdfb; }
.progress-metric span, .progress-metric strong { display: flex; align-items: center; gap: 7px; }
.progress-metric span { color: var(--stone); font-size: .76rem; }
.progress-metric strong { margin-top: 4px; font-size: 1rem; }
.progress-metric i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.progress-chart-scroll { width: 100%; overflow-x: auto; }
.progress-chart-scroll svg { display: block; min-width: 600px; width: 100%; }
.chart-grid { stroke: #dfe8e1; stroke-width: 1; }
.chart-zero { stroke: #9bad9f; stroke-width: 1.5; }
.chart-axis-label, .chart-date-label { fill: var(--stone); font-size: 12px; }
.progress-note { margin: 8px 0 0; color: var(--stone); font-size: .78rem; }

.professional-layout { min-height: calc(100vh - 140px); margin: 12px calc((100vw - min(1240px, calc(100vw - 36px))) / -2) 40px; display: grid; grid-template-columns: 350px 1fr; border: 1px solid var(--border); border-radius: 28px; overflow: hidden; background: white; box-shadow: var(--shadow); }
.professional-sidebar { padding: 28px 20px; background: #f2f7f3; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-head { padding: 0 8px; }
.sidebar-head h1 { margin: 0; font-size: 2.3rem; letter-spacing: -.04em; }
.sidebar-head > p:last-child { color: var(--stone); }
.panel-my-progress { margin-top: 16px; }
.search-field { display: block; margin: 18px 0 14px; }
.client-list { flex: 1; display: grid; align-content: start; gap: 8px; overflow: auto; }
.client-item { width: 100%; padding: 14px; border: 1px solid transparent; border-radius: 18px; text-align: left; color: inherit; background: transparent; cursor: pointer; }
.client-item:hover, .client-item.active { border-color: #b8d5bf; background: white; }
.client-item strong, .client-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-item small { margin-top: 3px; color: var(--stone); }
.client-status { display: inline-block; margin-top: 9px; padding: 4px 9px; border-radius: 999px; color: var(--forest); background: var(--mint); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.client-status.requested { color: #8b4d00; background: #fff0d5; }
.client-status.self { color: #617065; background: #e9eeea; }
.sidebar-signout { margin-top: 18px; width: 100%; }
.professional-main { min-width: 0; padding: 38px; background: var(--cream); }
.professional-empty { min-height: 620px; display: grid; place-content: center; justify-items: center; text-align: center; }
.professional-empty h2 { margin: 22px 0 5px; }
.professional-empty p { color: var(--stone); }
.empty-illustration { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 28px; color: white; background: var(--forest); font-size: 2.2rem; font-weight: 900; }
.detail-heading { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; }
.detail-heading h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
.detail-heading > div > p:last-child { color: var(--stone); }
.detail-actions { display: grid; justify-items: end; }
.detail-actions .form-message { max-width: 260px; margin-bottom: 0; }
.profile-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.fact { padding: 17px; border: 1px solid var(--border); border-radius: 18px; background: white; }
.fact small, .fact strong { display: block; }
.fact small { margin-bottom: 6px; color: var(--stone); }
.note-list { margin-top: 20px; }
.note-row p { margin: 0; white-space: pre-wrap; }
.professional-progress-card { margin-bottom: 20px; }

.app-footer { width: min(1240px, calc(100% - 36px)); margin: 0 auto; min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border); color: var(--stone); font-size: .8rem; }
.app-footer a { color: var(--forest); font-weight: 750; text-underline-offset: 3px; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .brand-panel { padding: 30px; }
  .large-logo { width: 84px; height: 84px; margin-bottom: 20px; }
  .brand-panel h1 { font-size: 2.5rem; }
  .benefit-list { display: none; }
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { justify-content: flex-start; }
  .summary-grid { grid-template-columns: 1fr; }
  .client-grid, .professional-detail-grid, .progress-grid { grid-template-columns: 1fr; }
  .professional-layout { margin-left: 0; margin-right: 0; grid-template-columns: 1fr; }
  .professional-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .client-list { max-height: 300px; }
  .professional-main { padding: 24px 18px; }
  .professional-empty { min-height: 320px; }
  .profile-facts { grid-template-columns: repeat(2, 1fr); }
  .detail-heading { align-items: flex-start; flex-direction: column; }
  .detail-actions { justify-items: start; }
  .progress-summary { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

@media (max-width: 600px) {
  .app-header { min-height: 76px; }
  .brand small { display: none; }
  .header-link { font-size: .85rem; }
  main { width: min(100% - 24px, 1240px); }
  .auth-layout { padding-top: 10px; }
  .brand-panel, .surface { border-radius: 22px; }
  .brand-panel { padding: 24px; }
  .brand-panel > p:not(.eyebrow) { font-size: .98rem; }
  .auth-card { padding: 24px 18px; }
  .mode-card { grid-template-columns: 46px 1fr 18px; padding: 12px; }
  .mode-icon { width: 44px; height: 44px; }
  .mode-card small { font-size: .73rem; }
  .workspace { padding-top: 22px; }
  .form-grid { grid-template-columns: 1fr; padding: 24px 18px; }
  .span-two { grid-column: auto; }
  .form-actions { justify-content: stretch; }
  .form-actions .button { width: 100%; }
  .summary-card { min-height: 112px; }
  .client-grid > .surface, .professional-detail-grid > .surface, .history-card { padding: 22px 18px; }
  .nutrition-fields { grid-template-columns: 1fr; gap: 0; }
  .measurement-fields { grid-template-columns: 1fr; gap: 0; }
  .progress-entry-card, .progress-chart-card, .professional-progress-card { padding: 22px 18px; }
  .progress-summary { grid-template-columns: 1fr 1fr; }
  .professional-layout { border-radius: 22px; }
  .profile-facts { grid-template-columns: 1fr 1fr; }
  .app-footer { align-items: flex-start; flex-direction: column; padding: 20px 0; }
}
