/* Диспетчерская доска цеха: эмаль, графитовая рама, бирки и магниты */
:root {
  --board: #f3f4f1;
  --board-2: #eceee9;
  --paper: #ffffff;
  --frame: #1f2428;
  --frame-2: #2b3137;
  --frame-ink: #c9ced2;
  --frame-ink-2: #8e969c;
  --ink: #16191c;
  --ink-2: #454c52;
  --ink-3: #646b71;
  --line: #d6d9d3;
  --line-2: #e6e8e3;
  --focus: #2557a7;
  --link: #1f4f99;

  --ok: #2f8f5b; --ok-ink: #1f6b42; --ok-bg: #e5f1e9; --ok-line: #b8d9c4;
  --warn: #e0a100; --warn-ink: #6f4e00; --warn-bg: #fbf0d0; --warn-line: #ecd08a;
  --bad: #d33a2c; --bad-ink: #a12218; --bad-bg: #fbe3df; --bad-line: #eeb1a9;
  --cur: #1f2428;

  --r: 8px;
  --r-sm: 6px;
  --shadow-1: 0 1px 0 rgba(22, 25, 28, .04), 0 1px 3px rgba(22, 25, 28, .06);
  --shadow-2: 0 2px 4px rgba(22, 25, 28, .05), 0 8px 24px rgba(22, 25, 28, .08);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-family: "Golos Text", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--board);
  accent-color: var(--frame);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; background: var(--board); }
