/* Стиль по мотивам iOS: «Здоровье» в светлой теме, «Фитнес» в тёмной. */
:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --fill: #F2F2F7;
  --fill-2: rgba(120, 120, 128, .12);
  --label: #000000;
  --label-2: rgba(60, 60, 67, .62);
  --label-3: rgba(60, 60, 67, .40);
  --sep: rgba(60, 60, 67, .18);
  --blue: #007AFF;          /* оклейка */
  --green: #28A745;         /* опт, отметки */
  --green-text: #248A3D;
  --orange: #FF9500;        /* предупреждения */
  --orange-text: #C93400;
  --red-text: #D70015;
  --ring-total: #000000;
  --ring-track-total: rgba(0, 0, 0, .08);
  --ring-track-blue: rgba(0, 122, 255, .14);
  --ring-track-green: rgba(40, 167, 69, .16);
  --value-total: var(--label);
  --value-blue: var(--label);
  --value-green: var(--label);
  --nav-bg: rgba(242, 242, 247, .82);
  --gutter: 16px;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1C1C1E; --fill: #2C2C2E; --fill-2: rgba(118, 118, 128, .24);
    --label: #FFFFFF; --label-2: rgba(235, 235, 245, .62); --label-3: rgba(235, 235, 245, .32); --sep: rgba(84, 84, 88, .55);
    --blue: #0A84FF; --green: #22B04B; --green-text: #30D158; --orange: #FF9F0A; --orange-text: #FF9F0A; --red-text: #FF6961;
    --ring-total: #FFFFFF; --ring-track-total: rgba(255, 255, 255, .14); --ring-track-blue: rgba(10, 132, 255, .24); --ring-track-green: rgba(48, 209, 88, .22);
    --value-total: #FFFFFF; --value-blue: #4DA3FF; --value-green: #30D158;
    --nav-bg: rgba(0, 0, 0, .78); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1C1C1E; --fill: #2C2C2E; --fill-2: rgba(118, 118, 128, .24);
  --label: #FFFFFF; --label-2: rgba(235, 235, 245, .62); --label-3: rgba(235, 235, 245, .32); --sep: rgba(84, 84, 88, .55);
  --blue: #0A84FF; --green: #22B04B; --green-text: #30D158; --orange: #FF9F0A; --orange-text: #FF9F0A; --red-text: #FF6961;
  --ring-total: #FFFFFF; --ring-track-total: rgba(255, 255, 255, .14); --ring-track-blue: rgba(10, 132, 255, .24); --ring-track-green: rgba(48, 209, 88, .22);
  --value-total: #FFFFFF; --value-blue: #4DA3FF; --value-green: #30D158;
  --nav-bg: rgba(0, 0, 0, .78); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px; line-height: 1.3; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.n { font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.unit { font-size: .58em; font-weight: 600; color: var(--label-2); margin-left: 3px; letter-spacing: 0; }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.login-icon { width: 76px; height: 76px; border-radius: 18px; margin-bottom: 8px; }
.login-card h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { color: var(--label-2); font-size: 15px; margin-bottom: 14px; }
.input { width: 100%; font: inherit; font-size: 17px; color: var(--label); background: var(--card); border: 0; border-radius: 12px; padding: 14px 16px; outline: none; text-align: center; }
.input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent); }
.btn-primary { width: 100%; border: 0; border-radius: 12px; padding: 14px 16px; font-weight: 600; font-size: 17px; background: var(--blue); color: #fff; cursor: pointer; }
.btn-primary:disabled { opacity: .5; }
.form-error { color: var(--red-text); font-size: 15px; min-height: 20px; }

/* ---------- навбар ---------- */
.navbar { position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: .5px solid transparent; transition: border-color .2s; }
.navbar.scrolled { border-bottom-color: var(--sep); }
.navbar-inner { max-width: 1080px; margin: 0 auto; height: 50px; display: grid; grid-template-columns: 44px 1fr 44px 44px; align-items: center; padding: 0 8px; }
.nav-title { text-align: center; font-size: 17px; font-weight: 600; opacity: 0; transition: opacity .2s; }
.navbar.scrolled .nav-title { opacity: 1; }
.nav-btn { width: 44px; height: 44px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--blue); border-radius: 50%; }
.nav-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn:disabled { color: var(--label-3); cursor: default; }
.refresh.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- страница ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter) calc(env(safe-area-inset-bottom) + 32px); }
.large-title { padding: 2px 4px 14px; }
.overline { font-size: 13px; font-weight: 600; color: var(--label-2); letter-spacing: .02em; }
.large-title h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; margin-top: 2px; }
.status { font-size: 15px; color: var(--label-2); margin-top: 4px; display: flex; align-items: center; gap: 7px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.status .dot.stale { background: var(--orange); }
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)) 18px; padding: 0 var(--gutter); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; font-size: 15px; font-weight: 600; padding: 8px 14px; border-radius: 999px; background: var(--fill-2); color: var(--label); }
.banner { margin-bottom: 14px; padding: 12px 14px; border-radius: var(--radius); background: color-mix(in srgb, var(--orange) 16%, var(--card)); color: var(--label); font-size: 15px; }
main { display: grid; gap: 30px; }
.footer { margin-top: 30px; font-size: 13px; color: var(--label-2); display: grid; gap: 8px; padding: 0 4px; }
.footer a { color: var(--blue); }
.linklike { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font-size: 13px; }

