:root {
  --canvas: #F4F1EA;
  --surface: #FBFAF6;
  --paper: #FFFEFB;
  --ink: #2F3437;
  --ink-soft: #5B5D5C;
  --muted: #8A8780;
  --faint: #B3AEA4;
  --line: #E4DED2;
  --line-strong: #D3CBBC;
  --sage: #DDE7DA;   --sage-ink: #3E6047;  --sage-soft: #EEF3EC;
  --clay: #F3E2D7;   --clay-ink: #9A5434;
  --sky: #E0EAF1;    --sky-ink: #2F5F7F;
  --butter: #F6EED5; --butter-ink: #85661A;
  --rose: #F7E3E3;   --rose-ink: #9F3A36;
  --font: "Bahnschrift", "Barlow", "DIN Alternate", "Segoe UI", sans-serif;
  --font-cond: "Bahnschrift", "Barlow Semi Condensed", "DIN Condensed", "Segoe UI", sans-serif;
  --radius: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
a { color: var(--sky-ink); }
button, input, textarea, select { font: inherit; color: inherit; }
.cond { font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75; }

.ambient {
  position: fixed; inset: -20vmax; pointer-events: none; z-index: 0;
  background:
    radial-gradient(40vmax 30vmax at 20% 15%, rgba(221, 231, 218, .55), transparent 70%),
    radial-gradient(35vmax 28vmax at 85% 70%, rgba(243, 226, 215, .45), transparent 70%);
  animation: drift 40s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(4vmax, -3vmax, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.985); } }
@media (prefers-reduced-motion: reduce) { .ambient { animation: none; } * { animation-duration: .01s !important; } }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(244, 241, 234, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75;
  font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 13px;
  color: var(--ink); text-decoration: none;
}
.mark-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--sage-ink); box-shadow: 5px 5px 0 var(--clay); }
.top-right { display: flex; align-items: center; gap: 20px; font-size: 13px; color: var(--muted); }
.quota { display: flex; align-items: center; gap: 8px; }
.quota-bar { width: 64px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.quota-bar i { display: block; height: 100%; width: 0; background: var(--sage-ink); transition: width .6s; }
.quota-num { color: var(--ink-soft); }
.who { color: var(--ink-soft); }
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong);
}
.link-btn:hover { color: var(--ink); }
.link-btn:disabled { opacity: .35; cursor: default; }

/* ---------- раскладка ---------- */
.wrap { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px) 80px; }
.intro { padding: clamp(36px, 7vw, 76px) 0 clamp(24px, 3.5vw, 40px); }
.headline {
  margin: 0; font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75;
  font-weight: 600; font-size: clamp(44px, 7.4vw, 92px); line-height: .98; letter-spacing: -.02em;
}
.headline em { font-style: normal; font-weight: 300; color: var(--muted); letter-spacing: 0; }

.grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); animation: rise .7s var(--ease) both; }
.registry { animation-delay: .08s; }

/* ---------- форма ---------- */
.form-card { padding: clamp(20px, 3vw, 36px); }
.step + .step { margin-top: 30px; }
.step-last { margin-top: 26px !important; }
.step-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.step-no { font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75; font-size: 13px; color: var(--clay-ink); letter-spacing: .08em; }
.step-title { font-weight: 600; font-size: 16px; }
.step-aside { margin-left: auto; color: var(--muted); font-size: 13px; }

