/* app.css — pay-style для ling (Контроль загруженности).
   Фон #f4f5f7, белые карточки, шапка #08182B, акцент #19A1E5.
   Flat-таблицы .table-wrap, бейджи, hover, сортировка; мобильные карточки ≤640px.
   Версия статики бампится в base.html при правках (?v=...). */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #f4f5f7;
  color: #1f2733;
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

a { color: #19A1E5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ шапка */
.topbar {
  background: #08182B;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-text { display: inline-block; }
.brand-sub { color: #19A1E5; font-weight: 500; margin-left: 4px; }
.brand-logo { height: 26px; background: #fff; border-radius: 3px; padding: 2px; }

.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-link {
  color: #c7d3e0;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-admin { position: relative; }
.nav-admin-label {
  color: #c7d3e0; cursor: pointer; padding: 6px 12px; border-radius: 4px;
}
.nav-admin:hover .nav-admin-label { background: rgba(255,255,255,.08); color: #fff; }
.nav-admin-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: #fff; border: 1px solid #e2e6ec; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(8,24,43,.12); min-width: 190px; padding: 6px 0;
}
.nav-admin:hover .nav-admin-menu { display: block; }
.nav-admin-menu a {
  display: block; padding: 8px 14px; color: #1f2733; font-size: 13px;
}
.nav-admin-menu a:hover { background: #f0f4f8; text-decoration: none; }

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.bell { position: relative; }
.bell-btn { color: #fff; font-size: 17px; display: inline-block; padding: 4px; }
.bell-badge {
  position: absolute; top: -4px; right: -6px;
  background: #e11d48; color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; padding: 0 5px; line-height: 15px;
}
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid #e2e6ec; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(8,24,43,.16); width: 320px; color: #1f2733;
  z-index: 60;
}
.bell-title { font-weight: 700; padding: 10px 12px; border-bottom: 1px solid #eef1f5; }
.bell-item { padding: 9px 12px; border-bottom: 1px solid #f2f4f7; }
.bell-item-title { font-weight: 600; }
.bell-item-body { color: #55606e; }
.bell-item-date { color: #8a94a2; font-size: 11px; margin-top: 2px; }
.bell-empty { padding: 14px 12px; color: #8a94a2; }
.bell-more a { color: #19A1E5; font-weight: 600; }
.help-link {
  color: #c7d3e0; border: 1px solid #2c4159; border-radius: 50%;
  width: 22px; height: 22px; line-height: 21px; text-align: center;
  font-size: 12px; display: inline-block;
}
.user-chip { text-align: right; }
.user-name { color: #fff; font-weight: 600; display: block; font-size: 13px; }
.user-role { color: #7f93ab; font-size: 11px; display: block; }
.logout-form { margin: 0; }

/* ------------------------------------------------------------ контейнер */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}
.page-head { margin: 4px 0 12px; }
.page-title { font-size: 18px; font-weight: 700; margin: 0; }

.panel-section {
  background: #fff; border: 1px solid #e6eaf0; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 14px;
}
.panel-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: #8a94a2; font-weight: 700; margin-bottom: 10px;
}
.workload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.workload-card {
  background: #f7f9fb; border: 1px solid #e6eaf0; border-radius: 6px;
  padding: 10px 12px; text-align: left; cursor: pointer;
  font: inherit; color: inherit;
}
.workload-card:hover { border-color: #19A1E5; background: #f2f9fe; }
.wc-name { font-weight: 700; font-size: 13px; }
.wc-dept { color: #8a94a2; font-size: 11px; margin-bottom: 6px; }
.wc-metric { display: inline-block; margin-right: 14px; margin-top: 4px; }
.wc-num { font-weight: 700; font-size: 16px; color: #08182B; }
.wc-label { color: #8a94a2; font-size: 11px; margin-left: 3px; }
.wc-overdue-badge {
  background: #e11d48; color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 8px;
}

/* ------------------------------------------------------- вкладки/фильтры */
.toolbar { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; background: #fff; border: 1px solid #e6eaf0; border-radius: 8px; padding: 4px; }
.tab {
  padding: 7px 14px; border-radius: 6px; color: #55606e; font-weight: 600;
  font-size: 13px;
}
.tab:hover { background: #f0f4f8; text-decoration: none; }
.tab.active { background: #19A1E5; color: #fff; }
.filters {
  display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap;
  background: #fff; border: 1px solid #e6eaf0; border-radius: 8px; padding: 8px 10px;
}
.filter-item { display: flex; flex-direction: column; gap: 2px; }
.filter-label { font-size: 11px; color: #8a94a2; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* Волна 3 (ТЗ 25.09): кнопка «Фильтры» и сворачиваемая панель фильтров */
.filters-bar { display: flex; gap: 8px; margin-bottom: 8px; }
.filters-toggle { white-space: nowrap; }
.filters-caret {
  display: inline-block; font-size: 10px; transition: transform .15s ease;
}
.filters-toggle[aria-expanded="false"] .filters-caret { transform: rotate(-90deg); }
.filters-count {
  background: #19A1E5; color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 6px;
}

/* ---------------------------------------------------------- кнопки/формы */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 5px;
  background: #eef1f5; color: #1f2733; padding: 7px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; min-height: 32px;
  line-height: 1.3; vertical-align: middle; text-align: center;
}
.btn:hover { background: #e2e7ee; text-decoration: none; }
.btn-primary { background: #19A1E5; color: #fff; }
.btn-primary:hover { background: #148ed0; }
.btn-ghost { background: transparent; border-color: #d5dbe3; color: #55606e; }
.btn-ghost:hover { background: #f0f4f8; }
.btn-sm { padding: 4px 10px; font-size: 12px; min-height: 28px; }
.btn-xs { padding: 2px 8px; font-size: 11px; min-height: 24px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

select, input[type="text"], input[type="search"], input[type="date"],
input[type="number"], input[type="url"], input[type="password"], textarea {
  border: 1px solid #d5dbe3; border-radius: 5px; padding: 6px 9px;
  font: inherit; color: inherit; background: #fff; min-height: 32px;
}
input[type="date"] { padding: 5px 8px; }
select { padding: 6px 8px; }
textarea { min-height: 52px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #19A1E5; }

.form-label { display: block; font-size: 12px; color: #55606e; margin: 8px 0 3px; font-weight: 600; }
.form-label select, .form-label input, .form-label textarea { width: 100%; }
.req { color: #e11d48; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
.hint { color: #8a94a2; font-size: 11px; margin-top: 3px; }
.muted { color: #8a94a2; }
.quick-add { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.quick-add input { flex: 1; min-height: 30px; }
.dept-hint { color: #8a94a2; font-size: 11px; display: block; }

/* ---------------------------------------------------------------- таблица */
.table-wrap {
  background: #fff; border: 1px solid #e6eaf0; border-radius: 8px;
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; padding: 9px 10px; border-bottom: 2px solid #eef1f5;
  color: #55606e; font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap; font-weight: 700;
}
.table td {
  padding: 9px 10px; border-bottom: 1px solid #f2f4f7; vertical-align: top;
}
.table tbody tr:hover { background: #f7fafc; }
.table .empty { text-align: center; color: #8a94a2; padding: 28px 10px; }

.th-sort-link { color: #55606e; font-weight: 700; }
.th-sort-link:hover { color: #19A1E5; text-decoration: none; }
.th-sort-link.sort-on { color: #19A1E5; }
.th-arrow { font-size: 10px; margin-left: 2px; }

.comment-cell { color: #55606e; max-width: 260px; white-space: normal; }
.progress-val { font-weight: 600; margin-left: 2px; }
.progress-input { width: 70px; min-height: 26px; padding: 3px 6px; }
.cp-name { font-weight: 600; }
.obj-cell { font-weight: 600; color: #08182B; }

/* Просрочка: мягкий красный фон строки (не кислотный) — ТЗ §3.1 */
.task-row.overdue td { background: #fdf1f1; }
.task-row.overdue:hover td { background: #fbe7e7; }
.task-row.overdue .obj-cell { color: #8f1f1f; }

/* Волна 5 ТЗ 25.09: деактивированные записи справочников (и сотрудники в
   админке) приглушены — видны, но не путаются с активными */
tr.user-inactive td { color: #8a94a3; }

/* Кнопка быстрого создания рядом с полем выбора (заказчик в новой задаче) */
.picker-inline { display: flex; gap: 6px; align-items: center; }
.picker-inline select { flex: 1 1 auto; }


/* Бейджи статусов и приоритетов (pay-стиль) */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.badge-red    { background: #fde3e3; color: #b42318; }
.badge-yellow { background: #fdf2cf; color: #92600a; }
.badge-gray   { background: #e9edf1; color: #55606e; }
.badge-green  { background: #dcf5e4; color: #0e7a3d; }
.badge-blue   { background: #ddf0fc; color: #1266a8; }
.badge-violet { background: #ede6fb; color: #5b3d9b; }
.badge-orange { background: #fdeeda; color: #b05a13; }
.badge-dark   { background: #08182B; color: #fff; }
.badge-amber  { background: #fdf2cf; color: #92600a; }

/* Инлайн-правка в строке */
.inline-edit { min-height: 26px; padding: 2px 6px; font-size: 12px; }

/* Раскрытая строка */
.detail-row td { background: #f7f9fb; padding: 14px 16px; }
/* Волна 4 ТЗ 25.09: фиксированная двухколоночная раскладка деталей задачи —
   слева «Редактирование» и «Часы», справа «История изменений» и «Вложения».
   Число колонок и места блоков заданы явно (grid-области, без auto-fit):
   порядок не зависит от высоты содержимого; блоки выровнены по верху и не
   растягиваются на высоту соседа (align-items: start). */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "edit history"
    "hours files";
  gap: 16px;
  align-items: start;
}
/* Нет права правки → блока «Редактирование» нет: пересобираем области,
   чтобы на его месте не осталось пустой дырки. */
.detail-grid-no-edit {
  grid-template-areas:
    "hours history"
    "files files";
}
.detail-block[data-block="edit"] { grid-area: edit; }
.detail-block[data-block="hours"] { grid-area: hours; }
.detail-block[data-block="history"] { grid-area: history; }
.detail-block[data-block="files"] { grid-area: files; }
/* Узкий экран (решение заказчика: ≤900px) — одна колонка в порядке разметки:
   Редактирование, Часы, История, Вложения. */
@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "edit"
      "hours"
      "history"
      "files";
  }
  .detail-grid-no-edit { grid-template-areas: "hours" "history" "files"; }
}
.detail-block-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: #8a94a2; font-weight: 700; margin-bottom: 6px;
}
.history-list { max-height: 220px; overflow-y: auto; }
.history-item { padding: 4px 0; border-bottom: 1px dashed #eef1f5; font-size: 12px; }
.history-item .h-tag { font-weight: 700; color: #1266a8; }
.history-item .h-old { color: #b42318; text-decoration: line-through; }
.history-item .h-new { color: #0e7a3d; font-weight: 600; }
.history-item .h-when { color: #8a94a2; font-size: 11px; }
.hours-list .hours-item { padding: 3px 0; font-size: 12px; }
.hour-add-form, .file-add-form { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.hour-add-form input, .file-add-form input { min-height: 30px; }
.hour-add-form input[type="date"] { flex: 0 0 130px; }
.hour-add-form .btn, .file-add-form .btn { min-height: 30px; }
.files-list .file-item { padding: 3px 0; font-size: 12px; }
.row-edit-form .btn { min-height: 32px; }

/* Скрытые элементы: атрибут hidden обязан побеждать правила отображения
   (иначе модальные окна с display:flex видно всегда и они блокируют интерфейс). */
[hidden] { display: none !important; }

/* ------------------------------------------------------------- модальные */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8,24,43,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 10px; width: 560px; max-width: 100%;
  box-shadow: 0 18px 50px rgba(8,24,43,.25);
}
.modal-sm { width: 420px; }
.modal-wide { width: 860px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #eef1f5;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 12px 18px 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* недельная сетка часов */
.week-grid { width: 100%; }
.week-grid th, .week-grid td { border: 1px solid #e6eaf0; padding: 4px; text-align: center; }
.week-grid input { width: 60px; min-height: 30px; text-align: center; }
.week-grid .week-note { color: #8a94a2; }
.hours-table-total { font-weight: 700; }

/* ------------------------------------------------------------- флэш-сообщения */
.flashes { margin-bottom: 12px; }
.flash { border-radius: 6px; padding: 9px 12px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.flash-error { background: #fde3e3; color: #b42318; border: 1px solid #f8c9c9; }
.flash-success { background: #dcf5e4; color: #0e7a3d; border: 1px solid #bfeccc; }
.flash-info { background: #ddf0fc; color: #1266a8; border: 1px solid #bfe0f7; }
.flash-close { background: none; border: none; font-size: 15px; cursor: pointer; color: inherit; min-width: 32px; min-height: 32px; }

/* Предупреждения на странице (недоступный справочник центра, резервный режим прав) */
.alert { border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.alert-warning { background: #fdf3d7; color: #7d5d00; border: 1px solid #f3e2a8; }
.field-hint { font-size: 12px; color: #8a94a2; margin-top: 4px; }
.field-hint-error { color: #b42318; }

/* ------------------------------------------------------------- подвал */
.footer {
  max-width: 1400px; margin: 0 auto; padding: 14px 16px 30px;
  color: #8a94a2; font-size: 12px; display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.footer a.doc-link { color: #55606e; }

/* ------------------------------------------------------------- login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f4f5f7; }
.login-wrap { width: 100%; max-width: 400px; padding: 16px; }
.login-card { background: #fff; border: 1px solid #e6eaf0; border-radius: 12px; padding: 28px 28px 22px; }
.login-brand { font-size: 26px; font-weight: 800; color: #08182B; }
.login-brand span { color: #19A1E5; }
.login-sub { color: #8a94a2; margin: 2px 0 18px; }
.login-source { color: #a7b0bc; font-size: 11px; margin: -10px 0 14px; }
.login-divider { text-align: center; color: #8a94a2; font-size: 11px; margin: 14px 0 10px; }
.user-option { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; cursor: pointer; }
.user-option-name { font-weight: 600; }
.user-option-meta { color: #8a94a2; font-size: 11px; }
.sso-form .btn { min-height: 40px; }
/* форма логина/пароля на странице входа */
.login-form .field-label, .login-form label { display: block; font-size: 12px; color: #55606e; margin: 8px 0 3px; font-weight: 600; }
.login-form .input, .login-form input[type="text"], .login-form input[type="password"] { width: 100%; }
.login-form .btn { margin-top: 14px; min-height: 40px; }
/* вход по имени (D14): поиск + список сотрудников по отделам */
.login-search { margin: 0 0 10px; }
.login-search .input { width: 100%; }
.login-employees { max-height: 58vh; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.login-dept { margin-bottom: 8px; }
.login-dept-name { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #8a94a2; font-weight: 700; margin: 8px 0 4px; }
.employee-form { margin: 0; }
.employee-option { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 7px 8px; cursor: pointer; font: inherit; color: #08182B; }
.employee-option:hover { background: #eef6fd; }
.employee-option-name { font-weight: 600; }
.employee-option-meta { color: #8a94a2; font-size: 11px; }
.login-dev-link {
  position: fixed; right: 8px; bottom: 6px; color: #c4ccd6; font-size: 13px;
}

/* ---------------------------------------------------------- error-страница */
.error-page { text-align: center; padding: 60px 16px; }
.error-code { font-size: 46px; font-weight: 800; color: #08182B; }
.error-message { color: #55606e; font-size: 15px; margin: 8px 0 18px; }

/* ----------------------------------------------------------------- набор шрифтов в таблицах */
.first-col-fixed th:nth-child(1), .first-col-fixed td:nth-child(1) { white-space: nowrap; }
.num-col { width: 42px; color: #8a94a2; }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions .btn { margin-left: 4px; }

/* ===================================================== МОБИЛЬНАЯ ВЕРСИЯ ≤640px */
@media (max-width: 640px) {
  .container { padding: 10px 8px 30px; }
  .topbar-inner { height: 50px; gap: 10px; padding: 0 10px; }
  .main-nav { overflow-x: auto; }
  .user-role { display: none; }
  .filters { width: 100%; flex-direction: column; align-items: stretch; }
  .filter-item { flex-direction: row; align-items: center; gap: 8px; }
  .filter-label { width: 110px; flex: none; }
  /* Волна 3: кнопка «Фильтры» во всю ширину, панель — в общем потоке */
  .filters-toggle { width: 100%; }
  .filters-bar { margin-bottom: 10px; }
  .workload-grid { grid-template-columns: 1fr 1fr; }
  .modal-overlay { padding: 12px 8px; }
  .modal-body { padding: 10px 12px 14px; }
  .form-row { flex-direction: column; gap: 0; }

  /* строка таблицы → карточка с data-label */
  .table-wrap { background: transparent; border: none; }
  .table, .table tbody, .table tr, .table td, .table th { display: block; }
  .table thead { display: none; }
  .table tbody tr {
    background: #fff; border: 1px solid #e6eaf0; border-radius: 8px;
    margin-bottom: 10px; display: block;
  }
  .table td {
    display: flex; justify-content: space-between; align-items: flex-start;
    border: none; padding: 7px 10px; font-size: 13px;
  }
  .table td::before {
    content: attr(data-label);
    color: #8a94a2; font-size: 11px; text-transform: uppercase;
    letter-spacing: .03em; font-weight: 700; flex: 0 0 40%;
    padding-right: 8px;
  }
  .table td:empty::before { content: attr(data-label); }
  .task-row.overdue td { background: #fdf1f1; }
  .detail-row td { background: #f7f9fb; }
  .detail-row td::before { content: none; }
  /* раскладка деталей на узком экране — общим правилом ≤900px выше */
  .num-col { width: auto; }
  .col-actions { justify-content: flex-end; }
  .hour-add-form, .file-add-form { flex-direction: column; }
  .hour-add-form input[type="date"], .hour-add-form input, .file-add-form input { width: 100%; flex: none; }
  .btn { min-height: 36px; }
  .row-toggle, .row-delete { min-height: 32px; }
  .week-grid { overflow-x: auto; display: block; }
  .week-grid input { width: 48px; }
  .tabs { flex: 1; }
  .tab { flex: 1; text-align: center; padding: 8px 4px; }
}
/* =========================================================================
   План-график (веха E1): список отдел → сотрудник → задачи + диаграмма
   ========================================================================= */

.page-head .muted { margin-top: 2px; }

.plan-filters { margin-bottom: 12px; }
.plan-filters .filter-check {
  flex-direction: row; align-items: center; gap: 6px;
  color: #55606e; font-size: 12px; min-height: 32px;
}
.plan-filters .filter-check input { min-height: auto; }

/* =========================================================================
   T1: календарь-таблица области диаграммы (эталон
   reference/plan_table_design_20260924/mockup.html). Библиотека диаграммы
   больше не используется: строка — задача, слева три липкие информационные
   колонки, справа календарь (месяцы, числа дней, выходные, линия «сегодня»),
   полосы лежат на сетке дней.
   ========================================================================= */

.plan-board {
  --plan-row-h: 30px;
  /* Волна 2 (ТЗ 25.09): отступ значений первого информационного столбца в
     строках-задачах — визуальное подчинение заголовку группы (12–16 px). */
  --plan-info-indent: 14px;
  margin-bottom: 14px;
}

.plan-board-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-bottom: 8px;
}
.pbt-label { color: #8a94a2; font-size: 12px; }
.pbt-seg {
  display: inline-flex; border: 1px solid #d5dbe3; border-radius: 8px;
  background: #fff; overflow: hidden;
}
.pbt-btn {
  border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 12px;
  color: #55606e; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.pbt-btn + .pbt-btn { border-left: 1px solid #d5dbe3; }
.pbt-btn.active { background: #19A1E5; color: #fff; font-weight: 600; }

.plan-legend {
  display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 8px;
  font-size: 11px; color: #4b5563;
}
.plan-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.plan-legend .lg i {
  width: 11px; height: 11px; border-radius: 3px; display: inline-block;
}
.plan-legend .lg i.hatch {
  background: repeating-linear-gradient(45deg, #fff 0 3px, #c9d3e0 3px 6px);
  border: 1px solid #b9c4d4;
}

.plan-calendar-wrap {
  background: #fff; border: 1px solid #e3e8ef; border-radius: 10px;
  overflow: auto; max-height: 74vh;
  box-shadow: 0 1px 3px rgba(20, 40, 80, .06);
}
.plan-calendar {
  border-collapse: separate; border-spacing: 0; table-layout: fixed;
}
.plan-calendar th, .plan-calendar td {
  height: var(--plan-row-h); border-bottom: 1px solid #eef1f6;
  background: #fff; font-size: 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; padding: 0;
}
.plan-calendar thead th {
  position: sticky; top: 0; z-index: 5; background: #f7f9fc;
  font-weight: 600; color: #42506b;
}
.plan-calendar thead tr.plan-months th {
  height: 26px; font-size: 11.5px; text-align: left; padding: 0 8px;
  border-bottom: 1px solid #e3e8ef;
}
.plan-calendar thead tr.plan-days th {
  top: 26px; height: 32px; font-size: 10.5px; font-weight: 500;
  color: #6b7280; text-align: center; border-right: 1px solid #eef1f6;
  padding: 1px 0; line-height: 1.05; overflow: visible; position: sticky;
}
.plan-calendar thead tr.plan-days th.we { background: #e9f0fd; color: #0f7bb5; }
.plan-calendar thead tr.plan-days th.today { background: #19A1E5; color: #fff; }
.plan-day { position: relative; }
.plan-day-num { display: block; }
.plan-dow { display: block; font-size: 8.5px; color: #9aa4b2; }
.plan-day.today .plan-dow { color: #eaf6fd; }
.plan-today-flag {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; overflow: hidden; font-size: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid #08182B;
}

.plan-info { position: sticky; border-right: 1px solid #e3e8ef; padding: 0 8px; }
.plan-calendar thead th.plan-info { z-index: 7; background: #f7f9fc; }
.plan-calendar td.plan-info { z-index: 2; }
/* Волна 2: значения первого информационного столбца в строке-задаче — с
   отступом под заголовок группы (строки-группы и thead — без отступа).
   Величина — переменная --plan-info-indent уровня .plan-board; действует
   и в мобильном диапазоне (≤640 px). */
.plan-info.plan-info-indent { padding-left: calc(8px + var(--plan-info-indent)); }
.plan-info.plan-info-primary { font-weight: 600; color: #1f2430; }
.plan-info.plan-info-secondary, .plan-info.plan-info-tertiary { color: #8a94a6; }
.plan-info.plan-info-task { color: #33405a; }
.plan-info.plan-info-days { color: #8a94a6; text-align: right; font-variant-numeric: tabular-nums; }
.plan-calendar thead th.plan-info-days { text-align: right; }
.plan-calendar td.plan-info-days { text-align: right; }
.plan-calendar tbody tr:hover td.plan-info { background: #f6faff; }

.plan-calendar tr.plan-group-row td { background: #eef4fb; height: 28px; }
.plan-calendar tr.plan-group-row td.plan-group-cell {
  font-weight: 600; color: #0f7bb5; padding: 0 8px;
}
.plan-calendar tr.plan-group-row td.plan-group-days { background: #eef4fb; }
.plan-chip {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px;
  background: #fff; border: 1px solid #cfe0f2; font-size: 10.5px;
  font-weight: 500; color: #0f7bb5;
}
.plan-chip.over { background: #fdeaef; border-color: #f3c2ce; color: #e11d48; }
.plan-chip.load-ok { background: #eefaf4; border-color: #bfe8d7; color: #0f7d5c; }
.plan-chip.load-over { background: #fdeaef; border-color: #f3c2ce; color: #e11d48; }
.plan-group-over { color: #e11d48; font-weight: 600; }
.plan-out-count { color: #b45309; font-weight: 600; }
/* N1: задача вне окна шкалы — пометка в строке и засечка у края группы. */
.plan-out-badge {
  display: inline-block; float: right; margin-left: 4px; padding: 0 6px;
  border-radius: 9px; background: #fff3e0; border: 1px solid #f0c78a;
  color: #b45309; font-size: 10px; font-weight: 600; cursor: pointer;
  vertical-align: middle;
}
.plan-out-badge::before { content: "◀ "; }
.plan-out-badge.future::before { content: "▶ "; }
.plan-out-badge:hover { background: #ffe6c2; }
.plan-group-bar-out { background: #b45309; }
.plan-group-bar-out .plan-group-cap { background: #b45309; }

.plan-calendar td.plan-days { padding: 0; position: relative; }
.plan-track {
  position: relative; height: var(--plan-row-h);
  background-image: repeating-linear-gradient(to right, transparent 0,
    transparent var(--dw1), #eef1f6 var(--dw1), #eef1f6 var(--dw));
}
.plan-track.plan-track-weeks {
  background-image: repeating-linear-gradient(to right, transparent 0,
    transparent var(--ww), rgba(25, 161, 229, .06) var(--ww),
    rgba(25, 161, 229, .06) var(--ww2), transparent var(--ww2),
    transparent var(--wfull));
}
.plan-today {
  position: absolute; top: 0; bottom: 0; width: 2px; background: #19A1E5;
  opacity: .85; z-index: 0;
}

/* B1: у полосы НЕТ padding/border — иначе при border-box ширина меньше
   padding + border «раздувается» браузером, и на малых масштабах полоса
   выходит за свой день. Отступ подписи — margin'ами внутри. */
.plan-bar {
  position: absolute; top: 6px; height: 18px; border-radius: 5px;
  color: #fff; font-size: 10.5px; line-height: 18px; padding: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .16); z-index: 1; cursor: pointer;
}
.plan-bar-label { margin: 0 4px; }
/* N5: штриховка полупрозрачная — цвет группы (background-color полосы)
   просвечивает сквозь неё (решение заказчика №1: окраска по группировке,
   состояние поверх). */
.plan-bar.pending {
  background-image: repeating-linear-gradient(45deg,
    rgba(255, 255, 255, .8) 0 4px, rgba(185, 196, 212, .8) 4px 8px);
  color: #24303f; border: 1px solid #9aa7ba; box-shadow: none;
}
.plan-bar.not-started { opacity: .55; }
.plan-bar.paused { opacity: .72; }
.plan-bar.done::after { content: "✓"; margin-left: 4px; font-weight: 700; }
.plan-bar.overdue { border: 1px solid #b91c1c; }
/* приоритет дополнительно влияет на насыщенность/контур полосы (TZ §3.3) */
.plan-bar.prio-high {
  box-shadow: 0 0 0 1.5px rgba(185, 28, 28, .85) inset,
              0 1px 2px rgba(0, 0, 0, .16);
}
.plan-bar.prio-low { filter: saturate(.6); }
.plan-bar-progress {
  position: absolute; left: 0; bottom: 0; height: 3px;
  background: rgba(255, 255, 255, .55); border-radius: 0 0 0 4px;
}
.plan-tail {
  position: absolute; top: 6px; height: 18px; border-radius: 0 5px 5px 0;
  background: repeating-linear-gradient(45deg, #e11d48 0 4px, #ff8098 4px 8px);
  z-index: 1;
}
/* --- T2: полоса-итог группы (окно работ на шкале) --- */
.plan-group-track { overflow: visible; background-image: none; }
.plan-calendar tr.plan-group-row td.plan-group-days {
  padding: 0; position: relative; background: #eef4fb;
}
.plan-group-bar {
  position: absolute; top: 12px; height: 6px; border-radius: 3px;
  background: #9db8dd; z-index: 1;
}
.plan-group-cap {
  position: absolute; top: -3px; width: 2px; height: 12px;
  background: #0f7bb5; border-radius: 1px;
}
.plan-group-cap.start { left: 0; }
.plan-group-cap.end { right: 0; }
.plan-group-arrow {
  display: inline-block; width: 12px; color: #0f7bb5; font-weight: 700;
  cursor: pointer;
}
.plan-group-label { color: #5b7bbd; }
.plan-calendar tr.plan-group-row { cursor: pointer; }
.plan-calendar tr.plan-group-row:hover td { background: #e6eefb; }
.plan-row-hidden { display: none; }
.plan-bar { cursor: grab; }
.plan-bar:active { cursor: grabbing; }
.plan-drag-tip {
  position: fixed; z-index: 1000; pointer-events: none;
  background: #08182B; color: #fff; font-size: 11.5px; padding: 4px 8px;
  border-radius: 6px; box-shadow: 0 4px 14px rgba(8, 24, 43, .3);
  white-space: nowrap;
}
.plan-undo { color: #0f7bb5; }
.plan-undo:disabled { opacity: .5; cursor: default; }
.plan-hint {
  margin: 8px 2px 0; color: #8a94a6; font-size: 11.5px;
}
.plan-legend .lg-group {
  background: none; border: none; padding: 0; margin: 0; font: inherit;
  font-size: 11px; color: #4b5563; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.plan-legend .lg-group:hover { color: #0f7bb5; }
.plan-legend .lg i.plan-tail-legend {
  background: repeating-linear-gradient(45deg, #e11d48 0 3px, #ff8098 3px 6px);
}
.plan-bar.hl { outline: 2px solid #08182B; outline-offset: 1px; }
.plan-calendar tr.plan-task-row { cursor: pointer; }
.plan-calendar tr.plan-task-row.hl td { background: #eaf6fd; }
.plan-calendar tr.plan-task-row.pstate-overdue td.plan-info,
.plan-calendar tr.plan-task-row.pstate-late td.plan-info { box-shadow: inset 3px 0 0 #e11d48; }
.plan-calendar-loading { padding: 10px; }

/* --- M3: переключатель группировки --- */
.plan-group-toggle {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.pgt-label { color: #8a94a2; font-size: 12px; }
.pgt-btn {
  padding: 5px 12px; border: 1px solid #d5dbe3; background: #fff;
  color: #55606e; border-radius: 8px; text-decoration: none;
  font-size: 13px; line-height: 1.2;
}
.pgt-btn:hover { background: #f7fafc; }
.pgt-btn.active { background: #19A1E5; color: #fff; border-color: #19A1E5; }

/* --- панель нагрузки --- */
.plan-load-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.plan-load-head .panel-title { margin-bottom: 0; }
.plan-load-caption { flex: 1 1 auto; min-width: 0; font-size: 12px; }
.plan-load-table .num { text-align: right; white-space: nowrap; }
.plan-load-table tr.overload td { background: #fff4f4; }
.plan-load-table tr.overload td.num { color: #b42318; font-weight: 700; }

/* --- E2: действия на диаграмме --- */
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.plan-head .muted { max-width: 70ch; }

/* кнопка «＋ задача» строки сотрудника */
.plan-add-task {
  display: block; width: -webkit-fit-content; width: fit-content;
  max-width: 100%; margin: 4px 0 2px auto; padding: 4px 10px;
  background: none; border: 1px dashed #c2cad6; border-radius: 6px;
  color: #19A1E5; font: inherit; font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
.plan-add-task:hover { background: #eaf6fd; border-color: #19A1E5; }

/* кликабельные числа панели нагрузки (E2.5) */
.load-link {
  background: none; border: none; padding: 2px 4px; font: inherit; cursor: pointer;
  color: inherit; border-radius: 4px; text-decoration: underline dotted;
}
.load-link:hover { background: #eaf6fd; color: #1266a8; }
.load-link.active { background: #19A1E5; color: #fff; text-decoration: none; }
.load-over { color: #b42318; font-weight: 700; font-size: 11px; margin-left: 6px; }

/* карточка задачи (E2.3) */
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.card-fields { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; margin: 0 0 10px; }
.card-fields dt { color: #8a94a2; font-size: 12px; }
.card-fields dd { margin: 0; font-size: 13px; }
.card-fields dd.danger { color: #b42318; font-weight: 600; }
.card-actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.card-approve-row { padding-bottom: 10px; border-bottom: 1px solid #eef1f5; }
.card-edit { border-top: 1px solid #eef1f5; padding-top: 6px; }
.card-prog-val { float: right; color: #08182B; font-weight: 700; }
#planCardProgress { width: 100%; margin-top: 4px; }
#planCardProgressNum { width: 80px; }
.card-edit .form-label input[type="range"] { width: 100%; }

/* --- мобильная версия плана (T1: календарь прокручивается вбок) --- */
@media (max-width: 900px) {
  .plan-calendar-wrap { max-height: 68vh; }
}
@media (max-width: 640px) {
  .plan-board { --plan-row-h: 28px; }
  .plan-board-tools { gap: 8px; }
  /* N3: строка-итог группы — короткие счётчики и чип нагрузки переносятся на
     вторую строку; ничего не обрезается. */
  .plan-calendar tr.plan-group-row td { height: auto; }
  .plan-calendar tr.plan-group-row td.plan-group-cell {
    white-space: normal; overflow: visible; line-height: 1.35; padding: 4px 8px;
  }
  .plan-group-cell .plan-chip { white-space: normal; margin-left: 4px; }
  .plan-group-load { display: block; margin-top: 2px; }
  .plan-group-load .plan-chip { margin-left: 0; }
  /* Поля фильтров: селекты не должны диктовать ширину по самому длинному
     пункту — иначе форма растягивает документ шире экрана на телефоне. */
  .plan-filters { max-width: 100%; flex-wrap: nowrap; }
  .plan-filters .filter-item { min-width: 0; max-width: 100%; }
  .plan-filters .filter-item select,
  .plan-filters .filter-item input:not([type="checkbox"]) {
    flex: 1 1 auto; min-width: 0; width: auto;
  }
  .plan-group-toggle { flex-wrap: wrap; }
  /* Таблица нагрузки на телефоне — теми же карточками с подписями полей
     (общие правила .table ≤640px); длинное имя/отдел переносится, числа не
     выезжают за карточку. */
  .plan-load-table { min-width: 0; }
  .plan-load-table td { min-width: 0; overflow-wrap: anywhere; }
  .plan-load-table td::before { flex: 0 0 45%; }
}

/* Мобильная шапка: правый блок (колокольчик, пользователь, «Выйти» / «Выйти
   везде») переносится и не растягивает страницу по горизонтали (E1.5). */
@media (max-width: 640px) {
  .topbar-inner { height: auto; min-height: 50px; flex-wrap: wrap; padding: 6px 10px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 100%; }
  .user-name {
    max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}

/* --- M2: выбор проекта с поиском --- */
.project-field { position: relative; }
.project-field .project-input { width: 100%; padding-right: 28px; }
.project-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: #8a94a2; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 4px;
}
.project-clear:hover { color: #b42318; }
.pp-suggestions {
  position: absolute; z-index: 40; left: 0; right: 0; top: 100%; margin-top: 2px;
  background: #fff; border: 1px solid #d7dee7; border-radius: 8px;
  box-shadow: 0 8px 22px rgba(8, 24, 43, .14); max-height: 280px; overflow-y: auto;
}
.pp-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #f2f4f7; }
.pp-item:last-child { border-bottom: none; }
.pp-item.active, .pp-item:hover { background: #eef6fd; }
.pp-name { font-size: 13px; color: #08182B; }
.pp-sub { font-size: 11px; color: #8a94a2; margin-top: 1px; }
.card-project-customer { margin: 2px 0 6px; font-size: 12px; }

/* Колонка «Проект» в таблице задач: обрезается по ширине, полное — в title */
.col-project { max-width: 190px; }
.project-cell { max-width: 190px; }
.project-label {
  display: inline-block; max-width: 190px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  color: #55606e;
}
@media (max-width: 640px) {
  .project-cell { max-width: none; }
  .project-label { max-width: none; white-space: normal; overflow: visible; }
}

/* --- Волна 1 (25.09): блок «Колонки таблиц» на /admin/settings --- */
.tc-block { margin: 0 0 18px; }
.tc-block:last-child { margin-bottom: 0; }
.tc-block-title { font-weight: 700; color: #08182B; margin: 0 0 6px; }
.tc-cols code { font-size: 11px; color: #8a94a2; }
.tc-cols input[type="number"] { width: 90px; min-width: 0; min-height: 28px; }
.tc-cols .field-error { padding: 2px 8px 8px; }


