/* Дом — общий стиль. Светлая и тёмная тема через переменные. */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f6f2;
  --text: #1d1b18;
  --muted: #76716a;
  --line: #e6e1d9;
  --accent: #2f6f5e;
  --accent-soft: #e2efe9;
  --accent-text: #ffffff;
  --warn: #b5562b;
  --warn-soft: #f8e6dc;
  --c1: #2f6f5e;
  --c2: #c9772f;
  --c3: #5864a8;
  --c4: #a8456a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 27, 24, .05), 0 4px 16px rgba(29, 27, 24, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1e1d1a;
    --surface-2: #262420;
    --text: #efebe4;
    --muted: #9b958c;
    --line: #34312c;
    --accent: #6cbfa5;
    --accent-soft: #1f3530;
    --accent-text: #0f1f1a;
    --warn: #e59167;
    --warn-soft: #3a261c;
    --c1: #6cbfa5;
    --c2: #e3a065;
    --c3: #94a0e6;
    --c4: #e086a8;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 18px; letter-spacing: -.01em; }
h3 { font-size: 15px; }
p { margin: 0; }

.page { max-width: 760px; margin: 0 auto; padding: 16px 16px 24px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 0 16px;
}
.page-head .back { font-size: 15px; display: inline-block; margin-bottom: 4px; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Карточки */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card--flush { padding: 0; overflow: hidden; }
.card--accent { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.card--accent .muted { color: inherit; opacity: .75; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value { font-size: 20px; font-weight: 650; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li, .list > a { display: block; padding: 12px 16px; border-top: 1px solid var(--line); color: inherit; }
.list > :first-child { border-top: 0; }
a.list-item:active { background: var(--surface-2); }

/* Прогресс */
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.card--accent .bar { background: rgba(255,255,255,.25); border-color: transparent; }
.card--accent .bar__fill { background: var(--accent-text); }
.bar__fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar--warn .bar__fill { background: var(--warn); }

/* Кнопки и формы */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn--danger { color: var(--warn); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn-round { width: 44px; padding: 0; font-size: 22px; }

.field { display: block; }
.field + .field { margin-top: 12px; }
.field > span, .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 17px; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=file] { font-size: 14px; }
.inputs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inputs-2 .field + .field { margin-top: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-actions .btn { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.errors { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* Сообщения */
.flash { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.flash--notice { background: var(--accent-soft); color: var(--accent); }
.flash--alert { background: var(--warn-soft); color: var(--warn); }

/* Нижнее меню */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__inner { display: flex; width: 100%; max-width: 560px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab__icon { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab__icon { filter: none; opacity: 1; }

/* Переключатели */
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented__item { flex: 1; text-align: center; padding: 7px 10px; border-radius: 9px; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); font-weight: 600; }
.badge--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

.chart { position: relative; width: 100%; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* Ссылки на сервисы */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.service { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-weight: 600; }
.service__icon { font-size: 22px; }

/* Зал */
.thumb { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--surface-2); flex: none; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 1px solid var(--line); }
.photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius); }
.sets { display: flex; flex-wrap: wrap; gap: 6px; }
.set { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.set--pending { border-style: dashed; opacity: .75; }
.set__del { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 0 0 0 2px; cursor: pointer; line-height: 1; }
.logger { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5; }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; align-items: center; }
.stepper input { text-align: center; font-weight: 700; font-size: 20px; padding: 8px 4px; }
.timer { font-size: 28px; font-weight: 700; letter-spacing: .02em; }
.timer-card[hidden] { display: none; }
.prev-hint { font-size: 14px; color: var(--muted); min-height: 20px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.status-dot--off { background: var(--warn); }
.week-dots { display: flex; gap: 4px; align-items: flex-end; height: 40px; }
.week-dots span { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; opacity: .85; }
.week-dots span.zero { background: var(--line); }

table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-weight: 600; color: var(--muted); font-size: 12px; border-top: 0; }
.table-scroll { overflow-x: auto; }
.delta-up { color: var(--accent); }
.delta-down { color: var(--warn); }

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 380px; }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.center { text-align: center; }
.set--error { border-color: var(--warn); color: var(--warn); }

/* Плитки сервисов на главной */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px; min-height: 128px;
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--text); -webkit-tap-highlight-color: transparent;
}
.tile:active { transform: scale(.98); }
.tile__head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tile__icon { font-size: 26px; line-height: 1; }
.tile__name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__value { font-size: 20px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__ext { color: var(--accent); }
.tile--add { align-items: center; justify-content: center; gap: 4px; border-style: dashed; box-shadow: none; background: transparent; color: var(--muted); }
.tile--add span:first-child { font-size: 26px; }
.tab__label { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn:disabled { opacity: .35; cursor: default; }
input[type=url] { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 17px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.list > li.row, .list > a.row { display: flex; align-items: center; gap: 8px; }
