* { box-sizing: border-box; }
:root {
  --bg: #f4f7fb; --surface: #fff; --text: #182230; --muted: #667085; --border: #e4e7ec;
  --primary: #2457d6; --primary-soft: #eaf0ff; --success: #12805c; --warning: #b54708; --danger: #c1153b;
  --shadow: 0 8px 30px rgba(16,24,40,.07);
}
body { margin: 0; font-family: Inter, Segoe UI, Arial, sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
.mobile-header,.sidebar-backdrop { display: none; }
.sidebar { width: 260px; background: #12213f; color: white; padding: 24px 18px; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 20; transition: transform .2s ease; }
/* 44px, not 36: between 721 and 1024 these two are the only way to hide or bring
   back the menu - the hamburger belongs to the mobile header, which does not
   exist at that width - and a 768px tablet is a touch screen. */
.sidebar-collapse-toggle,.sidebar-rail-toggle { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 8px; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: white; font-size: 22px; line-height: 1; }
/* В потоке, а не поверх шапки: см. комментарий в base.html. margin-left:auto
   прижимает кнопку к правому краю, flex-shrink:0 не даёт ей сплющиться, когда
   названию не хватает места. */
.sidebar-collapse-toggle { margin-left: auto; flex-shrink: 0; }
.sidebar-rail-toggle { display: none; position: fixed; left: 14px; top: 18px; z-index: 25; background: #12213f; box-shadow: 0 8px 24px rgba(16,24,40,.2); }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .sidebar-rail-toggle { display: inline-flex; }
body.sidebar-collapsed .main { margin-left: 0; width: 100%; padding-left: 66px; }
/* gap 10, а не 12: в строку помещаются логотип, название и кнопка, и на
   ширине 260 названию хватает одной строки. */
.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 28px; }
.logo { width: 44px; height: 44px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; background: #3f73ff; font-weight: 800; font-size: 22px; }
/* min-width:0 - иначе элемент flex не даёт себя сузить меньше содержимого, и
   название выталкивает кнопку за край панели. */
.brand-text { min-width: 0; }
/* Без размера h1 брал браузерное значение 2em - 32px в панели шириной 260. */
.brand h1 { font-size: 16px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.brand h1,.brand p { margin: 0; } .brand p { color: #b8c3d9; font-size: 12px; }
nav { display: grid; gap: 7px; }
.nav-item { border: 0; background: transparent; color: #cbd5e7; text-align: left; padding: 11px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.1); color: white; }
.user-card { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; display: grid; gap: 6px; }
.user-card span { color: #b8c3d9; font-size: 12px; }
.link-button { background: transparent; border: 0; color: #cbd5e7; padding: 0; text-align: left; cursor: pointer; min-height: 44px; justify-content: flex-start; }
.main { margin-left: 260px; width: calc(100% - 260px); padding: 30px; }
.login-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; }
.topbar h2,.topbar p { margin: 0; } .topbar p,.muted { color: var(--muted); margin-top: 6px; }
.primary, button, .secondary { border: 1px solid var(--border); background: white; color: var(--text); padding: 10px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.primary { border-color: var(--primary); background: var(--primary); color: white; }
.secondary { margin-top: 12px; }
.cards-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.cards-grid.compact .stat-card strong { font-size: 24px; }
.stat-card,.panel,.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.stat-card { padding: 18px; display: grid; gap: 8px; border-left: 4px solid var(--primary); }
.stat-card.warning { border-left-color: var(--warning); } .stat-card.danger { border-left-color: var(--danger); }
.stat-card span,.stat-card small { color: var(--muted); } .stat-card strong { font-size: 32px; }
.content-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { padding: 20px; margin-bottom: 18px; } .narrow { max-width: 760px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.panel-header h3 { margin: 0; }
.badge,.status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 2px; }
.badge { background: var(--primary-soft); color: var(--primary); }
.status.waiting { background: #fff4e5; color: #9a4b00; } .status.active { background: #eaf0ff; color: #2457d6; }
.status.done { background: #e9f8f1; color: #12715b; } .status.critical { background: #ffedf1; color: #b42345; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th,td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
/* A register is opened to compare rows, so we scroll rather than fold cells into
   cards - but once you have scrolled right, the row needs to keep saying whose
   it is. */
.table-wrap.sticky-first th:first-child,.table-wrap.sticky-first td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}
.table-wrap.sticky-first tr.row-danger td:first-child { background: #fff1f3; }
.table-wrap.sticky-first tr.row-ok td:first-child { background: #effaf4; }
/* Free-text and JSON columns: one audit row carries the whole POST body, which
   on its own stretched the table to several screens. */
td .cell-long,td code { display: block; max-width: 46ch; max-height: 4.5em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.defects-list { display: grid; gap: 12px; } .defect { border: 1px solid var(--border); border-radius: 8px; padding: 13px; background: white; }
.defect strong,.defect span { display: block; } .defect span { color: var(--muted); margin-top: 5px; font-size: 13px; }
.unread { border-left: 4px solid var(--primary); }
input,select,textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font: inherit; background: white; }
input,select,textarea,button,a { -webkit-tap-highlight-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
.filters,.form-grid { display: grid; gap: 14px; } .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.login-card { width: min(460px, 100%); padding: 28px; } .login-brand { color: var(--text); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; } .tabs a { padding: 8px 10px; background: var(--primary-soft); color: var(--primary); border-radius: 8px; font-weight: 600; }
.message { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--primary-soft); color: var(--primary); }
.message.error { background: #ffedf1; color: var(--danger); } .message.success { background: #e9f8f1; color: var(--success); }
.row-danger { background: #fff1f3; } .row-ok { background: #effaf4; } .danger-text { color: var(--danger); }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.dialog-actions,.inline-form { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.attachment-box { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 16px; }
.attachment-box h3 { margin: 0 0 12px; }
.report-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.report-card { background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; min-height: 230px; }
.report-card h3 { margin: 0 0 8px; font-size: 18px; }
.report-card p { margin: 0; color: var(--muted); line-height: 1.4; }
.report-icon { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; color: white; background: var(--primary); font-weight: 800; }
.report-card-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.report-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.report-filters label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.filter-actions,.export-actions,.pagination { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.export-actions { margin-bottom: 14px; }
.secondary.excel { border-color: #12805c; color: #12805c; }
.secondary.pdf { border-color: #c1153b; color: #c1153b; }
.pagination { justify-content: flex-end; margin-top: 16px; }
.pagination a { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: white; }
canvas { max-height: 280px; }
.kanban-mode .main { padding: 22px 18px 18px; overflow-x: hidden; }
.kanban-mode .topbar { margin-bottom: 12px; }
.kanban-mode .topbar h2 { font-size: 32px; line-height: 1.15; }
.kanban-page { display: grid; gap: 14px; }
/* The board lives inside [data-kanban-board-shell], which the refresh script
   replaces wholesale and which carried no styles at all. As a grid item it took
   min-width: auto - a minimum the size of its contents - so the shell stretched
   to the board's full 2258px, the board was never narrower than what it held,
   its overflow-x: auto therefore produced no scrollbar, and .main's
   overflow-x: hidden cut the last columns off with no way to reach them.
   Measured at a 1280px window: shell 2258px inside a 1020px main, seventh
   column unreachable; with this rule, shell 984px and the board scrolls. */
[data-kanban-board-shell],.kanban-board,.kanban-toolbar { min-width: 0; }
.kanban-toolbar { background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 12px; }
/* auto-fit rather than seven named tracks: the named version demanded 1140px
   of content and so tore open at 1366x768 - the most ordinary laptop there is -
   taking the right edge of the board with it. */
.kanban-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: center; }
.kanban-filters input[name="q"] { grid-column: span 2; }
.kanban-board { display: grid; grid-template-columns: repeat(7, minmax(310px, 330px)); gap: 14px; overflow-x: auto; padding: 2px 2px 14px; min-height: calc(100vh - 184px); align-items: stretch; }
.kanban-column { background: #edf2f8; border: 1px solid #d8e0ec; border-radius: 8px; padding: 12px; height: calc(100vh - 198px); min-height: 560px; display: flex; flex-direction: column; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -2px -2px 10px; padding: 8px 4px 10px; background: #edf2f8; border-bottom: 1px solid #d8e0ec; }
.kanban-head strong { font-size: 20px; line-height: 1.1; }
.kanban-column-search { margin-bottom: 12px; }
.kanban-cards { display: grid; gap: 12px; align-content: start; flex: 1; overflow-y: auto; padding-right: 3px; }
.kanban-card { background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 14px; display: grid; gap: 10px; cursor: grab; }
.kanban-card h3,.kanban-card p { margin: 0; }
.kanban-card h3 { font-size: 19px; line-height: 1.22; }
.kanban-card-title,.kanban-card-flags,.kanban-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kanban-card-title strong { font-size: 17px; }
.kanban-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.kanban-card-grid p { font-size: 13px; color: var(--text); display: grid; gap: 3px; min-width: 0; word-break: break-word; }
.kanban-card-grid span { color: var(--muted); font-size: 12px; font-weight: 700; }
.kanban-card-actions { gap: 8px; }
.kanban-card-actions form { flex: 1 1 40%; }
.kanban-card-actions .primary,.kanban-card-actions .secondary { width: 100%; min-height: 44px; margin-top: 0; }
.kanban-card-actions > .secondary { flex: 1 1 100%; }
.kanban-card-back { color: var(--muted); }
/* The board scrolls sideways on every screen narrower than seven columns, so it
   should come to rest on a column rather than halfway across two. */
.kanban-board { scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
.kanban-column { scroll-snap-align: start; }
.kanban-empty { padding: 20px 8px; text-align: center; }
audio { width: 240px; max-width: 100%; }
/* One ladder: <=720 phone, 721-1024 tablet, >=1025 desktop. The grids below
   size themselves and need no breakpoint at all - the old 1200/1300 rules were
   there to patch tracks that could not shrink. */
.cards-grid,.report-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.filters,.report-filters { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.meta-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* 721-1024 used to be nobody's land: the mobile header had not appeared yet and
   the fixed 260px sidebar already took a third of a 768px tablet. */
@media (max-width: 1024px) {
  .sidebar { width: 216px; padding: 20px 12px; }
  .main { margin-left: 216px; width: calc(100% - 216px); padding: 22px 18px; }
  .content-grid { grid-template-columns: 1fr; }
  .stat-card strong { font-size: 26px; }
  .kanban-mode .topbar h2 { font-size: 26px; }
}
@media (max-width: 720px) {
  body.menu-open { overflow: hidden; }
  body.sidebar-collapsed .sidebar { transform: translateX(-105%); }
  body.sidebar-collapsed .sidebar-rail-toggle { display: none; }
  .mobile-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #12213f;
    color: white;
    box-shadow: 0 8px 24px rgba(16,24,40,.18);
  }
  .menu-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    border-color: rgba(255,255,255,.18);
    background: rgba(255,255,255,.08);
    color: white;
    font-size: 22px;
  }
  .mobile-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
  .mobile-brand .logo { width: 38px; height: 38px; font-size: 20px; }
  .mobile-brand strong,.mobile-brand span { display: block; line-height: 1.15; }
  .mobile-brand span { color: #b8c3d9; font-size: 12px; }
  .mobile-notifications {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    padding: 0 4px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: white;
    font-weight: 800;
  }
  .sidebar {
    width: min(310px, 86vw);
    padding: 22px 18px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 40;
    box-shadow: 18px 0 50px rgba(16,24,40,.28);
  }
  .sidebar-collapse-toggle { display: none; }
  body.menu-open .sidebar { transform: translateX(0); }
  .sidebar .brand div:last-child,.sidebar .nav-item,.sidebar .user-card { font-size: initial; }
  .sidebar .nav-item { min-height: 44px; display: flex; align-items: center; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.48);
    z-index: 35;
  }
  body.menu-open .sidebar-backdrop { display: block; }
  .main,body.sidebar-collapsed .main { margin-left: 0; width: 100%; padding: 18px 14px 28px; }
  .cards-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 16px; }
  .topbar h2 { font-size: 26px; line-height: 1.15; }
  .topbar p { font-size: 15px; }
  .panel { padding: 14px; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  /* Full width for real form buttons only. The blanket rule used to stretch the
     voice widget's × across its whole panel and blow up the little action
     buttons that live inside table cells. */
  .primary, button, .secondary { min-height: 44px; }
  .filters button,.form-grid button,.dialog-actions button,.export-actions button,
  .filter-actions button,.kanban-filters button,form > .primary,form > .secondary { width: 100%; }
  .dialog-actions,.inline-form,.filter-actions,.export-actions,.pagination { justify-content: stretch; }
  th,td { padding: 11px 9px; font-size: 13px; white-space: nowrap; }
  .inspection-table input,.inspection-table select { min-width: 150px; }
  .table-wrap { margin-inline: -14px; padding-inline: 14px; }
  .login-main { padding: 16px; align-items: start; padding-top: 42px; }
  .login-card { padding: 22px; }
  .report-grid { grid-template-columns: 1fr; }
  .kanban-mode .main { padding: 14px; }
  .kanban-filters { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(7, minmax(285px, 300px)); min-height: calc(100vh - 210px); }
  .kanban-column { height: calc(100vh - 224px); min-height: 520px; }
  .kanban-card-grid { grid-template-columns: 1fr; }
}

/* ---- link out to the analytics console --------------------------------- */
.pm-console {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.pm-console__text h3 { margin: 0 0 4px; }
.pm-console__text p { margin: 0; font-size: 13px; max-width: 60ch; }
.pm-console__link {
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* ---- Заказ на производство -------------------------------------------------
   Бумажный бланк, узнаваемый с первого взгляда: плотные строки, тонкие линии,
   числа моноширинным шрифтом - иначе колонка цифр не читается вертикально.
   Цветом отмечено только то, чего на бумаге нет: недовыпуск и закрытые
   позиции. При печати цвет уходит, лист становится прежним. */
.sheet-page { display: grid; gap: 14px; }
.sheet-dates { display: flex; align-items: center; gap: 10px; }
.sheet-dates .secondary { margin-top: 0; min-width: 44px; }
.sheet-dates__pick input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.sheet-dates__hint { color: var(--muted); font-size: 13px; margin-left: auto; }
.sheet-dates__hint .is-short { color: var(--danger); }

.sheet-head { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; box-shadow: var(--shadow); }
.sheet-head h3 { margin: 0; font-size: 17px; letter-spacing: .01em; }
.sheet-head__meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

/* Наименований под сотню, поэтому таблица прокручивается внутри себя, а шапка
   остаётся на месте: иначе к середине списка забываешь, какой столбец где. */
.sheet-scroll { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); overflow: auto; max-height: 70vh; }
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; }
.sheet th, .sheet td { border: 1px solid var(--border); padding: 7px 10px; }
.sheet thead th { position: sticky; top: 0; z-index: 1; background: #f8fafc; font-weight: 600; text-align: center; white-space: nowrap; }
.sheet thead tr:nth-child(2) th { top: 33px; }
.sheet__shift small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.sheet__name { text-align: left; min-width: 260px; }
.sheet .num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; }
.sheet tbody tr:nth-child(even) { background: #fcfdff; }
.sheet tbody tr:hover { background: var(--primary-soft); }
.sheet__total { font-weight: 600; }
.sheet__plan { background: #fbfcfe; }
.sheet__rest { font-weight: 600; }
.sheet__empty { text-align: center; padding: 28px; }

.sheet tbody tr.is-short .sheet__rest { color: var(--danger); }
.sheet tbody tr.is-short .sheet__name { box-shadow: inset 3px 0 0 var(--danger); }
.sheet tbody tr.is-done .sheet__total { color: var(--success); }

.sheet tfoot td { position: sticky; bottom: 0; background: #f8fafc; font-weight: 700; border-top: 2px solid var(--text); }
.sheet-note { color: var(--muted); font-size: 12.5px; margin: 0; max-width: 70ch; }

@media print {
  .sidebar, .topbar, .no-print, .mobile-header, .sidebar-rail-toggle { display: none !important; }
  .main { margin: 0; width: 100%; padding: 0; }
  body { background: white; }
  .sheet-scroll { max-height: none; overflow: visible; border: 0; box-shadow: none; }
  .sheet-head { border: 0; box-shadow: none; padding: 0 0 10px; }
  .sheet { font-size: 11px; }
  .sheet th, .sheet td { padding: 3px 6px; border-color: #000; }
  .sheet thead th { position: static; background: white; }
  .sheet tfoot td { position: static; background: white; }
  .sheet tbody tr:nth-child(even) { background: white; }
  /* На бумаге цвета нет - и подсветка недовыпуска только мешала бы читать. */
  .sheet tbody tr.is-short .sheet__rest,
  .sheet tbody tr.is-done .sheet__total { color: inherit; }
  .sheet tbody tr.is-short .sheet__name { box-shadow: none; }
  .sheet thead { display: table-header-group; }
}

/* ============================================================================
   Оформление: спокойнее, тише, просторнее.

   Слой намеренно последний и трогает только внешний вид - цвета, скругления,
   тени, типографику, состояния. Геометрия не тронута: сетки, брейкпоинты и
   правила ширины доски выше писались по следам конкретных поломок, и
   переоформление не повод их ворошить.

   Принцип, по которому выбрано: убрать линии и краску там, где они несут
   информации меньше, чем шума. Рамка вокруг каждой карточки соревнуется с
   содержимым; мягкая тень отделяет не хуже, но молчит.
   ========================================================================== */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  /* Волосяная линия вместо серой планки: на светлом фоне видно ровно столько,
     сколько нужно, чтобы отделить, и не больше. */
  --border: rgba(0, 0, 0, .09);
  --primary: #0071e3;
  --primary-soft: #e8f2fe;
  --success: #1d8a4e;
  --warning: #b25000;
  --danger: #d0021b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .05), 0 12px 32px rgba(0, 0, 0, .09);
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
               "Segoe UI", Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, .stat-card strong { letter-spacing: -.02em; }
.topbar h2 { font-size: 28px; font-weight: 600; }
.stat-card strong { font-weight: 600; }

/* Панели и карточки: тень вместо рамки. Рамка остаётся только волосяной, чтобы
   на белом фоне (печать, тёмная тема браузера) элемент не растворялся. */
.stat-card, .panel, .login-card, .report-card, .kanban-toolbar, .kanban-card,
.sheet-head, .sheet-scroll, .defect {
  border-radius: var(--radius);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.stat-card { border-left-width: 3px; }

/* Кнопки: скруглены до капсулы, как принято в интерфейсах Apple, и отвечают на
   касание - лёгкий подъём под курсором, вдавливание при нажатии. */
.primary, button, .secondary, .pagination a, .tabs a {
  border-radius: 980px;
  font-weight: 500;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease),
              transform .12s var(--ease), border-color .18s var(--ease);
}
.primary { border-color: transparent; box-shadow: 0 1px 2px rgba(0, 113, 227, .3); }
.primary:hover { background: #0077ed; box-shadow: 0 2px 8px rgba(0, 113, 227, .35); }
.secondary:hover, button:hover { border-color: rgba(0, 0, 0, .22); }
.primary:active, button:active, .secondary:active { transform: scale(.97); }

/* Видимый фокус - для тех, кто ходит по интерфейсу с клавиатуры. Раньше его не
   было вовсе, и место фокуса приходилось угадывать. */
:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input, select, textarea {
  border-radius: var(--radius-sm);
  border-color: var(--border);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, .12);
}

/* Боковое меню: почти чёрное вместо синего. Синий в меню спорил с синим в
   кнопках, и взгляд не понимал, что из этого действие. */
.sidebar { background: #1d1d1f; padding: 22px 14px; }
.nav-item { border-radius: var(--radius-sm); transition: background-color .18s var(--ease), color .18s var(--ease); }
.nav-item:hover { background: rgba(255, 255, 255, .08); }
.logo { background: var(--primary); border-radius: 12px; }
.brand p, .user-card span, .link-button { color: #98989d; }

/* Таблицы: линия только между строками, шапка тише содержимого. */
th, td { border-bottom-color: var(--border); }
th { font-weight: 500; font-size: 13px; letter-spacing: .01em; }
tbody tr { transition: background-color .15s var(--ease); }

.badge, .status, .message, .tabs a { border-radius: 980px; font-weight: 500; }
.message { border-radius: var(--radius-sm); }

/* Доска: колонка перестаёт быть коробкой и становится фоном, карточка на ней -
   единственный предмет. Так видно партии, а не разлиновку. */
.kanban-column { background: rgba(0, 0, 0, .035); border-color: transparent; border-radius: var(--radius); }
.kanban-head { background: transparent; border-bottom-color: var(--border); }
.kanban-head strong { font-weight: 600; letter-spacing: -.01em; }
.kanban-card { transition: box-shadow .18s var(--ease), transform .18s var(--ease); }
.kanban-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.kanban-card:active { cursor: grabbing; }

/* Кому анимация мешает - тому её не будет. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Поле плана в листе: выглядит как ячейка, пока в него не целятся. Рамка у
   каждой из шестидесяти строк превратила бы таблицу в анкету. */
.sheet__input { width: 100%; min-width: 72px; padding: 4px 6px; border: 1px solid transparent;
  background: transparent; border-radius: 6px; text-align: right;
  font: inherit; font-variant-numeric: tabular-nums; }
.sheet__input:hover { border-color: var(--border); background: #fff; }
.sheet__input:focus { border-color: var(--primary); background: #fff; }
.sheet-form { display: contents; }
.sheet-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sheet-actions .muted { font-size: 12.5px; }

/* Прогноз: чем меньше наблюдений за цифрой, тем она бледнее. Это единственная
   честная передача уверенности - процент пришлось бы выдумать. */
.sheet td.is-low { color: var(--muted); }
.sheet td.is-none { color: #b9b9be; }

/* ---- меню по ролям ---------------------------------------------------------
   У директора пунктов семнадцать, у оператора семь. Поэтому длинное меню
   разбито на группы с тихими заголовками, а короткое остаётся сплошным
   списком: заголовок над одной строкой ничего не разделяет.

   Текущий пункт наконец отмечен. Раньше меню никак не отвечало на то, где ты
   находишься, и на восьмой странице подряд это заметно.
   ---------------------------------------------------------------------------*/
/* Заголовки и разделители добавляют высоту, а у администратора пунктов
   семнадцать - поэтому в сгруппированном меню строки плотнее. Иначе кнопка
   «Выйти» внизу уезжает ещё дальше за край. */
.nav-grouped { gap: 0; }
.nav-grouped .nav-item { padding: 9px 12px; }
.nav-group { display: grid; gap: 1px; padding-bottom: 10px; }
.nav-group + .nav-group { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 10px; }
.nav-group__title {
  margin: 0 0 4px;
  padding: 0 12px;
  color: #8a8a8f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.nav-item.is-active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 500; }
.nav-item b { color: #fff; }

/* ---- страница настроек -----------------------------------------------------
   Одна колонка карточек и прилипающее оглавление слева. Вкладок нет намеренно:
   у оператора здесь два раздела, у технолога четыре, и переключатель стоил бы
   лишнего щелчка на каждом.
   ---------------------------------------------------------------------------*/
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: grid; gap: 2px; }
.settings-nav a {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.settings-nav a:hover { background: rgba(0, 0, 0, .04); color: var(--text); }
/* minmax(0, 1fr), а не подразумеваемый auto: у дорожки auto нижняя граница -
   min-content содержимого, а это таблица этапов с неразрывными колонками. На
   телефоне карточка становилась 413px в окне 375px и утаскивала за собой всю
   страницу вбок. Те же грабли, что у доски выше. */
.settings-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.settings-card { margin-bottom: 0; padding: 24px; scroll-margin-top: 24px; min-width: 0; }
.settings-card__head { margin-bottom: 18px; }
.settings-card__head h3 { margin: 0 0 4px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.settings-card__head p { margin: 0; font-size: 13.5px; max-width: 68ch; }

.settings-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.settings-fields--narrow { grid-template-columns: minmax(0, 420px); }
.field { display: grid; gap: 6px; align-content: start; }
.field > span { color: var(--muted); font-size: 13px; font-weight: 500; }
/* Значение, которое отсюда не поменять, набрано как текст, а не серым полем:
   заблокированный ввод выглядит поломкой, а это просто справка. */
.field__static { margin: 0; padding: 10px 0; font-weight: 500; }
.field__hint { color: var(--muted); font-size: 12.5px; font-style: normal; line-height: 1.35; }
.field__error { color: var(--danger); font-size: 12.5px; font-style: normal; }
.field ul { margin: 0; padding-left: 18px; }

.settings-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 20px; }
.settings-actions .muted { margin: 0; font-size: 12.5px; max-width: 56ch; }

.settings-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.settings-tile {
  display: grid;
  gap: 3px;
  align-content: start;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease), border-color .18s var(--ease);
}
.settings-tile:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); border-color: transparent; }
.settings-tile strong { font-size: 28px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.settings-tile span { font-weight: 500; }
.settings-tile small { color: var(--muted); }
.settings-tile p { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.35; }

/* Этапы: строка настроек, а не отчёт, поэтому поле названия притворяется
   текстом, пока в него не целятся - тем же приёмом, что и план в листе. */
.stages { width: 100%; border-collapse: collapse; }
.stages th, .stages td { padding: 8px 10px; vertical-align: middle; }
.stages__order, .stages__held, .stages__on { width: 1%; white-space: nowrap; text-align: center; }
.stages__code { width: 1%; white-space: nowrap; }
.stages__code code { color: var(--muted); font-size: 12.5px; }
.stages__held { font-variant-numeric: tabular-nums; }
.stages__on input { width: 20px; height: 20px; accent-color: var(--primary); }
.stages__move { display: inline-flex; gap: 4px; }
.stages__move button {
  width: 30px; min-height: 30px; padding: 0;
  border-radius: 8px; font-size: 14px; line-height: 1; color: var(--muted);
}
.stages__move button:disabled { opacity: .35; cursor: default; transform: none; }
.stages__name {
  border-color: transparent; background: transparent; padding: 7px 9px; font-weight: 500;
}
.stages__name:hover { border-color: var(--border); background: #fff; }
.stages tr.is-off .stages__name, .stages tr.is-off .stages__code code { color: #a1a1a6; }

@media (max-width: 1024px) {
  .settings { grid-template-columns: 1fr; gap: 16px; }
  /* Прилипшее оглавление на узком экране закрывало бы собой карточку. */
  .settings-nav { position: static; display: flex; flex-wrap: wrap; gap: 6px; }
  .settings-nav a { background: rgba(0, 0, 0, .04); }
  .settings-card { padding: 18px; }
}
@media (max-width: 720px) {
  .settings-fields, .settings-fields--narrow { grid-template-columns: 1fr; }
  .stages th, .stages td { padding: 8px 6px; }
  /* Палец, а не курсор: правило выше выставляет 44px всем кнопкам, и стрелкам
     оно тоже нужно - иначе в них не попасть. */
  .stages__move button { width: 40px; min-height: 44px; }
}

/* Заказ на производство: выбранные строки уходят на доску одним заказом. */
.sheet__queue-check { width: 68px; text-align: center; }
.sheet__queue-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.sheet__queued { color: var(--primary); font-weight: 600; }
.sheet__queue-create { min-width: 220px; }
.sheet__queue-create input { width: 112px; min-width: 112px; padding: 7px 8px; text-align: right; }
.sheet__queue-create .secondary { margin: 0 0 0 6px; padding: 7px 11px; min-height: 36px; }
.sheet-actions .secondary { margin-top: 0; }
.sheet__pick { width: 42px; min-width: 42px; text-align: center; }
.sheet__pick input { width: 19px; height: 19px; margin: 0; accent-color: var(--primary, #1769e0); cursor: pointer; }

/* История заказов — карточки времени и выполнения вместо служебной таблицы. */
.order-history-toolbar { padding-block: 14px; }
.order-history-filters { grid-template-columns: minmax(240px, 2fr) minmax(180px, 1fr) auto auto; align-items: center; margin: 0; }
.order-filter-reset { margin-top: 0; }
.order-history-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
/* align-content: start - карточки в ряду одной высоты, и это правильно: сетка
   ровная. Но без этой строки грид растягивал и внутренние ряды, разгоняя
   заголовок, даты и товары по углам с пустотой между ними. Теперь лишняя
   высота остаётся одним полем внизу, а не тремя щелями посередине. */
.order-history-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 17px; align-content: start; transition: transform .16s var(--ease), box-shadow .16s var(--ease); }
.order-history-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.order-history-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.order-history-card__head > div { display: grid; gap: 1px; }
.order-history-card__head strong { font-size: 22px; color: var(--primary); }
.order-history-card__eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.order-time-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.order-time-grid > div { background: var(--bg); border-radius: var(--radius-sm); padding: 10px; display: grid; gap: 2px; }
.order-time-grid span,.order-time-grid small { color: var(--muted); font-size: 12px; }
.order-time-grid strong { font-size: 14px; }
.order-progress { display: grid; gap: 8px; }
.order-progress__labels { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.order-progress__labels span { color: var(--muted); }
.order-progress__track { height: 8px; overflow: hidden; border-radius: 999px; background: #e8edf5; }
.order-progress__track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #36a881); }
.order-products-preview { display: flex; flex-wrap: wrap; gap: 7px; }
.order-products-preview > span { padding: 6px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; background: var(--bg); }
.order-products-preview b { margin-left: 4px; }
/* Три ряда товаров - и хватит. В заводском заказе их три десятка, и без
   границы одна карточка вытягивала весь ряд на высоту экрана. Состав читают
   на странице заказа; здесь довольно узнать заказ в лицо. */
.order-products-clip { position: relative; max-height: 96px; overflow: hidden; }
/* Обрыв не должен выглядеть обрезкой: нижний ряд уходит в фон, и видно, что
   там есть продолжение. */
.order-products-clip::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 28px;
  background: linear-gradient(180deg, transparent, var(--surface));
  pointer-events: none;
}
.order-products-clip.is-whole { max-height: none; }
.order-products-clip.is-whole::after { display: none; }
.order-products-toggle {
  margin-top: 8px; padding: 0; border: 0; background: none;
  font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer;
}
.order-products-toggle:hover { text-decoration: underline; }
.order-empty { grid-column: 1 / -1; display: grid; place-items: center; gap: 6px; min-height: 180px; }

@media (max-width: 720px) {
  .order-history-list,.order-history-filters,.order-time-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Карточка заказа

   Заказ читают, чтобы ответить на два вопроса: где он сейчас и что с ним не
   так. Полоса состояния отвечает на первый, бейджи у позиций - на второй.
   Всё остальное здесь молчит: цветом отмечено только то, что требует решения.
   ========================================================================== */

.crumbs { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a:hover { color: var(--primary); }
.crumbs__here { color: var(--text); font-weight: 600; }

.order-status { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.order-status__main { flex: 1 1 380px; min-width: 0; }
.order-status__side { flex: 0 1 280px; display: flex; flex-direction: column; gap: 16px; }
.order-status__label { margin: 0; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.order-status__value { margin: 2px 0 20px; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Полоса состояния. Линия между делениями рисуется на самом делении, а не
   отдельным элементом: так она не разъезжается с точками при любой ширине. */
.steps { display: flex; list-style: none; margin: 0; padding: 0; }
.steps__item { flex: 1; position: relative; padding-top: 22px; text-align: center; font-size: 12.5px; color: var(--muted); }
.steps__item::before {
  content: ""; position: absolute; top: 6px; left: -50%; width: 100%; height: 2px;
  background: var(--border);
}
.steps__item:first-child::before { display: none; }
.steps__dot {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border);
}
.steps__item.is-done { color: var(--text); }
.steps__item.is-done::before,
.steps__item.is-current::before { background: var(--success); }
.steps__item.is-done .steps__dot { background: var(--success); border-color: var(--success); }
.steps__item.is-current { color: var(--text); font-weight: 700; }
.steps__item.is-current .steps__dot {
  background: var(--primary); border-color: var(--primary);
  /* Кольцо, а не увеличенная точка: размер деления задаёт линию, и менять его
     значило бы сдвигать полосу. */
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.order-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.order-facts dt { font-size: 12px; color: var(--muted); }
.order-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; }

.order-actions { display: flex; flex-direction: column; gap: 8px; }
.order-actions .inline-form { margin: 0; }
.order-actions button { width: 100%; }
button.danger { background: transparent; color: var(--danger); border: 1px solid rgba(208, 2, 27, .35); }
button.danger:hover { background: rgba(208, 2, 27, .06); }
.order-actions button[disabled] { opacity: .55; cursor: default; }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.panel-head h3 { margin: 0; }
.panel-head .muted { margin: 2px 0 0; font-size: 13px; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: var(--primary-soft); color: var(--primary);
}
.chip.is-ok { background: rgba(29, 138, 78, .12); color: var(--success); }
.chip.is-warn { background: rgba(178, 80, 0, .12); color: var(--warning); }

/* Позиция заказа. Раскрыта по умолчанию - расчёт сырья и есть то, за чем сюда
   заходят; прятать его за лишним щелчком было бы вредно. */
.order-line { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; background: var(--surface); }
.order-line__head {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center;
  padding: 12px 14px; cursor: pointer; list-style: none;
}
.order-line__head::-webkit-details-marker { display: none; }
.order-line__head:hover { background: rgba(0, 0, 0, .015); border-radius: var(--radius-sm); }
.order-line__no { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: 13px; }
.order-line__name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.order-line__qty { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.order-line__batches { text-align: right; font-size: 12.5px; white-space: nowrap; }
.order-line__batches a { color: var(--primary); font-weight: 600; }
.order-line__batches small { display: block; color: var(--muted); }
.order-line__body { padding: 0 14px 14px; border-top: 1px solid var(--border); }
.order-line__caption { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin: 12px 0 8px; }
.order-line__caption .muted { font-weight: 500; text-transform: none; letter-spacing: 0; }

/* Три колонки: полтора десятка ингредиентов в один столбец уводят кнопку
   «добавить» за пределы экрана, а читают их как справку, а не построчно. */
.ingredients { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 2px 24px; }
.ingredients li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: 13px; }
.ingredients__name { color: var(--muted); }
/* Точки от названия к числу: без них глаз теряет строку на широкой колонке. */
.ingredients li::after { content: ""; flex: 1; border-bottom: 1px dotted var(--border); }
.ingredients__value { order: 3; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin: 12px 0 0; }
.notice.is-warn { background: rgba(178, 80, 0, .08); color: var(--warning); }
.notice strong { display: block; }

.order-bottom { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
.panel.hint { background: var(--primary-soft); }
.panel.hint p { margin: 8px 0 0; font-size: 13px; line-height: 1.5; }
.order-event { margin: 6px 0; font-size: 13px; }

@media (max-width: 900px) {
  .order-bottom { grid-template-columns: 1fr; }
  .order-line__head { grid-template-columns: 28px 1fr; }
  .order-line__qty, .order-line__batches { grid-column: 2; text-align: left; }
  .steps__item { font-size: 11.5px; }
}

/* Удаление с доски: кнопка не должна выглядеть соседкой «Дальше» - рука тянется
   к ней только осознанно. Поэтому тихая, во всю ширину нижнего ряда, краснеет
   лишь под курсором. */
.kanban-card-delete-form { flex: 1 1 100%; }
.kanban-card-delete { width: 100%; min-height: 36px; background: transparent;
  border-color: transparent; color: var(--muted); font-size: 12.5px; }
.kanban-card-delete:hover { color: var(--danger); border-color: rgba(208, 2, 27, .35); }
