@font-face {
  font-family: "Pervye Book";
  src: url("/static/fonts/Pervye_Book.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Pervye Extended";
  src: url("/static/fonts/Pervye_Extended-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --red: #d90912;
  --red-dark: #b0070f;
  --red-light: #fdecee;
  --white: #ffffff;
  --black: #000000;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --line: #e3e3e3;
  --stripe: #f6f6f6;
  --green: #1e7a3c;
  --green-light: #e8f5ec;
  --green-bar: #2e9e57;
  --yellow: #f2b705;
  --grey-bar: #b8b8b8;
  --font-text: "Pervye Book", "Segoe UI", Arial, sans-serif;
  --font-head: "Pervye Extended", "Pervye Book", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font-family: var(--font-text);
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 16px;
  color: var(--black);
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 12px;
}

a {
  color: var(--red);
}

a:hover {
  color: var(--red-dark);
}

.header {
  background: var(--red);
  color: var(--white);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--white);
  text-decoration: none;
}

.brand:hover {
  color: var(--white);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.header-button {
  display: inline-block;
  padding: 7px 20px;
  border: 2px solid var(--white);
  border-radius: 999px;
  color: var(--white);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
}

.header-button:hover,
.header-button.active {
  background: var(--white);
  color: var(--red);
}

.header-button:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 3px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.user-name {
  font-size: 0.9rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

.nav {
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  display: inline-block;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 4px solid transparent;
  font-size: 0.95rem;
}

.nav a:hover {
  color: var(--red);
}

.nav a.active {
  color: var(--red);
  border-bottom-color: var(--red);
  font-family: var(--font-head);
  font-weight: 700;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.container-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 20px 60px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 4px solid var(--red);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-plain {
  border-top: 1px solid var(--line);
}

.lead {
  color: var(--muted);
  margin-bottom: 20px;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.flash {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--stripe);
}

.flash-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.flash-success {
  background: var(--green-light);
  border-color: var(--green);
  color: #11471f;
}

.flash-error {
  background: var(--red-light);
  border-color: var(--red);
  color: #7d0409;
}

.btn {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  padding: 14px 26px;
  border-radius: 8px;
  border: 2px solid var(--red);
  background: var(--red);
  color: var(--white);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: var(--white);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--black);
  outline-offset: 2px;
}

.btn-outline {
  background: var(--white);
  color: var(--red);
}

.btn-outline:hover {
  background: var(--red-light);
  color: var(--red-dark);
}

.btn-big {
  font-size: 1.15rem;
  padding: 18px 36px;
}

.btn-small {
  font-size: 0.85rem;
  padding: 8px 14px;
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-light {
  background: transparent;
  border-color: var(--white);
  color: var(--white);
}

.btn-light:hover {
  background: var(--white);
  border-color: var(--white);
  color: var(--red);
}

.field {
  margin-bottom: 18px;
}

.field label,
.label {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  font-family: var(--font-text);
  font-size: 1rem;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--red);
}

.inline-form {
  display: inline;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.row > .field {
  flex: 1 1 220px;
  margin-bottom: 0;
}

.row + .field {
  margin-top: 18px;
}

.row-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

.checklist {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 460px;
  overflow-y: auto;
}

.checklist li {
  border-bottom: 1px solid var(--line);
}

.checklist li:last-child {
  border-bottom: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
}

.check:hover {
  background: var(--red-light);
}

.check input {
  width: 24px;
  height: 24px;
  accent-color: var(--red);
  flex: none;
}

.check-name {
  flex: 1;
}

.check-date {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background: var(--red);
  color: var(--white);
  font-family: var(--font-head);
  font-weight: 700;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: var(--stripe);
}

.num {
  text-align: right;
  white-space: nowrap;
}

th.wrap {
  white-space: normal;
  min-width: 96px;
  max-width: 150px;
  vertical-align: bottom;
  line-height: 1.25;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.fold {
  margin: 18px 0;
}

.fold summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 0;
  color: var(--red);
}

.fold summary:focus-visible {
  outline: 3px solid var(--black);
  outline-offset: 2px;
}

.charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.charts .card {
  margin-bottom: 0;
}

.charts-wide {
  grid-column: 1 / -1;
}

.bar-row {
  margin-bottom: 14px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.bar-label {
  overflow-wrap: anywhere;
}

.bar-value {
  font-family: var(--font-head);
  font-weight: 700;
  white-space: nowrap;
}

.bar-svg {
  display: block;
  width: 100%;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.bar-bg {
  fill: var(--stripe);
}

.seg-approved {
  fill: var(--green-bar);
}

.seg-started {
  fill: var(--yellow);
}

.seg-idle {
  fill: var(--grey-bar);
}

.bar-split {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.bar-split .dot:not(:first-child) {
  margin-left: 8px;
}

.bar-share {
  margin-left: auto;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.dot-approved {
  background: var(--green-bar);
}

.dot-started {
  background: var(--yellow);
}

.dot-idle {
  background: var(--grey-bar);
}

.legend {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  align-items: center;
  margin: -6px 0 18px;
  font-size: 0.85rem;
}

.legend .dot {
  margin-right: 6px;
}

.container-wide {
  max-width: 1500px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.field-button {
  flex: 0 0 auto;
}

.kpi .summary-item {
  border-left-width: 6px;
}

.summary-item.kpi-approved {
  border-left-color: var(--green-bar);
}

.summary-item.kpi-started {
  border-left-color: var(--yellow);
}

.summary-item.kpi-idle {
  border-left-color: var(--grey-bar);
}

.kpi-percent {
  font-size: 1rem;
  color: var(--green);
}

.kpi-of {
  font-size: 1rem;
  color: var(--muted);
  font-family: var(--font-text);
  font-weight: 400;
}

.kpi-main {
  flex: 2 1 280px;
  background: var(--green-light);
}

.kpi-main .summary-value {
  font-size: 2.1rem;
  color: var(--green);
}

.ok-number {
  color: var(--green);
  font-weight: 700;
}

.of {
  margin-left: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}

.bar-of {
  font-family: var(--font-text);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
}

.card-work {
  border-top-color: var(--yellow);
}

.muted {
  color: var(--muted);
}

.search {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search input[type="search"] {
  flex: 1 1 320px;
  max-width: 520px;
  font-family: var(--font-text);
  font-size: 1rem;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
}

.search input[type="search"]:focus {
  border-color: var(--red);
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.th-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  text-align: right;
}

.table-scroll-tall {
  max-height: 72vh;
}

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.88rem;
}

.grid th,
.grid td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.grid th:not(.wrap):not(.col-1):not(.col-2) {
  min-width: 96px;
}

.grid th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--red);
  border-right-color: rgba(255, 255, 255, 0.35);
  border-bottom: 0;
}

.grid th:last-child,
.grid td:last-child {
  border-right: 0;
}

.grid tbody tr:last-child td {
  border-bottom: 0;
}

.grid tbody tr:hover td {
  background: var(--red-light);
}

.grid .col-1,
.grid .col-2 {
  position: sticky;
  z-index: 2;
}

.grid th.col-1,
.grid th.col-2 {
  z-index: 4;
}

.grid-schools .col-1 {
  left: 0;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
}

.grid-schools .col-2 {
  left: 64px;
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  border-right: 2px solid var(--line);
}

.grid-directory .col-1 {
  left: 0;
  width: 72px;
  min-width: 72px;
  max-width: 72px;
}

.grid-directory .col-2 {
  left: 72px;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  border-right: 2px solid var(--line);
}

.grid-directory td.directory-aliases {
  min-width: 420px;
}

.grid-directory td.directory-aliases .badge {
  margin: 2px 4px 2px 0;
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.grid-directory .directory-name .hint {
  margin: 2px 0 0;
}

.grid-districts .col-1 {
  left: 0;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
}

.grid-districts .col-2 {
  left: 140px;
  width: 124px;
  min-width: 124px;
  max-width: 124px;
  border-right: 2px solid var(--line);
}

.grid .total-row td {
  background: var(--stripe);
  border-bottom: 2px solid var(--line);
}

.heat-1 {
  background: rgba(46, 158, 87, 0.07) !important;
}

.heat-2 {
  background: rgba(46, 158, 87, 0.14) !important;
}

.heat-3 {
  background: rgba(46, 158, 87, 0.22) !important;
}

.heat-4 {
  background: rgba(46, 158, 87, 0.32) !important;
}

.heat-5 {
  background: rgba(46, 158, 87, 0.44) !important;
  font-weight: 700;
}

.grid tbody tr:hover td.num[class*="heat-"] {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.break {
  word-break: break-word;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 130px;
  padding: 20px;
  border: 2px dashed var(--grey-bar);
  border-radius: 12px;
  background: var(--stripe);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--red);
  background: var(--red-light);
}

.dropzone:focus-within {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--green);
  background: var(--green-light);
}

.dropzone.is-bad {
  border-color: var(--red);
  background: var(--red-light);
}

.dropzone input.dropzone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}

.dropzone-text span {
  color: var(--muted);
  font-size: 0.9rem;
}

.dropzone-file {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.dropzone.is-bad .dropzone-file {
  color: var(--red-dark);
}

.check-inline {
  padding: 10px 0 0;
}

.check-inline:hover {
  background: transparent;
}

.cancel-form {
  margin-top: 12px;
}

td.col-name {
  min-width: 260px;
}

td.col-kpe {
  min-width: 120px;
  text-align: center;
}

td.col-variants {
  min-width: 300px;
}

td.col-variants .badge {
  margin: 3px 6px 3px 0;
}

td.col-variants .inline-form {
  display: block;
  margin: 3px 0;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--white);
}

.badge-red {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-light);
}

.badge-green {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

.summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.summary-item {
  flex: 1 1 200px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 8px;
  padding: 14px 18px;
}

.summary-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.1;
}

.summary-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.error-code {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 4rem;
  color: var(--red);
  line-height: 1;
  margin-bottom: 12px;
}

.center {
  text-align: center;
}

.code-input {
  font-family: var(--font-head);
  font-size: 1.6rem;
  letter-spacing: 0.3em;
  text-align: center;
}

.steps {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.steps li {
  margin-bottom: 6px;
}

.qr {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.qr img {
  width: 220px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.secret {
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  background: var(--stripe);
  padding: 10px 12px;
  border-radius: 8px;
}

.login-title {
  text-align: center;
  margin-bottom: 24px;
}

.mini-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.mini-form input[type="text"],
.mini-form input[type="password"],
.mini-form select {
  width: auto;
  min-width: 180px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .charts {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  html {
    font-size: 17px;
  }

  .container {
    padding: 20px 14px 48px;
  }

  .card {
    padding: 18px;
  }

  .btn-big {
    width: 100%;
  }

  .check {
    flex-wrap: wrap;
  }

  .kpi {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi .summary-item {
    padding: 10px 12px;
  }

  .kpi .summary-value {
    font-size: 1.3rem;
  }

  .grid .col-1,
  .grid .col-2 {
    position: static;
  }

  .grid-schools .col-1,
  .grid-districts .col-1 {
    min-width: 0;
  }

  .grid-schools .col-2 {
    min-width: 180px;
  }

  .table-scroll-tall {
    max-height: 65vh;
  }
}

.help ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.help li {
  margin-bottom: 8px;
}

.help .card p:last-child,
.help .card ul:last-child,
.help .card ol:last-child {
  margin-bottom: 0;
}
