/* Журнал на планшете — по принятому макету docs/mockups/journal-tablet.html: стиль анкеты, iPad 6 в обеих ориентациях */
:root {
  --card: rgba(255, 255, 255, 0.94); --text: #1d2433; --muted: #5d6678; --line: #cfd6e2; --rule: #e3e7ef;
  --accent: #2f6fed; --accent-ink: #ffffff; --ok: #1a7f37; --err: #c62828; --notice: #fff4d6; --notice-ink: #6b4d00;
  --radius: 12px; --wait: #6a5acd; --hall: #1a7f37; --pause: #9a6a00; --gone: #5d6678;
  color-scheme: light;  /* журнал всегда светлый: тёмная тема iPad его не перекрашивает (§2.4) */
}
html { -webkit-text-size-adjust: 100%; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums; background: linear-gradient(160deg, #3a7bd5 0%, #6a5acd 55%, #e0679a 100%) fixed; }
[hidden] { display: none !important; }
.card { background: var(--card); border-radius: 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }

button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 16px; white-space: nowrap;
  font: inherit; font-size: 16px; font-weight: 600; border-radius: var(--radius); border: 1.5px solid var(--accent); background: transparent; color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.big { height: 48px; font-size: 17px; padding: 0 20px; }
button:disabled { opacity: 0.6; }
.sub { font-size: 14px; color: var(--muted); }
.err { color: var(--err); font-weight: 600; min-height: 22px; }
.note { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* Привязка */
.bind { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.bind-card { width: min(480px, 100%); padding: 24px; display: grid; gap: 12px; }
.bind-card h1 { margin: 0; font-size: 24px; }
.bind-card p { margin: 0; }

/* Поле как в анкете: подпись внутри, мелко у верхнего края */
.float { position: relative; display: block; }
.float > span { position: absolute; top: 4px; left: 15px; font-size: 12px; line-height: 14px; color: var(--muted); pointer-events: none; }
.float > input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 14px 0;
  font: inherit; font-size: 17px; background: #fff; color: var(--text); }
.float > input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Экран журнала: шапка закреплена, список прокручивается (§2.4) */
/* Экран — видимая область: 100vh в Safari на iPad выше видимой части с панелью вкладок, и шапка уезжала (симулятор, iOS 17.5) */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; container-type: inline-size; --act: 216px; }
.top { flex: none; display: flex; align-items: center; gap: 16px; min-height: 60px; margin: 8px 12px; padding: 4px 10px 4px 18px; }
.top .primary { width: var(--act); flex: none; }  /* кнопка не сжимается (QA tablet-16) */
/* не влезает — уступает только имя точки, многоточием: статус — одной строкой, «+ Визит» — на экране (решение 34, §2.4) */
.place { font-size: 21px; font-weight: 700; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.date { color: var(--muted); white-space: nowrap; }
.sync { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; font-size: 16px; line-height: 1.25; }
.sync.ok { color: var(--ok); }
.sync.warn { color: var(--notice-ink); background: var(--notice); padding: 6px 12px; border-radius: var(--radius); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: none; }
/* «i» — связь, версии и предупреждения (решение 34); красная точка — есть предупреждение */
.info-btn { position: relative; flex: none; width: 44px; padding: 0; border-radius: 50%; font: italic 700 20px Georgia, serif; }
.info-btn.has-warn::after { content: ""; position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--err); border: 2px solid #fff; }
.pop { position: fixed; top: 76px; right: 12px; z-index: 1; width: 380px; max-width: calc(100% - 24px); margin: 0; padding: 14px 18px;
  background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); display: grid; grid-template-columns: auto 1fr;
  gap: 8px 14px; font-size: 15px; max-height: calc(100% - 88px); overflow-y: auto; }  /* много отказов — прокрутка (решение 34, §2.4) */
.pop[hidden] { display: none; }
.pop dt, .info dt { color: var(--muted); }
.pop dd, .info dd { margin: 0; }
.pop .warn, .pop .refused { grid-column: 1 / -1; }
.pop .warn, .info .warn { color: var(--err); font-weight: 600; }
.pop .push-btn { grid-column: 1 / -1; margin-top: 4px; }  /* пока нет разрешения на уведомления (ADR-0063 п. 12) */
.list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 12px; }

.group { background: var(--card); border-radius: 20px; overflow: hidden; margin-bottom: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
.group-head { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px 0 18px; font-weight: 700; border-bottom: 1px solid var(--rule); }
.group-head::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: none; }
.group-head .n { font-weight: 400; color: var(--muted); }
.group-head:has(.more-btn) { min-height: 52px; }
.more-btn { margin-left: auto; width: var(--act); padding: 0 8px; font-size: 15px; }
.g-yesterday .group-head { color: var(--err); }
.g-wait .group-head { color: var(--wait); }
.g-hall .group-head { color: var(--hall); }
.g-pause .group-head { color: var(--pause); }
.g-gone .group-head { color: var(--gone); }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
/* Имя — всё, что осталось от прочих колонок, на любой ширине (решение 34) */
col.c-marks { width: 112px; } col.c-in { width: 68px; } col.c-run { width: 64px; } col.c-sum { width: 96px; } col.c-act { width: 234px; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 8px 4px; border-bottom: 1px solid var(--rule); }
td { padding: 4px 8px; height: 50px; border-bottom: 1px solid var(--rule); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child, th:first-child { padding-left: 18px; }
td:last-child { padding-right: 10px; }
td.num, th.num { text-align: right; }
td.c-fix { white-space: normal; overflow-wrap: anywhere; }  /* длинное имя — целиком, переносом (QA tablet-23) */
/* «заявка по QR в …, ждёт … мин» в «Ждут» — переносом, а не под «Не пришли» (владелец 2026-10-28); на 768 pt — три строки
   в высоте строки (решение 34) */
td.sub { white-space: normal; line-height: 16px; }
/* строки одной высоты (решение 34): имя — не больше двух строк, целиком — в карточке «О ребёнке» */
.list .name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.name { font-size: 17px; font-weight: 600; }
.c-fix { cursor: pointer; }  /* «Исправить» — вся ячейка имени (QA tablet-08) */
.name::after { content: " ›"; color: var(--muted); font-weight: 400; }  /* нажатие на имя — «Исправить» */
.age { color: var(--muted); font-weight: 400; }
/* Отметки — по одной в строке (решение 34: «Подели на 2 высоту и в каждой сделай значек») */
td.c-marks { padding: 4px; }  /* отметки не налезают на «Вход» (симулятор iPad 6) */
/* Отметки — не больше двух, по одной в строке (решение 34) */
.marks { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.marks .line { display: flex; align-items: center; gap: 4px; }
.tag { font-size: 12px; line-height: 18px; font-weight: 600; padding: 0 5px; border-radius: 6px; white-space: nowrap; color: var(--wait); background: #efedfb; }
.tag.bday { color: var(--notice-ink); background: var(--notice); }
.tag.pause { color: var(--pause); background: var(--notice); }
.time { font-size: 17px; font-weight: 600; }
.sum { font-size: 17px; font-weight: 700; white-space: nowrap; }
/* Блоки семей (решение 34): у каждого ребёнка — заголовок семьи, у гостя — «Гости»; блок — карточка со скруглёнными углами
   на сером, синий заголовок и полоса слева; заголовки и строки одной высоты */
.list table { border-collapse: separate; border-spacing: 0; background: #dbe2ef; padding: 0 8px 8px; }
.list th { border-bottom: 0; }
.list tr.row td, .list tr.fam td, .list tr.total td { height: 58px; background: #fff; border-bottom: 1px solid #b9c3d6; }
.list tr.gap td { height: 10px; padding: 0; border: 0; background: transparent; }
.list tr.fam td { background: #cfdcfa; border-bottom: 0; }
.list tr.fam .who { color: #173d9c; font-size: 18px; }
.list tr.fam .sub { color: #173d9c; }
.list tr.fam td:first-child, .list tr.kid td:first-child { box-shadow: inset 6px 0 0 var(--accent); }
.list tr.kid td:first-child { padding-left: 28px; }
.list tr.fam .actions button { background: #fff; }
.list tr.fam td:first-child { border-top-left-radius: 14px; } .list tr.fam td:last-child { border-top-right-radius: 14px; }
.list tr.kid:has(+ tr.gap) td, .list tr.kid:last-child td { border-bottom: 0; }
.list tr.kid:has(+ tr.gap) td:first-child, .list tr.kid:last-child td:first-child { border-bottom-left-radius: 14px; }
.list tr.kid:has(+ tr.gap) td:last-child, .list tr.kid:last-child td:last-child { border-bottom-right-radius: 14px; }
.list tr.hl td { background: var(--notice); }
.actions { display: grid; grid-template-columns: 1fr 92px; gap: 8px; }
.actions button { width: 100%; padding: 0 8px; }
.actions button:only-child { grid-column: 1 / -1; }
.hl td { background: var(--notice); }
.fam .who { font-size: 17px; font-weight: 700; }
.total td { font-weight: 600; white-space: normal; }  /* расчёт скидки переносится, а не раздвигает таблицу на 768 pt */
.total .calc { color: var(--muted); font-size: 15px; font-weight: 400; }
.total .sum { font-size: 20px; }
/* Оплата после «Стоп» (ADR-0070): сбой кассы — красным в строке итога, «Пробито вручную» — мельче, оплачено — зелёным */
.total .calc.bad { color: var(--err); font-weight: 600; }
.actions button.small { font-size: 13px; line-height: 1.1; white-space: normal; }
/* «Оплатить снова · N ₽» рядом с «Пробито вручную» не влезает — своей строкой над ней, длинная сумма переносится (ADR-0070, §2.4) */
.actions .wide, .actions .wide + button { grid-column: 1 / -1; }
.actions button.wide { white-space: normal; line-height: 1.15; }
td.paid { color: var(--ok); font-weight: 700; white-space: normal; }

/* Вертикально (iPad 6 — 768 pt): те же колонки, уже (решение 34) */
@container (max-width: 800px) {
  col.c-marks { width: 100px; } col.c-run { width: 56px; } col.c-sum { width: 84px; } col.c-act { width: 230px; }
  .top, .list { --act: 212px; }
  .total .sum { font-size: 17px; }
}
/* Шапка в две строки — телефон, iPad mini вертикально и зум Safari 125 % (648 pt): в одну строку не влезает (решение 34, §2.4) */
@container (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 4px 12px; padding: 8px 10px 8px 14px; }
  /* первая строка — точка и «+ Визит», вторая — дата, статус и «i» */
  .place { font-size: 19px; flex: 1 1 0; } .top .primary { width: auto; order: 1; }
  .top::after { content: ""; order: 2; flex-basis: 100%; }  /* перенос после «+ Визит»: на 648–760 pt дата влезла бы в первую (решение 34, §2.4) */
  .date { order: 3; } .sync { order: 4; } .info-btn { order: 5; }
  .pop { top: 128px; max-height: calc(100% - 140px); }  /* под второй строкой шапки: «i» не закрыто (решение 34, §2.4) */
}
/* Телефон и зум Safari 125 % на iPad 9/10 вертикально (648–656 pt): карточкой — в таблице имени 44 pt, рвётся посреди слова (решение 34) */
@container (max-width: 700px) {
  .list { padding: 0 8px 12px; }
  table, tbody { display: block; } colgroup, tr:has(> th) { display: none; }
  tr.row { display: grid; grid-template-columns: auto 1fr auto; column-gap: 12px; row-gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
  tr.row td { display: block; height: auto; border: 0; padding: 0; }
  tr.row td.c-fix { grid-column: 1 / 3; grid-row: 1; }
  tr.row td.sum { grid-column: 3; grid-row: 1; align-self: start; }
  tr.row td.c-marks { grid-column: 1 / -1; grid-row: 2; }
  tr.row .marks { flex-direction: row; flex-wrap: wrap; align-items: center; }
  tr.row td.time { grid-column: 1; grid-row: 3; font-size: 15px; }
  tr.row td.time::before { content: "Играет "; font-weight: 400; color: var(--muted); }
  tr.row td.c-in { grid-column: 2 / 4; grid-row: 3; font-size: 15px; color: var(--muted); align-self: center; }
  tr.row td.c-in::before { content: "вход "; }
  tr.row td:last-child { grid-column: 1 / -1; grid-row: 4; padding-top: 8px; }
  tr.row td.sub { grid-column: 1 / -1; grid-row: 3; }
  tr.row[data-request] td.c-in { display: none; }  /* у заявки «вход —» не налезает на «заявка по QR…» */
  .list table { padding: 0 4px 4px; }
  .list tr.gap { display: block; height: 8px; }
  .list tr.row, .list tr.total { background: #fff; } .list tr.fam { background: #cfdcfa; }
  .list tr.row td, .list tr.fam td, .list tr.total td { height: auto; background: transparent; border: 0; }
  .list tr.row.hl, .list tr.total.hl { background: var(--notice); }  /* долгая пауза (§2.3), сбой кассы (ADR-0070) */
  .list tr.kid:has(+ tr.gap), .list tr.kid:last-child { border-radius: 0 0 14px 14px; }
  .list tr.kid { box-shadow: inset 6px 0 0 var(--accent); padding-left: 22px; }
  .list tr.fam { box-shadow: inset 6px 0 0 var(--accent); border-radius: 14px 14px 0 0; }
  /* полоса, скругления и табличный отступ имени — только у строки: у ячеек ложились на «Семья», «Гости» и имена (решение 34, §2.4) */
  .list tr.fam td:first-child, .list tr.fam td:last-child, .list tr.kid td:first-child,
  .list tr.kid:has(+ tr.gap) td:first-child, .list tr.kid:last-child td:first-child,
  .list tr.kid:has(+ tr.gap) td:last-child, .list tr.kid:last-child td:last-child { box-shadow: none; border-radius: 0; padding-left: 0; }

  tr.fam, tr.total { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 14px; }
  tr.fam td, tr.total td { display: block; height: auto; border: 0; padding: 0; white-space: normal; }
  /* кнопки, что не влезли рядом с текстом, — переносом, а не поверх «Итого»: у семьи справа, у «Итого» во всю ширину (§2.4) */
  tr.fam, tr.total { flex-wrap: wrap; }
  tr.fam td:has(> .actions) { flex: none; margin-left: auto; }
  tr.total td:first-child { flex: 1 1 0; }
  tr.total td:has(> .actions) { flex: 1 0 100%; }
}

/* Окна поверх журнала — в верхней половине: клавиатура iPad закрывает нижнюю (§2.2) */
.shade { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); }
.sheet { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); width: min(980px, calc(100% - 24px)); max-height: calc(100% - 32px);
  overflow-y: auto; background: #fff; border-radius: 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); }
.sheet.fix { width: min(640px, calc(100% - 24px)); }
.sheet-head { position: sticky; top: 0; background: #fff; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 0 12px; border-bottom: 1px solid var(--rule); }
.sheet-head h3 { margin: 0 auto; padding: 0 12px; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head button { flex: none; }  /* длинный заголовок не сжимает «Отмена» и «Сохранить» (QA tablet-07) */
.sheet-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 14px 18px 16px; }
.fix-body { padding: 16px 20px 20px; }
.fix-body h4 { margin: 12px 0 8px; font-size: 14px; color: var(--muted); }
.msg { margin: 8px 0; font-size: 15px; font-weight: 600; color: var(--notice-ink); }
.msg.bad { color: var(--err); }
.pick { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; font-size: 17px; background: #fff; overflow-wrap: anywhere; }
.pick:has(input:checked) { border-color: var(--accent); }
.pick input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.pick.off { color: var(--muted); }
.fam-card { min-height: 52px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: var(--radius); font-size: 17px; }
.fam-card.party { grid-column: 1 / -1; margin-bottom: 8px; }  /* праздник и аренда — на семью (QA tablet-09) */
/* Карточка «О ребёнке» (решение 34) */
.info { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; padding: 16px 20px; font-size: 17px; }
.info-act { padding: 0 20px 20px; }
.info-act button { width: 100%; }
.kids2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px; }  /* слитное имя не раздвигает окно (QA tablet-06) */
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 2px 0 8px; }
.seg button { flex: 1; border: 0; border-right: 1px solid var(--line); border-radius: 0; color: var(--text); padding: 0 6px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.field-row { display: flex; align-items: center; gap: 12px; font-weight: 600; margin: 8px 0; }
.field-row input, .time-field input { height: 44px; min-width: 120px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; font: inherit; font-size: 17px; }
.time-field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.time-field .bad, .field-bad { color: var(--err); font-weight: 600; }
#fix-cancel { margin-top: 12px; width: 100%; border-color: var(--err); color: var(--err); }

@media (max-width: 800px) { .sheet-body { grid-template-columns: 1fr; } }
/* Телефон: кнопки шапки окна, что не влезли, — второй строкой справа; «День рождения» — в две строки (решение 34, §2.4) */
@media (max-width: 600px) {
  .sheet-head { flex-wrap: wrap; padding: 8px 12px; }
  .sheet-head h3 { flex: 1 1 0; min-width: 150px; }  /* «Новый визит» целиком, длинный заголовок — многоточием, «Сохранить» — второй строкой (§2.4) */
  .sheet-head .primary { margin-left: auto; }
  .seg button { white-space: normal; line-height: 1.15; }
}
