:root {
  --navy: #17324d;
  --navy-2: #244b68;
  --teal: #168596;
  --blue: #2f80c4;
  --bg: #f3f7f8;
  --panel: #ffffff;
  --text: #172b38;
  --muted: #647783;
  --line: #d5e0e5;
  --soft: #eaf3f6;
  --danger: #b53a3a;
  --success: #137553;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); padding-bottom: 78px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { height: 58px; background: var(--navy); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 12px #17324d22; }
.brand { font-size: 14px; letter-spacing: .11em; }
.brand strong { color: #64d3d7; }
.logout-form { margin: 0; }
.logout-form button { border: 1px solid #ffffff55; border-radius: 8px; padding: 6px 10px; background: transparent; color: white; font-size: 12px; font-weight: 700; }
.logout-form button:hover { background: #ffffff18; }
.login-body { padding: 0; background: linear-gradient(145deg, var(--navy), #235775); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); padding: 30px; border-radius: 20px; background: white; box-shadow: 0 24px 70px #071d2e66; }
.login-card h1 { margin: 5px 0 7px; color: var(--navy); font-size: 32px; }
.login-intro { margin: 0 0 22px; color: var(--muted); }
.login-form { display: grid; gap: 14px; }
.login-form input { margin-top: 6px; }
.login-form .primary { width: 100%; margin: 6px 0 0; }
.login-message { margin: 0 0 18px; padding: 12px; border-radius: 10px; font-size: 13px; line-height: 1.45; }
.login-message.error { border: 1px solid #efcaca; background: #fff3f3; color: var(--danger); }
.login-message code { display: block; margin-top: 7px; overflow-wrap: anywhere; color: var(--navy); }
.container { width: min(1040px, 100%); margin: 0 auto; padding: 26px 18px 52px; }
.hero, .page-title { margin: 4px 0 24px; }
.hero h1, .page-title h1, .workout-header h1 { margin: 3px 0 5px; font-size: clamp(27px, 5vw, 42px); line-height: 1.1; color: var(--navy); }
.hero p:last-child, .page-title p:last-child { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.plan-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.plan-grid-empty { grid-column: 1 / -1; }
.plan-grid-empty a { color: var(--teal); font-weight: 800; }
.plan-card { min-height: 102px; display: grid; grid-template-columns: 46px 1fr 20px; align-items: center; gap: 12px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 20px #17324d0c; transition: transform .15s, border-color .15s; }
.plan-card:hover { transform: translateY(-2px); border-color: var(--teal); }
.plan-number { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--navy); color: white; font-size: 20px; font-weight: 800; }
.plan-card strong { display: block; font-size: 16px; }
.plan-card small, .history-row small, .export-card small { display: block; color: var(--muted); margin-top: 4px; }
.arrow { color: var(--teal); font-size: 30px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 30px 2px 10px; }
.section-head h2, .panel h2 { margin: 0; font-size: 18px; color: var(--navy); }
.section-head a { color: var(--teal); font-size: 14px; font-weight: 700; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 20px #17324d0b; }
.history-list { overflow: hidden; }
.history-row { display: grid; grid-template-columns: 92px 1fr; gap: 18px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-row time { color: var(--teal); font-weight: 800; }
.history-row p { margin: 7px 0 0; color: var(--muted); }
.history-row.large { padding-block: 20px; }
.workout-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.workout-header h1 { font-size: clamp(22px, 4vw, 34px); }
.back { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; background: white; border: 1px solid var(--line); font-size: 31px; color: var(--navy); }
.date-panel { display: flex; justify-content: flex-end; margin-bottom: 12px; }
label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--text); padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #1685961b; }
.date-panel label { width: 210px; }
.date-panel input { margin-top: 5px; }
.exercise-list { display: grid; gap: 15px; }
.exercise-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 5px 20px #17324d0b; }
.exercise-card > header { padding: 17px 18px 12px; }
.exercise-card > header > div { display: flex; gap: 10px; align-items: center; }
.exercise-card h2 { margin: 0; color: var(--navy); font-size: 18px; }
.exercise-card header p { margin: 7px 0 0 38px; color: var(--muted); font-size: 13px; }
.exercise-position { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--soft); color: var(--teal); font-weight: 900; }
.previous { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 18px; background: var(--soft); border-block: 1px solid #dce9ed; font-size: 13px; }
.previous span { color: var(--muted); }
.previous strong { color: var(--navy); }
.text-button, .add-set { border: 0; background: transparent; color: var(--teal); font-weight: 800; padding: 6px; }
.sets { padding: 9px 12px 2px; }
.set-row { display: grid; grid-template-columns: 28px minmax(78px, 1fr) 18px minmax(74px, 1fr) minmax(115px, 1.15fr) minmax(120px, 1.5fr) 30px; gap: 7px; align-items: end; padding: 6px; border-bottom: 1px solid #edf2f4; }
.set-row:last-child { border-bottom: 0; }
.set-number { align-self: center; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--navy); color: white; font-size: 12px; font-weight: 800; }
.set-row label span { display: block; margin: 0 0 3px 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.set-row input, .set-row select { padding: 9px 8px; }
.times { align-self: center; text-align: center; color: var(--muted); }
.remove-set { align-self: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: #91a0a8; font-size: 20px; }
.remove-set:hover { background: #fff0f0; color: var(--danger); }
.add-set { margin: 4px 14px 12px; }
.workout-notes { margin-top: 16px; padding: 17px; }
.workout-notes textarea { margin-top: 6px; resize: vertical; }
.primary, .secondary { border: 0; border-radius: 11px; padding: 12px 18px; font-weight: 800; }
.primary { background: var(--teal); color: white; }
.primary.big { display: block; width: min(480px, 100%); margin: 12px auto; padding: 16px; font-size: 16px; box-shadow: 0 7px 18px #16859635; }
.primary.inline { display: inline-block; margin-top: 18px; }
.secondary { background: var(--navy); color: white; }
.secondary.compact { display: inline-block; padding: 9px 13px; border-radius: 9px; font-size: 13px; }
.danger-button { border: 1px solid #efcaca; border-radius: 9px; padding: 9px 13px; background: #fff7f7; color: var(--danger); font-weight: 800; }
.danger-button:hover { background: #ffeded; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--navy); font-weight: 900; }
.icon-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.icon-button:disabled { cursor: default; opacity: .3; }
button:disabled { opacity: .55; cursor: wait; }
.save-status { min-height: 23px; text-align: center; margin-top: 11px; font-weight: 700; }
.save-status.error, .notice.error { color: var(--danger); }
.save-status.success { color: var(--success); }
.selector { padding: 16px; margin-bottom: 14px; }
.selector select { margin-top: 6px; font-weight: 700; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin: 12px 0; }
.metric { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-top: 4px; font-size: 24px; color: var(--navy); }
.metric strong small { font-size: 12px; }
.chart-panel, .table-panel { padding: 18px; margin-top: 12px; }
.chart-panel header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.chart-panel header span { color: var(--muted); font-size: 12px; }
#progress-chart { display: block; width: 100%; height: 280px; }
.table-panel h2 { margin-bottom: 13px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--navy); color: white; text-align: left; padding: 11px; white-space: nowrap; }
td { padding: 11px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.positive { color: var(--success); font-weight: 800; }
.negative { color: var(--danger); font-weight: 800; }
.report-form { padding: 17px; }
.report-fields { display: grid; grid-template-columns: 1fr 1fr 1.7fr; gap: 12px; margin-bottom: 12px; }
.report-fields input, .report-fields select { margin-top: 5px; }
.report-note { display: block; margin-bottom: 12px; }
.report-note textarea { margin-top: 5px; resize: vertical; }
.report-metrics { margin-top: 14px; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 14px; }
.export-card { border: 1px solid var(--line); border-radius: var(--radius); background: white; padding: 20px; text-align: left; color: var(--text); }
.export-card > span { display: inline-grid; place-items: center; min-width: 54px; height: 32px; padding: 0 9px; border-radius: 8px; color: white; font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.export-card.pdf > span { background: #c34b4b; }
.export-card.xlsx > span { background: #23845d; }
.export-card strong { display: block; margin-top: 12px; font-size: 17px; color: var(--navy); }
.export-card:hover { border-color: var(--teal); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.plans-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.plans-title .primary { flex: 0 0 auto; margin-bottom: 2px; }
.plan-manage-list { overflow: hidden; }
.plan-manage-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.plan-manage-row:last-child { border-bottom: 0; }
.plan-manage-row strong, .plan-manage-row small { display: block; }
.plan-manage-row small { margin-top: 3px; color: var(--muted); }
.plan-order, .exercise-order { display: flex; gap: 5px; }
.plan-name-panel { padding: 17px; }
.plan-name-panel input { margin-top: 6px; font-size: 17px; font-weight: 700; }
.plan-exercises-head { margin-top: 24px; }
.plan-exercise-list { display: grid; gap: 12px; }
.plan-exercise { padding: 16px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 20px #17324d0b; }
.plan-exercise-head { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.plan-exercise-head .exercise-position { margin-bottom: 7px; }
.exercise-name input, .plan-exercise-fields input, .plan-exercise-fields textarea { margin-top: 5px; }
.exercise-order { align-items: center; margin-bottom: 1px; }
.remove-exercise { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: #fff3f3; color: var(--danger); font-size: 20px; }
.plan-exercise-fields { display: grid; grid-template-columns: .8fr 1.2fr 1.5fr; gap: 10px; margin: 13px 0 0 38px; }
.plan-exercise-fields textarea { resize: vertical; }
.bottom-nav { position: fixed; z-index: 30; bottom: 0; left: 0; right: 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: center; background: #ffffffee; backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.nav-item { width: min(145px, 20%); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
.nav-item span { font-size: 20px; line-height: 20px; }
.nav-item.active { color: var(--teal); }

@media (max-width: 720px) {
  .container { padding: 19px 12px 36px; }
  .plan-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .set-row { grid-template-columns: 28px 1fr 16px 1fr 30px; }
  .set-type { grid-column: 2 / 4; }
  .set-note { grid-column: 4 / 6; }
  .remove-set { grid-column: 5; grid-row: 1; }
  .previous { grid-template-columns: 1fr auto; }
  .previous strong { grid-column: 1 / -1; order: 3; }
  .report-fields { grid-template-columns: 1fr 1fr; }
  .report-fields label:nth-child(n+3) { grid-column: 1 / -1; }
  .export-grid { grid-template-columns: 1fr; }
  .plan-manage-row { grid-template-columns: 42px minmax(0, 1fr) auto auto; gap: 8px; }
  .plan-manage-row .plan-order { grid-column: 2; grid-row: 2; }
  .plan-manage-row .secondary { grid-column: 3; grid-row: 1 / 3; }
  .plan-manage-row .danger-button { grid-column: 4; grid-row: 1 / 3; }
  .plan-exercise-fields { grid-template-columns: 1fr 1fr; }
  .plan-exercise-fields label:last-child { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .topbar { height: 52px; padding-inline: 15px; }
  .history-row { grid-template-columns: 82px 1fr; gap: 10px; padding-inline: 14px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 21px; }
  .exercise-card > header { padding-inline: 13px; }
  .previous { padding-inline: 13px; }
  .sets { padding-inline: 6px; }
  .set-row { gap: 5px; padding-inline: 3px; }
  .plans-title { align-items: flex-start; flex-direction: column; }
  .plans-title .primary { margin-top: 0; }
  .plan-manage-row { grid-template-columns: 36px minmax(0, 1fr) auto; padding-inline: 11px; }
  .plan-manage-row .plan-number { width: 34px; height: 34px; }
  .plan-manage-row .plan-order { grid-column: 2; }
  .plan-manage-row .secondary { grid-column: 3; grid-row: 1; }
  .plan-manage-row .danger-button { grid-column: 3; grid-row: 2; }
  .plan-exercise { padding: 12px; }
  .plan-exercise-head { grid-template-columns: 28px 1fr; }
  .exercise-order { grid-column: 2; }
  .plan-exercise-fields { grid-template-columns: 1fr; margin-left: 38px; }
  .plan-exercise-fields label:last-child { grid-column: auto; }
  .nav-item { font-size: 10px; }
  .login-card { padding: 24px 19px; }
}