/* период */
.range { position: relative; }
.range-field {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper);
  cursor: pointer; text-align: left; transition: border-color .2s;
}
.range-field:hover, .range-field[aria-expanded="true"] { border-color: var(--sage-ink); }
.range-date {
  font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75;
  font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: .01em;
}
.range-arrow { width: 22px; height: 1px; background: var(--ink-soft); position: relative; flex: none; }
.range-arrow::after { content: ""; position: absolute; right: 0; top: -3px; width: 7px; height: 7px; border-top: 1px solid var(--ink-soft); border-right: 1px solid var(--ink-soft); transform: rotate(45deg); }
.range-days { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preset {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--line); background: transparent;
  color: var(--ink-soft); font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.preset:hover { border-color: var(--line-strong); color: var(--ink); }
.preset[aria-pressed="true"] { background: var(--sage); border-color: var(--sage-ink); color: var(--sage-ink); }

.cal-pop {
  position: absolute; z-index: 15; top: 64px; left: 0; width: min(620px, calc(100vw - 32px));
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px; padding: 16px 18px 14px;
  box-shadow: 0 18px 40px rgba(60, 50, 30, .08); animation: pop .25s var(--ease) both;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cal-inputs { display: flex; align-items: center; gap: 12px; }
.cal-input {
  width: 116px; padding: 6px 2px; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent;
  outline: 0; text-align: center; font-size: 16px; letter-spacing: .03em;
}
.cal-input:focus { border-bottom-color: var(--sage-ink); }
.cal-input.bad { border-bottom-color: var(--rose-ink); color: var(--rose-ink); }
.cal-nav {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: transparent;
  cursor: pointer; font-size: 20px; line-height: 1; color: var(--ink-soft);
}
.cal-nav:hover { background: var(--canvas); }
.cal-nav:disabled { opacity: .3; cursor: default; }
.cal-months { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 14px; }
.month-title { text-align: center; font-weight: 600; font-size: 14px; margin-bottom: 8px; text-transform: capitalize; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.dow { text-align: center; font-size: 11px; color: var(--faint); padding-bottom: 4px; letter-spacing: .04em; }
.day {
  position: relative; height: 34px; border: 0; background: transparent; cursor: pointer; font-size: 14px;
  color: var(--ink); padding: 0;
}
.day span { position: relative; z-index: 1; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; transition: background .12s; }
.day:hover span { background: var(--canvas); }
.day.in::before { content: ""; position: absolute; inset: 1px 0; background: var(--sage-soft); }
.day.start::before { left: 50%; }
.day.end::before { right: 50%; }
.day.start.end::before { display: none; }
.day.start span, .day.end span { background: var(--ink); color: var(--paper); }
.day.today span { box-shadow: inset 0 0 0 1px var(--line-strong); }
.day.off { color: var(--line-strong); cursor: default; }
.day.off:hover span { background: transparent; }
.day.blank { cursor: default; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ИНН: разлинованный лист, название организации — прямо в строке */
.ledger {
  display: grid; grid-template-columns: 40px 1fr;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); overflow: hidden;
}
.ledger:focus-within { border-color: var(--sage-ink); }
.ledger-gutter {
  padding: 12px 10px 12px 0; text-align: right; color: var(--line-strong); font-size: 12px; line-height: 26px;
  border-right: 1px solid var(--line); background: #F8F5EE; overflow: hidden; user-select: none;
}
.ledger-gutter b { display: block; font-weight: 400; }
.ledger-gutter b.ok { color: var(--sage-ink); }
.ledger-gutter b.bad { color: var(--rose-ink); }
.ledger-body { position: relative; overflow: hidden; }
.ledger textarea, .ledger-names {
  margin: 0; padding: 12px 14px; font-size: 15px; line-height: 26px; letter-spacing: .04em;
  white-space: pre; font-family: var(--font);
}
.ledger textarea {
  position: relative; z-index: 1; display: block; width: 100%; height: 236px; resize: vertical; border: 0; outline: 0;
  background:
    linear-gradient(var(--paper), var(--paper)) 0 0 / 100% 13px no-repeat local,
    repeating-linear-gradient(transparent 0 25px, #EFEAE0 25px 26px) 0 12px / 100% 26px local;
  overflow: auto;
}
.ledger-names { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; color: transparent; }
.ledger-names div { height: 26px; overflow: hidden; text-overflow: ellipsis; }
.ledger-names i { font-style: normal; color: transparent; display: inline-block; min-width: 8.6em; }
.ledger-names em { font-style: normal; letter-spacing: 0; color: var(--muted); margin-left: 14px; font-size: 13px; }
.ledger-names em.bad { color: var(--rose-ink); }
.ledger-names em.wait { color: var(--faint); }
.ledger textarea::placeholder { color: var(--faint); letter-spacing: 0; }

.region { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.region .hint { white-space: nowrap; }
.select {
  appearance: none; padding: 7px 30px 7px 2px; border: 0; border-bottom: 1px solid var(--line-strong);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235B5D5C' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 6px center;
  outline: 0; cursor: pointer; min-width: 200px;
}
.select:focus { border-bottom-color: var(--sage-ink); }

/* коды */
.codes { list-style: none; margin: 8px 0 0; padding: 0; }
.code {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 2px 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.code-num { font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.code-num { grid-column: 1; grid-row: 1; }
.code .badge { grid-column: 3; grid-row: 1; }
.code-x { grid-column: 4; grid-row: 1; }
.code-name { grid-column: 1 / 4; grid-row: 2; color: var(--ink-soft); font-size: 13px; line-height: 1.4; }
.code-name:empty { display: none; }
.code.bad .code-num { color: var(--rose-ink); text-decoration: line-through; text-decoration-color: rgba(159, 58, 54, .4); }
.code-x { border: 0; background: none; cursor: pointer; color: var(--faint); font-size: 18px; line-height: 1; padding: 0 4px; }
.code-x:hover { color: var(--rose-ink); }

.plain-input {
  width: 100%; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--line-strong);
  background: transparent; outline: 0;
}
.plain-input:focus { border-bottom-color: var(--sage-ink); }
.plain-input::placeholder { color: var(--faint); }

.form-foot { display: flex; align-items: center; gap: 18px; margin-top: 30px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }
.form-error { margin: 18px 0 0; padding: 10px 14px; border-radius: 6px; background: var(--rose); color: var(--rose-ink); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 6px; border: 1px solid transparent; cursor: pointer;
  font-weight: 600; text-decoration: none; transition: background .2s, transform .1s, opacity .2s; white-space: nowrap;
}
.btn-sm { padding: 7px 16px; font-size: 14px; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #454B4E; }
.btn-primary:disabled { opacity: .3; cursor: default; transform: none; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); font-weight: 500; }
.btn-ghost:hover { background: #F0ECE3; }
.btn-ghost.danger { color: var(--rose-ink); }

/* ---------- метки ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10.5px;
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; line-height: 1.6;
}
.b-ok, .st-done { background: var(--sage); color: var(--sage-ink); }
.b-warn, .st-queued, .st-review { background: var(--butter); color: var(--butter-ink); }
.b-bad, .st-error { background: var(--rose); color: var(--rose-ink); }
.b-wait { background: #ECE8E0; color: var(--muted); }
.st-running, .st-scanning { background: var(--sky); color: var(--sky-ink); }
.st-cancelled { background: #ECE8E0; color: var(--muted); }

/* ---------- реестр ---------- */
.registry { padding: 24px 0 8px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; position: sticky; top: 78px; }
.registry-head { padding: 0 24px 14px; border-bottom: 1px solid var(--line); }
.registry-head h2 { margin: 0; font-size: 16px; }
.jobs { list-style: none; margin: 0; padding: 0; overflow: auto; }
.job {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 24px;
  border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s;
}
.job.enter { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.job:hover { background: #F5F2EB; }
.job.active { background: #F1EEE6; box-shadow: inset 3px 0 0 var(--sage-ink); }
.job-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .badge { align-self: start; }
.job-meta { grid-column: 1 / -1; display: flex; gap: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.job-bar { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.job-bar i { display: block; height: 100%; background: var(--sage-ink); transition: width .6s; }
.empty { padding: 20px 24px; color: var(--muted); margin: 0; }

/* ---------- выгрузка ---------- */
.detail { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--line-strong); animation: rise .6s var(--ease) both; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.detail-kicker { color: var(--muted); font-size: 13px; letter-spacing: .03em; }
.detail-title {
  margin: 4px 0 0; font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75;
  font-weight: 600; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; letter-spacing: -.01em;
}
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.meter { margin-top: 28px; }
.meter-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.figure { padding: 18px 0 14px 20px; border-right: 1px solid var(--line); }
.figure:first-child { padding-left: 0; }
.figure:last-child { border-right: 0; }
.figure-num {
  display: block; font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75;
  font-size: clamp(34px, 5vw, 60px); font-weight: 600; line-height: 1; letter-spacing: -.02em;
}
.figure-cap { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.ruler {
  position: relative; height: 14px; margin-top: 6px;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 10%);
  border-bottom: 1px solid var(--line-strong);
}
.ruler-fill { position: absolute; left: 0; bottom: 0; height: 6px; width: 0; background: var(--sage-ink); transition: width .8s var(--ease); }
.meter-note { margin-top: 10px; color: var(--muted); font-size: 13px; min-height: 20px; }
.notes { margin-top: 18px; padding: 14px 18px; border-radius: 8px; background: var(--butter); color: var(--butter-ink); font-size: 14px; white-space: pre-line; }
.notes.err { background: var(--rose); color: var(--rose-ink); }

/* выбор групп */
.pick { margin-top: 30px; }
.pick-wrap { max-height: 60vh; }
.pick-table td, .pick-table th { padding: 10px 12px; }
.pick-table tr.zero td { color: var(--faint); }
.pick-table tbody tr { cursor: pointer; }
.pick-table td.num { text-align: right; font-weight: 500; }
.pick-table th.num { text-align: right; }
.check {
  appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--line-strong);
  border-radius: 5px; background: var(--paper); cursor: pointer; display: grid; place-items: center; vertical-align: middle;
}
.check:checked { background: var(--sage-ink); border-color: var(--sage-ink); }
.check:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-1px) rotate(-45deg); }
.check:disabled { opacity: .4; cursor: default; }
.pick-bar {
  position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 14px; padding: 12px 12px 12px 20px; background: var(--ink); color: var(--paper); border-radius: 10px;
}
.pick-sum { font-size: 15px; }
.pick-sum b { font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75; font-size: 22px; font-weight: 600; margin: 0 2px; }
.pick-bar .btn-primary { background: var(--paper); color: var(--ink); }
.pick-bar .btn-primary:hover { background: var(--sage); }
.pick-bar .btn-primary:disabled { opacity: .4; }

.table-tools { display: flex; align-items: center; gap: 20px; margin: 34px 0 12px; flex-wrap: wrap; }
.table-tools .search { flex: 1 1 280px; max-width: 460px; }
.pager { margin-left: auto; display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 13px; }
.table-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.sheet th {
  position: sticky; top: 0; z-index: 1; background: #E9EEE5; color: #2E3B30; font-weight: 600; font-size: 12px;
  line-height: 1.25; padding: 10px; border-bottom: 2px solid #A9B8A6; text-align: center; vertical-align: middle;
}
.sheet td { padding: 7px 10px; border-bottom: 1px solid #EFEAE0; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet tbody tr:hover td { background: #F7F4EC; }
.sheet .c { text-align: center; }
.sheet .l { text-align: left; }
.sheet td.l { max-width: 380px; }
.sheet td.chars { max-width: 520px; }
.sheet a { color: var(--sky-ink); text-underline-offset: 2px; }

/* таблица выгрузки: ширина столбцов задана явно (можно тянуть) */
.sheet.fixed { table-layout: fixed; min-width: 0; }
.sheet.fixed td.l, .sheet.fixed td.chars { max-width: none; }
.sheet.fixed th { padding: 0; }
.th-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; min-height: 46px; padding: 6px 12px 6px 8px;
  border: 0; background: transparent; cursor: pointer; font: inherit; color: inherit; text-align: center; line-height: 1.25;
}
.th-btn:hover { background: #DFE7DA; }
.th-btn .arr { font-size: 11px; color: var(--sage-ink); }
.sheet th.flt .th-btn { background: #D6E2D1; box-shadow: inset 0 -3px 0 var(--sage-ink); }
.rz { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 2; touch-action: none; }
.rz::after { content: ""; position: absolute; top: 25%; bottom: 25%; right: 3px; width: 1px; background: #B8C5B4; }
.rz:hover::after, .rz.drag::after { top: 0; bottom: 0; width: 2px; right: 2px; background: var(--sage-ink); }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }

/* фильтр столбца */
.colpop {
  position: fixed; z-index: 40; width: 290px; padding: 14px 16px 12px;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 18px 40px rgba(60, 50, 30, .1); animation: pop .2s var(--ease) both; font-size: 14px;
}
.colpop h4 { margin: 0 0 10px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.colpop .sorts { display: flex; gap: 6px; margin-bottom: 12px; }
.colpop .sorts button {
  flex: 1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.colpop .sorts button:hover { border-color: var(--line-strong); color: var(--ink); }
.colpop .sorts button[aria-pressed="true"] { background: var(--sage); border-color: var(--sage-ink); color: var(--sage-ink); }
.colpop .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.colpop label { display: block; font-size: 11px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.colpop input { width: 100%; padding: 6px 2px; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; outline: 0; font-size: 15px; }
.colpop input:focus { border-bottom-color: var(--sage-ink); }
.colpop .foot2 { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }

/* активные фильтры */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -2px 0 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 6px;
  background: var(--sage); color: var(--sage-ink); font-size: 13px; cursor: pointer;
}
.chip b { font-weight: 600; }
.chip .x { border: 0; background: none; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; opacity: .7; }
.chip .x:hover { opacity: 1; }

/* закреплённые слева колонки (год, №, заказчик) */
.sheet .fix { position: sticky; z-index: 1; background: var(--paper); }
.sheet th.fix { z-index: 3; background: #E9EEE5; }
.sheet .fix-last { box-shadow: inset -1px 0 0 var(--line-strong); }
.sheet tbody tr:hover td.fix { background: #F7F4EC; }
/* высота строк */
.sheet.compact td { padding-top: 3px; padding-bottom: 3px; font-size: 12.5px; }
.sheet.roomy td { padding-top: 10px; padding-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 11px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--sage); color: var(--sage-ink); }

/* ---------- открытая выгрузка: отдельный экран на всю ширину ---------- */
.back {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 6px 12px 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-size: 14px; transition: background .15s, color .15s;
}
.back:hover { background: #F0ECE3; color: var(--ink); }
body.viewing .intro, body.viewing .grid, body.viewing .foot { display: none; }
body.viewing .wrap { max-width: none; padding: 0 clamp(12px, 1.6vw, 28px) 40px; }
body.viewing .detail { margin-top: 18px; padding-top: 0; border-top: 0; }
body.viewing .detail-title { font-size: clamp(24px, 2.4vw, 36px); }
body.viewing .detail:not(.done) { max-width: 1180px; }   /* проверка и выбор — без широкой таблицы */
body.viewing .table-tools { margin-top: 18px; }
.detail.done .meter { margin-top: 14px; }
.detail.done .figure { padding: 8px 0 6px 18px; }
.detail.done .figure:first-child { padding-left: 0; }
.detail.done .figure-num { font-size: 28px; }
.detail.done .figure-cap { margin-top: 2px; }
.detail.done .ruler { display: none; }
.detail.done .meter-note:empty { display: none; }

.foot { position: relative; z-index: 1; padding: 28px clamp(16px, 4vw, 48px) 40px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

/* ---------- вход ---------- */
.login { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); padding: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); animation: rise .7s var(--ease) both; }
.login-title { margin: 28px 0 26px; font-family: var(--font-cond); font-stretch: 75%; font-variation-settings: "wdth" 75; font-size: 56px; line-height: .95; font-weight: 600; letter-spacing: -.02em; }
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 12px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.field input { width: 100%; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; outline: 0; font-size: 16px; }
.field input:focus { border-bottom-color: var(--sage-ink); }
.login-card .btn { width: 100%; margin-top: 10px; }

/* ---------- узкие экраны ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .registry { max-height: none; position: static; }
}
@media (max-width: 640px) {
  .cal-months { grid-template-columns: 1fr; }
  .cal-months .month:nth-child(2) { display: none; }
  .cal-input { width: 100px; }
  .range-date { font-size: 21px; }
  .range-days { display: none; }

}
@media (max-width: 560px) {
  .top-right { gap: 12px; }
  .quota { display: none; }
  .meter-figures { grid-template-columns: 1fr 1fr; }
  .figure:nth-child(2) { border-right: 0; }
  .figure:nth-child(3), .detail.done .figure:nth-child(3) { grid-column: 1 / -1; padding-left: 0; border-top: 1px solid var(--line); }
  .pick-bar { flex-direction: column; align-items: stretch; }
}
.pick-table td.l { white-space: normal; max-width: none; min-width: 260px; line-height: 1.35; }
