/* =========================================================================
   assets/app.css — стили приложения «Заявка на отпуск»
   ========================================================================= */

/* ---------- Переменные ---------- */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e4e9;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2f6feb;
  --accent-dark: #1f4fbf;
  --warn-bg: #fff3cd;
  --warn-br: #ffe08a;
  --info-bg: #e7f1ff;
  --info-br: #b6d4fe;
  --ok-bg: #e6f6ea;
  --ok-br: #b7e4c7;
  --err-bg: #fdecef;
  --err-br: #f5b5c0;
  --radius: 10px;
  --conflict: #ff2d2d;
}

/* ---------- Сброс / база ---------- */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 16px;
}

h2, h3, h4 {
  margin: 0 0 10px;
  font-weight: 600;
}

h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- Автокомплит (группы пересечений) ---------- */
.group-add {
  position: relative;
}

.autocomplete {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 20;
  margin-top: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}

.ac-item {
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ac-item:hover {
  background: #eef1f6;
}

.ac-fio {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.ac-pos {
  color: var(--muted);
  font-size: 12px;
}

.ac-item.ac-muted {
  color: var(--muted);
  font-style: italic;
  cursor: default;
}

.ac-item.ac-muted:hover {
  background: transparent;
}

.ac-item.ac-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ac-item.ac-disabled:hover {
  background: transparent;
}

/* ---------- Контейнер ---------- */
.app {
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.whoami {
  color: var(--muted);
  font-size: 13px;
}

.whoami b {
  color: var(--text);
  font-weight: 600;
}

#whoami-roles {
  margin-left: 8px;
  color: var(--muted);
}

/* ---------- Вкладки ---------- */
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
  background: #eef1f6;
}

.tab.active {
  background: var(--card);
  color: var(--accent);
  border-color: var(--border);
  border-bottom-color: var(--card);
  margin-bottom: -2px;
  font-weight: 600;
}

.tab .badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
  vertical-align: middle;
}

.tab .badge:empty {
  display: none;
}

.tab.hidden {
  display: none;
}

/* ---------- Панели вкладок ---------- */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.card > h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Формы ---------- */
.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

input[type="date"],
input[type="text"],
input[type="search"],
input[type="number"],
select {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, outline 0.15s;
}

input[type="date"]:focus,
input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid #cfe0ff;
  outline-offset: 0;
  border-color: var(--accent);
}

input[disabled],
button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Кнопки ---------- */
button {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover {
  background: #f0f3f8;
}

button:active {
  transform: translateY(1px);
}

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

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

button.ok {
  border-color: #2f9e44;
  color: #2f9e44;
}

button.ok:hover {
  background: var(--ok-bg);
}

button.danger {
  border-color: #e5484d;
  color: #e5484d;
}

button.danger:hover {
  background: var(--err-bg);
}

button.small {
  padding: 4px 8px;
  font-size: 12px;
}

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- Списки заявок ---------- */
.req-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.req {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  background: #fff;
}

.req .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  grid-column: 1 / -1;
}

.req .dates {
  font-weight: 600;
}

.req .fio {
  font-weight: 600;
}

.req .tag {
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.tag.PENDING_MANAGER {
  background: var(--warn-bg);
  border-color: var(--warn-br);
  color: #7a5b00;
}

.tag.PENDING_HR {
  background: var(--info-bg);
  border-color: var(--info-br);
  color: #0b4f9c;
}

.tag.APPROVED {
  background: var(--ok-bg);
  border-color: var(--ok-br);
  color: #1c6b34;
}

.tag.REJECTED {
  background: var(--err-bg);
  border-color: var(--err-br);
  color: #b42318;
}

.req .approver {
  color: var(--muted);
  font-size: 12.5px;
  grid-column: 1 / -1;
}

.req .approver b {
  color: var(--text);
  font-weight: 600;
}

.req .reason {
  grid-column: 1 / -1;
  color: #b42318;
  font-size: 12.5px;
}

.req .actions {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  justify-content: flex-end;
  grid-column: 2;
  grid-row: 1;
}

.req .meta + .actions {
  grid-row: 1;
  align-self: start;
}

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 6px 0;
  grid-column: 1 / -1;
}

/* ---------- Подгруппы внутри карточек ---------- */
.subgroup {
  margin-top: 14px;
}

.subgroup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.subgroup-head h4 {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 12px;
  margin: 0;
}

.subgroup-head h4 .hint {
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* ---------- Списки сотрудников / группы пересечений ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 800px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.emp-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.emp-box h4 {
  margin: 0 0 8px;
}

.emp-search {
  width: 100%;
  margin-bottom: 8px;
}

.emp-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow: auto;
}

.emp-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
}

.emp-list li:hover {
  background: #eef1f6;
}

.emp-list li .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emp-list li .pos {
  color: var(--muted);
  font-size: 12px;
}

.emp-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.emp-add input {
  flex: 1;
}

/* ---------- Группы пересечений ---------- */
#groups-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

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

.group-head b {
  font-size: 14px;
}

.group-members {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.group-member span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.group-add input {
  flex: 1;
}

/* ---------- Периоды запуска ---------- */
#launch-editor {
  margin-bottom: 10px;
}

.lp-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.lp-row input[type="date"] {
  width: 160px;
}

/* ---------- Подсказки / сообщения ---------- */
.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 6px;
}

