:root {
  --paper: #f4f2ed; --card: #fff; --ink: #171614; --ink2: #55524a;
  --line: #ddd8ce; --blue: #1b4f9c; --green: #15703f; --red: #a82f1c;
  --amber-bg: #fdf3dc; --amber-ink: #6b4605;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink);
       font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 15px; }
a { color: var(--blue); } a:hover { color: #123566; }
button, input, select { font: inherit; }

.top { background: var(--card); border-bottom: 1px solid var(--line);
       padding: 0 28px; display: flex; align-items: center; gap: 26px; height: 64px; }
.top__brand { font-family: "Oswald", sans-serif; font-size: 20px; font-weight: 600;
              letter-spacing: 1px; text-decoration: none; color: var(--ink); }
.top nav { display: flex; gap: 22px; height: 100%; }
.top nav a { display: flex; align-items: center; text-decoration: none; color: var(--ink2);
             border-bottom: 2px solid transparent; }
.top nav a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 16px;
              color: var(--ink2); font-size: 14px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 28px 64px; }
h1 { font-family: "Oswald", sans-serif; font-size: 30px; font-weight: 600;
     letter-spacing: 0.5px; margin: 0 0 4px; }
.lead { color: var(--ink2); margin: 0 0 22px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
        padding: 18px 20px; margin-bottom: 16px; }
.caps { font-family: "Oswald", sans-serif; font-size: 13px; font-weight: 500;
        letter-spacing: 1.4px; text-transform: uppercase; color: var(--ink2); }
.display { font-family: "Oswald", sans-serif; font-weight: 600; line-height: 1.05; }
.mono { font-family: "IBM Plex Mono", monospace; }
.muted { color: var(--ink2); } .green { color: var(--green); } .red { color: var(--red); }
.amber { color: var(--amber-ink); }

