/* Цвета взяты с topframe-group.com: там черный текст и кнопки, зеленый как
   акцент. Зеленый #489223 на белом дает контраст 3.88, для обычного текста
   этого мало, поэтому для ссылок берется затемненный тон того же цвета. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --fg: #1a1a1a;
  --muted: #66707c;
  --line: #e3e6ea;
  --line-strong: #d1d3d5;
  --accent: #1a1a1a;
  --accent-soft: #f0f2ec;
  --brand: #489223;
  --brand-text: #3d7c1e;
  --brand-soft: #e8f0e2;
  --danger: #b91c1c;
  --radius: 8px;
  --cell-min: 104px;
  --page-max: 1760px;
  --page-pad: 16px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; }

/* Атрибут hidden обязан прятать элемент. Без этого правила его перебивает
   любой свой display, и скрытая кнопка остается на виду. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand-text); }
a:hover { color: #2f6117; }

/* ---------- каркас ---------- */

/* Тёмная полоса на всю ширину, содержимое внутри выровнено по той же сетке,
   что и контент страницы. Иначе логотип и таблица живут в разных сетках. */
.topbar {
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 9px var(--page-pad);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 600; font-size: 16px; margin-right: 8px; }
.topbar nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
.topbar nav a { opacity: .85; padding: 2px 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { opacity: 1; }
/* Активный пункт подчеркнут фирменным зеленым: на черном он читается,
   контраст 4.48 */
.topbar nav a.active { opacity: 1; border-bottom-color: var(--brand); }
.topbar .who { font-size: 13px; opacity: .85; }

.wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 14px var(--page-pad) 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.layout { display: flex; gap: 16px; align-items: flex-start; }
.layout main { flex: 1 1 auto; min-width: 0; max-width: 100%; }

/* Карточка мероприятия. После клика по мероприятию именно она интересует
   человека, поэтому места ей отдано примерно половина экрана, а не узкая
   полоска сбоку. Календарь при этом остается виден и остается рабочим. */
.panel {
  flex: 0 0 clamp(400px, 42vw, 720px);
  position: sticky;
  top: 66px;
  max-height: calc(100vh - 84px);
  overflow: auto;
}
.panel:empty { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card + .card { margin-top: 12px; }

h1 { font-size: 19px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--fg);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-soft); color: var(--fg); }
/* Главная кнопка черная, как на сайте. Зеленый фон с белым текстом дал бы
   контраст 3.88, это ниже порога, поэтому зеленым кнопки не заливаем */
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #383838; color: #fff; }
.btn.danger { color: var(--danger); border-color: #e6c3c3; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 4px 8px; line-height: 1; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--fg);
}
textarea { resize: vertical; }

/* Подсказки для состава участников */
.people-hints {
  position: relative;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  max-height: 220px;
  overflow-y: auto;
}
.people-hint {
  text-align: left;
  padding: 7px 10px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.people-hint:last-child { border-bottom: none; }
.people-hint:hover, .people-hint.on { background: var(--brand-soft); }
.people-hint .tag {
  font-size: 11px;
  color: var(--brand-text);
  border: 1px solid #cfe0c2;
  border-radius: 10px;
  padding: 1px 7px;
}

/* Поле даты: печатаем руками, а кнопка справа открывает родной календарь */
.date-wrap { position: relative; display: block; }
.date-wrap .date-picker-hidden {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: none;
  background: none;
  color: transparent;
  cursor: pointer;
}
.date-wrap .date-picker-hidden::-webkit-datetime-edit,
.date-wrap .date-picker-hidden::-webkit-inner-spin-button,
.date-wrap .date-picker-hidden::-webkit-clear-button { display: none; }
.date-wrap .date-picker-hidden::-webkit-calendar-picker-indicator {
  opacity: .65;
  cursor: pointer;
  padding: 4px;
}
.date-wrap input.date-manual { padding-right: 40px; }

/* Родное поле выбора файла низкое, пальцем в него попадаешь через раз.
   Поднимаем до той же высоты, что у остальных полей и кнопок. */
input[type=file] {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 14px;
}
input[type=file]::file-selector-button {
  font: inherit;
  font-size: 13px;
  margin-right: 10px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--fg);
  cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #a8ce8c;
  outline-offset: -1px;
  border-color: var(--brand);
}

