* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f2f2f7;
  color: #111;
  min-height: 100vh;
}

/* ── Шапка ── */
.topbar {
  position: sticky; top: 0;
  background: #fff;
  border-bottom: 1px solid #e5e5ea;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  z-index: 10;
}
.topbar-back {
  background: none; border: none;
  font-size: 26px; color: #007aff;
  cursor: pointer; line-height: 1; padding: 0 2px;
}
.topbar-title { font-size: 16px; font-weight: 700; flex: 1; }

/* ── Сторінки ── */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* ── Головне меню ── */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
.menu-tile {
  background: #fff;
  border-radius: 16px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: none;
  width: 100%;
  position: relative;
}
.menu-tile:active { opacity: .7; }
.menu-tile-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.menu-tile-label { font-size: 14px; font-weight: 600; color: #111; }

/* ── Списки ── */
.list-card {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 12px;
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: #f5f5f5; }
.list-item-label { font-size: 15px; }
.list-arrow { font-size: 16px; color: #c7c7cc; }

/* ── Місяці ── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.month-btn {
  background: #fff; border: none;
  border-radius: 12px; padding: 16px 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.month-btn:active { background: #007aff; color: #fff; }

/* ── Деталі аналітики ── */
.detail-header {
  background: #fff; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.detail-obj  { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.detail-meta { font-size: 13px; color: #888; }
.total-box {
  background: #007aff; color: #fff;
  border-radius: 12px; padding: 12px 16px;
  margin-bottom: 12px;
  display: flex; justify-content: space-between;
  font-size: 15px; font-weight: 600;
}
.control-row {
  background: #fff; border-radius: 12px;
  padding: 12px 16px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.control-name  { font-size: 13px; color: #333; flex: 1; margin-right: 10px; }
.control-count { font-size: 15px; font-weight: 700; color: #007aff; min-width: 28px; text-align: right; }

/* ── Форма перевірки ── */
.section-label {
  font-size: 12px; color: #8e8e93;
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 8px; margin-top: 4px;
}
.check-group { margin-bottom: 16px; }
.check-group-title {
  font-size: 13px; font-weight: 700;
  color: #007aff; margin-bottom: 6px; padding: 0 4px;
}
.check-item {
  display: flex; align-items: center;
  gap: 12px; padding: 11px 16px;
  background: #fff; border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.check-item:first-of-type { border-radius: 14px 14px 0 0; }
.check-item:last-of-type  { border-radius: 0 0 14px 14px; border-bottom: none; }
.check-item:only-of-type  { border-radius: 14px; border-bottom: none; }
.check-item:active { background: #f5f5f5; }
.check-box {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 6px; border: 2px solid #c7c7cc;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all .15s;
}
.check-box.checked { background: #007aff; border-color: #007aff; color: #fff; }
.check-label { font-size: 14px; color: #111; flex: 1; }

.input-field {
  width: 100%; padding: 13px 16px;
  font-size: 15px; border: none;
  border-radius: 12px; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  outline: none; margin-bottom: 12px;
}
textarea.input-field { resize: vertical; min-height: 80px; }

.submit-btn {
  width: 100%; padding: 15px;
  background: #007aff; color: #fff;
  border: none; border-radius: 14px;
  font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
}
.submit-btn:disabled { opacity: .5; cursor: default; }
.submit-btn:active:not(:disabled) { opacity: .85; }

/* ── Успіх ── */
.success-screen { text-align: center; padding: 40px 16px; }
.success-icon { font-size: 64px; margin-bottom: 16px; }
.success-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.success-sub { font-size: 14px; color: #888; margin-bottom: 32px; }
.success-btn {
  padding: 14px 32px; background: #007aff; color: #fff;
  border: none; border-radius: 14px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ── Фото ── */
.photos-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.photo-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 10px; }
.photo-item { position: relative; }
.photo-del {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #ff3b30; color: #fff; border: none;
  font-size: 13px; line-height: 20px; text-align: center;
  cursor: pointer; padding: 0;
}
.add-photo-btn {
  padding: 0 14px; height: 44px; border-radius: 10px;
  border: 2px dashed #c7c7cc; background: #fff;
  font-size: 14px; cursor: pointer; color: #636366;
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap;
}

/* ── Sampling choices ── */
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.choice-btn {
  padding: 8px 14px; border-radius: 20px; border: 2px solid #e5e5ea;
  background: #fff; font-size: 14px; cursor: pointer; transition: all .15s;
  color: #1c1c1e;
}
.choice-btn.active { background: #007aff; color: #fff; border-color: #007aff; }
.samp-labrep-item {
  padding: 12px 16px; border-bottom: 1px solid #f2f2f7;
  cursor: pointer; font-size: 14px;
}
.samp-labrep-item:last-child { border-bottom: none; }
.samp-labrep-item:hover { background: #f2f2f7; }

/* ── Загальне ── */
.loader { text-align: center; padding: 50px; opacity: .5; font-size: 15px; }
.empty  { text-align: center; padding: 50px; opacity: .4; font-size: 14px; }

/* ── Charts ── */
#a-groups-chart { max-height: 340px; }
#a-summary-chart { max-height: 260px; }
#a1-chart { max-height: 200px; }
#a2-chart { width: 100%; }

/* ── Місяць-стрічка ── */
.month-strip {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px;
  margin-bottom: 12px; scrollbar-width: none;
}
.strip-btn {
  flex-shrink: 0; padding: 5px 12px; border-radius: 16px;
  border: 1.5px solid #e5e5ea; background: #fff;
  font-size: 13px; cursor: pointer; color: #1c1c1e; white-space: nowrap;
}
.strip-btn.active { background: #007aff; color: #fff; border-color: #007aff; }

/* ── Акордеон ── */
.accord-item {
  background: #fff; border-radius: 12px;
  margin-bottom: 8px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.accord-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; cursor: pointer; user-select: none;
}
.accord-name { font-size: 14px; font-weight: 600; }
.accord-arrow { font-size: 18px; color: #8e8e93; transition: transform 0.2s; display: inline-block; }
.accord-body { border-top: 1px solid #f2f2f7; }
.accord-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid #f2f2f7; font-size: 13px;
}
.accord-row:last-child { border-bottom: none; }
.accord-ctrl-name { color: #3a3a3c; flex: 1; padding-right: 12px; }

/* ── Кнопки чернеток / лічильники ── */
.draft-btn {
  flex: 1; padding: 14px; border-radius: 14px; border: none; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.draft-btn.primary   { background: #007aff; color: #fff; }
.draft-btn.secondary { background: #f2f2f7; color: #1c1c1e; }
.count-ctrl { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.count-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none; font-size: 18px;
  cursor: pointer; background: #f2f2f7; color: #1c1c1e; line-height: 1;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.count-btn.plus { background: #007aff; color: #fff; }
.count-val { min-width: 22px; text-align: center; font-size: 15px; font-weight: 700; color: #007aff; }

/* ── Активні чернетки ── */
.active-check-card {
  background: #fff; border-radius: 14px; padding: 14px 16px;
  margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  display: flex; justify-content: space-between; align-items: center;
}
.active-check-info { flex: 1; }
.active-check-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.active-check-meta { font-size: 12px; color: #8e8e93; }
.active-check-del {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: #ff3b30; color: #fff; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Коментар до контролю ── */
.comment-btn {
  flex-shrink: 0; background: none; border: none; font-size: 16px;
  cursor: pointer; padding: 4px 6px;
  opacity: 0; transform: scale(0.5);
  transition: opacity .18s ease, transform .18s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.comment-btn.visible          { opacity: .4; transform: scale(1); pointer-events: auto; }
.comment-btn.visible.has-cmt  { opacity: 1; }
.comment-mini {
  width: 100%; font-size: 13px; border: 1px solid #e5e5ea; border-radius: 8px;
  padding: 6px 10px; resize: none; box-sizing: border-box;
  font-family: inherit; color: #1c1c1e; display: block;
}
.comment-wrap {
  overflow: hidden; max-height: 0; opacity: 0;
  transition: max-height .22s ease, opacity .18s ease, padding .22s ease;
  padding: 0 0 0 46px;
}
.comment-wrap.open { max-height: 80px; opacity: 1; padding: 2px 0 8px 46px; }

/* ── Історія / Планування ── */
.history-card {
  background: #fff; border-radius: 14px; padding: 14px 16px;
  margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  display: flex; justify-content: space-between; align-items: center;
}
.history-info { flex: 1; }
.history-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.history-meta { font-size: 12px; color: #8e8e93; }
.history-dl {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #007aff; color: #fff; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sched-status {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  flex-shrink: 0; margin-left: 8px; white-space: nowrap;
}
.sched-ok   { background: #e8f5e9; color: #2e7d32; }
.sched-due  { background: #fff8e1; color: #f57c00; }
.sched-over { background: #ffebee; color: #c62828; }
.sched-done-btn {
  flex-shrink: 0; margin-left: 8px;
  background: #34c759; color: #fff; border: none;
  border-radius: 10px; padding: 5px 10px;
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sched-card-done {
  opacity: 0.6;
}
@media (prefers-color-scheme: dark) {
  .sched-ok   { background: #1b3a1b; color: #81c784; }
  .sched-due  { background: #3a2e00; color: #ffcc02; }
  .sched-over { background: #3a0000; color: #ef9a9a; }
}
