:root {
  --blue:#005387;
  --green:#28713e;
  --ink:#193248;
  --muted:#687d8e;
  --line:#dce5ec
}

* {
  box-sizing:border-box
}

body {
  margin:0;
  font:14px/1.55 Arial,system-ui,sans-serif;
  color:var(--ink);
  background:#f2f5f8
}

aside {
  width:242px;
  position:fixed;
  inset:0 auto 0 0;
  background:#fff;
  border-right:1px solid var(--line);
  padding:28px 18px;
  display:flex;
  flex-direction:column
}

.brand {
  font-size:34px;
  font-weight:800;
  letter-spacing:-1px;
  text-decoration:none;
  padding:0 14px 24px
}

.brand small {
  font-size:9px;
  letter-spacing:2px;
  margin-top:0
}

.nav-label {
  font-size:14px;
  letter-spacing:1.4px;
  color:var(--muted);
  margin:23px 14px 8px
}

nav a {
  display:block;
  padding:10px 14px;
  border-radius:7px;
  color:#355367;
  text-decoration:none
}

nav a:hover {
  background:#edf4fa;
  color:var(--blue)
}

footer {
  margin-top:auto;
  padding:18px 14px 0;
  font-size:11px;
  color:var(--muted)
}

main {
  margin-left:242px
}

header {
  height:70px;
  background:white;
  border-bottom:1px solid var(--line);
  padding:0 34px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:12px;
  color:var(--muted)
}

.content {
  padding:34px;
  max-width:1800px
}

.eyebrow {
  font-size:10px;
  letter-spacing:1.8px;
  color:var(--blue);
  font-weight:700;
  margin:0 0 12px
}

h1 {
  font-size:29px;
  letter-spacing:-.8px;
  margin:0 0 8px;
  font-weight:650
}

h2 {
  font-size:17px;
  margin:0 0 15px
}

h3 {
  font-size:13px
}

.muted {
  color:var(--muted)
}

.title {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:15px;
  margin-bottom:24px
}

.panel {
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  padding:22px;
  margin:18px 0
}

.stats {
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:16px;
  margin:24px 0
}

.stats article {
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  padding:20px
}

.stats span {
  color:var(--muted);
  font-size:12px
}

.stats strong {
  display:block;
  font-size:30px;
  margin-top:8px
}

.filters,.actions {
  display:flex;
  align-items:end;
  gap:12px;
  flex-wrap:wrap
}

.actions {
  margin:20px 0
}

.grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:18px;
  margin-top:20px
}

label {
  display:block;
  font-size:12px;
  color:var(--muted)
}

input,select,textarea {
  font:inherit;
  border:1px solid #c9d6e0;
  border-radius:6px;
  padding:10px;
  background:white;
  color:var(--ink);
  display:block;
  width:100%;
  margin:6px 0 12px
}

textarea {
  resize:vertical
}

input:focus,textarea:focus,select:focus {
  outline:2px solid #b6d7f2;
  border-color:var(--blue)
}

button,.button {
  font:inherit;
  border:0;
  border-radius:6px;
  padding:10px 17px;
  background:var(--blue);
  color:white;
  text-decoration:none;
  cursor:pointer;
  display:inline-block;
  white-space:nowrap
}

.secondary {
  background:#e9f1f7;
  color:var(--blue)
}

.quiet {
  background:none;
  color:var(--blue);
  padding:0
}

.inline {
  display:inline
}

.danger {
  background:#a62d36
}

.danger-zone {
  border-color:#ecc6c9
}

.table-wrap {
  overflow:auto;
  max-height:65vh;
  padding:0
}

table {
  border-collapse:collapse;
  width:100%;
  font-size:12px
}

th {
  background:#f6f9fb;
  color:#567085;
  font-size:11px;
  text-align:left;
  font-weight:600;
  position:sticky;
  top:0;
  z-index:1;
  white-space:nowrap
}

td,th {
  padding:13px 16px;
  border-bottom:1px solid #e7edf2;
  vertical-align:top
}

td {
  min-width:100px
}

td input {
  min-width:145px
}

td:first-child small {
  min-width:170px
}

small {
  display:block;
  color:var(--muted);
  font-size:11px;
  margin-top:5px
}

a {
  color:var(--blue)
}

.badge {
  padding:4px 9px;
  background:#eaf3ee;
  color:var(--green);
  border-radius:20px;
  font-size:11px;
  white-space:nowrap
}

.empty {
  text-align:center;
  padding:45px;
  color:var(--muted)
}

.negative {
  background:#fbe5e6;
  color:#9f2430
}

.positive {
  background:#e1f1e6;
  color:#246b37
}

.missing {
  background:#fff0bd
}

.message {
  padding:14px 18px;
  border-radius:7px;
  background:#e4f1e9;
  margin-bottom:20px
}

.message.error,.errorlist {
  background:#fbe4e6;
  color:#a52d36;
  padding:15px
}

.batch {
  display:flex;
  align-items:center;
  gap:15px;
  border-bottom:1px solid var(--line);
  padding:15px 0
}

.batch span {
  flex:1
}

.batch input {
  max-width:190px
}

summary {
  cursor:pointer;
  font-weight:600
}

pre {
  white-space:pre-wrap;
  overflow-wrap:anywhere
}

.login {
  max-width:450px
}

@media(max-width:1000px) {
  aside {
    width:200px
  }

  main {
    margin-left:200px
  }

  .content {
    padding:22px
  }

  .grid {
    grid-template-columns:1fr 1fr
  }

  .title {
    align-items:start;
    flex-direction:column
  }

}

