/* Брутализм: толстые чёрные рамки, жёсткие тени, крупная типографика. */
:root {
  --paper: #f3efe6;
  --card: #ffffff;
  --ink: #0d0d0d;
  --muted: #5b5850;
  --line: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --accent: #ffde1a;
  --blue: #3047ff;
  --green: #18a957;
  --red: #ff4a3d;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 500 16px/1.45 var(--sans);
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.05; letter-spacing: -0.02em; }
h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; text-transform: uppercase; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: var(--paper); padding: 26px 20px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px;
}
.logo { font: 700 24px/1 var(--sans); text-transform: uppercase; letter-spacing: -0.03em; }
.logo span { display: inline-block; background: var(--accent); color: var(--ink); padding: 2px 8px; margin-top: 6px; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav a {
  text-decoration: none; padding: 12px 14px; border: 2px solid transparent;
  font-weight: 700; text-transform: uppercase; font-size: 14px; letter-spacing: 0.04em;
}
.nav a:hover { border-color: var(--paper); }
.nav a.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.side .foot { margin-top: auto; font: 12px var(--mono); opacity: .6; }
.main { padding: 36px clamp(16px, 4vw, 56px) 80px; max-width: 1400px; width: 100%; }

@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center;
          padding: 12px 16px; gap: 12px; flex-wrap: wrap; border-bottom: var(--line); }
  .logo { font-size: 18px; }
  .logo span { margin-top: 0; }
  .nav { flex-direction: row; margin-left: auto; gap: 4px; }
  .nav a { padding: 8px 10px; font-size: 12px; }
  .side .foot { display: none; }
  .main { padding-top: 22px; }
}

/* ---------- элементы ---------- */
.card { background: var(--card); border: var(--line); box-shadow: var(--shadow); padding: 22px; }
.card + .card, .stack > * + * { margin-top: 26px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
        flex-wrap: wrap; margin-bottom: 26px; }
.kicker { font: 700 13px var(--mono); text-transform: uppercase; letter-spacing: .08em;
          display: inline-block; background: var(--ink); color: var(--paper); padding: 3px 8px; margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 15px var(--sans); text-transform: uppercase; letter-spacing: .03em;
  padding: 13px 20px; border: var(--line); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-sm); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .06s, box-shadow .06s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--accent); }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { padding: 8px 12px; font-size: 12px; }
