:root {
  --bg: #f6f7f1;
  --card: #fffef9;
  --soft: #eef0ea;
  --line: #dfe2d8;
  --text: #1d211e;
  --muted: #737a72;
  --lime: #ccff4f;
  --blue: #365be8;
  --blue-soft: #eef1ff;
  --peach: #fff0e5;
  --danger: #b34141;
  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; }
html, body { min-height: 100%; margin: 0; background: var(--bg); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.launch-state { display: grid; min-height: 100vh; place-content: center; justify-items: center; padding: 28px; text-align: center; }
.launch-state h1 { margin: 8px 0 4px; font-size: 30px; letter-spacing: -.04em; }
.launch-state p { max-width: 330px; margin: 0; color: var(--muted); line-height: 1.45; }
.launch-mark { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 18px; background: var(--lime); font-size: 30px; }
.miniapp { min-height: 100vh; padding: 18px 14px 88px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topbar h1 { margin: 0; font-size: 29px; font-weight: 560; letter-spacing: -.045em; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; gap: 7px; }
.tabs { position: sticky; z-index: 20; top: env(safe-area-inset-top); display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; margin-bottom: 12px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(246,247,241,.94); backdrop-filter: blur(12px); }
.tabs button { min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 680; }
.tabs button.active { background: var(--text); color: #fff; }
.button { min-height: 40px; border: 1px solid var(--line); border-radius: 11px; padding: 9px 13px; background: #fff; font-weight: 680; }
.button.primary { border-color: var(--text); background: var(--text); color: #fff; }
.button.ghost { background: transparent; }
.button.danger { border-color: #efb5ae; color: var(--danger); }
.button.small { min-height: 34px; padding: 7px 10px; font-size: 11px; }
.button:disabled { opacity: .45; cursor: default; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.panel { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: var(--card); box-shadow: 0 8px 30px rgba(30,36,28,.025); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0 0 3px; font-size: 16px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 10px; }
.pill { flex: 0 0 auto; border-radius: 999px; padding: 6px 9px; background: var(--soft); font-size: 10px; font-weight: 750; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .wide { grid-column: 1 / -1; }
label { display: flex; gap: 5px; flex-direction: column; }
label > span { color: var(--muted); font-size: 10px; font-weight: 680; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px; outline: none; background: #fff; }
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(54,91,232,.1); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { display: flex; min-height: 102px; justify-content: center; flex-direction: column; border-radius: 15px; padding: 13px; background: var(--soft); }
.kpi:nth-child(1) { background: #eff4ff; }
.kpi:nth-child(2) { background: #f0f8dd; }
.kpi span { color: var(--muted); font-size: 9px; font-weight: 760; text-transform: uppercase; letter-spacing: .06em; }
.kpi strong { margin: 7px 0 2px; font-size: 24px; line-height: 1; }
.kpi small { color: var(--muted); font-size: 9px; }
.heat-scroll { overflow-x: auto; padding: 4px 0; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7,13px); grid-auto-columns: 13px; gap: 4px; min-width: 440px; }
.heat { width: 13px; height: 13px; border-radius: 4px; background: #eceee8; }
.heat.l1 { background: #e7f7b7; }.heat.l2 { background: #cff172; }.heat.l3 { background: #9bd444; }.heat.l4 { background: #4e8d49; }
.rank-list, .client-list, .catalog-list, .workout-list { display: flex; flex-direction: column; }
.rank-row, .client-row, .catalog-row { display: grid; gap: 9px; align-items: center; min-height: 58px; border: 0; border-top: 1px solid #eceee8; padding: 9px 0; background: transparent; text-align: left; }
.rank-row { grid-template-columns: 24px minmax(0,1fr) auto; }
.rank-row small, .client-row small, .catalog-row small { color: var(--muted); font-size: 9px; }
.rank-count { border-radius: 10px; padding: 6px 8px; background: var(--blue-soft); color: var(--blue); font-size: 10px; font-weight: 760; }
.client-row { grid-template-columns: 42px minmax(0,1fr) auto; }
.client-row.selected { margin: 0 -8px; border-left: 3px solid var(--blue); padding-right: 8px; padding-left: 5px; background: #f1f3ff; }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; background: #e2f3eb; font-weight: 760; }
.client-name { display: flex; min-width: 0; flex-direction: column; }
.client-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-number { min-width: 56px; border-radius: 12px; padding: 8px; background: var(--lime); text-align: center; font-size: 11px; font-weight: 760; }
.workout-card { margin-top: 9px; border: 1px solid var(--line); border-radius: 15px; padding: 13px; }
.workout-title { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.workout-title small { color: var(--muted); }
.phase { margin-top: 7px; border-radius: 12px; padding: 10px; background: var(--blue-soft); }
.phase.activation { background: #f0f8dd; }
.phase span { display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; }
.phase strong { font-size: 12px; }
.phase small { display: block; color: var(--muted); font-size: 9px; }
.card-actions, .form-actions, .inline-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.card-actions { flex-wrap: wrap; }
.photo-button { display: inline-flex; align-items: center; cursor: pointer; }
.photo-button input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.media-gallery { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 10px; }
.media-gallery a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--soft); }
.media-gallery img { width: 100%; height: 100%; object-fit: cover; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.form-grid .wide { grid-column: 1 / -1; }
.main-row { display: grid; grid-template-columns: 1fr 34px; gap: 7px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.main-row select { grid-column: 1 / 2; }
.main-row .remove { grid-column: 2; grid-row: 1 / 3; border: 0; background: transparent; color: var(--danger); font-size: 23px; }
.quick-add { display: flex; gap: 7px; flex-wrap: wrap; }
.quick-add input { flex: 1 1 150px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.chip { border: 0; border-radius: 999px; padding: 6px 8px; background: var(--soft); font-size: 10px; }
.client-chip { display: inline-flex; overflow: hidden; border-radius: 999px; background: var(--soft); }
.client-chip .chip { border-radius: 0; }
.chip-archive { width: 28px; border: 0; border-left: 1px solid #d9dcd3; background: #f8e8e5; color: var(--danger); font-size: 16px; }
.catalog-row { grid-template-columns: 58px minmax(0,1fr) auto; }
.catalog-row code { color: var(--muted); font-size: 9px; }
.import-result { margin-top: 9px; border-radius: 10px; padding: 9px; background: #edf8d2; font-size: 10px; }
.import-result.bad { background: #ffe9e6; color: #9c3838; }
.empty { display: grid; min-height: 110px; place-content: center; color: var(--muted); text-align: center; font-size: 11px; }
.toast { position: fixed; z-index: 100; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); left: 12px; border: 1px solid #efb5ae; border-radius: 13px; padding: 12px; background: #fff2f0; color: #91352f; box-shadow: 0 12px 40px rgba(0,0,0,.15); font-size: 12px; }
.toast.ok { border-color: #bad877; background: #f0f8dd; color: #355022; }
.spinner { display: grid; min-height: 250px; place-items: center; color: var(--muted); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 7px; }
.section-title strong { font-size: 12px; }
@media (min-width: 760px) {
  .miniapp { max-width: 980px; margin: 0 auto; padding: 24px 24px 80px; }
  .overview-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
  .overview-grid .panel { margin-bottom: 0; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-grid { grid-template-columns: repeat(3,1fr); }
  .form-grid .wide { grid-column: span 2; }
}
