/* План офиса — общий стиль: браузер и Telegram Mini App */

:root {
  --bg: var(--tg-theme-bg-color, #f4f6f9);
  --text: var(--tg-theme-text-color, #1a1d26);
  --hint: var(--tg-theme-hint-color, #5c6578);
  --card: rgba(255, 255, 255, 0.85);
  --border: rgba(0, 0, 0, 0.08);
  --accent: #2563eb;
  --free: #16a34a;
  --occupied: #dc2626;
  --mine: #ca8a04;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #0f1419);
    --text: var(--tg-theme-text-color, #e8eaef);
    --hint: var(--tg-theme-hint-color, #9aa3b5);
    --card: rgba(30, 36, 48, 0.92);
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

body.webapp-loading #dateRow,
body.webapp-loading #officeSelect,
body.webapp-loading #authHelp,
body.webapp-loading #planSection,
body.webapp-loading #desks-heading,
body.webapp-loading #desksLead,
body.webapp-loading #deskLegend,
body.webapp-loading #grid,
body.webapp-loading #meetingsSection,
body.webapp-loading #myBookingsSection,
body.webapp-loading #notificationsSection,
body.webapp-loading .site-footer,
body.webapp-loading #fetchErr {
  display: none !important;
}

.notification-settings {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.notification-settings label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
}

.notification-settings input {
  margin-top: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 16px;
  background: var(--card);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header__inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.admin-nav-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
  white-space: nowrap;
}

.admin-nav-btn:hover {
  filter: brightness(1.06);
}

.site-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.site-brand small {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--hint);
  margin-top: 2px;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.12);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 10px;
  line-height: 1.3;
}

.lead {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--hint);
}

.date-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.date-row__line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.date-row__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  flex: 0 0 3.6rem;
  width: 3.6rem;
}

.date-row__input {
  font: inherit;
  font-size: 0.95rem;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
  flex: 1 1 auto;
}

.date-row__select {
  width: 100%;
  cursor: pointer;
}

.date-row__date {
  width: 100%;
  box-sizing: border-box;
}

.auth-help {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-help__title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.auth-help__text {
  font-size: 0.85rem;
  color: var(--hint);
  margin-bottom: 10px;
}

.auth-help__btn {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}

.plan-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.plan-card__scroll {
  max-height: min(72vh, 560px);
  overflow: auto;
  background: rgba(0, 0, 0, 0.04);
  -webkit-overflow-scrolling: touch;
}

.plan-panzoom {
  display: block;
  width: 100%;
  transform-origin: 50% 50%;
}

.plan-panzoom img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--hint);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Нет доступа к API (403 / 404): вместо демо — картинка и подпись */
.unauthorized-panel {
  text-align: center;
  padding: 20px 16px 24px;
  margin: 0 0 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.unauthorized-panel__img {
  display: block;
  max-width: min(280px, 100%);
  width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  object-fit: contain;
}

.unauthorized-panel__caption {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--hint);
}

.unauthorized-panel__intro {
  margin: 14px 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.unauthorized-panel__btn {
  margin-top: 10px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}

.desk {
  border: none;
  border-radius: 12px;
  padding: 14px 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.desk:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.desk:active {
  transform: translateY(0);
}

.desk.free {
  background: var(--free);
}
.desk.occupied {
  background: var(--occupied);
}
.desk.mine {
  background: var(--mine);
  color: #1a1a1a;
  text-shadow: none;
}

.desk.closed {
  background: #64748b;
  cursor: not-allowed;
  opacity: 0.92;
}

.desk.closed:hover {
  transform: none;
  filter: none;
}

.err {
  color: #b91c1c;
  font-size: 0.85rem;
  margin-top: 8px;
}

#meetingsSection,
#myBookingsSection {
  margin-top: 24px;
}

.bookings-cal__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.bookings-cal__nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.bookings-cal__month {
  font-weight: 700;
  font-size: 0.98rem;
  text-align: center;
  text-transform: capitalize;
}

.bookings-cal__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--hint);
}

.bookings-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.bookings-cal__cell {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  min-height: 44px;
  padding: 4px 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  cursor: pointer;
  font: inherit;
}

.bookings-cal__cell:disabled {
  opacity: 0.35;
  cursor: default;
}

.bookings-cal__cell--muted {
  color: var(--hint);
  opacity: 0.45;
}

.bookings-cal__cell--today {
  border-color: rgba(37, 99, 235, 0.45);
}

.bookings-cal__cell--selected {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.55);
}

.bookings-cal__daynum {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
}

.bookings-cal__marks {
  display: flex;
  gap: 3px;
  min-height: 6px;
}

.bookings-cal__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: #94a3b8;
}