@media(max-width:650px) {
  aside {
    position:static;
    width:100%
  }

  aside nav {
    display:flex;
    overflow:auto
  }

  aside footer,.nav-label {
    display:none
  }

  main {
    margin:0
  }

  .grid,.stats {
    grid-template-columns:1fr
  }

  header {
    padding:12px;
    height:auto
  }

  .batch {
    flex-wrap:wrap
  }

}

/* Читаемые таблицы, поля и выравнивание действий */
body {
  font-size:12pt
}

table {
  font-size:12pt
}

th,label,.stats span,small {
  font-size:12pt
}

.filters {
  align-items:flex-end
}

.filters label {
  margin-bottom:0
}

.filters input,.filters select {
  margin-bottom:0
}

.filters button,.filters .button {
  min-height:46px
}

.table-wrap table {
  width:max-content;
  min-width:100%
}

.bordered td,.bordered th {
  border:1px solid #9dafbd
}

.negative {
  background:#fbe5e6;
  color:#a32430
}

.positive {
  background:#e1f1e6;
  color:#246b37
}

.negative,.positive {
  display:inline-block;
  padding:3px 5px
}

.content {
  width:100%
}

.panel {
  min-width:0
}

.button,button {
  line-height:1.3;
  min-height:42px
}

.grid {
  grid-template-columns:repeat(auto-fit,minmax(190px,1fr))
}

@media(max-width:650px) {
  aside nav {
    flex-wrap:wrap
  }

  .content {
    padding:14px
  }

  .stats {
    grid-template-columns:1fr
  }

  .table-wrap {
    max-width:100%
  }

}

.sort-button {
  padding:0;
  min-height:0;
  background:transparent;
  color:var(--blue);
  font-size:inherit;
  font-weight:600;
  text-align:left
}

.sort-button:hover {
  text-decoration:underline
}

#grid input {
  min-width:125px;
  margin:0
}

#grid td {
  padding:4px
}

/* Таблицы истории: фиксированные поля и цвет ячейки */
td.negative, td.positive, td.missing { display: table-cell; }
.history-matrix { border-collapse: separate; border-spacing: 0; }
.history-matrix th:nth-child(1)[rowspan], .history-matrix td:nth-child(1) { position: sticky; left: 0; min-width: 150px; width: 150px; background: #fff; z-index: 2; }
.history-matrix th:nth-child(2)[rowspan], .history-matrix td:nth-child(2) { position: sticky; left: 150px; min-width: 120px; width: 120px; background: #fff; z-index: 2; }
.history-matrix th:nth-child(3)[rowspan], .history-matrix td:nth-child(3) { position: sticky; left: 270px; min-width: 160px; width: 160px; background: #fff; z-index: 2; }
.history-matrix thead th[rowspan] { z-index: 4; background: #f6f9fb; }
.history-matrix tbody td:nth-child(n+4) { padding: 0; }
.history-matrix tbody td:nth-child(n+4) a { display: block; min-width: 110px; padding: 13px 16px; border-bottom: 1px solid #9dafbd; }
.history-matrix a.negative, .history-matrix a.positive { display: block; }
.content { max-width: none; width: 100%; }
@media (min-width: 1800px) { .content { padding-left: 48px; padding-right: 48px; } }

/* Закреплённые материал и наименование при пересчёте */
.count-table { border-collapse: separate; border-spacing: 0; }
.count-table th:nth-child(1), .count-table td:nth-child(1) { position: sticky; left: 0; width: 150px; min-width: 150px; background: white; z-index: 2; }
.count-table th:nth-child(2), .count-table td:nth-child(2) { position: sticky; left: 150px; width: 280px; min-width: 280px; background: white; z-index: 2; }
.count-table thead th:nth-child(-n+2) { z-index: 4; background: #f6f9fb; }
#bulk-error { color: #a32430; }
.history-matrix .legacy-cell { display: block; min-width: 110px; padding: 13px 16px; border-bottom: 1px solid #9dafbd; }

/* Прокрутка меню и выполнение задания */
aside { overflow-y: auto; overscroll-behavior: contain; }
.task-progress { font-weight: 700; padding: 10px 14px; border-radius: 6px; color: #1b1b1b; }
.progress-red { background: #f4b4b4; }
.progress-orange { background: #ffc685; }
.progress-yellow { background: #ffed9a; }
.progress-green { background: #a9dfb3; }
.history-matrix th:not([rowspan]), .history-matrix td:nth-child(n+4) { min-width: 90px; width: 90px; max-width: 90px; }

.history-matrix tbody td:nth-child(n+4) a, .history-matrix .legacy-cell { min-width: 0; box-sizing: border-box; overflow-wrap: anywhere; padding-left: 6px; padding-right: 6px; }
.history-matrix thead th[colspan="2"] { min-width: 180px; width: 180px; max-width: 180px; }

/* Таблица формирования задания и действия выполнения */
#grid { width: auto; table-layout: fixed; }
#grid th:not(:nth-child(2)), #grid td:not(:nth-child(2)) { width: 100px; min-width: 100px; }
#grid th:nth-child(2), #grid td:nth-child(2) { width: 320px; min-width: 320px; }
#grid input { width: 100%; box-sizing: border-box; min-width: 0; }
.control-save { background: var(--green); border-color: var(--green); color: #fff; }
.print-export { margin-left: auto; }
#bulk-form > .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
