/* «Фокус» — в духе iOS (Apple HIG), как «Здоровье»: системные цвета и слои, списки inset grouped, только светлая тема,
   шрифт растёт с настройкой «Размер текста» iOS (-apple-system-body + rem), цели нажатия от 44 pt.
   Размеры шрифта — четыре: 2.1rem (главная цифра), 1rem (основной), .88rem (вторичный), .765rem (подписи). */
:root {
  color-scheme: light;
  --bg: #f2f2f7;               /* systemGroupedBackground */
  --cell: #ffffff;             /* secondarySystemGroupedBackground */
  --cell-pressed: #e5e5ea;
  --bar: rgba(242, 242, 247, .86);
  --label: #000;
  --label2: rgba(60, 60, 67, .6);
  --label3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .18);
  --fill: rgba(118, 118, 128, .12);
  --tint: #007aff;             /* systemBlue — управление и «заработано» */
  --tint-soft: rgba(0, 122, 255, .12);
  --wait: rgba(0, 122, 255, .45);
  --green: #34c759; --green-text: #248a3d; --green-soft: rgba(52, 199, 89, .15);
  --orange: #ff9500; --red: #ff3b30; --red-soft: rgba(255, 59, 48, .12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; font-size: 17px; line-height: 1.3; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
body { margin: 0; background: var(--bg); color: var(--label); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 6px; }
.ic { width: 1.35rem; height: 1.35rem; flex: none; }
.ic.sm { width: 1rem; height: 1rem; }
.muted { color: var(--label2); }
.pad { padding: 16px; }

/* ---------- шапка: крупный заголовок, переключатель, статус ---------- */
header.top { position: sticky; top: 0; z-index: 5; padding: env(safe-area-inset-top) 16px 8px;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; min-height: 52px; }
h1 { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: .01em; }
.icon-btn { width: 44px; height: 44px; margin-right: -10px; display: grid; place-items: center; color: var(--tint); }
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin-top: 8px; }
.seg button { flex: 1; min-height: 32px; border-radius: 7px; font-size: .88rem; font-weight: 600; color: var(--label); }
.seg button.on { background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.status { display: flex; align-items: center; gap: 6px; min-height: 24px; margin-top: 6px; font-size: .765rem; color: var(--label2); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.status.warn i { background: var(--orange); }
.status.off i { background: var(--label3); }
.status.off { color: var(--label); }

main { padding: 16px 16px calc(env(safe-area-inset-bottom) + 104px); max-width: 640px; margin: 0 auto; }

/* ---------- главная карточка ---------- */
.card, .hero { background: var(--cell); border-radius: 12px; }
.card { padding: 12px 16px; }
.hero { padding: 16px 16px 14px; margin-bottom: 24px; }
.cap { font-size: .765rem; color: var(--label2); }
.hero-num { margin-top: 4px; font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.hero-num span { font-size: 1rem; font-weight: 600; letter-spacing: 0; color: var(--label2); }
.hero-num.ok { color: var(--green-text); font-size: 1.6rem; }
.hero-sub { margin-top: 2px; font-size: .88rem; color: var(--label2); }
.hero-foot { margin-top: 12px; font-size: .765rem; color: var(--label2); }
.empty-state { padding: 24px 16px; text-align: center; color: var(--label2); }

.bar { position: relative; display: flex; height: 12px; margin-top: 16px; border-radius: 6px; background: var(--fill); overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar .e { background: var(--tint); }
.bar .w { background: var(--wait); }
.bar .p { background: repeating-linear-gradient(-45deg, rgba(0, 122, 255, .3) 0 4px, rgba(0, 122, 255, .1) 4px 8px); }
.bar .mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--label); opacity: .7; }
.bar-legend { position: relative; height: 18px; margin-top: 4px; font-size: .765rem; color: var(--label2); }
.bar-legend span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stats.two { grid-template-columns: repeat(2, 1fr); margin-top: 0; }
.stats b { display: block; font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats small { display: flex; align-items: center; gap: 5px; font-size: .765rem; color: var(--label2); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.e { background: var(--tint); } .dot.w { background: var(--wait); }
.dot.p { background: repeating-linear-gradient(-45deg, rgba(0, 122, 255, .55) 0 2px, rgba(0, 122, 255, .15) 2px 4px); }

.pill { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; padding: 4px 10px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; }
.pill.behind { background: var(--red-soft); color: var(--red); }
.pill.ahead, .pill.ok { background: var(--green-soft); color: var(--green-text); }

/* ---------- списки inset grouped ---------- */
.group { margin: 0 0 24px; }
.group-h { margin: 0 0 6px; padding: 0 16px; font-size: .765rem; font-weight: 400; color: var(--label2); text-transform: uppercase; }
.rows { background: var(--cell); border-radius: 12px; overflow: hidden; }
.rows + .rows, .card + .rows { margin-top: 12px; }
.row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; }
.row + .row::before, .deal + .deal::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); }
.row:has(.sq) + .row::before { left: 58px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .765rem; color: var(--label2); }
.row-sub.late { color: var(--red); }
.row-value { color: var(--label2); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: .88rem; }
.row-value.strong { color: var(--label); font-weight: 600; font-size: 1rem; }
.sq { width: 30px; height: 30px; flex: none; border-radius: 7px; display: grid; place-items: center; color: #fff; }
.sq .ic { width: 19px; height: 19px; }

.chart-card { padding: 12px 12px 8px; }
svg.chart { width: 100%; height: 140px; display: block; }
.axis { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: .765rem; color: var(--label2); }
.axis .key { display: inline-flex; align-items: center; gap: 5px; }
.axis .key i { display: inline-block; width: 14px; height: 0; border-top: 3px solid var(--tint); border-radius: 2px; }
.axis .key i.k-l { border-top: 2px dashed var(--label3); margin-left: 6px; }

/* ---------- предложения ---------- */
.week .mini { height: 6px; margin: 12px 0 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.week .mini i { display: block; height: 100%; background: var(--tint); border-radius: 3px; }
.deal { position: relative; padding: 10px 16px; }
.deal-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal-bot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.deal-bot .row-sub { flex: 1; min-width: 0; }
.acts { display: flex; gap: 8px; flex: none; }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 64px; min-height: 44px;
  padding: 0 14px; border-radius: 22px; font-size: .88rem; font-weight: 600; }
.chip.yes { background: var(--green-soft); color: var(--green-text); }
.chip.no { background: var(--fill); color: var(--label2); }
.chip:active { opacity: .6; }
.row.more { width: 100%; justify-content: center; min-height: 48px; color: var(--tint); font-weight: 600; }
.row.more::before, .deal + .row.more::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); }
.tag { flex: none; padding: 4px 10px; border-radius: 999px; font-size: .765rem; font-weight: 600; background: var(--green-soft); color: var(--green-text); }

