:root {
  color-scheme: dark;
  --bg: #18191c;
  --panel: #222428;
  --panel-raised: #2b2d32;
  --border: #3d4047;
  --text: #f0f1f3;
  --muted: #a1a5ad;
  --orange: #ff944d;
  --orange-dark: #42291b;
  --positive: #62d995;
  --positive-dark: #1e392a;
  --regression: #a5a9b0;
  --red: #f18c83;
  font-family: "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 28px 18px 22px; border-right: 1px solid var(--border); background: #1d1e21; }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 10px 38px; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--orange); color: #21160f; font-size: 19px; font-weight: 800; }
.brand-name { font: 800 21px "Segoe UI", sans-serif; letter-spacing: -.8px; }
.brand-subtitle { margin-top: 1px; color: var(--muted); font-size: 11px; }
.nav-label, .eyebrow { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1.15px; text-transform: uppercase; }
.nav-label { padding: 0 12px 12px; }
.nav-list { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--orange-dark); color: var(--orange); }
.nav-icon { display: grid; width: 22px; place-items: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.6; }
.sidebar-bottom strong { display: block; margin-bottom: 4px; color: var(--text); font-weight: 600; }

.main { width: min(1120px, 100%); margin: 0 auto; padding: 35px 48px 80px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 38px; }
.topbar-greeting { color: var(--muted); font-size: 13px; }
.topbar-date { margin-top: 4px; font: 600 14px "Segoe UI", sans-serif; text-transform: capitalize; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--panel); font-size: 17px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 27px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font: 700 clamp(27px, 4vw, 36px) "Segoe UI", sans-serif; letter-spacing: -1.35px; }
h2 { margin-bottom: 0; font: 700 17px "Segoe UI", sans-serif; letter-spacing: -.25px; }
h3 { margin-bottom: 0; font: 600 14px "Segoe UI", sans-serif; }
.page-description { margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow { margin-bottom: 10px; color: var(--orange); }

.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.two-column { grid-template-columns: minmax(0, 1.35fr) minmax(270px, .9fr); }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); }
.stat-card { padding: 19px 20px; border-top: 2px solid var(--stat-accent, var(--orange)); }
.stat-card:nth-child(1) { --stat-accent: #ff9b55; }
.stat-card:nth-child(2) { --stat-accent: #61c6e8; }
.stat-card:nth-child(3) { --stat-accent: #b19af0; }
.stat-card:nth-child(4) { --stat-accent: #f2bf69; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 11px; color: var(--stat-accent, var(--orange)); font: 700 29px "Segoe UI", sans-serif; letter-spacing: -1px; }
.stat-note { margin-top: 5px; color: var(--muted); font-size: 11px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 21px; }
.text-link { padding: 4px 0; border: 0; background: transparent; color: var(--orange); font-size: 12px; cursor: pointer; }
.text-link:hover { text-decoration: underline; }
.activity-list, .exercise-list, .advice-list { display: grid; min-width: 0; gap: 10px; }
.activity-row, .exercise-row, .advice-card { display: flex; min-width: 0; align-items: center; gap: 12px; padding: 12px; border-radius: 11px; background: var(--panel-raised); }
.activity-icon, .exercise-icon { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--orange-dark); font-size: 17px; }
.row-main { min-width: 0; flex: 1; }
.row-title { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-subtitle { margin-top: 4px; color: var(--muted); font-size: 11px; }
.row-value { min-width: 0; color: var(--text); font-size: 12px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.progress-label { display: flex; justify-content: space-between; gap: 8px; margin: 14px 0 7px; color: var(--muted); font-size: 11px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 8px; background: #44464b; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--orange); }
.progress-up { background: var(--positive-dark); color: var(--positive); }
.progress-down { background: #383a3f; color: var(--regression); }
.progress-mixed { background: var(--orange-dark); color: var(--orange); }
.progress-same { background: #383a3f; color: var(--regression); }
.progress-delta.up { color: var(--positive); font-weight: 600; }
.progress-delta.down { color: var(--regression); font-weight: 600; }
.muscle-bars { display: grid; gap: 3px; }
.group-status { padding: 0 0 10px; }
.group-status:last-child { padding-bottom: 0; }
.group-recommendations { display: grid; gap: 8px; margin-top: 15px; }
.group-tip { padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 12px; line-height: 1.5; }
.group-tip strong { color: var(--orange); }
.group-tip.warning strong { color: var(--orange); }
.empty-state { padding: 22px 10px; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center; }
.empty-emoji { margin-bottom: 9px; font-size: 25px; }
.section-spacer { margin-top: 18px; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 9px; height: 115px; padding-top: 10px; }
.chart-column { display: flex; height: 100%; flex-direction: column; justify-content: end; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.chart-bar { width: min(28px, 100%); min-height: 3px; border-radius: 6px 6px 2px 2px; background: #484a50; }
.chart-bar.today { background: var(--orange); }
.small-caption { margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }

.button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-raised); font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; }
.button:hover { border-color: #a96338; transform: translateY(-1px); }
.button.primary { border-color: var(--orange); background: var(--orange); color: #26170e; }
.button.primary:hover { background: #ffab70; }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.danger { color: var(--red); }
.button.small { min-height: 33px; padding: 0 10px; font-size: 11px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-button { display: grid; width: 33px; height: 33px; flex: 0 0 33px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: #393b40; color: var(--red); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #d0d2d6; font-size: 12px; font-weight: 600; }
.field-hint { color: var(--muted); font-size: 10px; }
.input, .select { width: 100%; min-width: 0; height: 43px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; outline: 0; background: #1b1c1f; color: var(--text); font-size: 13px; }
.input:focus, .select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px #ff944d2b; }
.input::placeholder { color: #858991; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.form-footer .form-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-card { margin-bottom: 17px; }
.date-control { width: auto; max-width: 180px; }
.date-heading { display: flex; align-items: center; gap: 12px; }
.day-plan { margin: 0 0 16px; padding: 13px 15px; border: 1px solid #62452f; border-radius: 11px; background: #29231f; }
.day-plan-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; color: var(--orange); font-size: 12px; font-weight: 600; }
.plan-exercise-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.plan-pick { padding: 7px 10px; border: 1px solid #48413c; border-radius: 8px; background: #211f1d; font-size: 11px; cursor: pointer; }
.plan-pick:hover { border-color: var(--orange); color: var(--orange); }
.workout-record { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.workout-record:last-child { border-bottom: 0; }
.record-meta { color: var(--muted); font-size: 11px; line-height: 1.5; }
.list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.list-header .muted { color: var(--muted); font-size: 11px; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 10px; margin-bottom: 14px; }
.exercise-row .row-subtitle { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 4px 8px; border: 1px solid var(--border); border-radius: 100px; color: #b5b7bc; font-size: 10px; }
.exercise-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 235px; overflow-y: auto; padding: 2px; }
.picker-item { display: flex; align-items: center; gap: 8px; min-height: 39px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: #1b1c1f; color: #d0d2d6; font-size: 11px; cursor: pointer; }
.picker-item:has(input:checked) { border-color: var(--orange); color: var(--orange); }
.picker-item input { accent-color: var(--orange); }
.plan-card { margin-bottom: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-raised); }
.plan-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.plan-actions, .plan-form-actions, .exercise-form-actions { display: flex; align-items: center; gap: 7px; }
.plan-card-day { margin-bottom: 4px; color: var(--orange); font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
.plan-card-title { font: 600 14px "Segoe UI", sans-serif; }
.plan-card-items { display: flex; flex-wrap: wrap; gap: 7px; }
.plan-item { padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; color: #c6c8cd; font-size: 11px; }
.advice-card { align-items: flex-start; }
.advice-mark { display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: var(--orange-dark); color: var(--orange); font-size: 15px; }
.advice-mark.caution { background: #382a20; color: var(--orange); }
.advice-copy { color: #c2c4c9; font-size: 12px; line-height: 1.65; }
.advice-copy strong { color: var(--text); font-weight: 600; }
.notice { margin-bottom: 16px; padding: 11px 14px; border: 1px solid #68583d; border-radius: 10px; background: #2b261d; color: #f2d6a5; font-size: 12px; line-height: 1.55; }
.notice.error { border-color: #714441; background: #30201f; color: #ffc0b8; }
.footer-note { margin: 16px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.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; }

.mobile-nav { display: none; }

@media (max-width: 1000px) {
  .main { padding-right: 30px; padding-left: 30px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: minmax(0, 1.15fr) minmax(250px, .85fr); }
}

@media (max-width: 760px) {
  .app-shell { display: block; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main { padding: 20px 17px 30px; }
  .topbar { margin-bottom: 29px; }
  .topbar-greeting { font-size: 11px; }
  .topbar-date { font-size: 12px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .button { min-height: 36px; padding: 0 9px; font-size: 11px; }
  .avatar { width: 34px; height: 34px; }
  .page-heading { align-items: flex-start; margin-bottom: 20px; }
  .page-description { font-size: 12px; line-height: 1.55; }
  .stats-grid { gap: 9px; margin-bottom: 12px; }
  .stat-card { padding: 14px; }
  .stat-label { font-size: 10px; }
  .stat-value { margin-top: 8px; font-size: 24px; }
  .stat-note { font-size: 10px; }
  .two-column { grid-template-columns: 1fr; gap: 12px; }
  .panel { padding: 17px; border-radius: 13px; }
  .panel-heading { margin-bottom: 15px; }
  .mobile-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 7px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: #1d1e21f2; backdrop-filter: blur(14px); }
  .mobile-nav .nav-item { min-height: 49px; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 2px; font-size: 9px; }
  .mobile-nav .nav-icon { font-size: 17px; }
  .form-grid, .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .field.full { grid-column: 1 / -1; }
  .row-value { max-width: 100px; font-size: 11px; line-height: 1.45; }
  .exercise-picker { grid-template-columns: 1fr; max-height: 190px; }
  .filters { grid-template-columns: 1fr; }
  .date-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .date-control { max-width: none; }
}

@media (max-width: 380px) {
  .main { padding-right: 13px; padding-left: 13px; }
  .panel { padding: 14px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 21px; }
  .form-footer { align-items: flex-start; flex-direction: column; }
}