.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field .error { font-size: 13px; color: var(--danger); margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.checks input { width: auto; }

.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages li {
  padding: 9px 12px; border-radius: 6px; margin-bottom: 6px;
  border: 1px solid var(--line); background: #fff;
}
.messages li.success { border-color: #b8e0c2; background: #f2fbf5; }
.messages li.error { border-color: #e8bcbc; background: #fdf3f3; }
.messages li.warning { border-color: #e6d5a8; background: #fdf9ef; }

/* ---------- панель управления календарем ---------- */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .title { font-size: 18px; font-weight: 600; min-width: 190px; }
.toolbar .spacer { flex: 1; }
.modes { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.modes a {
  padding: 6px 14px; text-decoration: none; color: var(--fg); background: #fff; font-size: 14px;
}
.modes a + a { border-left: 1px solid var(--line-strong); }
.modes a.active { background: var(--accent); color: #fff; }

.legend-box { margin-bottom: 10px; }
.legend-box > summary {
  cursor: pointer; font-size: 13px; color: var(--muted); padding: 2px 0; list-style: none;
}
.legend-box > summary::-webkit-details-marker { display: none; }
.legend-box > summary::before { content: "\25B8 "; }
.legend-box[open] > summary::before { content: "\25BE "; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 0; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.btn .short { display: none; }
.nav-group { display: inline-flex; gap: 6px; }
.brand .short { display: none; }
.topbar nav a.mobile-only { display: none; }

/* ---------- сетка месяца ---------- */

.month { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.month + .month { margin-top: 14px; }
.month > .caption {
  padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--line);
  background: #fafbfc; text-transform: capitalize;
}

.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line); background: #fafbfc;
}
.weekdays div {
  padding: 6px 8px; font-size: 12px; color: var(--muted); text-align: left;
  text-transform: uppercase; letter-spacing: .03em;
}

.week { position: relative; border-bottom: 1px solid var(--line); --rows: 0; }
.week:last-child { border-bottom: none; }

.week-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.day {
  /* Высота растет вместе с числом полос, иначе счетчик "еще N" выдавливается наружу */
  min-height: max(var(--cell-min), calc(28px + var(--rows) * 25px + 22px));
  border-right: 1px solid var(--line);
  padding: 4px 6px;
  position: relative;
}
.day:last-child { border-right: none; }
/* Дни соседних месяцев: раньше отличались бледной цифрой, но такую цифру
   было плохо видно. Теперь их выделяет фон, а число остается читаемым. */
.day.out { background: #eceef1; }
.day.out .num { color: #606a76; }
.day.today .num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
}
.day .num { font-size: 13px; color: var(--muted); }
.day .more {
  position: absolute; left: 4px; right: 4px; bottom: 3px;
  font-size: 12px; color: #376f1b; text-align: left;
  cursor: pointer; background: #eef4ea; border: none;
  padding: 2px 6px; border-radius: 4px; font-family: inherit;
  z-index: 3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day .more:hover { background: #d8e6cd; }
.day.clickable { cursor: pointer; }
.day.clickable:hover { background: #f7f9fb; }

.week-bands {
  position: absolute; left: 0; right: 0; top: 26px;
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px 0; pointer-events: none;
}
.band {
  pointer-events: auto;
  margin: 0 3px;
  height: 21px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  line-height: 21px;
  padding: 0 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border: none;
  text-align: left;
  font-family: inherit;
  display: block;
  width: calc(100% - 6px);
}
.band:hover { filter: brightness(1.12); }
.band.cont-left { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; width: calc(100% - 3px); }
.band.cont-right { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; width: calc(100% - 3px); }
.band.cont-left.cont-right { margin: 0; width: 100%; }
.band .warn { font-weight: 700; }
/* Стрелка у полосы означает, что мероприятие продолжается на следующей строке */
.band .cont-mark { float: right; opacity: .8; font-weight: 700; margin-left: 4px; }

/* ---------- квартал ---------- */

.quarter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;   /* иначе короткий месяц растягивается под соседний */
  --cell-min: 74px;
}
.quarter .month + .month { margin-top: 0; }
.quarter .band { font-size: 11px; height: 18px; line-height: 18px; padding: 0 5px; }
.quarter .week-bands { top: 24px; }

@media (max-width: 1200px) {
  .quarter { grid-template-columns: repeat(2, minmax(0, 1fr)); --cell-min: 82px; }
}
@media (max-width: 860px) {
  .quarter { grid-template-columns: minmax(0, 1fr); --cell-min: 74px; }
}

/* ---------- год ---------- */

.year {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; max-width: 100%; position: relative;
  scrollbar-width: thin;
}
.year::-webkit-scrollbar { height: 10px; }
.year::-webkit-scrollbar-thumb { background: #c3cad2; border-radius: 5px; }
.year::-webkit-scrollbar-track { background: #f0f2f5; }
.year-row { display: flex; border-bottom: 1px solid var(--line); }
.year-row:last-child { border-bottom: none; }
.year-row .mon {
  flex: 0 0 96px; padding: 8px 10px; font-size: 13px; text-transform: capitalize;
  border-right: 1px solid var(--line); background: #fafbfc; position: sticky; left: 0; z-index: 2;
}
/* Месяц без мероприятий занимает меньше места, чтобы не листать пустоту */
.year-row.empty .mon { padding: 4px 10px; color: var(--muted); }
.year-row.empty .year-track { padding: 0; min-height: 22px; }
.year-row .mon .hidden-count { display: block; font-size: 11px; color: var(--muted); }
.year-track {
  flex: 1 1 auto; position: relative; min-width: 620px;
  display: grid; grid-template-columns: repeat(31, 1fr);
  padding: 4px 0; gap: 2px 0;
}
.year-track .daycol { border-right: 1px solid #f0f1f3; grid-row: 1 / -1; }
.year-bar {
  height: 18px; line-height: 18px; border-radius: 4px; color: #fff; font-size: 11px;
  padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; border: none; font-family: inherit; text-align: left; margin: 0 1px;
  z-index: 1;
}
.year-bar:hover { filter: brightness(1.12); }
.year-head { display: flex; border-bottom: 1px solid var(--line); background: #fafbfc; }
.year-head .mon { flex: 0 0 96px; border-right: 1px solid var(--line); }
.year-head .nums {
  flex: 1 1 auto; min-width: 620px; display: grid; grid-template-columns: repeat(31, 1fr);
  font-size: 10px; color: var(--muted); text-align: center; padding: 3px 0;
}
.year-head .mon { position: sticky; left: 0; z-index: 3; background: #fafbfc; }

/* ---------- фильтры ---------- */

.filters { margin-bottom: 12px; }
.filters summary {
  cursor: pointer; padding: 8px 12px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 14px; list-style: none;
}
.filters summary::-webkit-details-marker { display: none; }
.filters summary .count {
  background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 8px;
  font-size: 12px; margin-left: 6px;
}
.filters .body {
  border: 1px solid var(--line); border-top: none; background: #fff;
  border-radius: 0 0 var(--radius) var(--radius); padding: 12px 14px;
}
.filters .group { margin-bottom: 12px; }
.filters .group > strong { display: block; font-size: 13px; margin-bottom: 5px; color: var(--muted); font-weight: 600; }
.filter-actions { display: flex; gap: 8px; }

/* ---------- карточка ---------- */

.stage-chip {
  display: inline-block; padding: 3px 11px; border-radius: 12px; color: #fff; font-size: 13px;
}
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 5px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.pkg { border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; margin-bottom: 8px; }
.pkg.selected { border-color: #16a34a; background: #f4fbf6; }
.pkg .head { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.pkg .price { font-weight: 600; white-space: nowrap; }
.pkg .tag { font-size: 12px; color: #15803d; }

.check-list { list-style: none; padding: 0; margin: 0; }

/* Строка подготовки живет и в широкой странице, и в узкой боковой панели.
   Раньше перенос включался медиазапросом по ширине окна, поэтому на большом
   мониторе в панели шириной 400 пикселей название схлопывалось в столбик
   по одной букве. Теперь строка переносится сама, когда места не хватает,
   и от ширины окна это не зависит. */
.check-item {
  display: flex; align-items: center; gap: 6px 8px; padding: 5px 0;
  border-bottom: 1px solid #f2f3f5;
  flex-wrap: wrap;
}
.check-item:last-child { border-bottom: none; }
/* Название занимает всю оставшуюся ширину, но не уже 150 пикселей:
   ниже этого текст перестает читаться */
.check-item .text { flex: 1 1 150px; min-width: 0; overflow-wrap: anywhere; }
.check-item input[type=date], .check-item select { min-width: 0; max-width: 100%; }
.check-item .btn.icon { flex: 0 0 auto; margin-left: auto; }
.check-item.done .text { color: var(--muted); text-decoration: line-through; }
.check-item .due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.check-item .due.overdue { color: var(--danger); font-weight: 600; border-color: #e3a0a0; background: #fdf5f5; }
.check-item.overdue-row { background: #fdf5f5; }
.check-item.overdue-row .text::after { content: " просрочено"; color: var(--danger); font-size: 12px; }
.check-item .who { font-size: 12px; color: var(--muted); white-space: nowrap; }
.check-item .drag { cursor: grab; color: #666f7b; }
.check-item.dragging { opacity: .45; }

.progress { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.progress .bar { flex: 1; height: 6px; background: #eceef1; border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: #16a34a; }

/* ---------- таблица ---------- */

.table-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; max-width: 100%; scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: #c3cad2; border-radius: 5px; }
.table-wrap::-webkit-scrollbar-track { background: #f0f2f5; }

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.grid th, table.grid td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { background: #fafbfc; font-weight: 600; white-space: nowrap; position: sticky; top: 0; z-index: 2; }
table.grid th a { text-decoration: none; color: var(--fg); }
table.grid tbody tr:hover { background: #f7f9fb; }
table.grid tbody tr:hover td.col-title { background: #f7f9fb; }
table.grid td.nowrap, table.grid td.col-dates { white-space: nowrap; }

/* Название всегда на виду при прокрутке вбок: без него строка не читается */
table.grid .col-title {
  position: sticky; left: 0; z-index: 1; background: var(--card);
  box-shadow: 1px 0 0 var(--line);
  min-width: 170px;
}
@media (max-width: 560px) {
  table.grid .col-title { min-width: 130px; max-width: 150px; }
  table.grid th, table.grid td { padding: 7px 7px; }
}
table.grid th.col-title { z-index: 3; background: #fafbfc; }

.scroll-hint { display: none; font-size: 12px; color: var(--muted); margin: 0 0 6px; }

/* ---------- вход ---------- */

.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login-wrap h1 { text-align: center; margin-bottom: 18px; }

/* ---------- телефон ---------- */

/* Ниже 1400 колонка ответственного только съедает ширину, в списке она почти всегда одна и та же */
@media (max-width: 1400px) {
  table.grid .col-resp { display: none; }
}
@media (max-width: 1100px) {
  table.grid .col-dirs { display: none; }
  .scroll-hint-table { display: block; }
}
/* Год помещается целиком вплоть до планшетов, подсказка нужна только на телефонах */
@media (max-width: 660px) {
  .scroll-hint-year { display: block; }
}

@media (max-width: 900px) {
  /* Ключевое: в колонке flex-start сжимал календарь по содержимому вместо ширины экрана */
  .layout { flex-direction: column; align-items: stretch; }
  .layout main { width: 100%; }
  :root { --cell-min: 76px; }
  .day { padding: 3px 4px; }
  .band { font-size: 11px; height: 18px; line-height: 18px; padding: 0 5px; }
  .week-bands { top: 22px; }
  .kv { grid-template-columns: 108px 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .wrap { padding: 10px 10px 32px; }

  /* На телефоне карточка открывается на весь экран, как требует ТЗ */
  .panel {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--bg);
    padding: 12px 12px 40px;
    overflow-y: auto;
    max-height: none;
    width: auto;
    -webkit-overflow-scrolling: touch;
  }
  .panel:empty { display: none; }

  /* Шапка в одну строку: бренд слева, меню лентой с прокруткой, выход справа */
  .topbar-inner {
    padding: 7px 10px; gap: 8px; flex-wrap: nowrap; align-items: center;
  }
  /* Бренд убираем: первый пункт меню называется так же, выходило "Календарь Календарь" */
  .topbar .brand { display: none; }
  .topbar nav a.mobile-only { display: inline; }
  /* Затухание справа подсказывает, что ленту меню можно листать */
  .topbar nav {
    position: relative;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent 100%);
  }
  .topbar nav {
    gap: 14px; font-size: 14px; overflow-x: auto; flex-wrap: nowrap;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; }
  .topbar .who { display: none; }
  .topbar .profile-link { display: none; }

  .toolbar { gap: 6px; align-items: center; }
  .toolbar .title { order: -1; width: 100%; min-width: 0; font-size: 17px; margin-bottom: 2px; }
  .toolbar .spacer { display: none; }
  .modes a { padding: 6px 10px; font-size: 13px; }
  .btn .full { display: none; }
  .btn .short { display: inline; }
  .nav-group .btn { padding: 7px 10px; }
  .legend-box { margin-bottom: 8px; }

  .check-item { flex-wrap: wrap; gap: 6px; }
  .check-item .text { flex: 1 1 100%; order: 2; }
  .check-item input[type=date], .check-item select { width: auto; flex: 1 1 40%; order: 3; font-size: 13px; }

  table.grid { font-size: 13px; }
}

@media (max-width: 700px) {
  /* Город в плашке первым уходит под нож, название держим до последнего */
  .band .city { display: none; }
  .table-tools { flex-wrap: wrap; }
  .table-tools form.search { order: 5; width: 100%; max-width: none; }
}

@media (max-width: 560px) {
  :root { --cell-min: 62px; }
  .weekdays div { padding: 5px 4px; font-size: 11px; }
  .band { font-size: 10px; padding: 0 4px; }
  .toolbar .count-note { display: none; }
  .day .more { font-size: 11px; padding: 2px 3px; left: 2px; right: 2px; }
  .toolbar .title { font-size: 16px; }
  .legend { font-size: 12px; gap: 4px 10px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 6px; font-size: 12px; }
  .btn { padding: 8px 12px; }
  .year-row .mon { flex-basis: 72px; font-size: 12px; padding: 8px 6px; }
  .year-track { min-width: 560px; }
  .year-head .nums { min-width: 560px; }
}

/* Кнопки и поля не меньше 44 пикселей, иначе пальцем не попасть */
@media (pointer: coarse) {
  .btn { min-height: 38px; }
  /* Ссылки в карточке, например сайт мероприятия: в строку текста пальцем
     не попасть, поэтому им нужна высота побольше */
  .kv dd a { display: inline-block; padding: 6px 0; }
  input[type=checkbox] { width: 20px; height: 20px; }
  .band { min-height: 22px; }
}

/* ---------- обновление жестом в PWA ---------- */

/* Гасит родное потягивание Chrome, чтобы не работали два жеста сразу.
   Заодно убирает эффект оттягивания страницы за края. */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: contain; }
}

.ptr {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
}
.ptr.back { transition: transform .22s ease, opacity .22s ease; }

.ptr-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Стрелка вниз, пока тянуть мало. Когда порог пройден, она зеленеет */
.ptr-arrow {
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid var(--muted);
}
.ptr-circle.ready .ptr-arrow { border-top-color: var(--brand); }

/* Жест принят: стрелка уходит, вместо нее крутится дуга */
.ptr.busy .ptr-arrow { display: none; }
.ptr.busy .ptr-circle {
  border-color: var(--line);
  border-top-color: var(--brand);
  border-width: 3px;
  animation: ptr-spin .7s linear infinite;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

@media print {
  .topbar, .toolbar, .filters, .panel, .ptr { display: none; }
}