/* ---------- секции и карточки ---------- */
.section { display: grid; gap: 10px; align-content: start; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.section-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.section-head .aside { font-size: 15px; color: var(--label-2); text-align: right; }
.grid { display: grid; gap: 10px; }
.two { grid-template-columns: 1fr 1fr; }
@media (min-width: 820px) {
  .wide-2 { grid-template-columns: 1fr 1fr; }
  .wide-3 { grid-template-columns: repeat(3, 1fr); }
  .wide-4 { grid-template-columns: repeat(4, 1fr); }
  main { gap: 36px; }
}
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 600; }
.card-title svg { width: 18px; height: 18px; flex: none; }
.card-meta { font-size: 15px; color: var(--label-2); white-space: nowrap; }
.c-blue { color: var(--blue); } .c-green { color: var(--green-text); } .c-orange { color: var(--orange-text); } .c-red { color: var(--red-text); } .c-label { color: var(--label); }
.c-2 { color: var(--label-2); }
.value { font-size: 34px; font-weight: 700; line-height: 1.05; }
.value-m { font-size: 26px; font-weight: 700; line-height: 1.1; }
.value-s { font-size: 22px; font-weight: 700; line-height: 1.1; }
.sub { font-size: 15px; color: var(--label-2); margin-top: 4px; }
.foot { font-size: 13px; color: var(--label-2); padding: 0 4px; line-height: 1.4; }

/* ---------- кольца ---------- */
.rings-card { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 18px 16px; }
.rings { width: 132px; height: 132px; display: block; }
.rings circle { fill: none; stroke-linecap: round; }
.ring-list { display: grid; gap: 10px; min-width: 0; }
.ring-item .k { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ring-item .v { font-size: 24px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.ring-item .v small { font-size: 15px; font-weight: 600; color: var(--label-2); margin-left: 2px; }
.v-total { color: var(--value-total); } .v-blue { color: var(--value-blue); } .v-green { color: var(--value-green); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.total { background: var(--ring-total); } .dot.blue { background: var(--blue); } .dot.green { background: var(--green); } .dot.orange { background: var(--orange); }
@media (max-width: 370px) { .rings { width: 112px; height: 112px; } .ring-item .v { font-size: 21px; } }
@media (min-width: 820px) { .rings-card { padding: 24px; gap: 32px; } .rings { width: 170px; height: 170px; } .ring-list { grid-template-columns: repeat(3, 1fr); } .ring-item .v { font-size: 28px; } }

/* ---------- прогресс ---------- */
.progress { position: relative; height: 8px; border-radius: 4px; background: var(--fill-2); margin: 12px 0 8px; }
.progress > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--label); }
.progress.blue > i { background: var(--blue); } .progress.green > i { background: var(--green); }
.progress .mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--orange); }
.legend-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--label-2); }

