:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #6b778c;
  --line: #e6ebf2;
  --primary: #2b6ef2;
  --primary-dark: #1f55c7;
  --danger: #d92d20;
  --shadow: 0 18px 45px rgba(22, 32, 51, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 24px 28px 14px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}

h1 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.12;
}

h2 {
  margin: 0 0 18px;
}

h3 {
  margin: 18px 0 10px;
}

.user-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  text-align: right;
  min-width: 150px;
}

.user-box span {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.user-box small {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 0 28px 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.calendar-panel {
  padding: 16px;
  min-height: calc(100vh - 128px);
}

.side-panel {
  padding: 22px;
  align-self: start;
  position: sticky;
  top: 18px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

button.primary:hover {
  background: var(--primary-dark);
}

button.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.compact-note {
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
  margin-top: 18px;
}

.legend {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 8px 0;
  color: var(--muted);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.dot.scheduled {
  background: #2b6ef2;
}

.dot.moved {
  background: #f79009;
}

.dot.done {
  background: #12b76a;
}

.dot.canceled {
  background: #98a2b3;
}

.mobile-help {
  display: none;
}

.floating-add {
  display: none;
}

.dialog {
  width: min(720px, calc(100vw - 32px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .24);
}

.dialog::backdrop {
  background: rgba(16, 24, 40, .42);
}

.dialog form {
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
}

.dialog label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  font-weight: 800;
}

.dialog input,
.dialog textarea,
.dialog select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  font-weight: 400;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  padding: 0;
  margin: 20px 0 0;
}

.spacer {
  flex: 1;
}

.hidden {
  display: none !important;
}

.resume-box {
  border: 1px dashed #b9c3d5;
  background: #f8fafc;
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
}

.resume-box a {
  color: var(--primary);
  font-weight: 800;
}

.fc {
  font-size: 14px;
}

.fc .fc-toolbar-title {
  font-size: 22px;
  font-weight: 900;
}

.fc .fc-button {
  border-radius: 10px !important;
  font-weight: 700 !important;
  padding: 8px 12px !important;
}

.fc .fc-button-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.fc .fc-button-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.fc-event {
  border: 0 !important;
  padding: 2px 4px;
  cursor: pointer;
}

.fc-event.status-moved {
  background: #f79009 !important;
}

.fc-event.status-done {
  background: #12b76a !important;
}

.fc-event.status-canceled {
  background: #98a2b3 !important;
}

.fc-list-event-title,
.fc-list-event-time {
  cursor: pointer;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #dbeafe, transparent 35%), var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 34px;
  box-shadow: var(--shadow);
  text-align: center;
}

.logo {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 20px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #2b6ef2, #7c3aed);
}

.error {
  color: var(--danger);
  margin-top: 14px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 720px) {
  body {
    background: #f4f7fb;
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .topbar {
    padding: 14px 14px 10px;
    align-items: flex-start;
  }

  .title-block {
    min-width: 0;
  }

  .eyebrow {
    font-size: 10px;
  }

  h1 {
    font-size: 24px;
  }

  .user-box {
    min-width: 104px;
    max-width: 128px;
    padding: 8px 10px;
    border-radius: 14px;
    font-size: 13px;
  }

  .user-box span {
    max-width: 104px;
  }

  .layout {
    display: block;
    padding: 0 10px 18px;
  }

  .side-panel {
    display: none;
  }

  .calendar-panel {
    padding: 10px;
    border-radius: 20px;
    min-height: auto;
  }

  .mobile-help {
    display: block;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .floating-add {
    display: grid;
    place-items: center;
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 20;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 0;
    background: var(--primary);
    color: white;
    font-size: 34px;
    font-weight: 700;
    box-shadow: 0 16px 35px rgba(43, 110, 242, .36);
  }

  .fc {
    font-size: 13px;
  }

  .fc .fc-toolbar {
    gap: 8px;
    align-items: stretch;
    margin-bottom: 10px !important;
  }

  .fc .fc-toolbar.fc-header-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
  }

  .fc .fc-toolbar-title {
    font-size: 16px;
    line-height: 1.15;
    text-align: center;
    padding-top: 4px;
  }

  .fc .fc-button {
    padding: 8px 9px !important;
    font-size: 13px !important;
  }

  .fc .fc-button-group {
    display: flex;
  }

  .fc .fc-list-day-cushion {
    padding: 10px 12px !important;
  }

  .fc .fc-list-event td {
    padding: 11px 8px !important;
  }

  .fc .fc-list-empty {
    padding: 36px 12px;
    color: var(--muted);
  }

  .dialog {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: calc(100vh - 18px);
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }

  .dialog form {
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 18px);
    overflow: auto;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .dialog-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 12px;
    padding-bottom: 2px;
  }

  .dialog-actions button {
    padding: 12px 14px;
  }
}

.calendar-export-box {
  margin: 12px 0;
}

.calendar-export-link {
  display: block;
  text-align: center;
  text-decoration: none;
  border-radius: 14px;
  padding: 13px 14px;
  background: #f0f6ff;
  color: #1f55c7;
  font-weight: 900;
  border: 1px solid #cfe0ff;
}

.calendar-export-link:hover {
  background: #e5efff;
}

@media (max-width: 720px) {
  .dialog {
    margin-top: 84px;
  }

  .dialog form {
    padding-top: 22px;
  }

  .dialog-head {
    position: sticky;
    top: -22px;
    z-index: 5;
    background: #fff;
    padding-top: 8px;
    padding-bottom: 10px;
  }
}

/* Скрываем старую кнопку выгрузки .ics из Mini App */
.calendar-export-box {
  display: none !important;
}

/* Скрываем статус из карточки встречи */
.dialog label:has(#status) {
  display: none !important;
}

/* Чуть фиксируем карточку на телефоне, чтобы она меньше "ездила" */
@media (max-width: 720px) {
  .dialog {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    margin: 0;
    max-height: 88vh;
    border-radius: 24px 24px 0 0;
  }

  .dialog form {
    max-height: 88vh;
    overflow: auto;
  }
}

.calendar-export-box,
#calendarExportBox,
#calendarExportLink {
  display: none !important;
}

/* Фиксируем горизонтальное движение интерфейса и карточки встречи */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
  overscroll-behavior-x: none;
}

.topbar,
.layout,
.calendar-panel,
.side-panel,
.dialog,
.dialog form {
  max-width: 100%;
  overflow-x: hidden !important;
}

@media (max-width: 720px) {
  html,
  body {
    position: relative;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
    touch-action: pan-y;
  }

  .dialog {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 0 !important;
    top: auto !important;

    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    min-width: 0 !important;

    margin: 0 !important;
    transform: none !important;

    max-height: 88vh !important;
    border-radius: 24px 24px 0 0 !important;

    overflow-x: hidden !important;
    touch-action: pan-y;
  }

  .dialog form {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    touch-action: pan-y;
  }

  .dialog-head,
  .dialog label,
  .dialog input,
  .dialog textarea,
  .dialog select,
  .resume-box,
  .calendar-export-box {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .dialog-actions {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    gap: 8px !important;
  }

  .dialog-actions button {
    min-width: 0 !important;
    white-space: nowrap;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .fc,
  .fc-view-harness,
  .fc-scrollgrid {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
}

/* ===== Свое окно сообщений вместо alert/confirm ===== */
.ui-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.ui-dialog::backdrop {
  background: rgba(16, 24, 40, 0.44);
}

.ui-dialog-form {
  padding: 20px;
}

.ui-dialog-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 12px;
}

.ui-dialog-text {
  white-space: pre-line;
  line-height: 1.5;
  color: var(--text);
}

.ui-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ===== Фикс desktop-версии ===== */
@media (min-width: 721px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body {
    padding-bottom: 0 !important;
  }

  .topbar,
  .layout {
    width: min(1440px, calc(100vw - 32px));
    max-width: min(1440px, calc(100vw - 32px));
    margin-left: auto;
    margin-right: auto;
  }

  .topbar {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 18px !important;
    padding-bottom: 14px !important;
  }

  .layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 18px;
    padding: 0 0 28px !important;
    align-items: start;
  }

  .calendar-panel {
    width: 100%;
    min-width: 0;
    min-height: calc(100vh - 140px);
    overflow: hidden;
  }

  .side-panel {
    display: block;
    position: sticky;
    top: 18px;
    align-self: start;
  }

  #calendar,
  .fc,
  .fc-view-harness,
  .fc-scrollgrid {
    width: 100% !important;
    max-width: 100% !important;
  }

  .fc .fc-header-toolbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
  }

  .fc .fc-toolbar-chunk {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .fc .fc-toolbar-title {
    font-size: 24px !important;
  }

  /* Карточка / новое собеседование на desktop */
  .dialog {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;

    width: min(760px, calc(100vw - 48px)) !important;
    max-width: min(760px, calc(100vw - 48px)) !important;
    min-width: 0 !important;

    max-height: 88vh !important;
    margin: 0 !important;
    border-radius: 24px !important;
    overflow: hidden !important;
  }

  .dialog form {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 24px !important;
  }

  .dialog-head {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #fff;
    padding-bottom: 12px;
  }

  .grid-2 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 14px !important;
  }

  .dialog-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: #fff;
    padding-top: 14px;
    padding-bottom: 2px;
  }

  .dialog label,
  .dialog input,
  .dialog textarea,
  .dialog select,
  .resume-box {
    max-width: 100%;
  }
}