::selection { background: #cfe0f7; color: var(--ink); }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; margin: 0; letter-spacing: -.015em; overflow-wrap: anywhere; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 650; margin: 0 0 12px; letter-spacing: -.005em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .92em; letter-spacing: -.01em; }
.ic { flex: none; display: block; }
* { scrollbar-width: thin; scrollbar-color: #bfc4bd transparent; }

/* ---------- рама и навигация ---------- */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.layout > * { min-width: 0; }
.side {
  background: var(--frame); color: var(--frame-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; border-right: 1px solid #12161a;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .04);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 8px 22px; color: #fff; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: #fff; display: grid; place-items: center; flex: none; }
.brand-mark i { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 1px 1px rgba(0,0,0,.3), inset 0 -2px 0 rgba(0,0,0,.18); }
.brand b { font-size: 14px; line-height: 1.2; font-weight: 650; display: block; }
.brand small { font-size: 11.5px; color: var(--frame-ink-2); display: block; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--frame-ink); font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s; position: relative; }
.nav a:hover { background: var(--frame-2); color: #fff; }
.nav a.active { background: #fff; color: var(--ink); }
.nav a.active .ic { color: var(--ink); }
.nav .ic { color: var(--frame-ink-2); }
.nav .count { margin-left: auto; font-family: var(--mono); font-size: 11.5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: var(--bad); color: #fff; font-weight: 600; }
.side .me { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--frame-2); font-size: 13px; color: var(--frame-ink-2); }
.side .me b { display: block; font-weight: 600; font-size: 13.5px; color: #fff; }
.side .me-actions { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.side .linkbtn { color: var(--frame-ink); }
.side .linkbtn:hover { color: #fff; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(127,127,127,.5); }
.linkbtn:hover { color: var(--ink); }
.demo-note { margin-top: 12px; font-size: 12px; color: var(--frame-ink-2); line-height: 1.45; padding: 9px 10px; border: 1px dashed #4a5258; border-radius: var(--r-sm); }
.demo-note .linkbtn { font-size: 12px; margin-top: 4px; }

.main { padding: 28px 36px 64px; max-width: 1320px; width: 100%; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar .sub { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 550; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-1); transition: background .15s, border-color .15s, transform .1s var(--ease), box-shadow .15s;
}
.btn:hover { border-color: #b9beb6; background: #fafbf9; color: var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--frame); border-color: var(--frame); color: #fff; }
.btn.primary:hover { background: #33393f; border-color: #33393f; color: #fff; }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--paper); }
.btn.danger { color: var(--bad-ink); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: #fff #fff transparent transparent; animation: spin .7s linear infinite; }
.btn:not(.primary).is-busy::after { border-color: var(--ink) var(--ink) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- магниты и бирки ---------- */
.magnet { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; background: var(--line); box-shadow: inset 0 -2px 0 rgba(0,0,0,.16), 0 1px 1.5px rgba(0,0,0,.25); }
.magnet.ok { background: var(--ok); }
.magnet.attention { background: var(--warn); }
.magnet.overdue { background: var(--bad); }
.magnet.done { background: #9aa19c; }
.magnet.cur { background: var(--cur); }
.magnet.lg { width: 16px; height: 16px; }
.snap { animation: snap .22s var(--ease); }
@keyframes snap { from { transform: scale(.7); } to { transform: scale(1); } }

.badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); }
.badge::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #9aa19c; box-shadow: inset 0 -1.5px 0 rgba(0,0,0,.16); }
.badge.ok { color: var(--ok-ink); border-color: var(--ok-line); background: var(--ok-bg); }
.badge.ok::before { background: var(--ok); }
.badge.attention { color: var(--warn-ink); border-color: var(--warn-line); background: var(--warn-bg); }
.badge.attention::before { background: var(--warn); }
.badge.overdue { color: var(--bad-ink); border-color: var(--bad-line); background: var(--bad-bg); }
.badge.overdue::before { background: var(--bad); }
.badge.done { color: var(--ink-3); }

.code-tag { font-family: var(--mono); font-weight: 600; font-size: 13px; letter-spacing: 0; display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--board); color: var(--ink); white-space: nowrap; }
.code-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1.5px #a8aea7; }
.tag { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; white-space: nowrap; background: var(--paper); }

/* ---------- полоса маршрута (длина сегмента = длительность этапа) ---------- */
.route { display: flex; gap: 2px; height: 10px; align-items: stretch; width: 100%; }
.route i { display: block; min-width: 4px; border-radius: 2px; background: #dfe2dc; position: relative; }
.route i.done { background: #8e9690; }
.route i.done_late { background: #c9a74a; }
.route i.cur { background: var(--cur); }
.route i.cur.attention { background: var(--warn); }
.route i.overdue { background: repeating-linear-gradient(-45deg, var(--bad) 0 3px, #f08a7f 3px 6px); }
.route i.rework { box-shadow: inset 0 0 0 1.5px var(--warn); }
.route.lg { height: 16px; gap: 3px; }
.route.lg i { border-radius: 3px; }
.route-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.route-legend span { display: inline-flex; align-items: center; gap: 6px; }
.route-legend i { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------- доска: счётчики-фильтры ---------- */
.chips { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 14px 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
  font-weight: 550; font-size: 14px; cursor: pointer; color: var(--ink-2); transition: border-color .15s, box-shadow .15s, color .15s;
}
.chip b { font-family: var(--mono); font-weight: 700; color: var(--ink); font-size: 15px; }
.chip:hover { border-color: #b9beb6; color: var(--ink); }
.chip.on { border-color: var(--frame); box-shadow: inset 0 0 0 1px var(--frame); color: var(--ink); }
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1; max-width: 380px; min-width: 200px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 36px; width: 100%; }

.board { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 14px; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-1); transition: box-shadow .2s var(--ease), border-color .2s, transform .2s var(--ease); position: relative;
}
a.card:hover { box-shadow: var(--shadow-2); border-color: #c4c9c1; transform: translateY(-1px); color: var(--ink); }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .title { font-weight: 650; font-size: 15.5px; line-height: 1.3; }
.card .client { color: var(--ink-2); font-size: 13.5px; margin-top: -6px; }
.card .stage { font-size: 13.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 10px; }
.card .stage span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .stage .num { color: var(--ink-3); flex: none; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--ink-3); }
.card.is-overdue { border-color: var(--bad-line); }
.card.is-attention { border-color: var(--warn-line); }

/* табло переходов */
.departures { background: var(--frame); color: #e9ecee; border-radius: var(--r); padding: 14px 14px 10px; position: sticky; top: 20px; box-shadow: var(--shadow-2); }
.departures h2 { color: #fff; font-size: 14px; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.departures .sub { font-size: 12px; color: var(--frame-ink-2); margin-bottom: 10px; }
.dep { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 9px 4px; border-top: 1px solid #343b41; text-decoration: none; color: inherit; border-radius: 4px; }
.dep:hover { background: var(--frame-2); color: #fff; }
.dep .when { font-family: var(--mono); font-size: 12px; font-weight: 600; background: #0f1215; border-radius: 4px; padding: 4px 0; text-align: center; color: #ffd76a; align-self: start; letter-spacing: .02em; }
.dep .when.late { color: #ff8a7d; }
.dep .when.today { color: #ffd76a; }
.dep .when.later { color: #a6d9b8; }
.dep b { font-family: var(--mono); font-size: 12.5px; color: #fff; font-weight: 600; }
.dep .what { font-size: 12.5px; line-height: 1.35; color: var(--frame-ink); }
.dep .next { font-size: 11.5px; color: var(--frame-ink-2); display: block; margin-top: 2px; }
.departures .empty-dep { font-size: 13px; color: var(--frame-ink-2); padding: 10px 4px; border-top: 1px solid #343b41; }

/* ---------- поля ---------- */
.input, select.input, textarea.input {
  height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); min-width: 0; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 8px 11px; resize: vertical; line-height: 1.45; }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23646b71' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:hover { border-color: #bcc1ba; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 87, 167, .16); }
.input:disabled { background: var(--board-2); color: var(--ink-3); }
.input::placeholder, textarea::placeholder { color: #80878c; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.field .input { width: 100%; }
.field small { font-size: 12px; color: var(--ink-3); }
.err-text { color: var(--bad-ink); font-size: 13.5px; min-height: 1.2em; }

.empty { padding: 44px 24px; text-align: center; color: var(--ink-2); background: var(--paper); border: 1px dashed var(--line); border-radius: var(--r); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--board-2) 0%, #f7f8f5 50%, var(--board-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.loading-grid .skeleton { height: 128px; }

/* ---------- карточка проекта ---------- */
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--ink-2); }
.meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--ink-2); margin-top: 10px; font-size: 14px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
.panel.pad { padding: 18px 20px; }
.route-panel { padding: 16px 20px 14px; margin-bottom: 16px; }
.route-panel .route-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 22px; margin-bottom: 16px; padding: 16px 20px; }
.facts > div > span:first-child { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.facts > div { font-size: 14.5px; font-weight: 500; }
.facts select.input { height: 32px; font-weight: 500; }

.stages-wrap { overflow-x: auto; padding: 4px 20px 18px; }
.stages { width: 100%; border-collapse: collapse; min-width: 640px; }
.stages th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 12px 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stages td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.stages tr:last-child td { border-bottom: 0; }
.stages tr.cur td { background: #f7f8f5; }
.stages tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--frame); }
.stages tr.cur .sname { font-weight: 650; }
.stages tr.future .sname { color: var(--ink-2); }
.stages .cmt td { padding-top: 0; background: transparent !important; box-shadow: none !important; }
.stages .sname { line-height: 1.35; }
.stages .sresp { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line); background: var(--paper); flex: none; color: var(--paper); }
.dot .ic { width: 14px; height: 14px; }
.dot.done { background: var(--ok); border-color: var(--ok); }
.dot.done_late { background: var(--warn); border-color: var(--warn); }
.dot.overdue { border-color: var(--bad); background: var(--bad-bg); }
.dot.attention { border-color: var(--warn); background: var(--warn-bg); }
.dot.cur::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--cur); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.dot.overdue.cur::after { background: var(--bad); }
.stages input[type=date] { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); width: 140px; font-family: var(--mono); font-size: 13px; }
.stages input[type=date]:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 87, 167, .16); }
.stages input.changed, .stages select.changed { border-color: var(--focus); background: #f1f5fc; }
.stages select { height: 32px; padding: 0 26px 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background-color: var(--paper); width: 180px; font-size: 13px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23646b71' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.stages select { width: 164px; }
.stages input[type=date] { width: 134px; }
.stages .rework { font-size: 11px; color: var(--warn-ink); border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: 999px; padding: 1px 7px; margin-left: 6px; white-space: nowrap; font-weight: 600; }
.date-ro { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.late-note { display: block; font-size: 11.5px; color: var(--bad-ink); margin-top: 2px; font-weight: 600; }
.comment-box { border: 1px solid var(--warn-line); background: #fffcf2; border-radius: var(--r-sm); padding: 10px 12px; }
.comment-box label { font-size: 12.5px; color: var(--warn-ink); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; font-weight: 550; }
.comment-box textarea { width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 9px; resize: vertical; background: #fff; line-height: 1.45; }
.comment-box textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 87, 167, .16); }
.comment-box.err { border-color: var(--bad); background: #fff6f5; }
.comment-box.err label { color: var(--bad-ink); }
.comment-box .hist { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.comment-box .hist div { margin-top: 3px; }
.comment-ro { font-size: 13px; color: var(--ink-2); border-left: 0; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 12px; background: var(--board); }
.comment-ro b { color: var(--ink); font-weight: 600; }
.savebar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.savebar .muted { font-size: 13.5px; }
.sticky-save { position: sticky; bottom: 0; z-index: 5; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); padding: 12px 20px; border-radius: 0 0 var(--r) var(--r); backdrop-filter: saturate(1.2); }
.sticky-save.dirty { box-shadow: 0 -6px 18px rgba(22, 25, 28, .07); }
.dirty-count { font-family: var(--mono); font-size: 12px; background: var(--frame); color: #fff; border-radius: 10px; padding: 1px 7px; }

/* ---------- формы ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.form-panel { padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-panel .wide, .form-panel h2, .form-panel ol, .form-panel .route { grid-column: 1 / -1; }
.form-panel.preview { display: block; }
.form-panel.preview .route { margin: 4px 0 14px; }
.stage-preview { margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.stage-preview li { padding: 7px 0; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: 12px; }
.stage-preview li:last-child { border-bottom: 0; }
.stage-preview li > span:last-child { white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); }
.edit-panel { padding: 18px 20px; margin-bottom: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; align-items: end; }

/* ---------- калькулятор ---------- */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.section { padding: 16px 20px 14px; margin-bottom: 14px; overflow-x: auto; }
.section h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.section h2 small { font-weight: 600; font-size: 14px; font-family: var(--mono); color: var(--ink-2); }
.lines { width: 100%; border-collapse: collapse; margin-bottom: 8px; table-layout: fixed; min-width: 560px; }
.lines th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lines td { padding: 6px; border-bottom: 1px solid var(--line-2); }
.lines input, .lines select { width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); }
.lines input[type=number] { font-family: var(--mono); font-size: 13px; }
.lines input:focus, .lines select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 87, 167, .16); }
.lines td.sum { text-align: right; white-space: nowrap; font-family: var(--mono); font-size: 13px; }
.lines .x { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 6px; border-radius: 4px; display: grid; place-items: center; }
.lines .x:hover { color: var(--bad-ink); background: var(--bad-bg); }
.totals { position: sticky; top: 20px; padding: 18px 20px; }
.totals .tl { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 10px; font-size: 14px; }
.totals .tl > span:last-child, .totals .tl > b:last-child { font-family: var(--mono); font-size: 13.5px; }
.totals .tl.sep { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.totals .tl.big { font-size: 15px; font-weight: 650; border-top: 2px solid var(--frame); margin-top: 8px; padding-top: 12px; }
.totals .tl.big > span:last-child { font-size: 22px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.totals .tl input { width: 70px; text-align: right; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); font-family: var(--mono); font-size: 13px; margin-left: 6px; }
.tablelist { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); }
.tablelist th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbf9; white-space: nowrap; }
.tablelist td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.tablelist tr:last-child td { border-bottom: 0; }
.tablelist tr.click { cursor: pointer; }
.tablelist tr.click:hover td { background: #f8f9f6; }
.tablelist tr.sel td { background: #eef2f8; }
.tablelist td .input { height: 34px; }

/* ТКП для печати */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 48px 56px; max-width: 860px; box-shadow: var(--shadow-2); }
.doc h1 { font-size: 22px; margin-bottom: 4px; }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.doc th, .doc td { border: 1px solid #cfd2cc; padding: 7px 9px; text-align: left; }
.doc td.r, .doc th.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc .tot td { font-weight: 700; }
.doc .head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 26px; color: var(--ink-2); font-size: 14px; }

/* ---------- вкладки, отчёты ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--ink-2); font-weight: 550; margin-bottom: -1px; font-size: 14px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--frame); }
.x-btn { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 13px; padding: 4px 6px; border-radius: 4px; display: inline-flex; gap: 5px; align-items: center; }
.x-btn:hover { color: var(--bad-ink); background: var(--bad-bg); }
.summary-strip { display: flex; flex-wrap: wrap; gap: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 18px; box-shadow: var(--shadow-1); }
.summary-strip > div { flex: 1 1 150px; padding: 14px 18px; border-right: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip b { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.summary-strip span { font-size: 13px; color: var(--ink-2); line-height: 1.3; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; }
.rep-grid .panel { padding: 16px 20px; }
.rep-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); align-items: start; }
.rep-row:first-of-type { border-top: 0; }
.rep-row .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.rep-row q { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 4px; quotes: '«' '»'; }
.bar { height: 8px; border-radius: 4px; background: repeating-linear-gradient(-45deg, var(--bad) 0 3px, #f08a7f 3px 6px); min-width: 3px; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.login-art { background: var(--frame); color: #e9ecee; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.login-art h2 { color: #fff; font-size: 28px; line-height: 1.2; max-width: 16ch; letter-spacing: -.02em; font-weight: 700; margin: 0; }
.login-art p { color: var(--frame-ink); max-width: 46ch; margin: 12px 0 0; }
.login-board { background: var(--board); border-radius: 10px; padding: 14px; display: grid; gap: 10px; max-width: 460px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-board .card { padding: 11px 13px; gap: 8px; }
.login-board .card .title { font-size: 14px; }
.login-pane { display: grid; place-items: center; padding: 32px 20px; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login form h1 { font-size: 24px; }
.demo { font-size: 13px; color: var(--ink-2); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.demo-logins { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.demo-logins button { font-family: var(--mono); font-size: 12px; padding: 4px 9px; border-radius: 4px; border: 1px solid var(--line); background: var(--board); cursor: pointer; }
.demo-logins button:hover { border-color: var(--frame); }
.demo-logins button span { font-family: "Golos Text", sans-serif; color: var(--ink-3); margin-left: 4px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--frame); color: #fff; padding: 11px 16px; border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease), transform .25s var(--ease); z-index: 60; max-width: calc(100vw - 32px); box-shadow: var(--shadow-2); font-size: 14px; display: flex; gap: 9px; align-items: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad-ink); }

/* ---------- адаптив ---------- */
@media (max-width: 1180px) {
  .board { grid-template-columns: 1fr; }
  .departures { position: static; order: -1; }
  .calc { grid-template-columns: 1fr; }
  .totals { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 4px; overflow-x: auto; }
  .brand { padding: 0 6px 0 0; }
  .brand > div { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { padding: 8px 10px; font-size: 13.5px; gap: 7px; white-space: nowrap; }
  .nav a span.lbl { display: none; }
  .nav a.active span.lbl { display: inline; }
  .nav .count { margin-left: 2px; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0 0 0 8px; }
  .side .me b, .side .me .role, .demo-note { display: none; }
  .side .me-actions { margin: 0; }
  .main { padding: 18px 16px 48px; }
  h1 { font-size: 22px; }
  .grid, .loading-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-panel { grid-template-columns: 1fr; padding: 16px; }
  .facts { grid-template-columns: 1fr 1fr; padding: 14px 16px; }
  .stages-wrap { padding: 2px 10px 12px; }
  .doc { padding: 24px 18px; }
  .rep-grid { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .sticky-save { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .side, .no-print, #toast, .departures { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; }
  body, :root { background: #fff; }
  .panel, .card, .doc { box-shadow: none; }
}
.card .title::first-letter, h1.cap::first-letter, .rep-row a b + span::first-letter { text-transform: uppercase; }
@media (max-width: 860px) {
  .departures .dep:nth-of-type(n+5) { display: none; }
  .dep > span:last-child { min-width: 0; overflow-wrap: anywhere; }
}

/* ---------- экскурсия ---------- */
.tour { position: fixed; inset: 0; z-index: 100; opacity: 0; transition: opacity .2s var(--ease); }
.tour.in { opacity: 1; }
.tour.out { opacity: 0; }
.tour-hole { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15, 18, 21, .62), 0 0 0 2px #fff inset; pointer-events: none; transition: top .35s var(--ease), left .35s var(--ease), width .35s var(--ease), height .35s var(--ease); }
.tour-card { position: fixed; background: var(--paper); border-radius: 12px; padding: 18px 20px 16px; box-shadow: 0 18px 48px rgba(0, 0, 0, .3); width: 380px; transition: top .35s var(--ease), left .35s var(--ease); outline: none; }
.tour-card.docked { left: 12px !important; right: 12px; bottom: 12px; top: auto !important; width: auto !important; }
.tour-step { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.tour-card h2 { font-size: 18px; margin: 0 0 8px; }
.tour-card p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.tour-dots { display: flex; gap: 5px; margin: 14px 0 12px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots i.past { background: #9aa19c; }
.tour-dots i.on { background: var(--frame); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- итерация совета: прогноз, переносы, доступность, цех ---------- */
.bad-text { color: var(--bad-ink); font-weight: 600; }
.moved-note { display: block; font-size: 12.5px; color: var(--warn-ink); margin-top: 2px; }
.fc-note { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.late-note { font-size: 12.5px; }
.field > label > .input { display: block; margin-top: 6px; font-size: 15px; font-weight: 400; color: var(--ink); width: 100%; }
.has-resp-col .sresp { display: none; }
.row-tools { display: inline-flex; gap: 2px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--frame); color: #fff; padding: 10px 14px; border-radius: var(--r-sm); text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 12px; color: #fff; }
.dep .next { font-size: 12.5px; }
.dep .what, .dep b { font-size: 13px; }
.route-legend { font-size: 12.5px; }
[aria-invalid="true"] { border-color: var(--bad) !important; box-shadow: 0 0 0 3px rgba(211, 58, 44, .14) !important; }
@media (max-width: 860px) {
  .stages { min-width: 0; }
  .stages .col-resp { display: none; }
  .has-resp-col .sresp { display: block; }
  .stages td:nth-child(2) { min-width: 0; }
  .stages input[type=date] { width: 136px; height: 44px; }
  .btn, .btn.small { min-height: 44px; }
  .chip { height: 44px; }
  .input, select.input { height: 44px; }
  .stages tr > :first-child { width: 34px; padding-left: 0; }
  .stages td, .stages th { padding: 8px 4px; }
  body { font-size: 15.5px; }
}
@media (max-width: 860px) {
  .stages thead { display: none; }
  .stages, .stages tbody { display: block; }
  .stages tr[data-row] { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr); gap: 6px 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); align-items: start; }
  .stages tr[data-row] > td { border: 0; padding: 0; background: transparent !important; box-shadow: none !important; }
  .stages tr.cur { background: #f7f8f5; box-shadow: inset 3px 0 0 var(--frame); padding-left: 6px; }
  .stages .c-dot { grid-row: span 3; padding-top: 2px !important; }
  .stages .c-name { grid-column: 2 / -1; }
  .stages .c-plan::before, .stages .c-fact::before { content: attr(data-label); display: block; font-size: 12.5px; color: var(--ink-3); margin-bottom: 3px; }
  .stages .c-plan input[type=date], .stages .c-fact input[type=date] { width: 100%; }
  .stages .c-act { grid-column: 2 / -1; }
  .stages .c-act:empty { display: none; }
  .stages .c-act .btn { width: 100%; }
  .stages tr.cmt { display: block; }
  .stages tr.cmt > td { display: block; padding: 0 0 12px; border: 0; }
  .stages tr.cmt > td:first-child { display: none; }
}