.btn.big { padding: 18px 28px; font-size: 18px; width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label.field { display: block; font: 700 13px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
input[type=text], input[type=password], input[type=date], input[type=number], textarea, select {
  width: 100%; margin-top: 6px; font: 500 17px var(--sans); color: var(--ink);
  background: #fff; border: var(--line); padding: 12px 14px; border-radius: 0; outline: none;
}
input:focus, textarea:focus { box-shadow: var(--shadow-sm); background: #fffbe0; }
textarea { font: 13px/1.5 var(--mono); min-height: 420px; resize: vertical; }

.badge { display: inline-block; font: 700 12px var(--mono); text-transform: uppercase;
         padding: 4px 8px; border: 2px solid var(--ink); background: #fff; white-space: nowrap; }
.badge.done { background: var(--green); color: #fff; }
.badge.error { background: var(--red); color: #fff; }
.badge.running { background: var(--accent); animation: blink 1.2s steps(2) infinite; }
.badge.queued { background: #ddd; }
@keyframes blink { 50% { background: #fff; } }

.alert { border: var(--line); padding: 14px 16px; font-weight: 700; margin-bottom: 20px; }
.alert.err { background: var(--red); color: #fff; }
.alert.ok { background: var(--green); color: #fff; }

/* ---------- новый отчёт ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 34px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.chip { font: 700 13px var(--sans); text-transform: uppercase; padding: 9px 12px; border: 2px solid var(--ink);
        background: #fff; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--paper); }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
@media (max-width: 560px) { .parts, .dates { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: center; border: 2px solid var(--ink); padding: 12px;
         background: #fff; cursor: pointer; font-weight: 700; user-select: none; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); margin: 0; flex: none; }
.check:has(input:checked) { background: var(--accent); }

.drops { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
@media (max-width: 560px) { .drops { grid-template-columns: 1fr; } }
.drop { position: relative; border: 3px dashed var(--ink); background: #fff; padding: 18px 14px; min-height: 120px;
        display: flex; flex-direction: column; justify-content: center; gap: 6px; cursor: pointer; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop b { text-transform: uppercase; font-size: 15px; }
.drop .fname { font: 12px var(--mono); word-break: break-all; color: var(--muted); }
.drop.over { background: #fffbe0; border-style: solid; }
.drop.has { border-style: solid; background: #e9ffe9; }
.drop.has .fname { color: var(--ink); font-weight: 700; }
.section { margin-top: 24px; }
.section > .field { margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- история ---------- */
.runs { display: flex; flex-direction: column; gap: 12px; }
.run-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; text-decoration: none;
            background: #fff; border: var(--line); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.run-item:hover { background: #fffbe0; }
.run-item .period { font: 700 20px var(--sans); letter-spacing: -0.02em; }
.run-item .meta { grid-column: 1 / -1; font: 12px var(--mono); color: var(--muted); }
.empty { border: 3px dashed var(--ink); padding: 30px; text-align: center; font-weight: 700; }

/* ---------- отчёт ---------- */
.progress { border: var(--line); background: var(--ink); color: #b8ffb0; padding: 0; }
.progress .bar { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px;
                 background: var(--accent); color: var(--ink); font: 700 13px var(--mono); text-transform: uppercase; }
.progress pre { margin: 0; padding: 14px; height: 340px; overflow: auto; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; }
details.log summary { cursor: pointer; font: 700 13px var(--mono); text-transform: uppercase; padding: 10px 0; }
details.log pre { margin: 0; background: var(--ink); color: #ddd; padding: 14px; max-height: 420px; overflow: auto;
                  font: 12px/1.5 var(--mono); white-space: pre-wrap; border: var(--line); }

.toolbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
           background: var(--paper); padding: 12px 0; border-bottom: var(--line); margin-bottom: 22px; }
@media (max-width: 899px) { .toolbar { top: 64px; } }
.toolbar .sel { font: 700 13px var(--mono); margin-left: auto; }

.group { margin-top: 34px; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
              border-bottom: var(--line); padding-bottom: 10px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr 1fr; gap: 12px; } }
.tile { background: #fff; border: var(--line); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; position: relative; }
.tile.sel { outline: 4px solid var(--blue); outline-offset: 2px; }
.tile .thumb { aspect-ratio: 5 / 4; background: #fff; border-bottom: var(--line); cursor: zoom-in; overflow: hidden;
               display: flex; align-items: center; justify-content: center; }
.tile .thumb img { width: 100%; height: 100%; object-fit: contain; }
.tile .doc { font: 700 40px var(--mono); cursor: pointer; }
.tile .doc.pdf { background: var(--red); color: #fff; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.tile .doc.xlsx { background: var(--green); color: #fff; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.tile .name { padding: 10px 12px 4px; font-weight: 700; font-size: 14px; line-height: 1.25; word-break: break-word; }
.tile .acts { margin-top: auto; display: flex; border-top: 2px solid var(--ink); }
.tile .acts a, .tile .acts button { flex: 1; font: 700 11px var(--mono); text-transform: uppercase; padding: 10px 4px; text-align: center;
                 text-decoration: none; border: 0; background: #fff; cursor: pointer; color: var(--ink); }
.tile .acts > * + * { border-left: 2px solid var(--ink); }
.tile .acts a:hover, .tile .acts button:hover { background: var(--accent); }
.tile .pick { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; accent-color: var(--blue); z-index: 2; cursor: pointer; }

.share { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.share input { flex: 1 1 260px; margin: 0; font: 13px var(--mono); }

/* лайтбокс */
.lb { position: fixed; inset: 0; background: rgba(13, 13, 13, .92); z-index: 100; display: flex; flex-direction: column; }
.lb .bar { display: flex; gap: 10px; padding: 12px; align-items: center; color: var(--paper); flex-wrap: wrap; }
.lb .bar .t { font-weight: 700; margin-right: auto; }
.lb .img { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 12px 12px; min-height: 0; }
.lb img { max-width: 100%; max-height: 100%; background: #fff; border: var(--line); }

/* ---------- настройки ---------- */
table.mgr { width: 100%; border-collapse: collapse; }
table.mgr th { text-align: left; font: 700 12px var(--mono); text-transform: uppercase; padding: 8px; border-bottom: var(--line); }
table.mgr td { padding: 8px; border-bottom: 2px solid #ddd; vertical-align: middle; }
table.mgr input[type=text] { margin: 0; font-size: 15px; padding: 9px 10px; }
table.mgr .ord { white-space: nowrap; }
table.mgr .ord button { border: 2px solid var(--ink); background: #fff; font: 700 14px var(--mono); width: 32px; height: 32px; cursor: pointer; }
table.mgr .c { text-align: center; }
table.mgr input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--ink); }
@media (max-width: 700px) {
  table.mgr thead { display: none; }
  table.mgr tr { display: grid; grid-template-columns: 1fr auto; gap: 6px; border: var(--line); padding: 10px; margin-bottom: 12px; background: #fff; }
  table.mgr td { border: 0; padding: 0; }
  table.mgr td.crm, table.mgr td.nm { grid-column: 1 / -1; }
  table.mgr td.c { text-align: left; }
}

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
         background: repeating-linear-gradient(-45deg, var(--paper) 0 22px, #ebe5d6 22px 44px); }
.login .card { width: min(440px, 100%); }
.login h1 { font-size: 40px; margin-bottom: 6px; }
.login form > * + * { margin-top: 16px; }

/* ---------- понятность: шаги, подсказки, этапы ---------- */
.lead { max-width: 720px; margin: 14px 0 0; font-size: 17px; color: var(--muted); }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 14px; margin-top: 26px; padding-top: 22px; border-top: 2px dashed #bbb; }
.step:first-of-type { border-top: 0; padding-top: 0; margin-top: 20px; }
.step-n { width: 44px; height: 44px; display: grid; place-items: center; background: var(--ink); color: var(--accent);
          font: 700 22px var(--mono); }
.step-title { font: 700 19px var(--sans); margin: 8px 0 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.opt { font: 700 11px var(--mono); text-transform: uppercase; border: 2px solid var(--ink); padding: 2px 6px; background: #fff; }
.step-body > input { margin-top: 10px; }
.drop .what { font-size: 13px; }
.notes { margin: 12px 0 0; padding-left: 18px; font-size: 13.5px; color: var(--muted); }
.notes li + li { margin-top: 4px; }
.check { align-items: flex-start; }
.check span { display: flex; flex-direction: column; gap: 3px; }
.check small { font-weight: 500; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.check:has(input:checked) small { color: #3b3a33; }
.submit { margin-top: 28px; }
@media (max-width: 560px) { .step { grid-template-columns: 1fr; gap: 8px; } }
.run-item .open { grid-column: 1 / -1; font: 700 12px var(--mono); text-transform: uppercase; }

.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stage { border: var(--line); background: #fff; padding: 12px 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.stage i { font-style: normal; font: 700 16px var(--mono); width: 26px; height: 26px; display: grid; place-items: center; border: 2px solid var(--ink); flex: none; }
.stage.active { background: var(--accent); }
.stage.active i { animation: blink 1s steps(2) infinite; }
.stage.done { background: var(--ink); color: var(--paper); }
.stage.done i { border-color: var(--paper); }
.group-hint { margin: -8px 0 16px; color: var(--muted); font-size: 14px; }
.btn-note { font-size: 12px; color: var(--muted); margin-top: 6px; max-width: 220px; }
.actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.actions form { display: flex; flex-direction: column; }
.nav-label { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; opacity: .5; margin: 10px 0 2px 2px; }
@media (max-width: 899px) { .nav-label { display: none; } }
.stage.skipped { background: #e4e0d6; color: var(--muted); border-style: dashed; flex-wrap: wrap; }
.stage small { flex-basis: 100%; font: 700 11px var(--mono); text-transform: uppercase; padding-left: 36px; margin-top: -4px; }

/* ---------- файлы на сервере ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat { border: var(--line); background: #fff; box-shadow: var(--shadow-sm); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat span { font: 700 12px var(--mono); text-transform: uppercase; color: var(--muted); }
.stat b { font: 700 30px var(--sans); letter-spacing: -0.02em; }
.howto { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.store td { white-space: nowrap; }
table.store tr.picked td { background: #fffbe0; }
.clean-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-top: 22px;
                 padding-top: 20px; border-top: var(--line); }
.clean-actions .btn { width: 100%; }
.clean-actions .btn-note { max-width: none; }
.inline-err { color: var(--red); font-weight: 700; margin-top: 10px; }
