:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1d21;
  --muted: #8a8f98;
  --line: #e7e9ee;
  --brand: #2f6fed;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --warn: #f59e0b;
  --warn-soft: #fdf2e0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 23, 33, 0.04), 0 6px 20px rgba(20, 23, 33, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 14px 48px;
}

/* ---------- Шапка ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 14px 0 10px;
}

.header h1 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 13px;
}

select#apartment {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 40px 13px 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ---------- Общий прогресс ---------- */
.overall {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.overall-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.overall-top .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.overall-top .pct { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }

.bar {
  height: 9px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #5b8def);
  transition: width 0.35s ease;
}

.chips {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}

.chip b { color: var(--text); }
.chip.delivered b { color: var(--warn); }
.chip.installed b { color: var(--ok); }

/* ---------- Этапы (аккордеон) ---------- */
.stages { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }

.stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stage-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}

.stage-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--accent-soft);
}

.stage-meta { flex: 1; min-width: 0; }

.stage-meta .step {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
}

.stage-meta .title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.stage-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.stage-mini .bar { flex: 1; height: 6px; }
.stage-mini .bar > span { background: var(--accent); }
.stage-mini .pct { font-size: 12px; font-weight: 700; color: var(--accent); min-width: 34px; text-align: right; }

.chevron { color: var(--muted); font-size: 14px; transition: transform 0.25s ease; }
.stage.open .chevron { transform: rotate(90deg); }

.stage-body { display: none; padding: 0 16px 8px; }
.stage.open .stage-body { display: block; }

/* ---------- Категории ---------- */
.category { padding-top: 6px; }

.category-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 2px 8px;
}

/* ---------- Позиция ---------- */
.item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.thumb {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 12px;
  background: var(--bg) center/cover no-repeat;
  border: 1px dashed var(--line);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.thumb.has-photo { border-style: solid; border-color: var(--line); }

.thumb.icon-thumb {
  background-color: var(--accent-soft);
  border-style: solid;
  border-color: transparent;
}
.thumb.icon-thumb .ic { font-size: 26px; line-height: 1; }
.thumb .cam {
  position: absolute;
  right: 2px;
  bottom: 2px;
  font-size: 11px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border-radius: 6px;
  padding: 1px 3px;
  line-height: 1;
}

.item-main { flex: 1; min-width: 0; }
.item-name { font-size: 14.5px; font-weight: 600; margin-bottom: 8px; }
.item.done .item-name { color: var(--muted); }

.toggles { display: flex; gap: 8px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle.on.delivered { background: var(--warn-soft); border-color: var(--warn); color: #b4760a; }
.toggle.on.installed { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

/* ---------- Подвал ---------- */
.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }
.reset {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
