:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #23262b;
  --muted: #6b7079;
  --line: #e4e0d8;
  --accent: #2f6fdb;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --ok-bg: #e5f5ea;
  --ok-ink: #1d6b38;
  --err-bg: #fdeaea;
  --err-ink: #a12a2a;
  --booked: #ffd9a8;
  --booked-ink: #6b3d00;
  --free: #dff3e4;
  --off: #f1efea;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0.4em 0 0.3em; }
h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
pre { background: var(--off); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1100px; }
main.wrap { padding-bottom: 48px; }

.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 0.9rem; text-align: right; }

/* Шапка */
.top { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.top-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; padding: 4px 2px; border-bottom: 2px solid transparent; }
.nav a.on { border-bottom-color: var(--accent); }
.inline { display: inline; margin: 0; }

/* Карточки и сообщения */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0; }
.card.narrow { max-width: 420px; }
.hero { text-align: center; padding: 32px 18px; }
.flash { padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.error { background: var(--err-bg); color: var(--err-ink); }
.tag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 99px; background: var(--off); color: var(--muted); vertical-align: middle; }

.tag.warn { background: var(--err-bg); color: var(--err-ink); }

/* Документы: политика и согласие */
.doc h3 { font-size: 1rem; margin: 1.2em 0 0.4em; }
.doc p, .doc li { max-width: 68ch; }
.doc ul { padding-left: 1.2em; }
.consent-box { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 14px; margin-bottom: 14px; font-size: 0.95rem; }
.consent-check { align-items: flex-start; margin-bottom: 14px; }
.consent-check input { flex: none; margin-top: 3px; }
.withdraw { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.9rem; margin-top: 8px; }
.withdraw button.link { text-decoration: underline; }

/* Подвал */
.foot { border-top: 1px solid var(--line); padding: 18px 0 28px; font-size: 0.88rem; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* Кнопки */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--off); }
.btn.danger { background: var(--err-ink); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.btn.link, button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.row { margin: 8px 0; }

/* Родитель: записи и свободные часы */
.when { font-weight: 600; }
.when.big { font-size: 1.25rem; margin: 0.2em 0; }
.bookings { list-style: none; margin: 0; padding: 0; }
.bookings li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.bookings li:first-child { border-top: 0; }
.days { display: grid; gap: 14px; }
.day-name { font-weight: 600; margin-bottom: 6px; }
.hours { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.slot { background: var(--accent-soft); color: var(--accent); min-width: 76px; }
.btn.slot:hover { background: var(--accent); color: var(--accent-ink); }

/* Формы */
.field { display: block; margin-bottom: 12px; font-weight: 600; font-size: 0.95rem; }
.field input, .field textarea, .kid-row input, .link-box input {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; }
.grid-form { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.grid-form .btn { justify-self: start; }
@media (min-width: 640px) {
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .full, .grid-form .btn { grid-column: 1 / -1; }
}
.checks { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.kid-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
.kid-row input { margin-top: 0; }
.kid-row .check { white-space: nowrap; }
.link-box { display: flex; gap: 8px; margin: 8px 0 12px; }
.link-box input { margin-top: 0; }

/* Списки */
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
.plain li:first-child { border-top: 0; }
.plain li.cancelled a { text-decoration: line-through; color: var(--muted); }
.families { list-style: none; padding: 0; margin: 0; }
.families li { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.families li:first-child { border-top: 0; }
.families li .copy { margin-left: auto; }
.families li.archived { opacity: 0.6; }

/* Календарь */
.week-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; margin-bottom: 10px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; border: 1px solid var(--line); }
.sw.booked { background: var(--booked); }
.sw.free { background: var(--free); }
.sw.off { background: var(--off); }

.cal-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cal { border-collapse: collapse; width: 100%; min-width: 640px; table-layout: fixed; }
.cal th, .cal td { border: 1px solid var(--line); }
.cal thead th { padding: 6px 4px; font-weight: 600; background: var(--card); position: sticky; top: 0; }
.cal thead th .date { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.cal th.today { color: var(--accent); }
.cal th.hour { width: 58px; font-weight: 400; color: var(--muted); font-size: 0.85rem; padding: 0 6px; text-align: right; }
.cal tr > :first-child { border-left: 0; }
.cal tr > :last-child { border-right: 0; }
.cal thead tr > * { border-top: 0; }
.cal tbody tr:last-child > * { border-bottom: 0; }

.cell { padding: 0; height: 44px; vertical-align: top; }
.cell a { display: block; height: 100%; padding: 4px 6px; text-decoration: none; color: inherit; font-size: 0.85rem; line-height: 1.25; }
.cell.free { background: var(--free); }
.cell.booked { background: var(--booked); color: var(--booked-ink); font-weight: 600; }
.cell.off { background: var(--off); }
.cell.today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
.cell.past { opacity: 0.45; }
.cell a:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell .hint { color: #4c8a5c; font-size: 0.78rem; }
.cell .who { display: block; overflow: hidden; text-overflow: ellipsis; }

.hours-grid { min-width: 480px; }
.hours-grid td { text-align: center; padding: 0; }
.tick { display: block; padding: 6px 0; cursor: pointer; }
.tick input { width: 18px; height: 18px; cursor: pointer; }