#launch-msg,
#cross-msg {
  margin-top: 8px;
}

#msg {
  margin-top: 8px;
}

/* ---------- Блок «Запрещённые периоды» ---------- */
#launch-info {
  background: var(--warn-bg);
  border: 1px solid var(--warn-br);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}

#launch-info strong {
  display: block;
  margin-bottom: 4px;
}

#launch-list {
  margin: 6px 0 0 20px;
  padding: 0;
}

#launch-list li {
  margin-bottom: 2px;
}

/* ---------- Тосты ---------- */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: #1f2328;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 360px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.err {
  background: #b42318;
}

.toast.ok {
  background: #2f9e44;
}

.toast.warn {
  background: #c98a00;
  color: #fff;
}

/* ---------- Адаптивность ---------- */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  .req {
    grid-template-columns: 1fr;
  }

  .req .actions {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-content: flex-start;
  }

  .lp-row input[type="date"] {
    width: 100%;
  }

  .tab {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* ---------- Скроллбар (для списков) ---------- */
.emp-list::-webkit-scrollbar {
  width: 8px;
}

.emp-list::-webkit-scrollbar-thumb {
  background: #cfd3da;
  border-radius: 4px;
}

.emp-list::-webkit-scrollbar-thumb:hover {
  background: #b8bdc6;
}

/* =========================================================
   Календарь отпусков (модалка)
   ========================================================= */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,18,22,.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: min(1300px, 97vw);
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; color: #000;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.modal-head label { color: #000; }
.modal-head select {
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: #000;
}
.modal-body { padding: 12px 18px 18px; overflow: auto; }

.cal-wrap { overflow-x: auto; }

/* ---------- Компактный календарь: выше и уже ---------- */
table.cal {
  border-collapse: separate; border-spacing: 0; font-size: 12px;
  min-width: 720px;   /* было 900 — уменьшили по горизонтали */
  color: #000;
}
table.cal th, table.cal td {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 4px 6px; text-align: center; white-space: nowrap; color: #000;
}
table.cal thead th {
  background: #fafbfd; position: sticky; top: 0; z-index: 2; font-weight: 600;
}
table.cal thead tr:nth-child(2) th { top: 28px; }

/* Метки недель — вертикально, чтобы сэкономить ширину */
table.cal thead th.week {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 84px;        /* место под вертикальный текст */
  padding: 4px 3px;
  font-weight: 500;
  font-size: 11px;
  white-space: nowrap;
}

table.cal .fio-col {
  position: sticky; left: 0; background: #fafbfd; z-index: 3;
  text-align: left; min-width: 200px; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis;
}
table.cal thead .fio-col { z-index: 4; }

/* Ячейки выше (34px) и уже (36px) */
table.cal tbody td.cell {
  width: 36px; min-width: 36px; height: 34px; position: relative;
}
table.cal tbody td.cell.vac { background: var(--vac-color); color: #000; font-weight: 600; }
table.cal tbody td.cell.pending {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 4px, transparent 4px 8px),
    var(--vac-color);
}
table.cal tbody td.cell.vac.start::after {
  content: ''; position: absolute; inset: 0;
  border-left: 3px solid rgba(0,0,0,.35);
}
table.cal tbody td.cell.vac.end::after {
  content: ''; position: absolute; inset: 0;
  border-right: 3px solid rgba(0,0,0,.35);
}
table.cal tbody td.cell.conflict {
  background: #ff2d2d !important; color: #000 !important; font-weight: 700;
}
table.cal tbody td.fio-col.colored { background: var(--vac-color); font-weight: 600; }
table.cal tbody tr.dept-row td {
  background: #eef1f6; font-weight: 700; text-align: left;
  padding: 6px 10px;
}

.legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px;
  color: #000; font-size: 12px;
}
.legend .sw {
  display: inline-block; width: 16px; height: 16px; border-radius: 3px;
  vertical-align: -3px; margin-right: 6px; border: 1px solid rgba(0,0,0,.1);
}
.legend .sw.pending {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 4px, transparent 4px 8px),
    #aec6ff;
}
.legend .sw.red { background: #ff2d2d; }

/* ---------- Выбор отделов в календаре ---------- */
.cal-dept-wrap { position: relative; }

.cal-dept-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: #000;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-dept-btn:hover { background: #f0f3f8; }

.cal-dept-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  width: 320px;
  max-height: 60vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  padding: 10px;
  color: #000;
}

.cal-dept-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  cursor: pointer;
}

.cal-dept-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.cal-dept-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 40vh;
  overflow: auto;
}

.cal-dept-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #000;
}
.cal-dept-item:hover { background: #eef1f6; }
.cal-dept-item input { flex: 0 0 auto; }
.cal-dept-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-dept-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

/* =========================================================
   Модалка «Сотрудники без заявки»
   ========================================================= */
.novac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: #000;
}
.novac-item:hover { background: #eef1f6; }

.novac-fio {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #000;
}
.novac-pos {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

/* Пометка «изменена» для RETURNED-заявок */
.tag-edit {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #fff0d6;
  border: 1px solid #ffd08a;
  color: #8a5200;
  font-weight: 600;
}

/* Бейдж статуса RETURNED */
.tag.RETURNED {
  background: #fff0d6;
  border-color: #ffd08a;
  color: #8a5200;
}

#edit-launch-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-br);
  padding: 8px 10px;
  border-radius: 8px;
}