/* Кнопка добавления внутри календаря, вместо кривого плавающего плюса в Telegram Desktop */
.mobile-actions {
  display: none;
  margin: 0 0 10px;
}

.mobile-add-btn {
  width: 100%;
  justify-content: center;
}

/* Собственное окно ошибок */
.ui-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
}

.ui-dialog::backdrop {
  background: rgba(16, 24, 40, 0.46);
}

.ui-dialog-form {
  padding: 22px;
}

.ui-dialog-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 12px;
}

.ui-dialog-text {
  white-space: pre-line;
  line-height: 1.5;
  color: var(--text);
}

.ui-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Telegram Desktop Mini App — ширина контейнера ограничена самим Telegram */
.tg-desktop .floating-add {
  display: none !important;
}

.tg-desktop .mobile-actions {
  display: block !important;
}

.tg-desktop .calendar-panel {
  padding: 10px !important;
}

.tg-desktop .mobile-help {
  margin-bottom: 10px;
}

.tg-desktop .dialog {
  left: 8px !important;
  right: 8px !important;
  bottom: 0 !important;
  top: auto !important;
  width: auto !important;
  max-width: calc(100vw - 16px) !important;
  transform: none !important;
  margin: 0 !important;
  border-radius: 24px 24px 0 0 !important;
}

