:root {
    --green: #16a34a;
    --green-dark: #12813c;
    --ink: #101828;
    --muted: #667085;
    --line: #e4e7ec;
    --bg: #f5f7fa;
    --card: #ffffff;
    --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--green-dark); text-decoration: none; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.topbar {
    display: flex; align-items: center; gap: 20px;
    padding: 12px 18px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--ink); }
.nav { display: flex; gap: 6px; flex: 1; }
.nav a {
    padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500;
}
.nav a.active { background: #e7f8ee; color: var(--green-dark); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.page { max-width: 1080px; margin: 0 auto; padding: 18px 18px 60px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
}

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.flash { background: #e7f8ee; color: #0b5d2b; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.flash.error { background: #fdeaea; color: #8f1d1d; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--card); color: var(--ink); font: inherit; font-weight: 500;
    cursor: pointer;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { color: var(--danger); border-color: #f3c4c4; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--green-dark); cursor: pointer; font: inherit; }

.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { flex: 1; min-width: 160px; }

input, select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line);
    border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; color: var(--ink); font-size: 15px; }

.form .actions { display: flex; gap: 8px; margin-top: 6px; }
.actions.end { align-items: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-main { flex: 1; min-width: 0; }
.row-main .name { font-size: 16px; font-weight: 600; color: var(--ink); }
.row-actions { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { background: #eef2f7; color: #344054; border-radius: 999px; padding: 3px 9px; font-size: 12px; }
.chip.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 6px; }
.table td { padding: 4px 6px; border-top: 1px solid #f1f3f7; }
.table td.right, .right { text-align: right; }
.nowrap { white-space: nowrap; }
.cell { padding: 6px 8px; border-radius: 8px; }
.stats { display: flex; gap: 28px; }
.stats strong { display: block; font-size: 20px; }

.exercise-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    min-height: 92px; padding: 6px; position: relative; display: flex; flex-direction: column; gap: 4px;
}
.cal-cell.out { opacity: .45; }
.cal-cell.today { border-color: var(--green); box-shadow: 0 0 0 2px #d9f5e4; }
.cal-num { font-size: 12px; color: var(--muted); }
.cal-item {
    display: block; background: #e7f8ee; color: #0b5d2b;
    border-radius: 7px; padding: 3px 6px; font-size: 11px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-add-link {
    margin-top: auto; display: block; text-align: center;
    border: 1px dashed var(--line); color: var(--muted); border-radius: 7px;
    font-size: 14px; line-height: 1.4; text-decoration: none;
}
.cal-add-link:hover { color: var(--green-dark); border-color: var(--green); }
.cal-add button {
    width: 100%; border: 1px dashed var(--line); background: transparent;
    color: var(--muted); border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1;
    padding: 2px 0;
}
.cal-add button:hover { color: var(--green-dark); border-color: var(--green); }

.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 22px; }

@media (max-width: 720px) {
    .grid2 { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; }
    .nav { order: 3; flex-basis: 100%; }
    .cal-cell { min-height: 70px; }
}
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}
.exercise-card { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 10px; }
.exercise-card .thumb {
    display: block; border-radius: 10px; overflow: hidden; background: #f1f3f7;
    aspect-ratio: 4 / 3;
}
.exercise-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; font-size: 28px; color: var(--muted);
}
.exercise-body { flex: 1; min-width: 0; }
.exercise-body .name { font-weight: 600; color: var(--ink); font-size: 15px; }
.exercise-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.star { background: none; border: 0; font-size: 20px; cursor: pointer; color: #98a2b3; line-height: 1; }
.star.on { color: #f59e0b; }
.chip.ok { background: #e7f8ee; color: #0b5d2b; }
.pager { margin-top: 14px; }
.pager-row { display: flex; align-items: center; gap: 12px; justify-content: center; }
.btn.disabled { opacity: .45; pointer-events: none; }
.detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; align-items: start; }
.detail-media { text-align: center; }
.detail-media .gif { max-width: 100%; border-radius: 12px; background: #f1f3f7; }
.detail-side { display: flex; flex-direction: column; gap: 12px; }
.actions-card { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.small { font-size: 12px; }
.table th { width: 44%; }

@media (max-width: 860px) {
    .detail { grid-template-columns: 1fr; }
    .grid-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
.superset-card { border: 1.5px solid #7c3aed; background: #faf7ff; }
.superset-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chip.sup { background: #ede9fe; color: #5b21b6; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #f1f3f7; }
.item-row:first-of-type { border-top: 0; }
.item-check input { width: 18px; height: 18px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; }
.item-sets { display: flex; align-items: center; gap: 4px; }
.cell.tiny { width: 56px; padding: 4px 6px; text-align: center; }
.item-actions { display: flex; gap: 4px; }
.add-bar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.add-bar .grid2 { flex: 1; margin: 0; }
.pick-card { cursor: pointer; position: relative; }
.pick-card input[type=checkbox] { width: 18px; height: 18px; }
.pick-mark { position: absolute; top: 8px; right: 8px; }
.pick-card:has(input:checked) { outline: 2px solid var(--green); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 760px) { .grid3 { grid-template-columns: 1fr; } }
.goal-card { display: flex; flex-direction: column; gap: 8px; }
.reco { background: #eef2ff; border-radius: 10px; padding: 10px; }
.reco-main { font-size: 16px; font-weight: 600; }
.reco-detail { font-size: 12px; color: var(--muted); }
.week-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 12px; }.reco-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.muted-reco { background: #f6f7f9; }
.muted-reco .reco-detail { color: var(--muted); }.move-buttons { margin-left: auto; display: flex; gap: 4px; }
.exercise-head { gap: 8px; }
/* Календарь по неделям: слева кнопка типа недели */
.week-cal { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.week-cal-head { display: grid; grid-template-columns: 92px repeat(7, 1fr); gap: 6px; }
.week-row { display: grid; grid-template-columns: 92px repeat(7, 1fr); gap: 6px; }
.week-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 1px dashed var(--line); background: var(--card); border-radius: 12px;
    cursor: pointer; padding: 4px; color: var(--muted); font-size: 11px; font-family: inherit;
}
.week-btn:hover { border-color: var(--green); color: var(--green-dark); }
.week-btn.filled { border-style: solid; color: var(--ink); font-weight: 600; }
.week-btn-dot { width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.week-btn-text { max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-day-link { display: block; }
.cal-cell.selected { box-shadow: 0 0 0 2px var(--green); }
.cal-cell.today .cal-num { color: var(--green-dark); font-weight: 700; }
.day-workout { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #f1f3f7; }
.day-workout:first-of-type { border-top: 0; }
.day-workout .name { flex: 1; font-weight: 600; color: var(--ink); }
.week-dialog {
    border: 1px solid var(--line); border-radius: 16px; padding: 18px; max-width: 420px; width: 92vw;
}
.week-dialog::backdrop { background: rgba(16, 24, 40, .45); }
.week-dialog label { margin-bottom: 10px; }
@media (max-width: 860px) {
    .week-cal-head, .week-row { grid-template-columns: 46px repeat(7, 1fr); gap: 3px; }
    .week-btn-text { display: none; }
}.day-results { margin: 0 0 10px 34px; padding: 8px 10px; background: #f7f9fb; border-radius: 10px; }
.day-results-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.day-results-list { margin: 0; padding-left: 16px; font-size: 13px; color: var(--ink); }
.day-results-list li { margin: 2px 0; }details.day-results > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
details.day-results > summary::-webkit-details-marker { display: none; }
details.day-results > summary::before { content: "▸"; color: var(--muted); margin-right: 2px; }
details.day-results[open] > summary::before { content: "▾"; }
.sets-table { margin-top: 8px; background: #fff; border-radius: 8px; }
.sets-table th { font-size: 11px; }
.sets-table td { font-size: 13px; }.cal-item { cursor: grab; }
.cal-item.dragging { opacity: .45; }
.cal-cell.drop-target { outline: 2px dashed var(--green); outline-offset: -2px; }
.cal-cell.drop-target::after { content: "перенести сюда"; position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--green-dark); }
.cal-cell { position: relative; }
.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.measure-tile { background: #f7f9fb; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.measure-tile strong { font-size: 17px; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.chart-card { margin: 0; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chart-head h3 { margin: 0 0 2px; font-size: 15px; }
.chart-value { text-align: right; }
.chart-value strong { font-size: 20px; }
.chart-delta { font-size: 12px; color: var(--muted); }
.chart-delta.up { color: #b45309; }
.chart-delta.down { color: #0f7a37; }
.chart-svg { width: 100%; height: 120px; display: block; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }
.chart-box { position: relative; margin-top: 6px; }
.chart-tooltip {
    position: absolute; top: 4px; z-index: 5; min-width: 170px;
    background: #101828; color: #fff; border-radius: 10px; padding: 8px 10px;
    font-size: 12px; box-shadow: 0 8px 20px rgba(16,24,40,.25); pointer-events: none;
}
.tt-date { font-weight: 600; margin-bottom: 4px; }
.tt-row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.tt-name { flex: 1; color: #cfd6e4; }
.tt-row strong { font-weight: 600; }
.chart-hover-line { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(16,24,40,.25); pointer-events: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; margin-top: 6px; color: var(--ink); }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
/* Оси и легенды графиков */
.chart-with-axis { display: grid; grid-template-columns: 46px 1fr; gap: 6px; margin-top: 8px; }
.chart-y-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; }
.chart-box { position: relative; }
.chart-x-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 4px 0 0 52px; }
.chart-svg { width: 100%; height: 120px; display: block; }

.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form select, .inline-form input { padding: 6px 8px; font-size: 13px; }
.ok-card { background: #ecfdf3; color: #0f7a37; border-color: #b7e4c7; }
.danger-card { background: #fef2f2; color: #b42318; border-color: #fecdca; }

.sets-report { margin: 8px 0; }
.sets-report-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.result-chip { display: inline-block; border: 1px solid; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.history-box { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 8px; padding: 8px 10px; background: #f7f9fb; border-radius: 10px; }
.history-line { font-size: 13px; }
.exercise-groups { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.exercise-group { border-left: 3px solid #e7ebf2; padding-left: 8px; }
.exercise-group-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.exercise-group-list { display: flex; flex-wrap: wrap; gap: 4px; }
.exercise-pill { background: #f1f5f9; border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.sets-by-exercise { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.sets-block { background: #fff; border: 1px solid #eef1f6; border-radius: 10px; padding: 8px 10px; }
.sets-block-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sets-block-rows { display: flex; flex-direction: column; gap: 4px; }
.sets-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sets-num { color: var(--muted); min-width: 78px; }
.sets-value { flex: 1; font-weight: 600; }