/* ---------- список как в iOS ---------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list.in-card { background: transparent; border-radius: 0; margin: 0 -16px -16px; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 11px 16px; min-height: 48px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
.row.has-lead + .row.has-lead::before { left: 40px; }
.row .lead { width: 12px; display: grid; place-items: center; }
.row:not(.has-lead) { grid-template-columns: 1fr auto; }
.row:not(.has-lead) .lead { display: none; }
.row .main { min-width: 0; }
.row .t { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 14px; color: var(--label-2); margin-top: 2px; line-height: 1.3; }
.row .r { text-align: right; font-size: 17px; font-weight: 600; white-space: nowrap; }
.row .r small { display: block; font-size: 13px; font-weight: 400; color: var(--label-2); }
a.row { cursor: pointer; }
a.row:active { background: var(--fill-2); }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 16px; position: relative; font-size: 17px; }
.kv-row + .kv-row::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
.kv-row .k { color: var(--label); }
.kv-row .k small { display: block; font-size: 13px; color: var(--label-2); margin-top: 1px; }
.kv-row .v { font-weight: 600; white-space: nowrap; text-align: right; }
.kv-row.total { font-weight: 700; }
.badge { display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 6px; margin-right: 6px; }
.badge.blue { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.badge.green { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green-text); }
.badge.orange { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange-text); }
.badge.gray { background: var(--fill-2); color: var(--label-2); }
.empty { padding: 14px 16px; color: var(--label-2); font-size: 15px; }

/* ---------- графики ---------- */
.chart-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; min-height: 64px; }
.chart-top .cap { font-size: 13px; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .02em; }
.chart-top .val { font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.chart-top .when { font-size: 15px; color: var(--label-2); margin-top: 2px; }
.chart-split { display: grid; gap: 2px; font-size: 15px; font-weight: 600; text-align: right; }
.chart-split span { display: flex; align-items: center; gap: 6px; justify-content: flex-end; white-space: nowrap; }
svg.chart { display: block; width: 100%; height: auto; margin-top: 10px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .gl { stroke: var(--sep); stroke-width: 1; }
.chart .ax { fill: var(--label-2); font-size: 12px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.chart .bw { fill: var(--blue); } .chart .bo { fill: var(--green); }
.chart .today-bar { opacity: .4; }
.chart .dim { opacity: .3; }
.chart .avg { stroke: var(--label-2); stroke-width: 1.5; stroke-dasharray: 3 4; }
.chart .cum { fill: none; stroke: var(--label); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: var(--label); opacity: .06; }
.chart .plan { fill: none; stroke: var(--orange); stroke-width: 2; stroke-dasharray: 5 5; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .cursor { stroke: var(--label-3); stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--label-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .ln { width: 16px; height: 3px; border-radius: 2px; background: var(--label); }
.chart-legend .ds { width: 16px; border-top: 2px dashed var(--orange); }
.chart-legend .da { width: 16px; border-top: 2px dashed var(--label-2); }
.chart-legend .sq { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- прочее ---------- */
.insight { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.insight .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; }
.insight .ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.insight h3 { font-size: 17px; font-weight: 600; }
.insight p { font-size: 15px; color: var(--label-2); margin-top: 4px; line-height: 1.4; }
.lock-form { display: grid; gap: 10px; margin-top: 12px; }
.lock-form .input { text-align: left; background: var(--fill); }
details.more > summary { list-style: none; cursor: pointer; padding: 12px 16px; color: var(--blue); font-size: 17px; position: relative; }
details.more > summary::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
details.more > summary::-webkit-details-marker { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px; font-size: 15px; position: relative; }
.check + .check::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
.check svg { width: 20px; height: 20px; flex: none; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
