/* =========================================================================
   Планировщик графика отпусков — оформление
   Тёмная боковая панель, светлая рабочая область, синий/бирюзовый акцент.
   ========================================================================= */

:root {
  /* размеры виртуализированной матрицы (читаются из JS) */
  --left-name: 220px;
  --left-email: 220px;
  --left-num: 84px;
  --day-w: 26px;

  --sidebar-w: 212px;

  --bg: #f2f5f8;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --line: #dde4ec;
  --line-strong: #c6d1de;
  --text: #16202b;
  --text-2: #46586b;
  --muted: #6d7f92;
  --muted-2: #8a9aab;

  --accent: #0f6fbf;
  --accent-2: #12a5a0;
  --accent-soft: #e7f1fb;
  --accent-soft-2: #e2f5f3;

  --work: #ffffff;
  --weekend: #eef1f5;
  --weekend-ink: #59697a;
  --holiday: #fdeaec;
  --holiday-ink: #b62a38;
  --holiday-line: #d64553;
  --vac: #0f9d94;
  --vac-ink: #04655f;
  --vac-soft: #d6f1ef;
  --violation: #d97706;
  --violation-ink: #8a4a04;
  --danger: #be2d3b;
  --warn: #b45309;
  --ok: #17845c;

  --sidebar-bg: #101a24;
  --sidebar-bg-2: #16232f;
  --sidebar-line: #24333f;
  --sidebar-text: #c8d4df;
  --sidebar-text-dim: #8a9aa8;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-1: 0 1px 2px rgba(16, 26, 36, .06), 0 1px 3px rgba(16, 26, 36, .05);
  --shadow-2: 0 6px 20px rgba(16, 26, 36, .12);
  --shadow-3: 0 18px 44px rgba(9, 18, 26, .28);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
  --row-h: 26px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font: 13px/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 17px; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; }