/* ---------- главная кнопка — в зоне большого пальца ---------- */
.cta-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 60%, rgba(242, 242, 247, 0)); }
.cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; max-width: 608px; margin: 0 auto;
  min-height: 52px; border-radius: 14px; background: var(--tint); color: #fff; font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 122, 255, .28), inset 0 1px 0 rgba(255, 255, 255, .25); }
.cta:active { opacity: .85; transform: scale(.985); }

/* ---------- шторка: как модальное окно iOS (Отмена — заголовок — Готово) ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .3); }
.sheet { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 12px); bottom: 0; overflow-y: auto;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 24px); background: var(--bg); border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .12); }
.grabber { width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: var(--label3); }
.sheet-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 52px; margin-bottom: 8px; }
.sheet-nav b { font-weight: 600; }
.nav-btn { justify-self: start; min-height: 44px; color: var(--tint); }
.nav-btn.strong { justify-self: end; font-weight: 600; }
.rows.form { margin-bottom: 16px; }
.row.field { cursor: text; min-height: 48px; }
.row.field .lbl { width: 4.6em; flex: none; }
.row.field input { flex: 1; min-width: 0; min-height: 32px; border: 0; outline: 0; background: none; font-size: 1rem; }
.row.field input::placeholder { color: var(--label3); }
.row.field input.end { text-align: right; }
.row.field .unit { color: var(--label2); }
.seg.kind { margin: 0 0 16px; }
.sheet-note { margin: 0 16px; font-size: .765rem; color: var(--label2); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 30;
  padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, .8); color: #fff; font-size: .88rem; }
