/* Управленка — мокапы. Дизайн-система «печатный цех»:
   бумага/краска + процессные CMYK-статусы + гроссбух-типографика. */

:root {
  --paper: #FAFAF7;
  --card: #FFFFFF;
  --ink: #191B1E;
  --ink-2: #555A61;
  --ink-3: #8A9097;
  --rule: #DDDFD9;
  --zebra: #F4F5F1;
  --thead: #EFF0EB;

  --cyan: #0087A8;        /* действия, ссылки, инфо */
  --cyan-bg: #E3F3F7;
  --magenta: #C31572;     /* ошибки данных */
  --magenta-bg: #FBE7F1;
  --warn: #6E5A00;        /* предупреждения */
  --warn-bg: #FBF3D0;
  --ok: #1E6B43;
  --ok-bg: #E3F1E9;

  --money-neg: #B42318;   /* «красная паста» */
  --money-pos: #1E6B43;

  --display: "Literata", Georgia, serif;
  --ui: "Golos Text", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--ui); font-size: 14px; line-height: 1.45;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ── Шапка ─────────────────────────────────────────── */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--rule);
  padding: 0 24px;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; display: flex; align-items: center;
  gap: 28px; min-height: 54px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-name {
  font-family: var(--display); font-weight: 700; font-size: 17px;
  letter-spacing: .01em;
}
/* Сигнатура: контрольная CMYK-шкала печатного листа */
.cmyk { display: inline-flex; gap: 2px; }
.cmyk i { width: 8px; height: 8px; display: inline-block; }
.cmyk .c { background: #009FDA; } .cmyk .m { background: #D6006E; }
.cmyk .y { background: #FFD500; } .cmyk .k { background: #1A1A1A; }
.cmyk .c2 { background: #7FCFEC; } .cmyk .m2 { background: #EA7FB6; }
.cmyk .y2 { background: #FFEA7F; } .cmyk .k2 { background: #8C8C8C; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--ink-2); padding: 16px 10px 13px; border-bottom: 3px solid transparent;
  font-weight: 500;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--ink); border-bottom-color: var(--ink); }
.nav a.soon, .tile.soon { cursor: default; opacity: .55; }
.nav a.soon:hover, .tile.soon:hover { text-decoration: none; }
.userchip { margin-left: auto; color: var(--ink-3); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.userchip b { color: var(--ink-2); font-weight: 600; }
.logoutform { display: inline; }
.linkbtn {
  font: 500 12.5px var(--ui); color: var(--cyan); background: none; border: none;
  padding: 0; cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }

/* ── Контент ───────────────────────────────────────── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 24px 64px; }
.pagehead { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin-bottom: 6px; }
h1 { font-family: var(--display); font-weight: 600; font-size: 27px; margin: 0; }
.pagehead .period { font-family: var(--mono); font-size: 15px; color: var(--ink-2); }
.subline { color: var(--ink-3); font-size: 13px; margin: 2px 0 18px; }

/* ── Карточки, панели ──────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  padding: 14px 16px;
}
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 18px; }
.tile .lab { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.tile .val { font-family: var(--mono); font-size: 24px; font-weight: 600; margin-top: 4px; }
.tile .note { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* ── Статус-панель отчёта ──────────────────────────── */
.statusbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 18px;
}
.statusbar .meta { color: var(--ink-2); font-size: 13px; }
.statusbar .sep { color: var(--rule); }

/* ── Кнопки, поля ──────────────────────────────────── */
.btn {
  font: 500 13.5px var(--ui); border: 1px solid var(--ink); background: var(--ink);
  color: #fff; border-radius: 4px; padding: 7px 14px; cursor: pointer;
}
.btn:hover { background: #33363B; }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--ink-2); }
.btn.secondary:hover { background: var(--zebra); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
select, input[type="text"], input[type="month"], input[type="search"], input[type="password"] {
  font: 400 13.5px var(--ui); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 4px; background: var(--card);
  padding: 6px 9px;
}
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters label { font-size: 12.5px; color: var(--ink-2); margin-right: 4px; }
.bulkbar { margin-bottom: 14px; }
.bulk-close-btn[disabled] { opacity: .45; cursor: not-allowed; }
.bulk-checkbox { width: 24px; height: 24px; cursor: pointer; }
.sugbox{position:absolute;top:100%;left:0;z-index:5;background:#fff;border:1px solid #c9c9c9;box-shadow:0 3px 8px rgba(0,0,0,.12);min-width:230px;max-height:270px;overflow-y:auto}
.sugbox:empty{display:none}
.client-sugitem{display:block;padding:7px 10px;font-size:14px;cursor:pointer}
.client-sugitem:hover{background:#eef3fd}

/* ── Бейджи ────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 12px; font-weight: 500; border-radius: 3px;
  padding: 2px 7px; white-space: nowrap;
}
.badge.err  { background: var(--magenta-bg); color: var(--magenta); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--cyan-bg); color: var(--cyan); }
.badge.ok   { background: var(--ok-bg); color: var(--ok); }
.badge.mute { background: var(--zebra); color: var(--ink-2); }

/* ── Таблицы ───────────────────────────────────────── */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--rule); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
  font: 600 12px var(--ui); text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-2); background: var(--thead); text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap;
  position: sticky; top: 0;
}
td { padding: 7px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #F7F8F4; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
/* task_398/402: узкая колонка «№» на /orders/ — длинные номера
   переносятся (402: ширина +30%, 70 -> 91px) */
td.ordnum { white-space: normal; overflow-wrap: anywhere; width: 91px; min-width: 91px; max-width: 91px; }
/* task_427: фиксация ширины заголовка «№» — без width/min-width колонка
   сжималась при перерисовке панели (расширение соседних th с сортировкой) */
th.ordnum-head { width: 91px; min-width: 91px; max-width: 91px; }
/* task_398: узкие переносимые заголовки на /orders/ */
th.narrowhead { white-space: normal; }
th.narrowhead.th-reg { width: 62px; }
th.narrowhead.th-ship { width: 62px; }
/* task_402: заголовок «Приори-тет» выровнен влево (значения строк — как
   есть, td.num не трогать); специфичность класса выше th.num (0,2,1) >
   (0,1,1) — переопределяет text-align:right без !important. */
th.narrowhead.th-priority { width: 56px; text-align: left; }
.sortlink { color: inherit; text-decoration: none; cursor: pointer; }
.sortlink:hover { text-decoration: underline; }
td.neg { color: var(--money-neg); }
td.pos { color: var(--money-pos); }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

/* ── Зеркальный горизонтальный скролл (заказы, /workload/) ─── */
.scroll-mirror {
  overflow-x: auto; overflow-y: hidden; height: 16px; margin-bottom: 4px;
  scrollbar-width: auto; scrollbar-color: var(--cyan) var(--zebra);
}
.scroll-mirror > div { height: 1px; }
.scroll-mirror::-webkit-scrollbar { height: 14px; }
.scroll-mirror::-webkit-scrollbar-track { background: var(--zebra); border-radius: 7px; }
.scroll-mirror::-webkit-scrollbar-thumb { background: var(--cyan); border-radius: 7px; border: 3px solid var(--zebra); }

/* ── P&L: гроссбух ─────────────────────────────────── */
table.pl td { padding: 6px 12px; border-bottom: none; }
table.pl tr.blockhead td {
  font-family: var(--display); font-weight: 600; font-size: 15px;
  padding-top: 20px; border-bottom: 1px solid var(--ink);
}
table.pl tr.line td:first-child { padding-left: 26px; }
table.pl tr.line2 td:first-child { padding-left: 44px; color: var(--ink-2); }
table.pl tr.pct td { padding-top: 0; padding-bottom: 4px; }
table.pl tr.pct td:first-child { padding-left: 26px; }
table.pl tr.pct { color: var(--ink-3); font-size: 12px; }
table.pl tr.total td { border-top: 1px solid var(--ink); font-weight: 600; }
/* двойная линия под финальным итогом — как в бухгалтерской книге */
table.pl tr.grand td {
  border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink);
  font-weight: 700; font-size: 15px;
}
table.pl tr.grand td.num { font-size: 17px; }
table.pl td .drill { color: var(--cyan); cursor: pointer; font-size: 12px; }
tr.drilldown td { background: var(--cyan-bg); border-bottom: 1px solid var(--rule); padding: 10px 12px 10px 44px; }
tr.drilldown table { font-size: 12.5px; background: transparent; }
tr.drilldown td, tr.drilldown th { border-bottom: 1px solid #C9E4EC; }

/* ── Мини-диаграмма (CSS-бары) ─────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 8px 4px 0; }
.bars .b { flex: 1; background: var(--ink-2); min-width: 14px; border-radius: 2px 2px 0 0; position: relative; }
.bars .b.cur { background: var(--cyan); }
.bars .b span {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); white-space: nowrap;
}
.bars-note { margin-top: 26px; font-size: 12px; color: var(--ink-3); }

/* ── Источники импорта ─────────────────────────────── */
.sources { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.source .name { font-weight: 600; }
.source .last { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 10px; }
.source .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dropzone {
  border: 1.5px dashed var(--ink-3); border-radius: 6px; padding: 22px;
  text-align: center; color: var(--ink-2); background: var(--card);
}

section.block { margin-top: 26px; }
h2 { font-family: var(--display); font-weight: 600; font-size: 19px; margin: 0 0 10px; }

/* ── Календарь смен (/shifts/, task_411) ───────────── */
.weeknav { margin: 8px 0 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.calwrap { overflow-x: auto; background: var(--card); border: 1px solid var(--rule); border-radius: 6px; }
table.cal { border-collapse: collapse; width: 100%; min-width: 1060px; }
table.cal th, table.cal td { border: 1px solid var(--rule); padding: 6px 8px; font-size: 13px; text-align: center; }
table.cal th.sec { text-align: left; min-width: 190px; background: var(--thead); font-weight: 600; }
table.cal th.sec .ext { justify-content: flex-start; margin-top: 4px; }
table.cal thead th { background: var(--thead); vertical-align: top; }
table.cal thead .ext { margin-top: 5px; padding-top: 4px; border-top: 1px dashed var(--rule); }
table.cal td.sun { background: var(--zebra); }
table.cal td.dayoff .hours, table.cal td.sun .hours { color: var(--ink-3); }
table.cal .hours { font-weight: 700; font-size: 15px; }
table.cal .hours.extended { color: var(--ok); }
table.cal .ext { display: flex; gap: 7px; justify-content: center; margin-top: 3px; }
table.cal .ext label { font-size: 11px; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
table.cal .sum { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
table.cal td.today { outline: 2px solid var(--ok); outline-offset: -2px; }
table.cal .cellhint { font-size: 10.5px; color: var(--magenta); margin-top: 2px; }
.exthint { font-size: 10px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }

/* ── Модал подтверждения (leavemodal, task_454 — перенесено из
   order_form.html, п.20 ui_контракт.md: стили виджета в общем css) ── */
.leavemodal-overlay { display: none; position: fixed; inset: 0; background: rgba(30, 30, 25, .4); z-index: 50; align-items: center; justify-content: center; }
.leavemodal-overlay.open { display: flex; }
.leavemodal { background: #fff; border-radius: 10px; padding: 20px 22px; max-width: 360px; box-shadow: 0 8px 28px rgba(0, 0, 0, .22); }
.leavemodal p { margin: 0; font-size: 14px; }
.leavemodal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 720px) {
  .topbar-inner { gap: 10px; }
  .wrap { padding: 16px 12px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