h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: 0 0 6px; }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #eef2f6; }
::-webkit-scrollbar-thumb { background: #b9c6d3; border: 2px solid #eef2f6; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #9fb0c0; }
::-webkit-scrollbar-corner { background: #eef2f6; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.grow { flex: 1 1 auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ============================== КНОПКИ, ПОЛЯ ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  font: 500 12.5px/1 var(--font);
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:hover { background: var(--panel-alt); border-color: #a9bacb; }
.btn:active { background: #eef2f6; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--accent); border-color: #0c5c9f; }
.btn-primary:hover { background: #0d63ab; border-color: #0a5289; }
.btn-primary:active { background: #0c5c9f; }
.btn-danger { color: var(--danger); border-color: #e3b6bb; background: #fff5f6; }
.btn-danger:hover { background: #fde8ea; border-color: #d79aa1; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--sidebar-text); }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); border-color: transparent; color: #fff; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-block { width: 100%; }
.btn.active { background: var(--accent-soft); border-color: #9dc4e6; color: #0b4f88; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  color: var(--text-2); background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.icon-btn:hover { background: rgba(15, 111, 191, .08); color: var(--accent); }

.seg { display: inline-flex; margin-left: auto; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn {
  height: 26px; padding: 0 11px;
  font: 500 12px/1 var(--font); color: var(--text-2);
  background: #fff; border: 0; border-right: 1px solid var(--line);
  cursor: pointer; white-space: nowrap;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--panel-alt); color: var(--text); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* --- выпадающий список с множественным выбором фильтров --- */
.mini-field.multiselect { position: relative; display: inline-flex; }
.ms-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; max-width: 240px; padding: 0 24px 0 9px;
  font: 12.5px/1 var(--font); color: var(--text); text-align: left;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  position: relative;
}
.ms-toggle::after {
  content: ""; position: absolute; right: 9px; top: 50%; margin-top: -2px;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--muted);
}
.ms-toggle:hover { border-color: #a9bacb; }
.ms-toggle.active { border-color: var(--accent); color: #0b4f88; background: var(--accent-soft); }
.ms-panel {
  position: absolute; z-index: 20; top: 32px; left: 0; width: 288px;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-2); padding: 6px;
}
.ms-head { display: flex; gap: 6px; margin-bottom: 6px; }
.ms-head .ms-search { flex: 1 1 auto; }
.ms-list { max-height: 250px; overflow-y: auto; }
.ms-list label { display: flex; align-items: center; gap: 6px; padding: 3px 4px; font-size: 12.5px; border-radius: 4px; cursor: pointer; }
.ms-list label:hover { background: var(--panel-alt); }
.ms-list .ms-empty { padding: 8px 4px; font-size: 12px; color: var(--muted); }
.ms-list .ms-sub { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.ms-note { padding: 5px 4px 1px; border-top: 1px solid var(--line); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], select, textarea {
  font: 13px/1.3 var(--font);
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  min-width: 0;
}
select { padding-right: 22px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 111, 191, .35); outline-offset: 0; border-color: var(--accent); }
input.field-invalid, input.field-invalid:focus { border-color: var(--danger); outline-color: rgba(190, 45, 59, .35); background: #fff7f8; }
input[disabled], select[disabled] { background: #f1f4f7; color: var(--muted); cursor: not-allowed; }
.input-sm { height: 26px; padding: 0 8px; font-size: 12px; }
select[multiple] { min-height: 62px; padding: 2px; }
select[multiple] option { padding: 2px 5px; border-radius: 4px; }
select[multiple] option:checked { background: var(--accent) linear-gradient(0deg, var(--accent), var(--accent)); color: #fff; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 11.5px; color: var(--text-2); font-weight: 500; }
.field .hint, .hint { font-size: 11px; color: var(--muted); margin: 0; }
.field-error { font-size: 11px; color: var(--danger); }

.inline-error {
  margin: 0 14px 10px;
  padding: 7px 10px;
  font-size: 12px;
  color: #7d1620;
  background: #fdecee;
  border: 1px solid #f0bcc2;
  border-radius: var(--radius-sm);
  white-space: pre-line;
}
.inline-error.floating { margin: 8px 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  font-size: 11.5px; color: var(--text-2);
  background: #eef3f8; border: 1px solid var(--line);
  border-radius: 999px; white-space: nowrap;
}
.chip-quiet { color: var(--muted); }
.chip-warn { color: var(--warn); background: #fdf5e6; border-color: #f0dcb4; }
.chip-bad { color: var(--danger); background: #fdecee; border-color: #f0bcc2; }
.chip-ok { color: var(--ok); background: #e8f6ef; border-color: #bfe3d1; }
.chip-accent { color: #0b4f88; background: var(--accent-soft); border-color: #bcd8f2; }

.count-badge {
  display: inline-block; min-width: 20px; padding: 1px 6px;
  font-size: 11px; font-weight: 600; text-align: center;
  color: var(--text-2); background: #eef3f8; border: 1px solid var(--line); border-radius: 999px;
}
.count-badge.count-bad { color: var(--danger); background: #fdecee; border-color: #f0bcc2; }
.count-badge.count-warn { color: var(--warn); background: #fdf5e6; border-color: #f0dcb4; }

.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid rgba(15, 111, 191, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-text { font-size: 11.5px; color: var(--accent); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================== ВХОД ============================== */

.login-view {
  display: flex; align-items: center; justify-content: center;
  height: 100%; padding: 24px;
  background:
    radial-gradient(1100px 500px at 12% -10%, rgba(18, 165, 160, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(15, 111, 191, .18), transparent 55%),
    linear-gradient(180deg, #f4f7fa, #e9eef4);
}
.login-card {
  width: 380px; max-width: 100%;
  padding: 24px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-2);
}
.login-brand { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.login-brand h1 { font-size: 16px; margin-bottom: 4px; }
.login-brand p { font-size: 12px; line-height: 1.45; }
.login-card .field { margin-bottom: 12px; }
.login-card .btn-block { margin-top: 4px; }
.login-card .hint { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }

.brand-mark {
  width: 28px; height: 28px; flex: none; border-radius: 8px;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px 6px;
  border-radius: 2px;
  background:
    linear-gradient(#fff, #fff) 0 0 / 100% 2px no-repeat,
    linear-gradient(#fff, #fff) 0 6px / 70% 2px no-repeat;
  opacity: .85;
}

/* ============================== КАРКАС ============================== */

.app { display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  border-right: 1px solid #0b131b;
}
.app.nav-collapsed .sidebar { display: none; }
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--sidebar-line); }
.sidebar-head .brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-head strong { font-size: 13px; color: #fff; }
.sidebar-head .muted { color: var(--sidebar-text-dim); font-size: 11px; }

.nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 9px; margin-bottom: 2px;
  font: 500 12.5px/1.2 var(--font); text-align: left;
  color: var(--sidebar-text); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(18, 165, 160, .16); border-color: rgba(18, 165, 160, .35); color: #fff; }
.nav-item.active .ic { color: #35d3cb; }
.nav-item .ic { color: var(--sidebar-text-dim); }
.nav-item span:nth-of-type(1) { flex: 1 1 auto; }
.nav-badge {
  min-width: 18px; padding: 1px 5px; font-size: 10.5px; font-weight: 600; text-align: center;
  color: #ffd9dc; background: rgba(190, 45, 59, .35); border-radius: 999px;
}
.sidebar-foot { padding: 10px 12px 12px; border-top: 1px solid var(--sidebar-line); }
.user-box { display: flex; flex-direction: column; margin-bottom: 8px; line-height: 1.35; }
.user-name { font-size: 12.5px; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mail { font-size: 11px; color: var(--sidebar-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: #35d3cb; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(16, 26, 36, .03);
  flex: none;
}
.page-title { font-size: 14.5px; }
.topbar-meta { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ============================== КОНТЕНТ / СЕКЦИИ ============================== */

.content { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.section { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.section:not(#section-schedule) { overflow-y: auto; padding: 12px; gap: 12px; }
#section-summary { gap: 12px; }
#section-schedule { padding: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 12px;
  min-width: 0;
}
.card + .card { margin-top: 0; }
.card.narrow { max-width: 620px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h3 { margin-right: 2px; }
.card-head .row-actions, .card-head .muted { margin-left: auto; }
.card-head .muted.small + .muted.small { margin-left: 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 12px; }
.scroll-y { max-height: 236px; overflow-y: auto; }
.scroll-y.tall { max-height: 420px; }

.toolbar {
  flex: none;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px 6px;
  display: flex; flex-direction: column; gap: 6px;
}
.toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sep { width: 1px; height: 20px; background: var(--line); }
.search { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.search .ic { position: absolute; left: 7px; color: var(--muted-2); pointer-events: none; }
.search input { width: 230px; padding-left: 26px; height: 28px; }
.mini-field { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); }
.mini-field > span { white-space: nowrap; }
.mini-field select { max-width: 260px; height: 28px; }
.mini-field select[size="1"] { min-height: 28px; }
.mini-field input[type="range"] { width: 110px; }
.mini-field.checkbox { gap: 4px; cursor: pointer; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cell-count { font-size: 11.5px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; padding: 2px 0 1px; }
.legend-title { font-size: 11.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); }
.sw { width: 20px; height: 12px; border: 1px solid var(--line-strong); border-radius: 3px; flex: none; }
.sw-work { background: #fff; }
.sw-weekend { background: repeating-linear-gradient(135deg, #e4e9ef 0 3px, #eef1f5 3px 6px); }
.sw-holiday { background: var(--holiday); border-color: #e7b6bc; box-shadow: inset 0 2px 0 var(--holiday-line); }
.sw-work-vac { background: var(--vac-soft); border-color: var(--vac); box-shadow: inset 0 0 0 1.5px var(--vac); }
.sw-weekend-vac { background: repeating-linear-gradient(135deg, #b9dfdc 0 3px, #d6f1ef 3px 6px); border-color: var(--vac); box-shadow: inset 0 0 0 1.5px var(--vac); }
.sw-holiday-vac { background: repeating-linear-gradient(135deg, #f3b6bd 0 3px, #fdeaec 3px 6px); border-color: var(--vac); box-shadow: inset 0 2px 0 var(--holiday-line), inset 0 0 0 1.5px var(--vac); }
.sw-violation { background: #fff; border-color: var(--violation); box-shadow: inset 0 0 0 2px #f6c68a; }
.sw-external { background: repeating-linear-gradient(45deg, #e6e9f2 0 3px, #fff 3px 6px); border-color: #97a3c4; }
.sw-pending { background: #f3f4f6; border: 1px dashed var(--muted-2); }

/* ============================== МАТРИЦА ============================== */

.matrix { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: #fff; }
.matrix-topline { display: flex; align-items: center; gap: 8px; padding: 3px 10px; border-bottom: 1px solid var(--line); background: var(--panel-alt); }
.matrix-topline .muted { font-size: 11px; }

.scroll-proxy { flex: none; overflow-x: auto; overflow-y: hidden; background: #eef2f6; border-bottom: 1px solid var(--line); height: 14px; }
.scroll-phantom { height: 1px; }

.matrix-header {
  flex: none; overflow: hidden; background: #fff;
  border-bottom: 2px solid var(--line-strong);
  max-height: 54px;
}
.hrow {
  display: flex; position: relative;
  /* ширина строк задаётся из JS: закреплённый блок + полосы месяцев / дни года */
}
.hrow.hrow-months { height: 30px; }
.hrow.hrow-days { height: 24px; }

/* --- закреплённый левый блок шапки (общий для обеих строк) --- */
.hcell.sticky { position: sticky; z-index: 4; background: #eff4f9; }
.hcell.h-name { justify-content: center; align-items: flex-start; padding: 4px 6px; }
.hcell.h-mail { justify-content: center; align-items: flex-start; padding: 4px 6px; }
.hcell.h-num { align-items: flex-end; padding: 4px 6px; }
.hrow-days .hcell.h-name, .hrow-days .hcell.h-mail, .hrow-days .hcell.h-num { padding: 0 6px; }
.hcell.c-edge { border-right: 1px solid var(--line-strong); box-shadow: 6px 0 8px -8px rgba(16, 26, 36, .45); background: #eff4f9; }

/* --- верхняя строка: полосы месяцев --- */
.hcell.h-month {
  position: relative; align-items: center; justify-content: center;
  background: #e8eff7; border-right: 1px solid #cfdae6; border-bottom: 1px solid var(--line-strong);
  color: #26445c; font-weight: 600; cursor: pointer; overflow: hidden;
}
.hcell.h-month:hover { background: #dfe9f5; }
.hcell.h-month .h-month-label {
  font-size: 11px; letter-spacing: .01em; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 0 4px;
}
.hrow-months.narrow .hcell.h-month .h-month-label.short { font-size: 9.5px; padding: 0; }

/* --- нижняя строка: числа и дни недели --- */
.hcell.h-day {
  height: 24px; flex-direction: row; gap: 2px; align-items: baseline; justify-content: center;
  background: #f7f9fb; border-bottom: 1px solid var(--line); padding: 0 2px;
}
.hcell.h-day .d-num { font-size: 10.5px; }
.hcell.h-day .d-wd { font-size: 9px; }
.hcell.h-day.h-weekend { background: #eef1f5; }
.hcell.h-day.h-weekend .d-num, .hcell.h-day.h-weekend .d-wd { color: var(--weekend-ink); }
.hcell.h-day.h-holiday { background: #fdeef0; }
.hcell.h-day.h-holiday .d-num, .hcell.h-day.h-holiday .d-wd { color: var(--holiday-ink); }
.hcell.h-lead, .hcell.h-tail { background: #f7f9fb; border-bottom: 1px solid var(--line); }

.matrix-body { flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; background: #fff; }
.matrix-canvas { position: relative; width: max-content; min-width: 100%; }
.rows-layer { position: relative; }

.mrow { position: absolute; left: 0; display: flex; height: var(--row-h); will-change: transform; }
.mrow.even .mcell { background: #fcfdfe; }
.mrow:hover .mcell { background: #f4f8fc; }
.mrow:hover .mcell.c-num { background: #eaf2fa; }
.mrow.row-flash .mcell { animation: flashRow 1.6s ease-out 1; }
@keyframes flashRow { 0% { background: #fdf0c9; } 100% { background: transparent; } }

.mcell {
  flex: none;
  height: var(--row-h);
  display: flex; align-items: center;
  padding: 0 6px;
  background: #fff;
  border-bottom: 1px solid #eef1f5;
  border-right: 1px solid #f1f4f7;
  overflow: hidden;
  font-size: 12px;
  color: var(--text);
}
.mcell.sticky { position: sticky; z-index: 3; }
.mcell.c-name { justify-content: flex-start; }
.mcell.c-num { justify-content: flex-end; font-variant-numeric: tabular-nums; color: var(--text-2); }
.mcell.n-remaining.pos { color: var(--ok); }
.mcell.n-remaining.neg { color: var(--danger); font-weight: 600; }
.mcell.n-remaining.unknown, .mcell.n-allocated.unknown { color: var(--muted-2); }
.mcell.n-limit.overridden { color: var(--accent); font-weight: 600; }
.mcell.c-edge { border-right: 1px solid var(--line-strong); box-shadow: 6px 0 6px -6px rgba(16, 26, 36, .28); }
.mcell .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.mcell .mail { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.mcell .warn-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-right: 5px; }
.mcell .warn-dot.bad { background: var(--danger); }
.mcell .warn-dot.pending { background: var(--muted-2); }
.mcell .readonly-mark { flex: none; margin-left: 5px; color: var(--muted-2); font-size: 11px; }

.hcell {
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #f7f9fb; border-right: 1px solid #e8edf3;
  font-size: 10.5px; color: var(--text-2); line-height: 1.15; overflow: hidden;
}
.hcell .m-name { font-weight: 600; font-size: 11px; color: #274153; white-space: nowrap; }
.hcell .d-num { font-weight: 600; color: var(--text); }
.hcell .d-wd { font-size: 9.5px; color: var(--muted); }

.dcell { position: relative; padding: 0; overflow: hidden; }
.dcell::before {
  content: ""; position: absolute; inset: 0;
  background: var(--work);
}
.dcell.d-weekend::before { background: repeating-linear-gradient(135deg, #e3e8ee 0 3px, #eef1f5 3px 6px); }
.dcell.d-holiday::before { background: var(--holiday); box-shadow: inset 0 2px 0 var(--holiday-line); }
.dcell.d-pending::before { background: #f3f4f6; border: 1px dashed #d6dae0; }
.dcell.d-pending .q { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 10px; }

/* Полоса отпуска: тип дня остаётся различимым — праздник подчёркнут красной линией,
   выходной заштрихован, рабочий день имеет сплошную бирюзовую заливку. */
.dcell .bar {
  position: absolute; left: 3px; right: 3px; top: 7px; bottom: 5px;
  border-radius: 3px; background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--vac);
}
.dcell.v-weekend .bar { background: repeating-linear-gradient(135deg, #b7dedb 0 3px, #d9f2f0 3px 6px); }
.dcell.v-holiday .bar {
  top: 3px;
  background: repeating-linear-gradient(135deg, #f3c0c5 0 3px, #fbe4e7 3px 6px);
  box-shadow: inset 0 0 0 1.5px var(--vac);
  border-top: 2px solid var(--holiday-line);
}
.dcell.v-pending .bar { top: 5px; background: #dfe3e8; box-shadow: inset 0 0 0 1.5px #9aa6b2; }
.dcell .bar.edge-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.dcell .bar.edge-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.dcell .bar.b-solid { background: var(--vac-soft); box-shadow: inset 0 0 0 1.5px var(--vac); }

.dcell.v-violation .bar { box-shadow: inset 0 0 0 1.5px var(--vac), 0 0 0 2px #f0b46a; }
.dcell.v-violation::after {
  content: ""; position: absolute; right: 2px; bottom: 1px;
  width: 0; height: 0; border-left: 5px solid transparent; border-bottom: 5px solid var(--violation);
}
.dcell.v-external::after {
  content: ""; position: absolute; inset: 3px;
  border: 1px dashed #7d89ad; border-radius: 3px; pointer-events: none;
}
.dcell.d-holiday.v-violation::after { border-bottom-color: var(--violation); }
.dcell.is-flash .bar { animation: flashCell 1.6s ease-out 1; }
@keyframes flashCell { 0%, 40% { box-shadow: inset 0 0 0 2.5px var(--accent), 0 0 0 3px rgba(15, 111, 191, .35); } 100% { box-shadow: inset 0 0 0 1.5px var(--vac); } }

.dcell.readonly { cursor: default; }
.dcell.selectable { cursor: cell; }
.dcell.draft { box-shadow: inset 0 0 0 2px var(--accent-2); }
.dcell.draft .bar { box-shadow: inset 0 0 0 1.5px var(--accent-2); background: var(--accent-soft-2); }

.overlay { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 60px; background: rgba(255, 255, 255, .72); z-index: 5; }
.overlay-card { max-width: 460px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); text-align: center; }
.overlay-card h3 { margin-bottom: 6px; }
.overlay-card p { margin-bottom: 10px; font-size: 12.5px; color: var(--text-2); }
.overlay-card .row-actions { justify-content: center; }

/* ============================== ТАБЛИЦЫ / СПИСКИ ============================== */

.table-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.data-table th, .data-table td { padding: 6px 9px; text-align: left; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f4f7fa; color: var(--text-2); font-weight: 600; font-size: 11.5px;
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.data-table tbody tr:hover td { background: #f7fafd; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.act, .data-table td.act { width: 1%; white-space: nowrap; text-align: right; }
.data-table .mail { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.data-table .tag { display: inline-block; margin: 0 4px 3px 0; padding: 1px 6px; font-size: 11px; color: #0b4f88; background: var(--accent-soft); border: 1px solid #cbe0f4; border-radius: 999px; }
.data-table .tag.neutral { color: var(--text-2); background: #eef2f6; border-color: var(--line); }
.data-table td .cell-flex { display: flex; align-items: center; gap: 6px; }

.list-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 6px; border-bottom: 1px solid #f1f4f7;
  font-size: 12px; cursor: pointer; border-radius: 4px;
}
.list-row:hover { background: #f4f8fc; }
.list-row .who { font-weight: 500; min-width: 168px; }
.list-row .what { color: var(--text-2); }
.list-row .val { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.list-row .val.bad { color: var(--danger); font-weight: 600; }
.list-row .val.warn { color: var(--warn); font-weight: 600; }
.list-row .val.ok { color: var(--ok); }
.empty-note { padding: 10px 6px; font-size: 12px; color: var(--muted); }

.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stat {
  min-width: 118px; padding: 7px 10px;
  background: var(--panel-alt); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.stat .k { display: block; font-size: 11px; color: var(--muted); }
.stat .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.bad .v { color: var(--danger); }
.stat.warn .v { color: var(--warn); }
.stat.ok .v { color: var(--ok); }

.preview-box { margin-top: 10px; padding: 10px; background: var(--panel-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12px; }
.preview-box h4 { margin-bottom: 6px; }
.preview-box ul { margin: 4px 0 0; padding-left: 18px; }
.preview-box li { margin-bottom: 2px; }
.preview-box .data-table { margin: 6px 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.preview-box .data-table td.changed { background: #eaf4fb; font-weight: 600; color: #0b4f88; }
.text-warn { color: var(--warn); }
.import-errors { margin-top: 10px; max-height: 320px; overflow: auto; border: 1px solid #f0bcc2; border-radius: var(--radius-sm); background: #fffafb; }
.file-input { font-size: 12px; }

/* ============================== МОДАЛЬНЫЕ ОКНА ============================== */

.modal {
  padding: 0; border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-3); background: #fff; color: var(--text);
  max-height: 92vh; width: auto;
}
.modal::backdrop { background: rgba(12, 20, 28, .42); }
.modal-wide { width: min(1120px, 96vw); }
.modal-narrow { width: min(560px, 94vw); }
.modal-form { display: flex; flex-direction: column; max-height: 92vh; margin: 0; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h3 { flex: 1 1 auto; }
.modal-body { padding: 12px 14px; overflow: auto; min-height: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel-alt); flex: none; border-radius: 0 0 10px 10px; }

.wizard-body { display: grid; grid-template-columns: minmax(430px, 1fr) minmax(330px, 420px); gap: 14px; }
.wizard-left, .wizard-right { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#editor-body .form-grid { grid-template-columns: 1fr; }
.field-label .req { color: var(--danger); }
.field-label .opt { color: var(--muted-2); font-weight: 400; }

.month-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.month-picker button {
  font: 500 11.5px/1 var(--font); padding: 5px 2px; color: var(--text-2);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.month-picker button:hover { background: var(--accent-soft); border-color: #bcd8f2; color: #0b4f88; }
.month-picker button.active { background: var(--accent); border-color: #0c5c9f; color: #fff; }

.mini-calendars { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 8px; }
.mini-month { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: #fff; }
.mini-month h5 { margin: 0 0 4px; font-size: 11.5px; font-weight: 600; color: var(--text-2); text-align: center; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-wd { font-size: 9.5px; text-align: center; color: var(--muted-2); padding-bottom: 2px; }
.mini-day {
  position: relative; height: 19px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text); background: #fff; border-radius: 3px; cursor: pointer; user-select: none;
}
.mini-day.pad { background: transparent; cursor: default; }
.mini-day.wk { background: #eef1f5; color: var(--weekend-ink); }
.mini-day.hol { background: var(--holiday); color: var(--holiday-ink); font-weight: 600; }
.mini-day.wk.hol { background: var(--holiday); }
.mini-day.pending { background: #f3f4f6; color: var(--muted-2); border: 1px dashed #d6dae0; }
.mini-day.in-range { background: var(--accent-soft); box-shadow: inset 0 0 0 1px #9dc4e6; }
.mini-day.sel { background: var(--accent); color: #fff; box-shadow: inset 0 0 0 1px #0c5c9f; }
.mini-day.dim { opacity: .45; }
.mini-day.other-period { box-shadow: inset 0 -2px 0 var(--vac); }
.mini-calendars.dragging { user-select: none; cursor: crosshair; }

.panel { padding: 10px; background: var(--panel-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.panel h4 { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin: 0; font-size: 12px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.bad { color: var(--danger); font-weight: 600; }
.kv dd.warn { color: var(--warn); font-weight: 600; }
.kv dd.ok { color: var(--ok); }
.kv dd.unknown { color: var(--muted-2); }
.kv dd.sep-row { grid-column: 1 / -1; }

.warn-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.warn-item { display: flex; gap: 6px; font-size: 11.5px; padding: 5px 7px; border-radius: 4px; background: #fff; border: 1px solid var(--line); }
.warn-item.warn { background: #fdf8ee; border-color: #f0dcb4; color: #6d4708; }
.warn-item.bad { background: #fdeef0; border-color: #f0bcc2; color: #7d1620; }
.warn-item.info { background: #f2f8fd; border-color: #cbe0f4; color: #14507f; }
.warn-item.ok { background: #eef8f3; border-color: #bfe3d1; color: #14603f; }
.warn-item .wi-mark { flex: none; font-weight: 700; }

.violation-item { margin-bottom: 6px; padding: 6px 8px; font-size: 11.5px; background: #fff; border: 1px solid #f0dcb4; border-left: 3px solid var(--violation); border-radius: 4px; }
.violation-item .vi-head { font-weight: 600; color: #6d4708; }
.violation-item .vi-body { color: var(--text-2); }
.violation-item .vi-parts { color: var(--muted); }

.member-picker { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; }
.member-picker .mp-head { display: flex; gap: 6px; padding: 6px; border-bottom: 1px solid var(--line); }
.member-picker .mp-list { max-height: 220px; overflow-y: auto; padding: 4px 6px; }
.member-picker label { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 12px; cursor: pointer; }
.member-picker label .mp-sub { color: var(--muted); font-size: 11px; }
.member-picker .mp-empty { padding: 8px; color: var(--muted); font-size: 12px; }
.grants-editor { display: flex; flex-direction: column; gap: 6px; }
.grant-row { display: grid; grid-template-columns: 118px 1fr 78px 28px; gap: 6px; align-items: center; }
.help-text { font-size: 11.5px; color: var(--muted); }

.toast-host { position: fixed; right: 14px; bottom: 14px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  padding: 9px 12px; font-size: 12.5px; color: var(--text);
  background: #fff; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
  animation: toastIn .16s ease-out 1; white-space: pre-line;
}
.toast.bad { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================== АДАПТАЦИЯ ============================== */

@media (max-width: 1500px) {
  .wizard-body { grid-template-columns: minmax(360px, 1fr) minmax(300px, 360px); }
}
@media (max-width: 1366px) {
  :root { --sidebar-w: 190px; }
  .search input { width: 180px; }
  .mini-field select { max-width: 190px; }
  .mini-calendars { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); }
  .wizard-body { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .scroll-y { max-height: 200px; }
}
@media (max-height: 800px) {
  .mini-calendars { max-height: 260px; overflow-y: auto; }
}
