:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Гарантируем что [hidden] всегда скрывает элемент, даже если CSS задаёт display */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.boot-error {
  margin: 0;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 1px solid var(--danger);
  color: #fecaca;
  font-size: 0.9rem;
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

/* Header */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.header__subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  background: var(--surface);
  padding: 0.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tabs__btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}

.tabs__btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tabs__btn--active {
  background: var(--accent);
  color: #fff;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.week-nav__label {
  font-weight: 600;
  margin-left: 0.5rem;
  min-width: 200px;
}

.toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--border);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn--danger-outline:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn--file {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.btn--sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn--success {
  background: var(--success, #22c55e);
  color: #fff;
}
.btn--success:hover {
  filter: brightness(1.1);
}

/* ── Toast-уведомления ── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  border-left: 3px solid #22c55e;
}

.toast--error {
  background: #450a0a;
  border-left: 3px solid #ef4444;
  color: #fca5a5;
}

/* Состояния кнопки "Сохранить пожелания" */
.pref-save-btn--ok {
  background: #15803d !important;
}
.pref-save-btn--err {
  background: #b91c1c !important;
}

/* Panels */
.panel-intro {
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.legend__swatch--ok { background: var(--success); }
.legend__swatch--warn { background: var(--warning); }
.legend__swatch--bad { background: var(--danger); }

.schedule-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.schedule {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.schedule th,
.schedule td {
  border: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
}

.schedule th {
  background: var(--surface-2);
  padding: 0.6rem 0.5rem;
  text-align: center;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}

.schedule th.col-employee {
  text-align: left;
  min-width: 180px;
  position: sticky;
  left: 0;
  z-index: 3;
}

.schedule td.col-employee {
  background: var(--surface-2);
  padding: 0.5rem 0.75rem;
  font-weight: 500;
  position: sticky;
  left: 0;
  z-index: 1;
  white-space: nowrap;
}

.schedule th .day-name {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.schedule th.is-today {
  background: rgba(59, 130, 246, 0.25);
}

.day-cell {
  min-width: 110px;
  min-height: 72px;
  padding: 0.35rem;
  cursor: pointer;
  transition: background 0.12s;
}

.day-cell:hover {
  background: rgba(59, 130, 246, 0.08);
}

.day-cell.is-today {
  background: rgba(59, 130, 246, 0.06);
}

.day-cell__coverage {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-align: right;
}

.shift-chip {
  display: block;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  color: #000;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  line-height: 1.3;
}

.shift-chip:hover {
  filter: brightness(1.1);
}

.shift-chip__time {
  font-weight: 600;
}

.shift-chip__note {
  opacity: 0.85;
  font-size: 0.65rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-cell__add {
  display: block;
  width: 100%;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.2rem;
  font-size: 0.7rem;
  cursor: pointer;
  margin-top: 0.15rem;
}

.day-cell__add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.employee-hours-total {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Workload */
.workload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .workload-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.card--full {
  grid-column: 1 / -1;
}

.card h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.card__hint {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hours-bar {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.hours-bar__track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}

.hours-bar__fill {
  height: 100%;
  border-radius: 5px;
  background: var(--accent);
  transition: width 0.3s;
}

.hours-bar__value {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hours-bar__extra {
  display: block;
  font-size: 0.65rem;
  color: #c4b5fd;
}

.hours-bar--compact {
  grid-template-columns: 72px 1fr 56px;
  font-size: 0.72rem;
  margin-bottom: 0.35rem;
}

.hours-bar--compact .hours-bar__track {
  height: 8px;
}

.hours-bar__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.stat {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.stat__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Heatmap */
.heatmap-wrap {
  overflow-x: auto;
  overflow-y: visible;
  /* запас, чтобы outline при hover не дёргал скролл страницы */
  padding: 2px;
}

.heatmap {
  border-collapse: collapse;
  font-size: 0.65rem;
  width: 100%;
}

.heatmap th,
.heatmap td {
  border: 1px solid var(--border);
  padding: 0;
  text-align: center;
}

.heatmap th {
  background: var(--surface-2);
  padding: 0.35rem 0.25rem;
  font-weight: 500;
}

.heatmap td {
  width: 28px;
  height: 22px;
  cursor: pointer;
  /* без transform:scale — на последнем ряде (вс) он вызывает дрожь из‑за скролла */
}

.heatmap td:hover {
  outline: 2px solid #fff;
  outline-offset: -2px;
  filter: brightness(1.15);
  z-index: 1;
  position: relative;
}

.heat-0 { background: #3f1d1d; color: #fca5a5; }
.heat-1 { background: #78350f; color: #fde68a; }
.heat-2 { background: #14532d; color: #86efac; }
.heat-3 { background: #166534; color: #bbf7d0; }
.heat-4plus { background: #15803d; color: #fff; }

.heat-hourly {
  box-shadow: inset 0 -3px 0 #a78bfa;
}

.schedule .is-highlight,
.schedule .day-cell--highlight {
  box-shadow: inset 0 0 0 2px #a78bfa;
}

.hourly-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.35rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.35);
  cursor: pointer;
}

.coverage-add-shift {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.coverage-list__meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Preferences */
.preferences-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pref-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pref-card__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 32px;
}

.pref-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pref-card__name-text {
  font-weight: 600;
  font-size: 0.95rem;
}

.pref-card__actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

/* Day grid */
/* ── Пожелания: плоский список записей ──────────────── */

.pref-entries {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0.4rem;
}

.pref-entry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border-radius: 7px;
  background: var(--surface-2);
  flex-wrap: wrap;
}

/* День-селект */
.pref-day-sel {
  font-size: 0.8rem;
  padding: 0.2rem 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
  cursor: pointer;
}

/* Вых. */
.pref-entry__off-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-muted);
  user-select: none;
  flex-shrink: 0;
  padding: 0.15rem 0.35rem;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.pref-entry__off-label:has(input:checked) {
  color: var(--accent);
  border-color: var(--accent);
}

/* Блок времени */
.pref-entry__times {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* Кнопка + Добавить день */
.pref-add-entry {
  font-size: 0.78rem;
  margin-top: 0.1rem;
  margin-bottom: 0.3rem;
}

/* Кнопка ✕ убрать запись */
.pref-remove-entry {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.55;
}

.pref-remove-entry:hover {
  opacity: 1;
}

.pref-sel {
  font-size: 0.8rem;
  padding: 0.18rem 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  width: 74px;
  flex-shrink: 0;
}

.pref-sel:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pref-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.pref-duty-label {
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-muted);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  border: 1px solid transparent;
}

.pref-duty-label:has(input:checked) {
  color: var(--warning);
  border-color: var(--warning);
  font-weight: 600;
}

.pref-add-s2,
.pref-rem-s2,
.pref-add-shift,
.pref-remove-shift {
  font-size: 0.7rem;
  padding: 0.15rem 0.35rem;
  flex-shrink: 0;
}

.pref-add-shift {
  margin-top: 2px;
  color: var(--accent);
  border-color: var(--accent);
}

/* Заметка сотрудника (свободный текст) */
.pref-comment-wrap {
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
  margin-top: 0.25rem;
}

.pref-comment-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  list-style: none;
  padding: 0.1rem 0;
}

.pref-comment-summary::-webkit-details-marker { display: none; }
.pref-comment-summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.15s; }
details[open] .pref-comment-summary::before { transform: rotate(90deg); }

.pref-comment-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.pref-comment-badge--filled {
  background: color-mix(in srgb, var(--warning) 20%, transparent);
  color: var(--warning);
}

.pref-comment-ta {
  width: 100%;
  margin-top: 0.35rem;
  min-height: 64px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.5;
}

.pref-comment-ta:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pref-comment-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0.2rem;
}

.pref-days-hint {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.pref-toolbar {
  margin-bottom: 0.75rem;
}

/* Team */
.team-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.team-card__fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.team-card__email {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 0;
}

.team-card input[type="text"],
.team-card input[type="email"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-family: inherit;
}

.team-card input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

/* Dialog */
.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: 420px;
  width: calc(100% - 2rem);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.dialog--sm {
  max-width: 320px;
}

.dialog--wide {
  max-width: 520px;
}

.pref-apply-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.pref-apply-list li {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.pref-apply-list li:last-child {
  border-bottom: none;
}

.pref-apply-warnings {
  font-size: 0.8rem;
  color: var(--warning);
  margin: 0 0 0.75rem;
}

.pref-apply-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.field span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field input,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -0.25rem 0 0.75rem;
}

.dialog__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  gap: 0.5rem;
}

.dialog__actions-right {
  display: flex;
  gap: 0.5rem;
}

.coverage-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.coverage-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.coverage-list li:last-child {
  border-bottom: none;
}

/* Deadline */
.deadline-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.deadline-bar--ok { border-color: var(--success); color: var(--success); }
.deadline-bar--soon { border-color: var(--warning); color: var(--warning); }
.deadline-bar--past { border-color: var(--danger); color: #fca5a5; background: rgba(239, 68, 68, 0.1); }

.pref-submitted-counter {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
}

.pref-submitted-counter--ok { color: var(--success); }

/* Schedule layout */
.schedule-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}

.schedule-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: 0.5rem;
}

.schedule-hours-panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
}

.schedule-hours-panel summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.schedule-hours-panel .card__hint {
  margin-bottom: 0.5rem;
}

.schedule-main {
  min-width: 0;
}

@media (max-width: 1100px) {
  .schedule-layout {
    grid-template-columns: 1fr;
  }

  .schedule-sidebar {
    position: static;
    order: 2;
  }
}

/* Problems sidebar */
.problems-aside {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
}

.problems-aside--ok {
  border-color: var(--success);
  color: var(--success);
  padding: 0.65rem 0.85rem;
}

.problems-details {
  margin: 0;
}

.problems-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  user-select: none;
}

.problems-details > summary::-webkit-details-marker {
  display: none;
}

.problems-details > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s;
}

.problems-details[open] > summary::before {
  transform: rotate(90deg);
}

.problems-details--danger > summary {
  color: #fca5a5;
}

.problems-details--warn > summary {
  color: #fde68a;
}

.problems-details__body {
  padding: 0 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
}

.problems-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  max-height: 55vh;
  overflow-y: auto;
  color: var(--text);
}

.problems-list li { margin-bottom: 0.35rem; }

.problems-list--danger { color: #fca5a5; }
.problems-list--warn { color: #fde68a; }

.problems-hint {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Employee cell extras */
.employee-pref {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  white-space: normal;
  max-width: 160px;
  margin-top: 0.25rem;
  line-height: 1.3;
}

.employee-pref--empty { font-style: italic; opacity: 0.7; }

.pref-status {
  display: inline-block;
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-top: 0.2rem;
}

.pref-status--done { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.pref-status--pending { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.shift-chip__tag {
  display: inline-block;
  font-size: 0.6rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0 0.25rem;
  border-radius: 3px;
  margin-right: 0.2rem;
}

.shift-chip--duty {
  box-shadow: inset 3px 0 0 #fbbf24;
}

.shift-chip--duty .shift-chip__tag {
  background: rgba(251, 191, 36, 0.45);
  color: #000;
}

/* Tag buttons */
.tag-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
}

.tag-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tag-btn--duty.tag-btn--active {
  background: #d97706;
  border-color: #d97706;
}

/* Month */
.month-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.month-label {
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

.month-table-wrap { overflow-x: auto; }

.month-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.month-table th,
.month-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.month-table th {
  background: var(--surface-2);
}

.month-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* History */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.field--inline span { white-space: nowrap; }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
}

.history-list li {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.history-list li:last-child { border-bottom: none; }

.history-list__time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.history-list__who {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.35rem;
}

.settings-card { margin-bottom: 1rem; }

.stat__value--warn { color: var(--warning); }
.stat__value--danger { color: var(--danger); }

/* Copy week dialog */
.copy-week-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0;
}

.copy-week-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.copy-week-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.copy-week-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
}

.copy-week-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  cursor: pointer;
}

.copy-week-list li:last-child { border-bottom: none; }

.copy-week-list li:hover { background: var(--surface-2); }

.copy-week-list__meta {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.employee-copy-btn {
  margin-top: 0.35rem;
  font-size: 0.68rem;
  padding: 0.15rem 0.35rem;
}

/* Vacations */
.vacation-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.vacation-grid-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.vacation-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.vacation-grid col.vacation-col-count { width: 2.25rem; }
.vacation-grid col.vacation-col-num { width: 2.25rem; }
.vacation-grid col.vacation-col-range { width: 7rem; }

.vacation-grid th,
.vacation-grid td {
  border: 1px solid var(--border);
  padding: 0.25rem 0.35rem;
  text-align: center;
  vertical-align: middle;
}

.vacation-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
}

.vacation-col-count,
.vacation-col-num,
.vacation-col-range {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  white-space: nowrap;
}

.vacation-col-num { left: 2.25rem; }

.vacation-col-range {
  left: 4.5rem;
  min-width: 7rem;
}

.vacation-grid thead .vacation-col-count,
.vacation-grid thead .vacation-col-num,
.vacation-grid thead .vacation-col-range {
  z-index: 3;
  background: var(--surface-2);
}

.vacation-col-emp {
  min-width: 0;
}

.vacation-emp-name {
  font-weight: 600;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
}

.vacation-emp-initial {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.vacation-emp-stat {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.vacation-emp-stat--over {
  color: var(--warning);
  font-weight: 600;
}

.vacation-emp-eligible {
  font-size: 0.6rem;
  color: var(--accent);
  margin-top: 0.1rem;
  line-height: 1.2;
}

.vacation-cell--locked {
  background: rgba(0, 0, 0, 0.15);
  opacity: 0.5;
}

.vacation-check:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.vacation-row--has {
  background: rgba(34, 197, 94, 0.12);
}

.vacation-row--current {
  box-shadow: inset 3px 0 0 var(--accent);
}

.vacation-cell--on {
  background: rgba(34, 197, 94, 0.25);
}

.vacation-check {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--success);
}

.vacation-week-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.vacation-week-link:hover { color: #93c5fd; }

.vacation-badge {
  display: inline-block;
  font-size: 0.65rem;
  background: rgba(34, 197, 94, 0.25);
  color: #86efac;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-top: 0.2rem;
}

.schedule-row--vacation .day-cell {
  opacity: 0.55;
}

.schedule-row--vacation .day-cell--vacation-week {
  background: rgba(34, 197, 94, 0.08);
  opacity: 1;
}

.day-cell--vacation-week .day-cell__add {
  opacity: 0.6;
}

/* ── Сетка (табличный вид: часы = столбцы, строки = смены) ── */

.ch-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ch-table {
  border-collapse: collapse;
  font-size: 0.72rem;
  white-space: nowrap;
  table-layout: fixed;
  width: 100%;
  min-width: 900px;
}

.ch-table th,
.ch-table td {
  border: 1px solid rgba(255,255,255,0.09);
  padding: 0;
}

/* Угол: «Дата» */
.ch-date-th {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5;
  background: var(--surface-2);
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  padding: 0.3rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

/* Заголовок часа */
.ch-h {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  text-align: center;
  padding: 0.25rem 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Sticky левая колонка (метка строки) */
.ch-lbl {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  font-size: 0.63rem;
  padding: 2px 4px;
  vertical-align: middle;
}

.ch-lbl--duty {
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.65rem;
}

/* Заголовок дня — растянутая строка */
.ch-day-hdr td { border-left: none; border-right: none; }
.ch-day-hdr-cell {
  padding: 0.22rem 0.6rem;
  font-weight: 700;
  font-size: 0.73rem;
  color: #a5b4fc;
  text-align: left;
  letter-spacing: 0.03em;
}
.ch-day-hdr { background: rgba(99,102,241,0.14); }
.ch-day-hdr--today { background: rgba(99,102,241,0.3); }
.ch-day-hdr--today .ch-day-hdr-cell { color: #c7d2fe; }

/* Строка смены */
.ch-lane { height: 26px; }

/* Строка дежурств */
.ch-duty-row { height: 24px; background: rgba(251,191,36,0.06); }
.ch-duty-row .ch-lbl--duty { background: rgba(251,191,36,0.1); }

/* Ячейка часа */
.ch-c {
  height: 26px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  text-align: center;
  padding: 0 2px;
  font-size: 0.67rem;
  font-weight: 600;
  color: #fff;
}

.ch-c--fill {
  color: #000;
  text-shadow: none;
}

.ch-c--hourly-mark::after {
  content: '⊕';
  font-size: 0.6rem;
  vertical-align: super;
  margin-left: 1px;
}

.ch-c--duty-fill {
  color: #000;
  text-shadow: none;
  opacity: 0.9;
}

.ch-c--duty-empty {
  background: rgba(251,191,36,0.05);
}

.ch-c--hourly {
  background: rgba(245,158,11,0.75);
  font-size: 0.75rem;
}

.ch-c--clickable {
  cursor: pointer;
}

.ch-c--clickable:not(.ch-c--fill):not(.ch-c--duty-fill):hover {
  background: rgba(99,102,241,0.18);
  outline: 1px dashed rgba(99,102,241,0.55);
  outline-offset: -1px;
}

.ch-c--clickable.ch-c--fill:hover,
.ch-c--clickable.ch-c--duty-fill:hover {
  filter: brightness(1.15);
  outline: 2px solid #fff;
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}

/* Продолжение ночной смены на следующий день */
.ch-c--spillover {
  opacity: 0.72;
  background-image: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0.18) 5px
  );
}

/* ── Ролевая модель ─────────────────────────────────────── */

.role-indicator {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-left: 0.5rem;
  vertical-align: middle;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cloud-status {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
  white-space: nowrap;
}
.cloud-status--off { background: rgba(148,163,184,0.15); color: #94a3b8; }
.cloud-status--wait { background: rgba(245,158,11,0.15); color: #fbbf24; }
.cloud-status--on { background: rgba(34,197,94,0.15); color: #4ade80; }
.cloud-status--err { background: rgba(239,68,68,0.15); color: #f87171; }

.role-indicator--manager {
  background: rgba(99, 102, 241, 0.18);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.role-indicator--senior {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.role-indicator--employee {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Чип смены — только для просмотра (нет права редактировать) */
.shift-chip--readonly {
  cursor: default;
  opacity: 0.8;
}

.shift-chip--readonly:hover {
  filter: none;
}

/* Почасовка заблокирована */
#coverage-hourly-toggle:disabled + span,
label:has(#coverage-hourly-toggle:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Диалог входа ─────────────────────────────────────── */

.login-dialog {
  max-width: 380px;
}

.login-dialog h2 {
  margin-bottom: 0.5rem;
}

.field-hint--error {
  color: var(--warning, #ef4444);
  margin-top: 0.25rem;
}

/* Непрозрачный фон за диалогом входа — данные не видны до авторизации */
#manager-dialog::backdrop {
  background: var(--bg, #0f1117);
  opacity: 1;
}

/* ── Роль-бейджи в разделе Команда ─────────────────── */

.team-role-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.team-role-badge--manager {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.team-role-badge--senior {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.team-role-badge--employee {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Карточка руководителя */
.team-card--manager {
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}

.team-card__manager-email {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  flex: 1;
}

.team-card__manager-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Селект роли в карточке сотрудника */
.team-card__role-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── PIN поля в карточках команды ───────────────────── */

.team-pin-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.team-pin-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  width: 100%;
}

.pin-set-badge {
  color: var(--success);
  font-weight: 600;
}

.pin-unset-badge {
  color: var(--warning);
  font-weight: 600;
}

/* ── Строка текущего пользователя в настройках ──────── */

.current-user-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.current-user-label {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
  font-weight: 500;
}

/* ── Кнопка смены пользователя в заголовке ──────────── */

.header__logout {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  margin-left: 0.25rem;
  opacity: 0.7;
  vertical-align: middle;
}

.header__logout:hover {
  opacity: 1;
}
