/* Табель — колокольчики. Мобильная вёрстка, без тёмной темы (утренний свет в раздевалке). */

:root {
  --paper: #f5f2ea;
  --paper-deep: #ece7db;
  --surface: #fffdf8;
  --ink: #23251e;
  --muted: #6f7265;
  --line: #e5dfd1;
  --line-strong: #d6cfbe;
  --accent: #2d6a4a;
  --accent-deep: #23553b;
  --accent-soft: #e3efe7;
  --absent: #a8422c;
  --absent-soft: #f6e5df;
  --warn-bg: #fbf1d8;
  --warn-ink: #7a5b12;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(35, 37, 30, .04), 0 6px 20px -14px rgba(35, 37, 30, .25);
  --tabs-h: 62px;
  --top-h: 54px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--absent); font-size: 14px; margin: 0; }

/* ---------- шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 242, 234, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  height: var(--top-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.brand-text {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 17px;
  letter-spacing: .01em;
}

.sync {
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  transition: background-color .2s ease, color .2s ease;
}

.sync .ico {
  width: 18px;
  height: 18px;
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sync[data-state="saved"],
.sync[data-state="live"] { background: var(--accent-soft); color: var(--accent); }
.sync[data-state="syncing"],
.sync[data-state="pending"],
.sync[data-state="reconnecting"] { background: var(--warn-bg); color: var(--warn-ink); }
.sync[data-state="offline"] { background: var(--absent-soft); color: var(--absent); }

.sync[data-state="saved"] .ico-ok,
.sync[data-state="live"] .ico-ok,
.sync[data-state="reconnecting"] .ico-busy,
.sync[data-state="syncing"] .ico-busy,
.sync[data-state="pending"] .ico-busy,
.sync[data-state="offline"] .ico-wait { display: block; }

.sync[data-state="syncing"] .ico-busy,
.sync[data-state="reconnecting"] .ico-busy { animation: sync-spin .9s linear infinite; }

@keyframes sync-spin { to { transform: rotate(360deg); } }

.main {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 14px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
}

#screen-today { padding-bottom: 132px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- день ---------- */

.daybar {
  position: sticky;
  top: calc(var(--top-h) + 8px);
  z-index: 10;
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  padding: 8px;
  margin-bottom: 12px;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: var(--paper-deep); }
.icon-btn:active { transform: scale(.96); }

.daylabel { position: relative; text-align: center; }

.date-text {
  display: block;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.2;
  padding: 4px 0;
  text-transform: lowercase;
}
.date-text::first-letter { text-transform: uppercase; }

.date-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid #ead9a8;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  margin: 0 0 12px;
}

.banner.danger {
  background: var(--absent-soft);
  color: var(--absent);
  border-color: #e8c7bc;
}

/* ---------- список детей ---------- */

