:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-alt: #fafbfc;
  --border: #e6e8ee;
  --border-strong: #aab2bf;
  --text: #1e293b;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
  --shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px -6px rgba(16,24,40,.10);
  --radius: 10px;
  --radius-lg: 14px;
  --weekend: #f5f7fb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas:
    "top top"
    "aside main";
}

.topbar {
  grid-area: top;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 18px;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; }
.role-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.role-badge:empty { display: none; }
.role-badge.admin {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #78350f;
}
.role-badge.unknown {
  background: #fee2e2;
  color: #991b1b;
}
.role-badge.unknown:hover { background: #fecaca; }
.logo {
  background: linear-gradient(135deg, #2563eb, #5588ff);
  color: white; font-weight: 700; font-size: 11px;
  padding: 5px 8px; border-radius: 6px; letter-spacing: .5px;
}

.view-switch { display: flex; gap: 3px; background: #eef1f7; border-radius: 10px; padding: 4px; }
.view-btn {
  border: 0; background: transparent; padding: 7px 18px;
  border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted);
  transition: background .12s, color .12s;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }

.period-nav { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; cursor: pointer; padding: 6px 10px; font-size: 14px;
}
.icon-btn.pill { padding: 6px 12px; font-weight: 500; }
.icon-btn:hover { background: #f3f5f9; border-color: #d7dbe3; }
.period-label { margin-left: 8px; color: var(--muted); font-weight: 500; }
.year-select {
  margin-left: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.year-select:hover { background: #f5f7fb; }

.actions { margin-left: auto; display: flex; gap: 8px; }
.actions button { display: inline-flex; align-items: center; gap: 6px; }
.btn-ico { width: 15px; height: 15px; flex-shrink: 0; }
.actions button.icon-only { padding: 8px 9px; }
.actions button.icon-only .btn-ico { width: 16px; height: 16px; }
button.primary {
  background: var(--accent); color: white; border: 0;
  padding: 8px 15px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px;
  box-shadow: 0 1px 2px rgba(37,99,235,.25);
}
button.primary:hover { background: var(--accent-dark); }
button.ghost {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 8px 13px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 500;
}
button.ghost:hover { background: #f3f5f9; border-color: #d7dbe3; }
button.danger {
  background: var(--danger); color: white; border: 0;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500;
}

.legend {
  grid-area: aside;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
}
.legend h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.legend ul { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 4px; }
.legend li.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, opacity 0.12s;
}
.legend li.legend-item:hover { background: #f0f4fb; }
.legend li.legend-item.off { opacity: 0.45; }
.legend li.legend-item.off .swatch { filter: grayscale(1); }
.legend .legend-cb {
  width: 14px; height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.legend .legend-label { flex: 1; line-height: 1.2; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.legend-footer { border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 10px; }
.user-count { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.filter-row { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.filter-row select, .filter-row input {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); font-size: 13px; color: var(--text);
}

.board {
  grid-area: main;
  position: relative;
  overflow: auto;
}
.loading, .error {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--panel); padding: 8px 14px; border-radius: 6px;
  box-shadow: var(--shadow); z-index: 4; font-size: 13px;
}
.error { background: #fdecec; color: var(--danger); }
.hidden { display: none !important; }

.auth-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #fff8e1;
  border: 1px solid #f0c040;
  color: #6b4f00;
  padding: 14px 18px;
  border-radius: 10px;
  max-width: 640px;
  box-shadow: 0 8px 32px rgba(20,30,60,.15);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  line-height: 1.4;
}
.auth-banner em { font-style: normal; font-weight: 600; color: #4a3500; }
.auth-banner button { white-space: nowrap; }

.grid {
  display: grid;
  grid-template-rows: 52px;
  grid-auto-rows: 52px;
  background: var(--panel);
  margin: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: clip;
  font-size: 13px;
  width: calc(100% - 28px);
  min-width: max-content;
  box-sizing: border-box;
}
.grid.year-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  grid-template-rows: none;
  grid-auto-rows: min-content;
  gap: 14px;
  padding: 14px;
  margin: 12px;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
  min-width: 0;
  width: auto;
}
.grid-header, .grid-row {
  display: grid;
  grid-template-columns: var(--cols);
}
.grid-header {
  position: sticky; top: 0; z-index: 3;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--muted);
}
.grid-header > div, .grid-row > .day-cell {
  border-left: 1px solid var(--border-strong);
  position: relative;
  box-sizing: border-box;
  min-height: 52px;
}
.grid-header > div.last-day,
.grid-row > .day-cell.last-day {
  border-right: 1px solid var(--border-strong);
}
.grid-header > div {
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  gap: 2px;
}
.day-num { font-size: 13px; font-weight: 600; color: var(--text); }
.day-wd  { font-size: 10px; font-weight: 400; color: var(--muted); text-transform: lowercase; }
.grid-header > div.today .day-num { color: var(--accent); }
.grid-header > div:last-child, .grid-row > div:last-child { border-right: 0; }
.grid-row {
  border-bottom: 1px solid var(--border-strong);
  min-height: 52px;
  align-items: stretch;
  background: var(--panel);
  position: relative;
}
.grid-row:nth-child(even) { background: var(--panel-alt); }
.grid-row:last-child { border-bottom: 0; }
.grid-row:hover { background: #f5f8ff; }
.grid-row > div.user-cell {
  position: sticky; left: 0; z-index: 2;
  background: inherit;
  display: flex; align-items: center; gap: 10px;
  font-weight: 500;
  padding: 6px 12px;
  min-height: 52px;
  box-sizing: border-box;
}
.grid-header > div.user-cell {
  position: sticky; left: 0; z-index: 4;
  background: #fafbfd;
  justify-content: flex-start;
  padding: 8px 12px;
  border-left: 0;
}
/* Правый блок тоталов месячного вида: «Итого» · «Дни отпуска» · «Отпуск за год».
   Единый светлый фон в тон строкам, спокойные акценты только цветом текста
   (синий — отпуск за месяц, зелёный — за год); от календаря отделён тонкой
   границей и лёгкой тенью. Ширина колонок одинаковая. */
.grid-header > div.grid-total-h,
.grid-header > div.grid-vac-h,
.grid-header > div.grid-year-h,
.grid-row > div.grid-total,
.grid-row > div.grid-vac,
.grid-row > div.grid-year {
  position: sticky;
  display: flex; align-items: center; justify-content: center; text-align: center;
  box-sizing: border-box; min-height: 52px; line-height: 1.15;
  border-left: 1px solid var(--border);
}
/* смещения справа: Итого → Дни отпуска → Отпуск за год (у самого края) */
.grid-header > div.grid-total-h,
.grid-row > div.grid-total { right: calc(2 * var(--total-col-w, 72px)); }
.grid-header > div.grid-vac-h,
.grid-row > div.grid-vac   { right: var(--total-col-w, 72px); }
.grid-header > div.grid-year-h,
.grid-row > div.grid-year  { right: 0; }
/* тонкая граница + лёгкая тень между календарём и блоком тоталов (слева от «Итого») */
.grid-header > div.grid-total-h,
.grid-row > div.grid-total {
  border-left: 1px solid var(--border-strong);
  box-shadow: -7px 0 11px -7px rgba(16, 24, 40, .12);
}
/* заголовки — единый стиль, акцент только цветом текста */
.grid-header > div.grid-total-h,
.grid-header > div.grid-vac-h,
.grid-header > div.grid-year-h {
  z-index: 4; background: #f4f6f9;
  font-size: 10.5px; font-weight: 600; padding: 4px 6px; letter-spacing: .1px;
}
.grid-header > div.grid-total-h { color: var(--muted); }
.grid-header > div.grid-vac-h   { color: #2563eb; }
.grid-header > div.grid-year-h  { color: #15803d; }
.grid-header .th-metric { font-weight: 700; }
.grid-header .th-period { font-size: 8.5px; font-weight: 500; opacity: .72; margin-top: 1px; }
/* значения — крупнее, semibold; фон в тон строки (чередование/hover как в календаре) */
.grid-row > div.grid-total,
.grid-row > div.grid-vac,
.grid-row > div.grid-year {
  z-index: 2; background: inherit; font-size: 15px; font-weight: 600;
}
.grid-row > div.grid-total { color: var(--text); }
.grid-row > div.grid-vac   { color: #2563eb; }
.grid-row > div.grid-year  { color: #15803d; }
.user-avatar {
  position: relative; overflow: hidden;
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6b93f5, #2563eb);
  color: white; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(16,24,40,.07) inset;
}
.user-avatar .ava-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
}
.user-avatar .ava-ini { line-height: 1; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.user-pos { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.user-name-2 { display: none; }   /* two-line surname/first-name — shown only on mobile */

.day-cell {
  cursor: pointer;
  background: transparent;
  transition: background-color 0.1s;
}
.day-cell.weekend { background: rgba(120, 140, 170, 0.08); }
.day-cell.today {
  background: rgba(34, 102, 255, 0.10);
  box-shadow: inset 0 -3px 0 var(--accent);
}
.day-cell:hover { background: rgba(34, 102, 255, 0.06); }

.absence-bar {
  position: absolute;
  top: 12px;
  height: 28px;
  border-radius: 4px;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.1px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
  pointer-events: auto;
  min-width: 0;
  transition: filter 0.12s, box-shadow 0.12s;
}
.absence-bar:hover { filter: brightness(1.08); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.absence-bar.narrow {
  padding: 0 2px;
  justify-content: center;
  font-size: 10px;
  letter-spacing: -0.3px;
}
.absence-bar.compact {
  padding: 0 5px;
  font-size: 10px;
  justify-content: center;
}

/* Read-only — записи из системного графика Битрикс24:
   диагональные полосы + вертикальные разделители дней */
.absence-bar.read-only {
  cursor: help;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.16) 0 6px, transparent 6px 12px);
}

/* ── Year view: 12-month calendar of per-employee absence markers ────────── */
.month-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 12px 12px;
}
.month-card-h { margin: 0 0 8px; font-size: 14px; font-weight: 600; text-align: center; color: var(--text); }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); column-gap: 0; row-gap: 3px; }
.mc-wd { font-size: 10px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0; }
.mc-wd.we { color: #b0563f; }
.mc-day {
  position: relative;
  min-height: 30px;
  padding: 1px 0 3px;            /* no horizontal padding → strips span full width and touch */
  background: var(--panel);
  overflow: hidden;
}
.mc-day:not(.empty) { cursor: pointer; }
.mc-day.empty { background: transparent; }
.mc-day.weekend { background: var(--weekend); }
.mc-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.mc-dnum { font-size: 10px; line-height: 1; color: var(--muted); padding-left: 3px; }
.mc-day.today .mc-dnum { color: var(--accent); font-weight: 700; }
/* Thin absence strips, full-width; vertical colour split (top = type, bottom =
   employee). Adjacent day cells touch (column-gap:0), so consecutive absence
   days join with no gap; rounding only at the absence start/end. */
/* Grid (not flex) so each bar can sit on its packed lane row; lane N is at the
   same vertical offset in every cell → runs stay aligned into one strip. */
.mc-bars { display: grid; grid-auto-rows: 14px; row-gap: 3px; margin-top: 3px; }
.mc-bar {
  height: 14px;
  cursor: pointer;
  /* crisp top/bottom edges only — stacked strips read as separate, but
     consecutive days still join (no left/right lines). */
  box-shadow: inset 0 1px 0 rgba(0,0,0,.16), inset 0 -1px 0 rgba(0,0,0,.16);
}
.mc-bar.run-start { border-top-left-radius: 7px; border-bottom-left-radius: 7px; }
.mc-bar.run-end { border-top-right-radius: 7px; border-bottom-right-radius: 7px; }
.mc-bar.ro { opacity: .7; cursor: help; }
.mc-bar:hover { outline: 2px solid var(--text); outline-offset: -1px; }

/* ── Vacation requests ─────────────────────────────────────────────────────── */
.vac-badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: #e11d48; color: #fff; font-size: 11px; line-height: 16px; text-align: center; font-weight: 700; }
.vac-list { display: flex; flex-direction: column; gap: 8px; }
.vac-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.vac-item .vac-main { flex: 1; min-width: 0; }
.vac-who { font-weight: 600; margin-bottom: 2px; }
.vac-dates { font-size: 14px; }
.vac-note { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.vac-actions { display: flex; gap: 6px; flex-shrink: 0; }
.vac-actions button { padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.vac-status { padding: 3px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.vac-pending_director, .vac-pending_hr { background: #fef3c7; color: #92400e; }
.vac-approved { background: #dcfce7; color: #166534; }
.vac-rejected { background: #fee2e2; color: #991b1b; }
.vac-cancelled { background: #e5e7eb; color: #4b5563; }
.vac-type { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .3px; }
.vac-type-edit { background: #dbeafe; color: #1e40af; }
.vac-type-delete { background: #fee2e2; color: #991b1b; }
.vac-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
#vac-list-modal section + section { margin-top: 16px; }
#vac-list-modal h3 { margin: 0 0 8px; font-size: 14px; }
.vac-cfg { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.vac-cfg > h3 { margin: 0 0 6px; font-size: 15px; }
.vac-cfg-cols { display: flex; gap: 16px; margin-top: 8px; }
.vac-cfg-col { flex: 1; min-width: 0; }
.vac-cfg-h { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.vac-cfg-list { max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: var(--panel); }
.vac-cfg-item { display: flex; align-items: center; gap: 8px; padding: 3px 4px; font-size: 13px; cursor: pointer; border-radius: 4px; }
.vac-cfg-item:hover { background: var(--weekend); }
.vac-cfg-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vac-cfg-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.vac-h-item { align-items: flex-start; }
.vac-trail { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.vac-h-step { font-size: 11px; color: var(--muted); }
.vac-del { flex: none; border: none; background: transparent; color: #c0392b; font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.vac-del:hover { background: rgba(192, 57, 43, .12); }

/* ── Year view: layout toggle + table (grid) variant ───────────────────────── */
.year-layout { display: inline-flex; gap: 4px; margin-left: 8px; background: #eef1f7; border-radius: 8px; padding: 3px; vertical-align: middle; }
.yl-btn { border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 13px; padding: 5px 10px; color: var(--muted); }
.yl-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.grid.year-view.yg-layout { display: block; }
.yg-month { margin: 0 0 22px; overflow-x: auto; }
.yg-month-title { font-weight: 700; font-size: 15px; margin: 0 0 6px 2px; color: var(--text); }
.yg-table { width: 100%; min-width: 820px; table-layout: fixed; border-collapse: collapse; font-size: 12px; background: var(--panel); }
.yg-table th, .yg-table td { border: 1px solid var(--border); text-align: center; }
.yg-table th { font-weight: 600; color: var(--muted); padding: 3px 0; background: var(--panel); }
.yg-name { width: 160px; text-align: left; padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--panel); z-index: 1; }
td.yg-name { color: var(--text); font-weight: 500; }
.yg-cell { height: 24px; cursor: pointer; }
.yg-cell.ro { opacity: .75; cursor: help; }
.yg-cell:hover { outline: 2px solid var(--text); outline-offset: -2px; }
.yg-we { background: var(--weekend); }
.yg-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.yg-total { width: 48px; min-width: 48px; font-weight: 700; padding: 0 6px; color: var(--text); }
/* Колонки «Дни отпуска» (левее) и «Итого» в таблицах-месяцах годового вида. */
.yg-vac   { width: 64px; min-width: 64px; text-align: center; font-weight: 700; padding: 0 6px; color: var(--accent); background: #eef6fc; }
.yg-total { background: #f0f2f6; }
/* «Итого за год» — карточка-сводка над месячными календарями (оба годовых вида). */
.yg-summary {
  margin: 0 0 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}
.yc-summary { grid-column: 1 / -1; }
.yg-summary-head { margin: 0 0 14px; padding: 0 0 12px; border-bottom: 1px solid var(--border); }
.yg-summary-titlerow { display: flex; align-items: baseline; gap: 12px; }
.yg-summary-title { font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -.2px; }
.yg-summary-cnt { font-size: 12px; color: var(--muted); font-weight: 500; }
.yg-summary-legend { margin-top: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.yg-summary-legend .lg-vac { color: #2563eb; }
.yg-summary-legend .lg-all { color: var(--text); }
.yg-summary-legend .lg-sep { margin: 0 9px; opacity: .5; }
.yg-sum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 10px 18px;
}
/* каждый сотрудник — отдельная «плитка»: аватар слева, ФИО + строка-описание справа */
.yg-sum-row {
  display: flex; align-items: center; gap: 11px;
  min-height: 58px; padding: 9px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background .12s, border-color .12s;
}
.yg-sum-row:hover { background: #eef4ff; border-color: #cdd9ee; }
.yg-sum-row .user-avatar { width: 40px; height: 40px; font-size: 14px; }
.yg-sum-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.yg-sum-emp {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.yg-sum-line { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.yg-sum-line b { font-weight: 600; }
.yg-sum-line b.vac { color: #2563eb; }
.yg-sum-line b.all { color: var(--text); }

/* ── Collapsible employee picker ───────────────────────────────────────────── */
.emp-toggle { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none; cursor: pointer; padding: 6px 0; font-size: 14px; font-weight: 600; color: var(--text); text-align: left; }
.emp-toggle:hover { color: var(--accent); }
.emp-toggle-caret { width: 12px; font-size: 11px; color: var(--muted); }
.emp-toggle-title { flex: 1; }
.emp-count { font-size: 12px; font-weight: 500; color: var(--muted); }
.emp-picker-body .filter-row { margin-bottom: 8px; }

/* ── Settings tabs ─────────────────────────────────────────────────────────── */
.settings-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.settings-tab { background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Custom groups (sidebar) ───────────────────────────────────────────────── */
.groups-box { margin-top: 12px; }
.groups-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.groups-title { font-weight: 600; font-size: 14px; }
.groups-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.groups-empty { font-size: 12px; color: var(--muted); padding: 2px 0; }
.group-item { display: flex; align-items: center; gap: 4px; border-radius: 6px; }
.group-item.on { background: var(--weekend); }
.group-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer; padding: 5px 6px; text-align: left; color: var(--text); border-radius: 6px; }
.group-pick:hover { background: var(--weekend); }
.group-item.on .group-pick { font-weight: 600; }
.group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.group-count { flex-shrink: 0; font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 0 6px; }
.group-actions { display: flex; gap: 2px; flex-shrink: 0; }
.group-actions button { background: none; border: none; cursor: pointer; font-size: 12px; padding: 4px; border-radius: 4px; opacity: .6; }
.group-actions button:hover { opacity: 1; background: var(--weekend); }
.group-members-label { font-weight: 600; font-size: 13px; margin: 10px 0 6px; }
.group-access-all { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; cursor: pointer; }
.vac-cfg-list.disabled { opacity: .45; pointer-events: none; }

/* ── Audit log ─────────────────────────────────────────────────────────────── */
.audit-wrap { max-height: 440px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-table th, .audit-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; }
.audit-table th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 600; z-index: 1; }
.audit-empty { text-align: center; color: var(--muted); padding: 16px; }
.audit-via { color: var(--muted); font-size: 11px; }
.audit-sync-synced { color: #166534; }
.audit-sync-pending { color: #92400e; }
.audit-sync-company { color: var(--muted); }
.year-hint {
  grid-column: 1 / -1;
  background: #eef4ff;
  border: 1px solid #c7dafe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

/* Employee picker — left sidebar, year view only */
.emp-picker { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.emp-picker-actions { display: flex; gap: 12px; margin-bottom: 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.emp-hint { margin: 0 0 8px; font-size: 11px; color: var(--muted); line-height: 1.3; }
#emp-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.emp-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 6px; border-radius: 8px; cursor: pointer; user-select: none; }
.emp-item .user-avatar { width: 24px; height: 24px; font-size: 10px; }
.emp-item .emp-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-item:hover { background: #f0f4fb; }
.emp-cb { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.emp-swatch { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); flex-shrink: 0; }
.emp-item.on .emp-name { font-weight: 600; }
.emp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100;
}
/* The request form is opened FROM the «Заявления» list (edit flow), so it must
   sit above it — both are .modal (z-index 100) and #vac-modal comes earlier in
   the DOM, which would otherwise stack it behind. */
#vac-modal { z-index: 110; }
.modal-card {
  background: var(--panel); border-radius: 16px; min-width: 420px; max-width: 90vw;
  box-shadow: 0 20px 60px -12px rgba(16,24,40,.28), 0 8px 24px -8px rgba(16,24,40,.14);
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-card header {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-card header h2 { margin: 0; font-size: 17px; flex: 1; }
.close { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; display: grid; gap: 12px; overflow-y: auto; }
.modal-body label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-body input, .modal-body select, .modal-body textarea {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
  font-size: 14px; color: var(--text); font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-body textarea { resize: vertical; }
.modal-body .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-card footer {
  display: flex; align-items: center; padding: 14px 20px;
  border-top: 1px solid var(--border); gap: 10px;
}
.modal-card footer .spacer { flex: 1; }

/* Settings (permissions) modal */
.modal-card.settings-card {
  min-width: 720px;
  max-width: 95vw;
}

/* Group modal — wider, with a roomier member list. */
#group-modal .modal-card { min-width: 600px; }
#group-members { max-height: 340px; }
/* Checkbox lists inside modals must stay single rows: the generic
   `.modal-body label` rule sets display:grid (for form fields) and `.modal-body
   input` adds field padding/border — both wrong for these checkbox rows. */
.modal-body label.vac-cfg-item { display: flex; align-items: center; gap: 8px; padding: 6px; font-size: 14px; color: var(--text); }
.modal-body label.vac-cfg-item span { color: var(--text); }
.modal-body label.group-access-all { display: flex; align-items: center; gap: 8px; color: var(--text); }
/* Native checkboxes everywhere in modals (the generic `.modal-body input` rule
   adds field padding/border that boxes them up). */
.modal-body input[type="checkbox"] { width: auto; flex: none; margin: 0; padding: 0; border: 0; border-radius: 0; }
.settings-hint {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px;
  background: #f5f8fc;
  border-radius: 6px;
  margin-bottom: 6px;
}
.perms-table-wrap {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.perms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.perms-table thead th {
  position: sticky; top: 0;
  background: #f5f7fb;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border-strong);
}
.perms-table thead th.th-name { text-align: left; }
.perms-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.perms-table tbody tr:last-child td { border-bottom: 0; }
.perms-table tbody tr:hover { background: #fafbfd; }
.perms-table .td-name {
  text-align: left;
  display: flex; align-items: center; gap: 10px;
  min-width: 220px;
}
.perms-table .td-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #5b8def, #2563eb);
  color: white; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.perms-table .td-pos { font-size: 11px; color: var(--muted); }
.perms-table .td-perm input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.settings-status { font-size: 12px; color: var(--muted); }
.roles-legend { display: grid; gap: 5px; font-size: 12px; color: var(--muted); margin: 0 0 12px; padding: 8px 12px; background: #f5f8fc; border-radius: 6px; line-height: 1.35; }
.roles-legend b { color: var(--text); }

/* ══ Mobile / responsive ═══════════════════════════════════════════════════
   Scoped to max-width, so the desktop layout above is unchanged. Single
   column: topbar → calendar (scrolls horizontally) → legend/filters below. */
@media (max-width: 820px) {
  html, body { height: auto; }
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "top"
      "main"
      "aside";
    min-height: 100vh;
  }

  /* Topbar: each group is its own full-width row with evenly-sized items. */
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
  .brand { min-width: 0; flex: 1 1 100%; }
  /* Неделя / Месяц / Год — three equal segments spanning the row. */
  .view-switch { flex: 1 1 100%; }
  .view-switch .view-btn { flex: 1; text-align: center; }
  /* ‹ Сегодня › on one line; month + year selects share the next line. */
  .period-nav { flex: 1 1 100%; flex-wrap: wrap; gap: 6px; align-items: center; }
  .period-label { display: none; }                 /* redundant with the month/year selects */
  .period-nav #today { flex: 1; }
  .period-nav .year-select { flex: 1 1 42%; margin-left: 0; }
  .year-layout { flex: 1 1 100%; margin-left: 0; }
  .year-layout .yl-btn { flex: 1; }
  /* Action buttons in tidy rows: primary request full-width, then pairs, icons compact. */
  .actions { flex: 1 1 100%; margin-left: 0; flex-wrap: wrap; gap: 6px; }
  .actions > button { flex: 1 1 auto; }
  .actions > #vac-new-btn { order: 1; flex: 1 1 100%; }
  .actions > #vac-list-btn { order: 2; flex: 1 1 40%; }
  .actions > #history-btn  { order: 3; flex: 1 1 40%; }
  .actions > #add-absence  { order: 4; flex: 1 1 auto; }
  .actions > #settings-btn { order: 5; flex: 0 0 46px; }
  .actions > #refresh      { order: 6; flex: 0 0 46px; }
  button.primary, button.ghost, button.danger, .view-btn, .icon-btn { white-space: nowrap; }

  /* The wide calendar grid keeps its own horizontal scroll inside .board. */
  .board { overflow: auto; }
  /* Compact the sticky employee column so more day columns fit on screen. */
  .grid-row > div.user-cell, .grid-header > div.user-cell { padding: 4px 6px; gap: 6px; }
  .user-avatar { width: 22px; height: 22px; font-size: 9px; }
  .user-pos { display: none; }
  /* Surname + first name on two lines so it's clear who it is in the narrow column. */
  .user-name { display: none; }
  .user-name-2 { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
  .user-name-2 .u-last { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-name-2 .u-first { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Legend/filters sit below the calendar (was the left sidebar). */
  .legend { border-right: 0; border-top: 1px solid var(--border); overflow-y: visible; }

  /* Modals fill the small screen; inner wide tables keep their own scroll. */
  .modal { padding: 8px; }
  .modal-card,
  .modal-card.settings-card,
  #group-modal .modal-card {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    max-height: 94vh;
  }
  #group-members, .audit-wrap { max-height: 60vh; }
}

@media (max-width: 480px) {
  .brand .logo { display: none; }
  .brand h1 { font-size: 14px; }
  .view-btn { padding: 6px 10px; font-size: 12px; }
  button.primary, button.ghost { padding: 8px 11px; font-size: 13px; }
  .modal-card header { padding: 12px 14px; }
  .modal-card header h2 { font-size: 15px; }
  .modal-body { padding: 14px; }
  .modal-body .row { grid-template-columns: 1fr; }   /* stack the from/to date fields */
  .modal-card footer { padding: 12px 14px; flex-wrap: wrap; }
  .vac-cfg-cols { flex-direction: column; gap: 10px; }
  .vac-item { flex-wrap: wrap; }
}
