:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --ink: #15171c;
  --muted: #6b7180;
  --line: #e4e6eb;
  --accent: #1f3bd1;

  --free: #ffffff;
  --free-line: #dfe2e8;
  --prebook: #ffd45c;
  --prebook-soft: #fff4cf;
  --prebook-ink: #6b4e00;
  --busy: #e5484d;
  --busy-soft: #fde1e1;
  --busy-ink: #ffffff;

  --radius: 16px;
  --radius-s: 10px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 0.9375rem; line-height: 1.4; }
a { color: inherit; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.0625rem; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.8125rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Верхняя панель */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.875rem 2rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 0.625rem; text-decoration: none; margin-right: auto; }
.brand-mark { font-weight: 700; letter-spacing: 0.18em; }
.brand-sub { color: var(--muted); }
.goto { display: flex; align-items: center; gap: 0.5rem; }
.goto label { color: var(--muted); font-size: 0.8125rem; }
.goto input, .goto button { font: inherit; padding: 0.375rem 0.625rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); }
.goto button { cursor: pointer; }
.sync { font-size: 0.8125rem; color: var(--muted); padding: 0.3rem 0.75rem; border-radius: 999px; background: var(--bg); }

.page { padding: 1.5rem 2rem 3rem; max-width: 1680px; margin: 0 auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.title-group { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pager { display: flex; gap: 0.375rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  min-height: 2.25rem; padding: 0 0.875rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); text-decoration: none; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: #c9cdd6; }
.btn.icon { width: 2.25rem; padding: 0; font-size: 1.125rem; }
.btn.disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); margin-top: 1rem; }
.pill { padding: 0.375rem 0.875rem; border-radius: 999px; font-size: 0.875rem; font-weight: 500; }
.pill.warn { background: var(--prebook-soft); color: var(--prebook-ink); }
.notice { background: var(--prebook-soft); color: var(--prebook-ink); padding: 0.75rem 1rem; border-radius: var(--radius-s); margin: 0 0 1rem; }

.card { background: var(--card); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: 0 1px 2px rgb(16 24 40 / 0.04); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }

