@font-face {
  font-family: "Golos Text";
  src: url("fonts/golos-text.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: oklch(0.968 0.005 235);
  --sheet: oklch(0.995 0.002 235);
  --ink: oklch(0.24 0.018 255);
  --ink-2: oklch(0.44 0.018 255);
  --rule: oklch(0.82 0.01 250);
  --shell: oklch(0.27 0.032 256);
  --shell-ink: oklch(0.95 0.008 256);
  --shell-rule: oklch(0.4 0.03 256);
  --stamp: oklch(0.5 0.19 258);
  --stamp-hover: oklch(0.44 0.19 258);
  --stamp-soft: oklch(0.94 0.03 258);
  --on-stamp: oklch(0.99 0 0);
  --stop: oklch(0.5 0.19 27);
  --stop-soft: oklch(0.955 0.025 27);
  --ochre: oklch(0.72 0.14 78);
  --ochre-soft: oklch(0.95 0.045 88);
  --ochre-ink: oklch(0.42 0.09 70);
  --line: 1px solid var(--rule);
  --frame: 1px solid var(--ink);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: "Golos Text", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  scrollbar-color: var(--rule) var(--paper);
  caret-color: var(--stamp);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: var(--stamp-soft); color: var(--ink); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
}

:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }

/* Основная надпись: полоса граф во всю ширину. */
.titleblock {
  display: flex;
  background: var(--shell);
  color: var(--shell-ink);
  border-bottom: 1px solid var(--shell-rule);
}
.tb-cell {
  margin: 0;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 3.25rem;
}
.tb-cell + .tb-cell { border-left: 1px solid var(--shell-rule); }
.tb-name { font-weight: 600; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 1.75rem; }
.tb-mark {
  font-weight: 750;
  letter-spacing: 0.04em;
  padding-right: 0.625rem;
  border-right: 1px solid var(--shell-rule);
  margin-right: 0.375rem;
}
.tb-room { color: oklch(0.82 0.015 256); }
.tb-exit { padding-block: 0.5rem; }

.sheet {
  width: min(100% - 2rem, 52rem);
  margin: 2.5rem auto 4rem;
  background: var(--sheet);
  border: var(--frame);
  padding: 2rem 2rem 2.25rem;
}
.sheet-login { width: min(100% - 2rem, 26rem); }
#view-history { width: min(100% - 2rem, 64rem); }

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
h2 { font-size: 1.125rem; font-weight: 650; margin: 0 0 0.75rem; }
.lead { margin: 0 0 1.75rem; color: var(--ink-2); max-width: 60ch; }
.note { margin: 0; color: var(--ink-2); font-size: 0.875rem; }