.tg-desktop .dialog form {
  padding: 18px 16px 84px !important;
}

.tg-desktop .dialog-actions {
  position: fixed !important;
  left: 8px !important;
  right: 8px !important;
  bottom: 0 !important;
  padding: 12px 16px 14px !important;
  background: #fff !important;
  border-top: 1px solid var(--line);
  border-radius: 0 0 24px 24px;
}

.tg-desktop .dialog-actions button {
  min-width: 0 !important;
}

.tg-desktop .ui-dialog {
  width: min(360px, calc(100vw - 28px));
}

/* Чужие собеседования для рекрутеров отображаются как занятый слот */
.fc-event.busy-slot,
.fc-event.status-busy {
  background: #98a2b3 !important;
  border-color: #98a2b3 !important;
  color: #ffffff !important;
  cursor: default !important;
}

.fc-event.busy-slot:hover,
.fc-event.status-busy:hover {
  filter: none !important;
}

.fc-list-event.busy-slot .fc-list-event-title,
.fc-list-event.status-busy .fc-list-event-title {
  color: #667085 !important;
  font-weight: 800;
}

button.secondary {
  border-color: #cfe0ff;
  background: #f0f6ff;
  color: #1f55c7;
  font-weight: 800;
}

button.secondary:hover {
  background: #e5efff;
}

.transfer-hint {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #cfe0ff;
  background: #f0f6ff;
  color: #1f55c7;
  font-weight: 700;
  line-height: 1.35;
}
