:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #14201f;
  --muted: #6b7a78;
  --line: #e2e7ea;
  --accent: #0f766e;
  --accent-soft: #d7f0ec;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 32, 31, .06), 0 8px 24px rgba(16, 32, 31, .06);
  --tap: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

.app { max-width: 720px; margin: 0 auto; padding: 12px 12px 24px; }
.loading { padding: 48px 16px; text-align: center; color: var(--muted); }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 17px; margin: 20px 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: grid; gap: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 10px 0;
}
.card.tight { padding: 10px; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px 6px;
}
.header .name { font-size: 21px; font-weight: 700; }
.header .sub { color: var(--muted); font-size: 13px; }

.banner {
  border-radius: 14px;
  padding: 12px 14px;
  margin: 10px 0;
  border: 1px solid transparent;
  font-weight: 600;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.banner.good { background: var(--good-soft); color: var(--good); border-color: #bbf7d0; }
.banner.info { background: var(--accent-soft); color: var(--accent); border-color: #99e2d9; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 650;
  background: #eef2f4;
  color: #374b49;
  border: 1px solid var(--line);
}
.badge.good { background: var(--good-soft); color: var(--good); border-color: #bbf7d0; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #fecaca; }
.badge.muted { background: #eef2f4; color: var(--muted); }

/* Задания на сегодня */
.task {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  margin: 8px 0;
}
.task .icon { font-size: 26px; line-height: 1; }
.task .title { font-weight: 650; }
.task .hint { color: var(--muted); font-size: 12.5px; }
.task.done { border-color: #bbf7d0; background: #f4fdf7; }
.task.closed { opacity: .62; }
.task .actions { display: flex; gap: 8px; }

.mark {
  min-width: 52px;
  min-height: var(--tap);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .06s ease;
}
.mark:active { transform: scale(.95); }
.mark.yes { color: var(--good); }
.mark.no { color: var(--bad); }
.mark .label { display: none; }
.mark[aria-pressed="true"].yes { background: var(--good); border-color: var(--good); color: #fff; }
.mark[aria-pressed="true"].no { background: var(--bad); border-color: var(--bad); color: #fff; }
.mark[disabled] { opacity: .4; cursor: not-allowed; }

.big {
  min-height: 64px;
  border-radius: 16px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  padding: 12px 18px;
  cursor: pointer;
}
.big:active { transform: scale(.98); }
.big.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.big.warn { background: var(--warn); }
.big[disabled] { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 6px; }

/* Детский режим */
.kid .task {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 6px;
  padding: 18px 14px;
  text-align: center;
  border-radius: 22px;
}
.kid .task .icon { font-size: 68px; }
.kid .task .title { font-size: 21px; }
.kid .task .hint { display: none; }
.kid .task .actions { justify-content: center; }
.kid .mark { min-width: 100%; min-height: 76px; font-size: 30px; }
.kid .mark .label { display: inline; margin-left: 10px; font-size: 24px; font-weight: 700; }
.kid .mark.no { display: none; }

/* Сетка месяца */
.month-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; font-size: 12px; }
table.grid th, table.grid td {
  border: 1px solid var(--line);
  width: 30px;
  height: 30px;
  text-align: center;
  padding: 0;
}
table.grid th.task-name, table.grid td.task-name { width: 150px; min-width: 150px; text-align: left; padding: 0 8px; }
table.grid thead th { background: #eef2f4; font-weight: 600; }
table.grid td.today { outline: 2px solid var(--accent); outline-offset: -2px; }
table.grid td.future { color: #b8c2c1; }
.dot-done { color: var(--good); font-weight: 700; }
.dot-mercy { color: var(--warn); font-weight: 700; }
.dot-catchup { color: #7c3aed; font-weight: 700; }
.dot-not { color: var(--bad); font-weight: 700; }
.dot-jockey { color: #6d28d9; }
.summary-row td { font-weight: 700; }

/* Рейтинг */
.rating-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.rating-row:last-child { border-bottom: 0; }
.rating-row.me { background: var(--accent-soft); border-radius: 12px; }
.rank { font-weight: 800; font-size: 16px; color: var(--muted); }
.rank.r1 { color: #b45309; }
.metric { text-align: right; font-variant-numeric: tabular-nums; }
.metric b { font-size: 18px; }

/* Формы */
label.field { display: block; margin: 10px 0; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.pin-input { letter-spacing: .4em; font-size: 22px; text-align: center; }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 2px;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabs a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11.5px;
}
.tabs a.active { color: var(--accent); background: var(--accent-soft); }
.tabs svg { width: 24px; height: 24px; }

.offline {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--warn);
  color: #fff;
  padding: 8px 12px;
  text-align: center;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #14201f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 40;
  max-width: 92vw;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f4;
  font-size: 12px;
  color: #374b49;
}
.chip.on { background: var(--good-soft); color: var(--good); }
.chip.off { background: var(--bad-soft); color: var(--bad); }

.admin-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.admin-tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.admin-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; }

.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button {
  font-size: 22px;
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.icon-pick button.sel { border-color: var(--accent); background: var(--accent-soft); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr 1fr; } }

.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 4px; }
.login-logo { font-size: 56px; text-align: center; }

.stat { text-align: center; padding: 8px 4px; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.section-note { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