/* Графа комплекта */
.kit { border: var(--line); }
.drop {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 1rem;
  row-gap: 0.125rem;
  align-items: start;
  padding: 1.5rem 1.25rem;
  background: repeating-linear-gradient(-45deg, transparent 0 9px, oklch(0.94 0.006 250) 9px 10px);
  cursor: pointer;
  transition: background-color 150ms var(--ease);
}
.drop-icon {
  grid-row: span 3;
  width: 2rem;
  height: 2rem;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.drop:hover, .drop.over { background-color: var(--stamp-soft); }
.drop.over .drop-icon, .drop:hover .drop-icon { stroke: var(--stamp); }
.kit:has(#files:focus-visible) .drop { outline: 2px solid var(--stamp); outline-offset: -2px; }
.kit:has(#files:disabled) .drop { cursor: progress; background-color: transparent; }
.drop-title { font-weight: 600; }
.drop-hint { color: var(--ink-2); font-size: 0.9375rem; max-width: 52ch; }
.drop-pick { margin-top: 0.5rem; color: var(--stamp); font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.picked {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: var(--line);
  font-size: 0.9375rem;
}
.picked li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.25rem;
  overflow-wrap: anywhere;
}
.picked li + li { border-top: var(--line); }
.picked .size { color: var(--ink-2); white-space: nowrap; }

.kit-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1rem 1.25rem;
  border-top: var(--line);
}
.kit-foot .note { flex: 1 1 18rem; }

/* Кнопки */
button, .button {
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 0;
  padding: 0.6875rem 1.375rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.primary { background: var(--stamp); color: var(--on-stamp); }
.primary:hover { background: var(--stamp-hover); }
.primary:active { background: oklch(0.4 0.17 258); }
button:disabled, button:disabled:hover { background: var(--rule); color: var(--ink-2); cursor: progress; }
.link {
  background: none;
  color: var(--stamp);
  padding-inline: 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.link:hover { color: var(--stamp-hover); }
.ghost {
  background: transparent;
  color: var(--shell-ink);
  border-color: var(--shell-rule);
  padding: 0.4375rem 1rem;
  font-weight: 500;
}
.ghost:hover { background: oklch(0.33 0.035 256); }
.titleblock :focus-visible { outline-color: var(--shell-ink); }

/* Сообщения */
.error {
  margin: 1.25rem 0 0;
  padding: 0.75rem 1rem;
  background: var(--stop-soft);
  color: var(--stop);
  border: 1px solid oklch(0.82 0.07 27);
  font-weight: 500;
}
.notice {
  margin: 1.25rem 0 0;
  padding: 0.75rem 1rem;
  background: var(--ochre-soft);
  border: 1px solid oklch(0.84 0.08 85);
  font-size: 0.9375rem;
}

/* Маршрутная карта стадий */
.route { margin-top: 2.25rem; }
.route-head, .stages li {
  display: grid;
  grid-template-columns: 2.75rem 1fr 8rem;
  align-items: center;
}
.route-head {
  border: var(--frame);
  border-bottom: var(--line);
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.route-head span, .stages li > span { padding: 0.5rem 0.75rem; }
.route-head span + span, .stages li > span + span { border-left: var(--line); align-self: stretch; display: flex; align-items: center; }
.stages {
  list-style: none;
  margin: 0;
  padding: 0;
  border: var(--frame);
  border-top: 0;
}
.stages li { min-height: 2.75rem; color: var(--ink-2); transition: background-color 200ms var(--ease); }
.stages li + li { border-top: var(--line); }
.stages .no { text-align: right; justify-content: flex-end; }
.stages li[data-state="current"] { background: var(--stamp-soft); color: var(--ink); font-weight: 600; }
.stages li[data-state="done"] { color: var(--ink); }
.stages li[data-state="failed"] { background: var(--stop-soft); color: var(--ink); font-weight: 600; }
.stages li[data-state="void"] .op { text-decoration: line-through; text-decoration-color: var(--rule); }

.mark { font-size: 0.8125rem; }
.stamp {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border: 3px double currentColor;
  font-weight: 650;
  line-height: 1.35;
  transform: rotate(-3deg);
  color: var(--stamp);
}
li[data-state="done"] .stamp { animation: stamp 220ms var(--ease) both; }
li[data-state="failed"] .stamp { color: var(--stop); animation: stamp 220ms var(--ease) both; }
.working { color: var(--stamp); font-weight: 600; }
.working::after {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  margin-left: 0.5rem;
  vertical-align: middle;
  background: linear-gradient(90deg, var(--stamp) 50%, transparent 0) 0 0 / 0.5rem 1px;
  animation: run 900ms linear infinite;
}

@keyframes stamp {
  from { opacity: 0; transform: scale(1.6) rotate(-9deg); }
  to { opacity: 1; transform: scale(1) rotate(-3deg); }
}
@keyframes run { to { background-position: 0.5rem 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Итог */
.result { margin-top: 0; }
.result h2:focus { outline: none; }
.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border: var(--frame);
}
.total { padding: 1rem 1.25rem 1.125rem; }
.total + .total { border-left: var(--line); }
.totals dt { font-size: 0.875rem; color: var(--ink-2); }
.totals dd { margin: 0.25rem 0 0; font-size: 2rem; line-height: 1.15; font-weight: 650; letter-spacing: -0.01em; }
.totals dd.hint { font-size: 0.875rem; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }
#doubts-row[data-doubts="some"] { background: var(--ochre-soft); }
#doubts-row[data-doubts="some"] #doubts { color: var(--ochre-ink); }
#doubts-row[data-doubts="some"] dt::before {
  content: "";
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  margin-right: 0.5rem;
  background: var(--ochre);
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-top: 1.5rem; }

/* Вход */
.login { display: grid; gap: 1.125rem; margin-top: 1.5rem; }
.login .error { margin: 0; }
.login button { justify-self: start; }
.sheet-login .note { margin-top: 1.5rem; padding-top: 1rem; border-top: var(--line); }
.field { display: grid; gap: 0.375rem; }
.field-label { font-size: 0.875rem; font-weight: 600; }
input:not([type="file"]) {
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid oklch(0.62 0.015 250);
  border-radius: 0;
  padding: 0.625rem 0.75rem;
  width: 100%;
}
input:not([type="file"]):hover { border-color: var(--ink-2); }
input:not([type="file"]):focus-visible { outline: 2px solid var(--stamp); outline-offset: -1px; border-color: var(--stamp); }

/* Кабинет: основная надпись повёрнута в колонку слева. */
.cabinet {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--shell);
  color: var(--shell-ink);
  border-right: 1px solid var(--shell-rule);
}
.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--shell-rule);
}
.sb-name { margin: 0; font-weight: 600; line-height: 1.3; }
.sb-name .tb-mark { display: block; margin: 0 0 0.125rem; padding: 0; border: 0; }
.sb-toggle { display: none; }
.sb-body { display: flex; flex: 1; flex-direction: column; }
.sb-nav { display: flex; flex-direction: column; }
.sb-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem;
  color: oklch(0.85 0.015 256);
  text-decoration: none;
  border-bottom: 1px solid var(--shell-rule);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.sb-nav a::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border: 1px solid currentColor;
  flex: none;
}
.sb-nav a:hover { background: oklch(0.31 0.034 256); color: var(--shell-ink); }
.sb-nav a[aria-current="page"] { background: oklch(0.33 0.035 256); color: var(--shell-ink); font-weight: 600; }
.sb-nav a[aria-current="page"]::before { background: oklch(0.68 0.15 258); border-color: oklch(0.68 0.15 258); }
.sb-exit { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--shell-rule); }
.sidebar :focus-visible { outline-color: var(--shell-ink); outline-offset: -2px; }