.children {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.child {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 30px;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  min-height: 58px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color .15s ease;
}
.child:first-child { border-top: 0; }
.child:hover { background: #fbf8f1; }
.child:active { background: var(--paper-deep); }

.child .num {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.child .name {
  font-size: 16px;
  letter-spacing: -.005em;
  overflow-wrap: break-word;
}

.child.absent {
  background: linear-gradient(90deg, rgba(168, 66, 44, .075), rgba(168, 66, 44, 0) 62%);
  box-shadow: inset 3px 0 0 var(--absent);
}

.check {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  border: 2px solid #cdd7ca;
  background: transparent;
  color: transparent;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.child:not(.absent) .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.child.absent .check {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
}

.child:active .check { transform: scale(.9); }

.chip {
  border: 0;
  border-radius: 999px;
  background: var(--absent-soft);
  color: var(--absent);
  font-size: 12.5px;
  padding: 5px 10px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip:empty { display: none; }
.chip.placeholder { background: var(--paper-deep); color: var(--muted); }

/* ---------- итоги дня ---------- */

.dayfoot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  z-index: 15;
  padding: 10px 14px 12px;
  background: linear-gradient(180deg, rgba(245, 242, 234, 0), rgba(245, 242, 234, .94) 28%);
}

.dayfoot-inner, .dayfoot { max-width: 760px; margin: 0 auto; }

.totals {
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  padding: 0 0 8px;
  font-variant-numeric: tabular-nums;
}
.totals b { color: var(--ink); font-weight: 600; }
.totals .neg { color: var(--absent); }

.dayfoot-actions { display: grid; grid-template-columns: auto 1fr; gap: 9px; }

/* ---------- кнопки ---------- */

.btn {
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid transparent;
  padding: 10px 18px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  transition: background-color .15s ease, transform .1s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }

.btn.ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn.ghost:hover { background: var(--paper-deep); }

.btn.danger {
  background: transparent;
  border-color: #e8c7bc;
  color: var(--absent);
}

.btn.big { min-height: 54px; font-size: 16.5px; width: 100%; }

/* ---------- месяц ---------- */

.monthbar {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  padding: 8px;
  margin-bottom: 10px;
}

.month-title { text-align: center; }
.month-title > span:first-child {
  display: block;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 19px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 2px 4px 10px;
}

.grid-scroll {
  overflow: auto;
  max-height: calc(100dvh - 250px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.grid th, .grid td {
  padding: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.grid tr:last-child td { border-bottom: 0; }
.grid th:last-child, .grid td:last-child { border-right: 0; }

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  font-weight: 600;
  color: var(--muted);
  padding: 6px 0;
  min-width: 36px;
}

.grid thead th small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: #9a9c8c;
  text-transform: lowercase;
}

.grid .corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: var(--surface);
  text-align: left;
  padding: 6px 10px;
  min-width: 152px;
  color: var(--muted);
  font-weight: 600;
}

.grid .name-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  padding: 0;
  min-width: 152px;
}

.grid .name-cell button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  font-size: 13.5px;
  line-height: 1.25;
  min-height: 40px;
  color: var(--ink);
}
.grid .name-cell button:hover { background: var(--paper-deep); }
.grid .name-cell button span { color: var(--muted); font-size: 11.5px; margin-right: 4px; }

.grid td.cell { padding: 0; }

.grid td.cell button {
  width: 100%;
  min-width: 36px;
  height: 40px;
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: transparent;
  display: grid;
  place-items: center;
}
.grid td.cell button:hover { background: var(--paper-deep); }

.grid td.cell.absent button {
  color: var(--absent);
  background: var(--absent-soft);
}

.grid td.cell.today-col { box-shadow: inset 1px 0 0 var(--accent), inset -1px 0 0 var(--accent); }
.grid thead th.today-col { color: var(--accent); }

.grid td.cell button:active { transform: scale(.94); }

.note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  padding: 0 4px;
}

/* ---------- экспорт ---------- */

.warnings { display: grid; gap: 8px; margin-bottom: 12px; }

.warning {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid #ead9a8;
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13.5px;
}
.warning.danger { background: var(--absent-soft); color: var(--absent); border-color: #e8c7bc; }
.warning.ok { background: var(--accent-soft); color: var(--accent-deep); border-color: #c9ded1; }

.stats { padding: 6px 16px; margin-bottom: 12px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  color: var(--muted);
}
.stat-row:first-child { border-top: 0; }
.stat-row b {
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card:not(.stats):not(.monthbar):not(.daybar) { padding: 14px 16px; margin-bottom: 12px; }

.card-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.mini-table { font-size: 14px; }

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.mini-row:first-child { border-top: 0; }
.mini-row .k { color: var(--ink); overflow-wrap: break-word; }
.mini-row .v { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-row .v.neg { color: var(--absent); }
.mini-empty { color: var(--muted); font-size: 13.5px; padding: 4px 0; }

.export-actions { display: grid; gap: 9px; margin-top: 4px; }

/* ---------- вкладки ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 253, 248, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
}

.tab-ico { font-size: 18px; line-height: 1; }
.tab.active { color: var(--accent); font-weight: 600; }
.tab.active .tab-ico { transform: translateY(-1px); }

/* ---------- нижний лист и модалки ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(30, 30, 24, .42);
  backdrop-filter: blur(2px);
  animation: fade-in .16s ease-out;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
  box-shadow: 0 -12px 40px -20px rgba(0, 0, 0, .4);
  animation: slide-up .22s cubic-bezier(.2, .8, .2, 1);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 0 auto 12px;
}

.sheet-title {
  margin: 0 0 4px;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 600;
}

.reason-list { display: grid; gap: 8px; margin: 12px 0; }

.reason-list button {
  min-height: 50px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  text-align: left;
  padding: 12px 16px;
  font-size: 15.5px;
}
.reason-list button:hover { background: var(--paper-deep); }
.reason-list button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.field { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }

.field input, .field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  padding: 9px 12px;
  font-size: 16px;
  color: var(--ink);
}

.sheet-custom { margin: 4px 0 12px; }

.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions.three { grid-template-columns: 1fr 1fr 1fr; }
.sheet-actions.three .btn { padding-left: 10px; padding-right: 10px; }

.modal {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  max-width: 420px;
  margin: 0 auto;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .5);
  animation: pop-in .18s ease-out;
}

.range-form { display: grid; gap: 10px; margin-top: 12px; }
.range-form .sheet-actions { margin-top: 4px; }

/* ---------- вход по коду ---------- */

.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}

.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 22px 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  text-align: center;
}

.gate-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 2px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 25px;
  font-weight: 700;
}

.gate-card h1 {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
}

.gate-card p { margin: 0; }
.gate-card .field { text-align: left; margin-top: 6px; }

/* ---------- тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + 84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: #2b2d25;
  color: #f7f4ec;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.5px;
  max-width: calc(100vw - 40px);
  text-align: center;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .5);
  animation: fade-in .15s ease-out;
}

/* ---------- анимации ---------- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop-in { from { transform: translateY(-50%) scale(.97); opacity: .5; } to { transform: translateY(-50%) scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 720px) {
  .date-text { font-size: 21px; }
  .child .name { font-size: 16.5px; }
}
