/* Визуальная система админки. Тот же язык, что в портале Химдивана: Inter, шкала slate,
   синий акцент, карточки с мягкой тенью. Всё локально, без CDN и сборки — на складе
   канал может отвалиться, а страница обязана открыться. */

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-soft: 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Каркас ──────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #0f172a;
  color: #cbd5e1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
  color: #fff; font-weight: 600; font-size: 15px; letter-spacing: -.01em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: #64748b; }

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 9px;
  color: #cbd5e1; font-size: 14px; text-decoration: none;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 500; }
.nav-count {
  font-size: 12px; font-variant-numeric: tabular-nums;
  background: rgba(148, 163, 184, .22); color: #e2e8f0;
  padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .nav-count { background: rgba(255, 255, 255, .22); color: #fff; }
.nav-gap { flex: 1; }
.nav-foot { font-size: 11px; color: #475569; padding: 8px 10px; line-height: 1.45; }

.main { flex: 1; min-width: 0; padding: 26px 30px 44px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.head h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.head .sub { color: var(--muted); font-size: 13px; }

/* ── Карточки и плитки ───────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--faint); }
.card-body { padding: 18px; }

.grid { display: grid; gap: 14px; margin-top: 18px; }
/* Внутри сетки вертикальный отступ задаёт сам grid: иначе правило .card + .card
   роняет вторую карточку на 18px ниже первой и колонки перестают быть колонками. */
.grid > .card { margin-top: 0; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px 17px;
}
.tile .label { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.tile .value {
  font-size: 27px; font-weight: 600; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.tile .foot { font-size: 12px; color: var(--faint); margin-top: 5px; }
.tile.accent .value { color: var(--brand); }
.tile.warn   .value { color: var(--warn); }
.tile.err    .value { color: var(--err); }

/* ── Состояние звеньев ───────────────────────────────────────────────────── */
.link-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line-soft);
}
.link-row:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.dot.ok   { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.err  { background: var(--err);  box-shadow: 0 0 0 3px var(--err-soft); }
.dot.idle { background: #cbd5e1;     box-shadow: 0 0 0 3px #f1f5f9; }
.link-name { font-weight: 500; font-size: 14px; }
.link-note { color: var(--muted); font-size: 13px; margin-left: auto; text-align: right; }

/* ── Таблицы ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fcfdfe;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.empty { padding: 40px 18px; text-align: center; color: var(--faint); font-size: 14px; }
.empty .big { font-size: 15px; color: var(--muted); margin-bottom: 4px; }

/* ── Значки состояний ────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: #f1f5f9; color: #475569;
}
.badge.ok   { background: var(--ok-soft);   color: #15803d; }
.badge.warn { background: var(--warn-soft); color: #b45309; }
.badge.err  { background: var(--err-soft);  color: #b91c1c; }
.badge.info { background: var(--brand-soft); color: var(--brand-dark); }

/* Сообщение о результате ручного действия и подсказка о режиме работы. */
.flash {
  margin-bottom: 18px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--brand-soft); border: 1px solid #bfdbfe;
  color: var(--brand-dark); font-size: 13.5px;
}
.note {
  margin-bottom: 18px; padding: 13px 17px; border-radius: var(--radius);
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 13.5px;
}
.note a { color: #92400e; }
.head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

/* ── Кнопки и поля ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 15px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .13s, border-color .13s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { min-height: 31px; padding: 0 11px; font-size: 13px; }
/* Кнопки, после которых данные не вернуть: цвет предупреждает раньше, чем текст. */
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Полоса кнопок под карточкой обслуживания: кнопка + пояснение рядом с ней. */
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn-row .hint { font-size: 12px; color: var(--faint); }

.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid #cbd5e1; border-radius: 9px;
  font: inherit; font-size: 14px; color: var(--text); background: #fff; outline: none;
}
.input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px var(--brand-soft); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: #334155; margin-bottom: 6px; }

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 220px; }

/* ── Вход ────────────────────────────────────────────────────────────────── */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 372px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-soft); padding: 30px;
}
.login-card h1 { margin: 0 0 5px; font-size: 19px; font-weight: 600; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.error-msg {
  background: var(--err-soft); color: #b91c1c; border: 1px solid #fecaca;
  padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .nav-gap, .nav-foot { display: none; }
  .main { padding: 18px 16px 32px; }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Фильтр журнала смены по сотрудникам (просьба заказчика 25.08.2026) */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
        border: 1px solid var(--line); border-radius: 999px; text-decoration: none;
        color: var(--fg); font-size: 14px; background: #fff; }
.chip.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip-n { font-size: 12px; opacity: .75; }
/* Журнал обмена: счётчики бед за сутки работают и как фильтр (22.09.2026).
   Ненулевая беда подсвечена — иначе её не видно среди тысяч успешных вызовов. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.bad { border-color: #fca5a5; background: var(--err-soft); color: #b91c1c; }
.chip.bad.on { border-color: var(--err); background: var(--err); color: #fff; }
/* Заголовок-ссылка сортировки: выглядит как заголовок, пока на него не навели. */
.sortlink { color: inherit; text-decoration: none; white-space: nowrap; }
.sortlink:hover { color: var(--brand); text-decoration: underline; }
.sortlink.on { color: var(--brand); }

/* Поля ввода в таблицах настроек: строка должна оставаться строкой таблицы,
   поэтому поля узкие и без собственных отступов. */
.fld {
  font: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; background: #fff; max-width: 100%;
}
.fld:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.fld-num { width: 52px; text-align: center; }
td .fld:not(.fld-num):not(.fld-ip) { width: 140px; }
.fld-ip  { width: 118px; }
select.fld { max-width: 210px; }
select.fld { padding: 5px 6px; }
.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.row-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
tr.off td { opacity: .55; }

.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

/* Состав участка (22.09.2026). ФИО на складе длинные — «Нигматулина Наталья
   Мхамадгалеевна» в общем поле на 140 px обрезается, и старший правит фамилию вслепую.
   Поэтому ФИО и должность тянутся по колонке, а служебные колонки ужаты: роль и стол
   выбираются из списка, лишняя ширина им ни к чему, зато три кнопки действий перестают
   уезжать за правый край таблицы. */
.staff td .fld:not(.fld-num) { width: 100%; }
.staff select.fld { max-width: 100%; }
.staff .col-fio   { min-width: 240px; }
.staff .col-job   { width: 170px; }
.staff .col-role  { width: 140px; }
.staff .col-place { width: 120px; }
.staff .col-on    { width: 74px; text-align: center; }
.staff .col-shift { width: 86px; }
.staff td.hint    { font-size: 12px; line-height: 1.3; }

/* Свёрнутый список «не в работе»: снятое с работы остаётся на странице (чтобы не
   искать, куда делся принтер), но не мешает увидеть аварию среди рабочих. */
.fold { border-top: 1px solid var(--line-soft); }
.fold > summary {
  padding: 11px 18px; cursor: pointer; font-size: 13px; color: var(--muted);
  list-style: none; user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸ "; color: var(--faint); }
.fold[open] > summary::before { content: "▾ "; }
.fold > summary:hover { color: var(--text); }
.fold .link-row { opacity: .7; }

/* ── Страница «Задания»: отборы, дни, сортировка ──────────────────────────── */
/* Счётчики на обзоре — ссылки сюда, поэтому таблица должна уметь то, ради чего
   в неё пришли: отобрать день и переставить порядок (просьба Ивана 17.09.2026). */
.chip-label { font-size: 13px; color: var(--muted); align-self: center; margin-right: 2px; }
th a.sort { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--line); }
th a.sort:hover { color: var(--brand); border-bottom-color: var(--brand); }
th a.sort.on { color: var(--brand); border-bottom-color: transparent; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-note { padding: 10px 18px; font-size: 12px; color: var(--faint);
              border-top: 1px solid var(--line-soft); }

/* Цифра на плитке обзора, ведущая в разбор. Подчёркивание пунктиром: это ссылка,
   но плитка не должна выглядеть как панель кнопок. */
.tile .value a, .tile .foot a { color: inherit; text-decoration: none;
                                border-bottom: 1px dashed currentColor; }
.tile .value a:hover, .tile .foot a:hover { color: var(--brand); }

/* ── Журнал смены: выбор сотрудника и выработка по часам (23.09.2026) ────── */
.perf-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px; }
.pf { display: flex; flex-direction: column; gap: 6px; }
.pf > span { font-size: 12px; color: var(--muted); }
.pf select, .pf input[type=date] {
  height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: inherit; color: var(--text);
}
.pf select { min-width: 340px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: 38px; }
.seg label { display: flex; align-items: center; padding: 0 14px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg label + label { border-left: 1px solid var(--line); }
.seg label.on { background: var(--brand-soft); color: var(--brand-dark); font-weight: 500; }
.seg input { display: none; }
.perf-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.perf-title { font-weight: 600; font-size: 15px; }
.perf-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.perf-plot { position: relative; }
.perf-plot svg { width: 100%; height: auto; display: block; }
.perf-plot .gl { stroke: var(--line-soft); stroke-width: 1; }
.perf-plot .ax { stroke: var(--line); stroke-width: 1; }
.perf-plot .yt { font-size: 11px; fill: var(--faint); text-anchor: end; font-variant-numeric: tabular-nums; }
.perf-plot .xt { font-size: 11px; fill: var(--faint); text-anchor: middle; font-variant-numeric: tabular-nums; }
.perf-plot .pl { font-size: 12px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.perf-plot .bar { fill: var(--brand); }
.perf-plot .hit { fill: transparent; cursor: default; }
.perf-plot .hit.on { fill: rgba(37, 99, 235, .06); }
.perf-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-soft);
  padding: 8px 11px; font-size: 12px; color: var(--text);
}
.perf-tip > b { display: block; margin-bottom: 4px; }
.perf-tip div { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.perf-tip div b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .pf select { min-width: 0; width: 100%; } .pf { flex: 1 1 100%; } }
.grid + .card.perf { margin-top: 18px; }
.card.perf-filters, .card.perf { padding: 16px 18px; }
.card.perf-export { padding: 12px 18px; }
.perf-export .hint { margin: 0 0 8px; font-size: 12px; color: var(--faint); align-self: flex-end; }