.desk { min-width: 0; }
.job-meta { margin: -0.5rem 0 0.75rem; color: var(--ink-2); font-size: 0.9375rem; overflow-wrap: anywhere; }
.empty { margin: 0; padding: 1.25rem; border: var(--line); color: var(--ink-2); }

/* Журнал расчётов */
.register { width: 100%; border-collapse: collapse; border: var(--frame); font-size: 0.9375rem; }
.register th {
  text-align: left;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--ink-2);
  padding: 0.5rem 0.75rem;
  border-bottom: var(--line);
}
.register td { padding: 0.625rem 0.75rem; border-top: var(--line); vertical-align: middle; }
.register th + th, .register td + td { border-left: var(--line); }
.register .num { text-align: right; white-space: nowrap; }
.register .date { white-space: nowrap; }
.register .kit-name { overflow-wrap: anywhere; min-width: 10rem; }
.register td[data-doubts="some"] { background: var(--ochre-soft); color: var(--ochre-ink); font-weight: 650; }
.register .stamp { animation: none; }
.stamp.stamp-stop { color: var(--stop); }
.row-actions { white-space: nowrap; }
.row-actions > * + * { margin-left: 0.875rem; }
.row-actions a { color: var(--stamp); text-underline-offset: 0.2em; }
.row-actions a:hover { color: var(--stamp-hover); }
.row-actions .link { padding: 0; font-weight: 500; }
.row-actions .ask { font-weight: 600; }
.danger { background: var(--stop); color: var(--on-stamp); padding: 0.3125rem 0.75rem; }
.danger:hover { background: oklch(0.44 0.19 27); }

@media (max-width: 56rem) {
  .cabinet { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: 0; border-right: 0; }
  .sb-toggle { display: inline-block; }
  .sb-body { display: none; }
  .menu-open .sb-body { display: flex; }
  .sb-exit { margin-top: 0; border-top: 0; }

  .register thead { display: none; }
  .register, .register tbody, .register tr, .register td { display: block; }
  .register { width: auto; border-collapse: separate; }
  .register tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-top: var(--line); padding: 0.5rem 0; }
  .register tbody tr:first-child { border-top: 0; }
  .register td { border: 0; padding: 0.25rem 0.75rem; }
  .register td + td { border-left: 0; }
  .register .kit-name { grid-column: 1 / -1; font-weight: 600; min-width: 0; order: -1; }
  .register td[data-label]::before { content: attr(data-label) " "; color: var(--ink-2); font-weight: 400; }
  .register .row-actions { grid-column: 1 / -1; white-space: normal; }
  .register td.num { text-align: left; }
}

@media (max-width: 40rem) {
  .tb-room { display: none; }
  .tb-cell { padding-inline: 1rem; }
  .tb-mark { display: none; }
  .sheet { margin-block: 1rem 2.5rem; padding: 1.25rem 1rem 1.5rem; }
  h1 { font-size: 1.5rem; }
  .route-head, .stages li { grid-template-columns: 2.25rem 1fr 6.5rem; }
  .totals { grid-template-columns: 1fr; }
  .total + .total { border-left: 0; border-top: var(--line); }
  .totals dd { font-size: 1.75rem; }
  .kit-foot button { width: 100%; }
}