.kpis { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.kpis .card { flex: 1 1 180px; margin: 0; }
.kpis .display { font-size: 38px; margin-top: 4px; }

.cols { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.cols > * { flex: 1 1 440px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: 0.8px; text-transform: uppercase;
     color: var(--ink2); font-weight: 600; padding: 0 10px 8px; border-bottom: 1px solid var(--line);
     white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid #efece4; vertical-align: top; }
tfoot td { border-bottom: none; padding-top: 16px; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.off td { opacity: 0.5; }

.bar-track { height: 22px; background: #efece4; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: #8c877c; }
.bar-fill.max { background: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center;
       height: 44px; padding: 0 20px; border-radius: 8px; border: none;
       background: var(--ink); color: #fff; font-weight: 600; cursor: pointer;
       text-decoration: none; }
.btn--ghost { background: var(--card); color: var(--ink); border: 2px solid var(--ink); }
.btn--small { height: 36px; padding: 0 14px; font-size: 14px; font-weight: 500; }

.note { background: var(--amber-bg); border-radius: 8px; padding: 14px 18px;
        color: var(--amber-ink); line-height: 1.5; margin-bottom: 16px; }
.flash { border-radius: 8px; padding: 12px 18px; margin-bottom: 16px; }
.flash.success { background: #e6f2ea; color: var(--green); }
.flash.error { background: #fbe9e4; color: var(--red); }
.flash.info { background: var(--amber-bg); color: var(--amber-ink); }

.price { width: 92px; height: 40px; text-align: right; padding: 0 10px;
         border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
         font-family: "IBM Plex Mono", monospace; }
.price:focus { background: #fff; outline: 2px solid var(--blue); }

.password-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 54px; }
.password-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.password-tools > span { margin-right: auto; font-size: 13px; }
.password-feedback { min-height: 20px; margin-top: 5px; font-size: 13px; }
.password-toggle { position: absolute; right: 4px; width: 42px; height: 38px;
                   display: flex; align-items: center; justify-content: center;
                   border: 0; border-radius: 6px; background: transparent;
                   color: var(--ink2); cursor: pointer; }
.password-toggle:hover { background: var(--line); color: var(--ink); }
.password-toggle:focus-visible { outline: 2px solid var(--blue); }
.password-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor;
                       stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .password-eye-slash { display: none; }
.password-toggle.is-hidden .password-eye-slash { display: initial; }

.check { width: 24px; height: 24px; accent-color: var(--ink); cursor: pointer; }

.packets-print { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
                 margin-bottom: 12px; }
.packets-check { width: 34px; text-align: center; }
.packets-check .check { width: 20px; height: 20px; vertical-align: middle; }

.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters select, .filters input { height: 40px; padding: 0 12px; border: 1px solid var(--line);
                                  border-radius: 8px; background: var(--card); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; }
.pill--held { background: #fbe9e4; color: var(--red); }
.pill--idle { background: var(--amber-bg); color: var(--amber-ink); }
.pill--done { background: #e6f2ea; color: var(--green); }

.login { max-width: 420px; margin: 12vh auto; padding: 0 20px; }
.login .card { padding: 28px; }
.login input { width: 100%; height: 52px; padding: 0 14px; border: 1px solid var(--line);
               border-radius: 10px; background: var(--paper); margin-bottom: 14px; font-size: 17px; }
.login .btn { width: 100%; height: 56px; font-size: 17px; }

form ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
form ul li label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
form input[type="text"], form input[type="password"],
form:not(.filters) input[type="date"], form:not(.filters) select {
  width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--paper); }
form input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ink); }

/* справочники: вкладки, строка добавления, кнопки в строке таблицы */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--ink2);
          border: 1px solid var(--line); background: var(--card); }
.tabs a.on { color: var(--card); background: var(--ink); border-color: var(--ink); font-weight: 600; }
.inline-form { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.inline-form > div:first-of-type { flex: 1 1 260px; max-width: 360px; }
.inline-form .btn { margin-top: 26px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
form input[type="number"].price { height: 46px; }
.btn--tiny { height: 30px; min-width: 30px; padding: 0 8px; font-size: 14px; border-width: 1px; }
.top__right a.on { font-weight: 600; color: var(--ink); }

/* меню шапки: группы раскрываются по наведению и с клавиатуры; на странице
   группы те же пункты продублированы вкладками — это путь для телефона */
.nav-group { position: relative; display: flex; }
.nav-group > a .caret { font-size: 11px; margin-left: 4px; color: var(--ink2); }
.nav-menu { display: none; position: absolute; top: 100%; left: -14px; z-index: 10;
            min-width: 180px; padding: 6px; background: var(--card);
            border: 1px solid var(--line); border-radius: 10px;
            box-shadow: 0 8px 24px rgba(23, 22, 20, 0.12); }
.nav-group--menu:hover .nav-menu, .nav-group--menu:focus-within .nav-menu { display: block; }
.top nav .nav-menu a { display: block; padding: 9px 12px; border: 0; border-radius: 6px;
                       color: var(--ink); }
.top nav .nav-menu a:hover { background: var(--paper); }
.top nav .nav-menu a.on { font-weight: 600; background: var(--paper); }

/* Телефон и планшет: меню в две строки, таблицы — списком.
   Меню-выпадашки на узком экране не нужны: по группе ходят вкладками. */
@media (hover: none), (max-width: 900px) {
  .nav-menu { display: none !important; }
  .nav-group > a .caret { display: none; }
}
@media screen and (max-width: 900px) {
  .top { height: auto; min-height: 56px; padding: 8px 16px; gap: 8px 16px;
         flex-wrap: wrap; align-items: center; }
  .top nav { order: 3; flex: 1 0 100%; height: 42px; gap: 18px;
             overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { white-space: nowrap; padding: 0 2px; }
  .top__right { margin-left: auto; gap: 12px; }
  .top__right > span { display: none; }

  .wrap { padding: 18px 16px 48px; }
  h1 { font-size: clamp(24px, 6vw, 30px); }
  .card { padding: 14px 16px; }

  .kpis .card { flex-basis: 140px; }
  .kpis .display { font-size: clamp(28px, 8vw, 38px); }

  /* Таблица с шапкой на телефоне — набор строк. Подпись колонки стоит слева,
     значение справа, поэтому горизонтальной прокрутки всей страницы нет. */
  table:has(thead):not(.matrix) { display: block; }
  table:has(thead):not(.matrix) thead { display: none; }
  table:has(thead):not(.matrix) tbody,
  table:has(thead):not(.matrix) tfoot { display: block; }
  table:has(thead):not(.matrix) tbody > tr { display: block; padding: 10px 0;
                                border-top: 1px solid var(--line); }
  table:has(thead):not(.matrix) tbody > tr:first-child { border-top: 0; }
  table:has(thead):not(.matrix) tfoot > tr { display: block; padding: 12px 0 4px;
                                border-top: 2px solid var(--line); }
  table:has(thead):not(.matrix) td { display: block; position: relative; width: 100%;
                        min-height: 30px; padding: 5px 0 5px 124px;
                        border: 0; text-align: right; overflow-wrap: anywhere; }
  table:has(thead):not(.matrix) td::before { content: attr(data-label); position: absolute;
                                left: 0; top: 5px; width: 112px; text-align: left;
                                color: var(--ink2); font-size: 11px; font-weight: 600;
                                letter-spacing: .06em; line-height: 1.2;
                                text-transform: uppercase; }
  table:has(thead):not(.matrix) td:not([data-label]) { padding-left: 0; }
  table:has(thead):not(.matrix) td:not([data-label])::before { content: none; }
  table:has(thead):not(.matrix) td.row-title { padding-left: 0; min-height: 0; text-align: left;
                                  font-size: 16px; font-weight: 600; }
  table:has(thead):not(.matrix) td.row-title::before { content: none; }
  table:has(thead):not(.matrix) td.row-title .muted { text-align: left; font-weight: 400; }
  table:has(thead):not(.matrix) td[colspan] { padding-left: 0; text-align: left; }
  table:has(thead):not(.matrix) td[colspan]::before { content: none; }
  table:has(thead):not(.matrix) td .muted { text-align: right; }
  table:has(thead):not(.matrix) .row-actions { justify-content: flex-end; flex-wrap: wrap; }
  table:has(thead):not(.matrix) tfoot td:first-child,
  table:has(thead):not(.matrix) tfoot td[colspan] { padding-left: 0; }

  /* «Этапов закрыто без цены»: на узком экране кнопка уходит на новую строку */
  .rates-pending { flex-wrap: wrap; }
  .rates-pending form { width: 100%; }
  .rates-pending .btn { width: 100%; }

  .price { width: 100%; max-width: 140px; }
  .filters select, .filters input { max-width: 100%; }
}

/* Узкий ноутбук: таблица ещё не превращается в список, но в карточку
   не влезает — пусть прокручивается внутри неё, а не ломает всю страницу. */
@media (min-width: 901px) and (max-width: 1100px) {
  .card { overflow-x: auto; }
}

/* исправления в карточке пакета: свёрнуты, пока не нужны */
.fix { margin: -8px 0 18px; }
td .fix { margin: 0; }
.fix summary { cursor: pointer; color: var(--blue); font-size: 14px; }
.fix__form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.fix__form input[type="text"] { width: auto; flex: 1 1 260px; height: 40px; }
.fix__form input[type="number"].price { height: 40px; }
.fix__hint { font-size: 13px; margin-top: 6px; max-width: 560px; }

/* окно подтверждения удаления: своё, в стиле админки, с красной кнопкой */
.confirm-overlay { position: fixed; inset: 0; background: rgba(23, 22, 20, .45);
                   display: flex; align-items: center; justify-content: center; z-index: 60; }
.confirm-overlay[hidden] { display: none; }
.confirm-box { background: var(--card); border-radius: 12px; padding: 26px 28px;
               max-width: 400px; width: calc(100% - 40px);
               box-shadow: 0 18px 50px rgba(23, 22, 20, .25); }
.confirm-box h3 { font-family: "Oswald", sans-serif; font-size: 20px; font-weight: 600;
                  margin: 0 0 8px; }
.confirm-box p { color: var(--ink2); margin: 0; font-size: 15px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.btn--danger { background: var(--red); color: #fff; border: none; }
.btn--danger:hover { background: #8f2313; }


/* Таблица кроя: цвет × модель × размер. На телефоне не превращается в
   список, а прокручивается внутри карточки — иначе теряются колонки. */
.matrix-wrap { overflow-x: auto; }
table.matrix { min-width: 720px; }
table.matrix th, table.matrix td { border: 1px solid var(--line); padding: 8px 10px; }
table.matrix thead th { background: #f7f5ef; vertical-align: middle; }
table.matrix .matrix__style { text-align: center; border-bottom: 2px solid var(--ink); }
table.matrix .matrix__norm { font-size: 11px; font-weight: 400; color: var(--ink2); }
table.matrix .matrix__size { font-size: 11px; color: var(--ink2); }
table.matrix .matrix__color { text-align: left; white-space: nowrap; }
table.matrix tbody tr:hover td { background: #fcfbf7; }
table.matrix .matrix__cell { min-width: 66px; vertical-align: middle; }
table.matrix .matrix__qty { font-weight: 700; font-size: 16px; line-height: 1.1; }
table.matrix .matrix__status { display: flex; gap: 3px; justify-content: flex-end;
                                flex-wrap: wrap; margin-top: 4px; }
table.matrix .matrix__status .pill { font-size: 11px; padding: 1px 6px; }
table.matrix .matrix__total { font-weight: 700; background: #f7f5ef; }
table.matrix tfoot td { background: #f7f5ef; }
table.matrix--form .matrix__input { padding: 4px; }
table.matrix--form input.qty { width: 74px; height: 38px; text-align: right;
                               border: 1px solid var(--line); border-radius: 6px;
                               background: var(--card); font-family: "IBM Plex Mono", monospace;
                               padding: 0 8px; }
table.matrix--form input.qty:focus { outline: 2px solid var(--blue); background: #fff; }
.pill--cut { background: #e7eef9; color: var(--blue); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
          margin: -4px 0 16px; font-size: 14px; }

/* Паспорт пачки: печатается на обычном принтере, QR ведёт в мобильный экран. */
.passport { background: #fff; border: 2px solid var(--ink); border-radius: 6px;
            padding: 18px 22px; max-width: 760px; margin: 0 auto 24px; }
.passport__top { display: flex; gap: 20px; align-items: flex-start; }
.passport__qr { flex-shrink: 0; text-align: center; }
.passport__qr img { width: 118px; height: 118px; display: block; }
.passport__manual { margin-top: 4px; }
.passport__manual span { display: block; font-size: 9px; }
.passport__manual strong { display: block; font-size: 23px; line-height: 1.1; }
.passport__head { flex-grow: 1; }
.passport__brand { font-family: "Oswald", sans-serif; font-size: 13px; letter-spacing: 2px;
                   text-transform: uppercase; color: var(--ink2); }
.passport__number { font-family: "Oswald", sans-serif; font-size: 44px; font-weight: 600;
                    line-height: 1; margin: 2px 0 6px; }
.passport__meta { font-size: 14px; line-height: 1.5; }
.passport__facts { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0;
                   border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink);
                   padding: 10px 0; }
.passport__facts > div { flex: 1 1 120px; }
.passport__facts span { display: block; font-size: 11px; letter-spacing: .08em;
                        text-transform: uppercase; color: var(--ink2); }
.passport__facts b { font-size: 17px; }
.passport__facts .passport__qty { font-size: 24px; }
.passport__stages th, .passport__stages td { padding: 7px 8px; }
.passport__foot { display: flex; justify-content: space-between; gap: 14px;
                  border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px;
                  color: var(--ink2); font-size: 11px; }

@media print {
  @page { size: A4; margin: 8mm; }
  @page cutSheet { size: A4 landscape; margin: 8mm; }
  body.printing-cut-sheet { page: cutSheet; }
  body { background: #fff; }
  .no-print, .top, .tabs, .flash { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  /* Четыре паспорта на A4: сетка 2×2, каждый — четверть листа (A6). */
  .passports { display: grid; grid-template-columns: repeat(2, 1fr);
               grid-auto-rows: 134mm; gap: 4mm 5mm; }
  .passport { border: 1px solid #000; border-radius: 0; max-width: none;
              margin: 0; height: 100%; padding: 6mm;
              display: flex; flex-direction: column;
              page-break-inside: avoid; break-inside: avoid; font-size: 9px; }
  .passport__top { gap: 8px; }
  .passport__qr img { width: 64px; height: 64px; }
  .passport__manual { margin-top: 1px; }
  .passport__manual span { font-size: 6.5px; }
  .passport__manual strong { font-size: 17px; }
  .passport__brand { font-size: 8.5px; letter-spacing: 1px; }
  .passport__number { font-size: 30px; margin: 1px 0 3px; }
  .passport__meta { font-size: 10px; line-height: 1.35; }
  .passport__facts { margin: 7px 0; padding: 5px 0; gap: 4px; }
  .passport__facts > div { flex: 1 1 60px; }
  .passport__facts span { font-size: 7.5px; }
  .passport__facts b { font-size: 12px; }
  .passport__facts .passport__qty { font-size: 17px; }
  .passport__stages { font-size: 9.5px; flex: 1; }
  .passport__stages th, .passport__stages td { padding: 3px 4px; }
  .passport__foot { margin-top: 4px; padding-top: 3px; font-size: 7px; gap: 6px; }

  /* Печать отдельной таблицы кроя в альбомной ориентации. */
  .cut-layout { display: block !important; }
  .cut-rail { display: none !important; }
  .cut-main { display: block !important; }
  .cut-sheet { scroll-margin: 0; margin: 0; padding: 0; border: 0; }
  .cut-sheet:not(.is-print-target) { display: none !important; }
  .cut-sheet .cut-head { display: block; margin-bottom: 4mm; }
  .cut-sheet .cut-head h1 { font-size: 20pt; margin: 0; }
  .cut-sheet .lead { font-size: 9pt; margin: 1mm 0; }
  .cut-sheet__print-date { display: block; font-size: 9pt; }
  .cut-sheet .cut-head__actions,
  .cut-sheet .kpis,
  .cut-sheet .cut-tools,
  .cut-sheet .inline-form,
  .cut-sheet__create-actions,
  .cut-sheet .matrix__remove { display: none !important; }
  .cut-sheet .cut-empty { border: .3mm solid #777; border-radius: 0; }
  .cut-sheet .legend { margin: 0 0 3mm; font-size: 8pt; }
  .cut-sheet .card { border: 0; border-radius: 0; padding: 0; margin: 0; }
  .cut-sheet .matrix-wrap { overflow: visible; }
  .cut-sheet table.matrix { min-width: 0; width: 100%; table-layout: auto;
                            font-size: 7pt; page-break-inside: auto; }
  .cut-sheet table.matrix thead { display: table-header-group; }
  .cut-sheet table.matrix tr { page-break-inside: avoid; }
  .cut-sheet table.matrix th,
  .cut-sheet table.matrix td { padding: 1.2mm .8mm; font-size: 7pt;
                               border: .25mm solid #777; }
  .cut-sheet table.matrix th { white-space: normal; }
  .cut-sheet table.matrix .matrix__cell { min-width: 12mm; }
  .cut-sheet table.matrix .matrix__qty { font-size: 8pt; }
  .cut-sheet table.matrix .matrix__status { gap: 1px; }
  .cut-sheet table.matrix .matrix__status .pill { font-size: 6pt; padding: 0 2px; }
  .cut-sheet table.matrix--form input.qty { width: 100%; max-width: 18mm; height: 7mm;
                                             border: 0; border-bottom: .25mm solid #777;
                                             border-radius: 0; padding: 0; background: transparent;
                                             font-size: 9pt; }
  .cut-sheet table.matrix--form input.qty::placeholder { color: transparent; }

  /* Печатаем именно список пачек, с этапом и сотрудником. */
  .wip-filters, .wip-summary, .wip-details .caps, .wip-details + .note {
    display: none !important;
  }
  .wip-print-head { display: block !important; margin-bottom: 5mm; }
  .wip-print-head h1 { font-size: 18pt; margin-bottom: 2mm; }
  .wip-details { border: 0; border-radius: 0; padding: 0; margin: 0; }
  .wip-packet-table { width: 100%; font-size: 8pt; }
  .wip-packet-table thead { display: table-header-group; }
  .wip-packet-table tr { page-break-inside: avoid; }
  .wip-packet-table th, .wip-packet-table td { padding: 2mm 1.5mm; border-bottom: .25mm solid #888; }
  .wip-packet-table th { white-space: normal; }
  .wip-packet-table a { color: #000; text-decoration: none; }
  .wip-packet-table .pill { border: .25mm solid #777; background: transparent; color: #000; }
}

.kpi-link { text-decoration: none; color: inherit; display: block; }
.kpi-link:hover { border-color: var(--ink2); }

/* Рабочий лист кроя: слева номера таблиц, справа все таблицы одна под другой. */
.cut-layout { display: flex; gap: 18px; align-items: flex-start; }
.cut-rail { position: sticky; top: 16px; flex: 0 0 58px; display: flex;
            flex-direction: column; gap: 6px; align-items: stretch;
            background: var(--card); border: 1px solid var(--line);
            border-radius: 10px; padding: 8px 6px; max-height: calc(100vh - 40px);
            overflow-y: auto; }
.cut-rail__cap { font-family: "Oswald", sans-serif; font-size: 10px; letter-spacing: 1px;
                 text-transform: uppercase; color: var(--ink2); text-align: center;
                 margin-bottom: 2px; }
.cut-rail__num { display: flex; align-items: center; justify-content: center;
                 height: 38px; border-radius: 8px; border: 1px solid var(--line);
                 color: var(--ink2); text-decoration: none; font-weight: 600;
                 font-variant-numeric: tabular-nums; }
.cut-rail__num.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cut-rail__new { margin: 0; }
.cut-rail__add { width: 100%; height: 38px; border-radius: 8px; border: 1px dashed var(--ink2);
                 background: transparent; color: var(--ink); cursor: pointer;
                 font-size: 20px; line-height: 1; }
.cut-rail__add:hover { background: var(--paper); }
.cut-rail__history { font-size: 11px; text-align: center; color: var(--ink2);
                     margin-top: 4px; text-decoration: underline; }
.cut-main { flex: 1; min-width: 0; }
.cut-sheet { scroll-margin-top: 16px; }
.cut-sheet + .cut-sheet { margin-top: 34px; padding-top: 30px; border-top: 2px solid var(--line); }
.cut-sheet__print-date { display: none; }
.wip-print-head { display: none; }
.cut-head { display: flex; justify-content: space-between; gap: 18px;
            align-items: flex-start; flex-wrap: wrap; }
.cut-head__actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.cut-date { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.cut-date input[type="date"] { width: auto; height: 36px; padding: 0 10px;
                               border: 1px solid var(--line); border-radius: 8px;
                               background: var(--card); }
.cut-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.picker { position: relative; }
.picker > summary { list-style: none; cursor: pointer; user-select: none; }
.picker > summary::-webkit-details-marker { display: none; }
.picker[open] > summary { background: var(--paper); }
.picker__box { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0;
               width: 320px; max-width: calc(100vw - 60px); padding: 14px;
               background: var(--card); border: 1px solid var(--line); border-radius: 10px;
               box-shadow: 0 10px 30px rgba(23, 22, 20, 0.16); }
.picker__box select { width: 100%; height: 40px; padding: 0 10px; margin: 6px 0 12px;
                      border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.picker__box .btn { width: 100%; margin-top: 10px; }
.picker__sizes { margin-bottom: 4px; }
.picker__checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.picker__checks label { display: flex; align-items: center; gap: 6px; cursor: pointer;
                        font-size: 14px; }
.picker__checks input[type="checkbox"] { width: 18px; height: 18px; }
.cut-empty { border: 2px dashed var(--line); border-radius: 10px; padding: 42px 22px;
             text-align: center; color: var(--ink2); background: var(--paper); }
.cut-empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.matrix__num { width: 46px; text-align: center; color: var(--ink2); }
.matrix__remove { opacity: 0.55; margin-left: 4px; vertical-align: middle; }
.matrix__remove:hover { opacity: 1; }
table.matrix--form input.qty { width: 62px; }
@media (max-width: 760px) {
  .cut-layout { display: block; }
  .cut-rail { position: static; flex-direction: row; flex-wrap: wrap; align-items: center;
              max-height: none; overflow: visible; margin-bottom: 14px; }
  .cut-rail__cap, .cut-rail__history { display: none; }
  .cut-rail__num, .cut-rail__add { width: 40px; height: 36px; }
  .cut-rail__new { width: auto; }
  /* На телефоне выпадашка «+ Модель/Цвет/Размер» иначе уезжает за левый
     край: кнопка стоит у края, а панель шире экрана. Раскрываем её в потоке. */
  .cut-tools { flex-direction: column; align-items: stretch; }
  .picker { width: 100%; }
  .picker > summary { width: 100%; justify-content: flex-start; }
  .picker__box { position: static; width: 100%; max-width: none; margin-top: 6px;
                 box-shadow: none; }

  /* Таблица кроя на телефоне: каждый цвет — карточка, а модель × размер —
     строка с полем ввода. Так не нужно крутить таблицу вбок и терять цвет. */
  .matrix-wrap { overflow: visible; }
  table.matrix { display: block; width: 100%; min-width: 0; }
  table.matrix thead { display: none; }
  table.matrix tbody, table.matrix tfoot { display: block; }
  table.matrix tbody > tr {
    display: block; margin-bottom: 12px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 10px; background: #fcfbf7;
  }
  table.matrix tbody > tr:last-child { margin-bottom: 0; }
  table.matrix tbody td {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    width: 100%; padding: 7px 0; border: 0; border-bottom: 1px dashed var(--line);
    text-align: right; white-space: normal;
  }
  table.matrix tbody td:last-child { border-bottom: 0; }
  table.matrix tbody td[data-label]::before {
    content: attr(data-label); flex: 1 0 100%; text-align: left;
    color: var(--ink2); font-size: 11px; font-weight: 600; line-height: 1.2;
    letter-spacing: .04em; text-transform: uppercase;
  }
  table.matrix tbody td.matrix__num { display: none; }
  table.matrix tbody td.matrix__color {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 0 0 8px; margin-bottom: 2px; border-bottom: 2px solid var(--ink);
    font-size: 17px; text-align: left; white-space: normal;
  }
  table.matrix tbody td.matrix__color::before { content: none; }
  table.matrix tbody td.matrix__color .matrix__remove { margin-left: auto; }
  table.matrix tbody td.matrix__cell .matrix__qty { font-size: 15px; }
  table.matrix tbody td.matrix__cell input.qty { width: 74px; margin-left: auto; }
  table.matrix tbody td.matrix__total {
    margin-top: 2px; padding-top: 9px; border-top: 2px solid var(--line);
    border-bottom: 0; background: transparent; font-size: 16px;
  }
  table.matrix tbody td.matrix__total::before { text-transform: none; }

  table.matrix tfoot { margin-top: 14px; }
  table.matrix tfoot tr {
    display: block; margin-bottom: 10px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 10px;
  }
  table.matrix tfoot td {
    display: flex; align-items: baseline; gap: 10px; width: 100%;
    padding: 4px 0; border: 0; text-align: right;
  }
  table.matrix tfoot td[colspan] { font-weight: 600; text-align: left; }
  table.matrix tfoot td[colspan]::before { content: none; }
  table.matrix tfoot td[data-label]::before {
    content: attr(data-label); flex: 1; text-align: left;
    color: var(--ink2); font-size: 12px; font-weight: 500;
  }
}
.cut-main .cut-date input[type="date"] { width: 150px; height: 36px;
  padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); }
.cut-main .cut-date { align-items: center; }

/* Печать всегда таблицей, даже если печатают с телефона: карточная
   раскладка из мобильной версии к бумаге не относится. */
@media print {
  .cut-sheet table.matrix { display: table; width: 100%; min-width: 0; }
  .cut-sheet table.matrix thead { display: table-header-group; }
  .cut-sheet table.matrix tbody,
  .cut-sheet table.matrix tfoot { display: table-row-group; }
  .cut-sheet table.matrix tbody > tr,
  .cut-sheet table.matrix tfoot tr { display: table-row; margin: 0; padding: 0;
    border: 0; border-radius: 0; background: transparent; }
  .cut-sheet table.matrix tbody td,
  .cut-sheet table.matrix tfoot td { display: table-cell; width: auto;
    padding: 1.2mm .8mm; border: .25mm solid #777; }
  .cut-sheet table.matrix tbody td::before,
  .cut-sheet table.matrix tfoot td::before { content: none; }
  .cut-sheet table.matrix tbody td.matrix__num { display: table-cell; }
  .cut-sheet table.matrix tbody td.matrix__color { display: table-cell;
    font-size: inherit; white-space: nowrap; }
  .cut-sheet table.matrix tbody td.matrix__total { display: table-cell;
    background: #f7f5ef; }
  .cut-sheet table.matrix tbody td.matrix__cell { display: table-cell; }
}

/* печать расценок: модели × этапы */
.rates-print th, .rates-print td { border: 1px solid var(--line); padding: 8px 10px; }
.rates-print thead th { background: #f7f5ef; white-space: normal; vertical-align: bottom; }
.rates-print__total { font-weight: 700; background: #f7f5ef; }
@media print {
  .wrap > .card:has(.rates-print) { border: 0; border-radius: 0; padding: 0; }
  .rates-print { font-size: 9pt; }
  .rates-print th { font-size: 7pt; letter-spacing: .3px; }
  .rates-print th, .rates-print td { border-color: #777; padding: 1.5mm 1mm; }
  .rates-print tr { break-inside: avoid; }
}

/* таблица кроя: сохранена, но не сформирована */
.cut-rail__num--draft { background: var(--amber-bg); border-color: #e6c77d; color: var(--amber-ink); }
.cut-state { margin: -10px 0 10px; }
@media print { .cut-sheet .cut-state { display: none; } }