.bookings-cal__dot--desk {
  background: var(--mine);
}

.bookings-cal__dot--meeting {
  background: var(--accent);
}

.bookings-cal__dot--both {
  background: linear-gradient(90deg, var(--mine) 50%, var(--accent) 50%);
}

.bookings-cal__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 12px 0 4px;
  font-size: 0.78rem;
  color: var(--hint);
  align-items: center;
}

.bookings-cal__legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bookings-cal__day {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.meeting-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 12px;
}

.meeting-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}

.meeting-form__times {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

#meetingTimeFields[hidden] {
  display: none !important;
}

#meetingDateRow[hidden],
body.meetings-only #meetingDateRow {
  display: none !important;
}

.meeting-slot-picker,
#meetingSlotPicker {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

#meetingSlotPicker[hidden] {
  display: none !important;
}

.meeting-slot-legend {
  margin: 0;
}

.meeting-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.meeting-slot {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 6px;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.25;
  color: #fff;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.meeting-slot:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.meeting-slot.free {
  background: var(--free);
}

.meeting-slot.occupied {
  background: var(--occupied);
  cursor: not-allowed;
}

.meeting-slot.mine {
  background: var(--mine);
  color: #1a1a1a;
  text-shadow: none;
  cursor: not-allowed;
}

.meeting-slot.closed {
  background: #64748b;
  cursor: not-allowed;
  opacity: 1;
}

.meeting-slot.selected {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 6px var(--accent);
}

.meeting-slot:disabled,
.meeting-slot[aria-disabled="true"] {
  opacity: 1;
  filter: none;
  -webkit-text-fill-color: currentColor;
}

.meeting-slot:disabled,
.meeting-slot[aria-disabled="true"]:hover,
.meeting-slot.occupied:hover,
.meeting-slot.mine:hover,
.meeting-slot.closed:hover {
  transform: none;
  filter: none;
}

.meeting-form__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meeting-form__row label {
  font-size: 0.82rem;
  color: var(--hint);
}

.meeting-form__row input {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
}

.meeting-form > .meeting-btn {
  grid-column: 1 / -1;
}

.meeting-btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}

.meeting-btn--ghost {
  color: var(--hint);
  background: transparent;
  border-color: var(--border);
}

.meeting-form__row textarea {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  resize: vertical;
  min-height: 72px;
}

.meeting-row__meta {
  display: block;
  font-size: 0.82rem;
  color: var(--hint);
  line-height: 1.35;
  margin-top: 4px;
}

.meeting-subtitle {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.meeting-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.booking-group-title {
  margin: 8px 0 2px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meeting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.meeting-row__time {
  font-size: 0.9rem;
}

.meeting-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  justify-content: flex-end;
}

.meeting-row__cancel {
  flex-shrink: 0;
  border: 1px solid rgba(185, 28, 28, 0.35);
  border-radius: 8px;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.82rem;
  background: rgba(185, 28, 28, 0.1);
  color: #b91c1c;
}

.meeting-row__actions .meeting-row__cancel:first-child {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--hint);
  border-top: 1px solid var(--border);
}

/* Нет в белом списке (403 API): только панель с котиком, без плана и календаря */
body.webapp-guest-only .site-header,
body.webapp-guest-only #subtitle,
body.webapp-guest-only #dateRow,
body.webapp-guest-only #authHelp,
body.webapp-guest-only #planSection,
body.webapp-guest-only #desks-heading,
body.webapp-guest-only #desksLead,
body.webapp-guest-only #deskLegend,
body.webapp-guest-only #grid,
body.webapp-guest-only #meetingsSection,
body.webapp-guest-only #myBookingsSection,
body.webapp-guest-only #notificationsSection,
body.webapp-guest-only .site-footer,
body.webapp-guest-only #fetchErr {
  display: none !important;
}

body.webapp-guest-only main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 24px);
  padding-top: 24px;
  padding-bottom: 24px;
}

body.webapp-guest-only #unauthorizedPanel {
  margin-top: auto;
  margin-bottom: auto;
}

.hidden {
  display: none !important;
}

/* In-page confirms: alert/confirm often blocked in Yandex/Messenger WebView */
.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.action-sheet[hidden] {
  display: none !important;
}
.action-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.action-sheet__panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 16px 14px;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
}
.action-sheet__title {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.action-sheet__msg {
  margin: 0 0 14px;
  color: var(--hint);
  white-space: pre-wrap;
  font-size: 0.92rem;
}
.action-sheet__input-wrap {
  margin: 0 0 14px;
}
.action-sheet__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.action-sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-sheet__btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.action-sheet__btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.action-sheet__btn--danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.action-sheet__btn--ghost {
  background: transparent;
}