/* Сетка месяца */
.grid-scroll { overflow-x: auto; }
.grid { border-collapse: separate; border-spacing: 3px; width: 100%; table-layout: fixed; min-width: 1100px; }
.grid th, .grid td { padding: 0; }
.grid .hall-col { width: 11rem; text-align: left; font-weight: 600; padding-right: 0.75rem; white-space: nowrap; }
.grid thead th a { display: flex; flex-direction: column; align-items: center; text-decoration: none; padding: 0.25rem 0; border-radius: var(--radius-s); }
.grid thead th.today a { background: var(--ink); color: #fff; }
.grid thead th.weekend .dname { color: var(--busy); }
.grid thead th.today .dname { color: #fff; }
.dnum { font-weight: 600; font-variant-numeric: tabular-nums; }
.dname { font-size: 0.75rem; color: var(--muted); }
.cell {
  position: relative; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 2px;
  height: 3.25rem; border-radius: 8px; text-decoration: none; border: 1px solid transparent;
}
.cell.st-free { background: var(--free); border-color: var(--free-line); }
.cell.st-prebook { background: var(--prebook); }
.cell.st-busy { background: var(--busy); }
.cell:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
td.today .cell { box-shadow: inset 0 0 0 2px var(--ink); }
td.past .cell { opacity: 0.55; }
.no-hall .hall-col { color: var(--muted); font-weight: 500; }
.no-hall-cell { height: 1.75rem; background: var(--prebook-soft); color: var(--prebook-ink); font-weight: 700; }

/* Пометки */
.mark {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.125rem; height: 1.125rem; padding: 0 3px;
  border-radius: 999px; font-size: 0.6875rem; font-weight: 700; line-height: 1; background: #fff; color: var(--ink);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08);
}
.mark-conflict { background: var(--ink); color: #fff; }
.mark-evening { background: #fff; color: var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; margin: 1.25rem 0 0; padding: 1rem 0 0; border-top: 1px solid var(--line); font-size: 0.8125rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 0.4rem; }
.swatch { width: 1rem; height: 1rem; border-radius: 4px; border: 1px solid transparent; }
.swatch.st-free { background: var(--free); border-color: var(--free-line); }
.swatch.st-prebook { background: var(--prebook); }
.swatch.st-busy { background: var(--busy); }

/* Шкала дня */
.day-layout { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.day-layout.with-card { grid-template-columns: minmax(0, 1fr) 22rem; }
.timeline { overflow-x: auto; }
.ruler, .lane { display: grid; grid-template-columns: 11rem minmax(760px, 1fr); align-items: center; }
.lane { border-top: 1px solid var(--line); min-height: 4.5rem; }
.lane-label { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; padding-right: 0.75rem; }
.track { position: relative; height: 3.5rem; }
.ruler-track { height: 1.5rem; }
.tick { position: absolute; transform: translateX(-50%); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ext {
  position: absolute; top: 0; bottom: 0; right: 0; border-radius: 6px;
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgb(21 23 28 / 0.05) 6px 12px);
}
.window {
  position: absolute; top: 0.5rem; bottom: 0.5rem; display: flex; align-items: center; justify-content: center;
  border: 1px dashed #b9c0cc; border-radius: var(--radius-s); color: var(--muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden;
}
.bar {
  position: absolute; top: 0.375rem; bottom: 0.375rem; display: flex; border-radius: var(--radius-s); overflow: hidden;
  text-decoration: none; z-index: 1;
}
.bar-body { width: var(--body); display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 0 0.625rem; overflow: hidden; white-space: nowrap; position: relative; }
.bar-body .mark { position: absolute; top: 4px; right: 4px; }
.bar-time { font-weight: 600; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.bar-text { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; }
.bar-break { flex: 1; }
.bar.st-busy .bar-body { background: var(--busy); color: var(--busy-ink); }
.bar.st-busy .bar-break { background: repeating-linear-gradient(135deg, var(--busy-soft) 0 5px, #fff 5px 10px); }
.bar.st-prebook .bar-body { background: var(--prebook); color: var(--prebook-ink); }
.bar.st-prebook .bar-break { background: repeating-linear-gradient(135deg, var(--prebook-soft) 0 5px, #fff 5px 10px); }
.bar.conflict { outline: 2px solid var(--ink); outline-offset: -2px; }
.bar.half { bottom: auto; height: calc(50% - 0.3rem); }
.bar.half.bottom { top: auto; bottom: 0.25rem; }
.bar.half.top { top: 0.25rem; }
.bar.half .bar-body { flex-direction: row; align-items: center; gap: 0.5rem; }
.tick.last { transform: translateX(-100%); }
.bar.selected { box-shadow: 0 0 0 3px var(--accent); }
.bar:hover { filter: brightness(0.97); }
.now { position: absolute; top: -0.5rem; bottom: -0.5rem; width: 2px; background: var(--accent); z-index: 2; }
.now span { position: absolute; top: -1.1rem; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: 0.6875rem; padding: 1px 6px; border-radius: 999px; }

.chip { display: inline-flex; align-items: center; padding: 0.125rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-decoration: none; }
.chip.st-free { background: var(--bg); color: var(--muted); }
.chip.st-prebook { background: var(--prebook); color: var(--prebook-ink); }
.chip.st-busy { background: var(--busy); color: var(--busy-ink); }
.conflict-chip { background: var(--ink); color: #fff; }
.expired-chip { background: var(--prebook-soft); color: var(--prebook-ink); }
.no-hall-list { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 1rem; padding: 0.75rem 1rem; border-radius: var(--radius-s); background: var(--prebook-soft); }

.booking-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; margin: 1rem 0 0; }
.booking-card dt { color: var(--muted); }
.booking-card dd { margin: 0; font-weight: 500; }
.booking-card .chip { margin-right: 0.25rem; }

@media (max-width: 900px) {
  .page { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  .day-layout.with-card { grid-template-columns: 1fr; }
}
.bar.half .bar-body .mark { position: static; }

/* Вход, учётные записи */
.account { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.account form { margin: 0; }
.who { font-weight: 500; margin-right: 0.25rem; }
.auth-card { max-width: 26rem; margin: 2rem auto; }
.auth-card h1 { margin-bottom: 1rem; }
.form { display: flex; flex-direction: column; gap: 0.375rem; }
.form label { color: var(--muted); font-size: 0.8125rem; margin-top: 0.5rem; }
.form input, .form select, .users input { font: inherit; padding: 0.5rem 0.625rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); }
.form .btn.primary { align-self: flex-start; }
.notice.error { background: var(--busy-soft); color: #8a1c20; }
.notice.ok { background: #e3f6e8; color: #17602c; }
.form-card { max-width: 26rem; margin-top: 1.25rem; }
.users { width: 100%; border-collapse: collapse; }
.users th { text-align: left; color: var(--muted); font-size: 0.8125rem; font-weight: 500; padding: 0.375rem 0.5rem; }
.users td { padding: 0.5rem; border-top: 1px solid var(--line); vertical-align: middle; }
.inline { display: flex; gap: 0.375rem; margin: 0; }

/* Лента соседних дней и шкала дня списком — для телефона (п. 60, Р31) */
.date-strip { display: none; }
.agenda { display: none; }

@media (max-width: 720px) {
  body { font-size: 1rem; }
  h1 { font-size: 1.375rem; }
  .topbar { gap: 0.5rem 1rem; }
  .brand { margin-right: 0; width: 100%; }
  .goto label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .goto { flex: 1; }
  .goto input { flex: 1; min-width: 0; min-height: 2.75rem; }
  .goto button { min-height: 2.75rem; }
  .sync { order: 3; }
  .btn { min-height: 2.75rem; }
  .btn.icon { width: 2.75rem; }
  .card { padding: 1rem; border-radius: 14px; }
  .head { margin-bottom: 0.75rem; }

  .date-strip { display: flex; gap: 0.375rem; overflow-x: auto; margin: 0 -1rem 1rem; padding: 0 1rem 0.25rem; scroll-snap-type: x mandatory; }
  .strip-day {
    flex: 1 0 3.25rem; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.125rem;
    padding: 0.5rem 0.25rem; border-radius: 12px; background: var(--card); text-decoration: none; border: 1px solid var(--line);
  }
  .strip-day.current { background: var(--ink); color: #fff; border-color: var(--ink); }
  .strip-day.current .dname { color: #fff; }
  .strip-day .dnum { font-size: 1.125rem; }

  .timeline, .timeline-card .card-head .small, .timeline-card .legend { display: none; }
  .agenda { display: flex; flex-direction: column; gap: 0.75rem; }
  .agenda-hall header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
  .agenda-hall ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
  .agenda-hall + .agenda-hall { border-top: 1px solid var(--line); padding-top: 0.75rem; }
  .agenda-item {
    position: relative; display: flex; flex-direction: column; gap: 0.125rem; padding: 0.625rem 2.5rem 0.625rem 0.875rem;
    border-radius: var(--radius-s); text-decoration: none;
  }
  .agenda-item.st-busy { background: var(--busy); color: var(--busy-ink); }
  .agenda-item.st-prebook { background: var(--prebook); color: var(--prebook-ink); }
  .agenda-item .mark { position: absolute; top: 0.625rem; right: 0.625rem; }
  .agenda-item .mark + .mark { right: 2rem; }
  .agenda-time { font-weight: 600; font-variant-numeric: tabular-nums; }
  .agenda-text, .agenda-break { font-size: 0.875rem; }
  .agenda-break { opacity: 0.85; }
  .agenda-window { padding: 0.5rem 0.875rem; border: 1px dashed #b9c0cc; border-radius: var(--radius-s); color: var(--muted); font-size: 0.875rem; }

  .grid .hall-col { position: sticky; left: 0; z-index: 1; background: var(--card); width: 7.5rem; white-space: normal; }
  .grid { min-width: 0; width: max-content; }
  .grid td, .grid thead th:not(.hall-col) { width: 2.75rem; }
  .legend { gap: 0.375rem 1rem; }
}

@media (max-width: 720px) {
  .topbar { padding: 0.625rem 1rem; }
  .brand { width: auto; flex: 1; }
  .brand-sub { display: none; }
  .account { gap: 0.375rem; flex-wrap: nowrap; }
  .account .who .muted { display: none; }
  .account .btn { min-height: 2.25rem; padding: 0 0.75rem; font-size: 0.875rem; }
  .goto { order: 2; width: 100%; }
  .sync { order: 3; padding: 0; background: none; font-size: 0.8125rem; }
  .day-head .pager { display: none; }
  .day-head .title-group { flex-wrap: nowrap; gap: 0.75rem; }
  .date-strip { scrollbar-width: none; }
  .date-strip::-webkit-scrollbar { display: none; }
}
@media (max-width: 720px) {
  .account .who { display: none; }
  .account { flex-wrap: wrap; justify-content: flex-end; }
  .btn { white-space: nowrap; }
}
@media (max-width: 720px) {
  .grid .hall-col { width: 5.25rem; font-size: 0.8125rem; line-height: 1.2; padding-right: 0.375rem; }
  .card-head .small { display: none; }
  .grid td, .grid thead th:not(.hall-col) { width: 2.5rem; }
}

/* Плашка «Нет связи с сервисом» (п. 104) */
.offline-banner {
  position: sticky; top: 0; z-index: 10; padding: 0.75rem 2rem;
  background: var(--prebook); color: var(--prebook-ink); font-weight: 600; text-align: center;
}
.offline-banner[hidden] { display: none; }
