:root {
  color-scheme: light;
  --canvas: #f5f6f2;
  --surface: #fff;
  --surface-subtle: #f9faf7;
  --ink: #202820;
  --muted: #6b756c;
  --line: #dde3dc;
  --line-strong: #cbd4ca;
  --green: #24583e;
  --green-dark: #19442f;
  --green-pale: #e8f2e9;
  --red: #a54136;
  --red-pale: #fff0ed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--green);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--green-dark);
}

:focus-visible {
  outline: 3px solid #81ad8c;
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100svh;
  min-height: 570px;
  padding: 32px 18px 22px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 12px 29px;
}

.brand__eyebrow,
.eyebrow {
  display: block;
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .11em;
  line-height: 1.35;
  text-transform: uppercase;
}

.brand__name {
  color: var(--ink);
  font-size: 17px;
  font-weight: 710;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.sidebar__nav {
  display: grid;
  gap: 4px;
}

.sidebar__nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #4d5a50;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .16s ease, color .16s ease;
}

.sidebar__nav a:hover,
.sidebar__nav a.is-active {
  color: var(--green-dark);
  background: var(--green-pale);
}

.sidebar__account {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  margin-top: auto;
  padding: 18px 12px 0;
  border-top: 1px solid var(--line);
}

.sidebar__username {
  font-weight: 700;
}

.sidebar__role {
  color: var(--muted);
  font-size: 13px;
}

.sidebar__account form {
  margin-top: 10px;
}

.workspace {
  min-width: 0;
  width: min(100%, 1480px);
  padding: 44px clamp(28px, 4.4vw, 74px) 80px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.page-heading h1 {
  margin: 8px 0 7px;
  font-size: clamp(31px, 3.7vw, 43px);
  font-weight: 710;
  letter-spacing: -.045em;
  line-height: 1.12;
}

.page-heading__description {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
}

.page-heading--item {
  align-items: center;
  margin-bottom: 34px;
}

.count-badge {
  flex: none;
  margin-bottom: 3px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: #57625a;
  background: var(--surface);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.notice-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.notice {
  padding: 12px 16px;
  border-left: 3px solid var(--green);
  border-radius: 5px;
  background: var(--green-pale);
  color: var(--green-dark);
}

.notice--error,
.notice--danger {
  border-left-color: var(--red);
  background: var(--red-pale);
  color: var(--red);
}

.sync-strip {
  display: flex;
  align-items: center;
  min-height: 104px;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 35px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--surface);
}

.sync-strip h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.sync-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.sync-strip .text-error {
  margin-top: 7px;
  color: var(--red);
}

.sync-strip form {
  flex: none;
}

.section {
  margin: 0 0 42px;
}

.section--narrow {
  max-width: 510px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 710;
  letter-spacing: -.025em;
}

.section-heading p {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 16px 17px;
  border-top: 1px solid #edf0eb;
  color: #515b53;
  vertical-align: middle;
}

.data-table tbody tr:first-child td {
  border-top: 0;
}

.data-table tbody tr:hover {
  background: #fafbf8;
}

.data-table__primary {
  color: var(--ink) !important;
  font-weight: 680;
}

.data-table__action {
  text-align: right;
  white-space: nowrap;
}

.data-table--audit {
  min-width: 820px;
}

.data-table--audit td:last-child {
  max-width: 380px;
}

.data-table code {
  display: block;
  max-height: 110px;
  overflow: auto;
  color: #506052;
  font-size: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.inline-link {
  font-weight: 680;
  text-decoration: none;
}

.inline-link span {
  display: inline-block;
  margin-left: 2px;
  transition: transform .16s ease;
}

.inline-link:hover span {
  transform: translateX(3px);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status--active {
  color: var(--green);
  background: var(--green-pale);
}

.status--inactive {
  color: #6f756f;
  background: #eef0ed;
}

.empty-state {
  padding: 42px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.breadcrumb {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb a {
  font-weight: 650;
  text-decoration: none;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 290px);
  align-items: start;
  gap: clamp(28px, 4.2vw, 64px);
}

.editor-grid__main {
  min-width: 0;
}

.form-stack {
  display: grid;
  gap: 20px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span,
.fieldset legend {
  color: #344337;
  font-size: 13px;
  font-weight: 700;
}

.field input:not([type="file"]),
.field select,
.field textarea {
  display: block;
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(25, 44, 28, .025);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.field input:not([type="file"]):focus,
.field select:focus,
.field textarea:focus {
  border-color: #6b9a73;
  box-shadow: 0 0 0 3px rgba(107, 154, 115, .18);
}

.field textarea {
  min-height: 150px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a0aaa1;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.field--short {
  max-width: 220px;
}

.page-copy-form {
  max-width: 820px;
}

.field__readout {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #48564b;
  background: var(--surface-subtle);
}

.fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset legend {
  margin-bottom: 11px;
  padding: 0;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
}

.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

.checkbox-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--green);
}

.form-actions {
  padding-top: 5px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button--primary {
  color: #fff;
  background: var(--green);
}

.button--primary:hover {
  color: #fff;
  background: var(--green-dark);
}

.button--secondary {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--surface);
}

.button--secondary:hover {
  border-color: #9baa9b;
  background: var(--surface-subtle);
}

.button--wide {
  width: 100%;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--green);
  background: none;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover {
  color: var(--green-dark);
}

.text-button--danger {
  color: var(--red);
}

.text-button--danger:hover {
  color: #772a24;
}

.source-panel {
  position: sticky;
  top: 30px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.source-panel h2 {
  margin: 5px 0 16px;
  font-size: 21px;
  letter-spacing: -.025em;
}

.facts-list {
  margin: 0;
}

.facts-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid #edf0eb;
  font-size: 13px;
}

.facts-list dt {
  flex: none;
  color: var(--muted);
}

.facts-list dd {
  margin: 0;
  font-weight: 660;
  text-align: right;
  overflow-wrap: anywhere;
}

.source-panel__note {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.media-list {
  border-top: 1px solid var(--line);
}

.media-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 106px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.media-row img {
  width: 118px;
  height: 82px;
  flex: none;
  border-radius: 5px;
  object-fit: cover;
  background: var(--surface-subtle);
}

.media-row__body {
  min-width: 0;
  flex: 1;
}

.media-row__label {
  color: var(--green);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.media-row p {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.muted-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 21px;
}

.upload-form input[type="file"] {
  width: 100%;
  min-height: 43px;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}

.upload-form input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
}

.admin-page--login {
  display: grid;
  min-height: 100svh;
  place-items: center;
}

.login-workspace {
  width: min(100%, 460px);
  padding: 28px;
}

.login-panel {
  padding: clamp(24px, 5vw, 36px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 48px rgba(33, 55, 36, .05);
}

.login-panel__heading {
  margin-bottom: 25px;
}

.login-panel h1 {
  margin: 10px 0 5px;
  font-size: 30px;
  font-weight: 710;
  letter-spacing: -.04em;
  line-height: 1.15;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1120px) {
  .upload-form {
    grid-template-columns: 1fr 1fr;
  }

  .upload-form .button {
    justify-self: start;
  }
}

@media (max-width: 930px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto;
    align-items: center;
    height: auto;
    min-height: 0;
    padding: 14px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0;
  }

  .sidebar__nav {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 2px;
    margin-top: 12px;
  }

  .sidebar__nav a {
    padding: 8px 11px;
    font-size: 13px;
  }

  .sidebar__account {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 11px;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar__role {
    display: none;
  }

  .sidebar__account form {
    margin: 0;
  }

  .workspace {
    padding: 35px 28px 65px;
  }
}

@media (max-width: 720px) {
  .editor-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .editor-grid__side { margin-top: 30px; }

  .source-panel {
    position: static;
  }

  .facts-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
  }

  .page-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .data-table {
    min-width: 670px;
  }

  .data-table--objects { min-width: 0; }
  .data-table--objects thead,
  .data-table--queue thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .data-table--objects tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 12px;
    padding: 15px;
    border-top: 1px solid var(--line);
  }
  .data-table--objects tbody tr:first-child { border-top: 0; }
  .data-table--objects td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .data-table--objects td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .data-table--objects td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12px; }
  .data-table--objects td:nth-child(3) { grid-column: 1; grid-row: 3; font-size: 12px; }
  .data-table--objects td:nth-child(4) { grid-column: 2; grid-row: 1; }
  .data-table--objects td:nth-child(5) { grid-column: 2; grid-row: 2 / span 2; align-self: end; }

  .data-table--queue { min-width: 0; }
  .data-table--queue tbody tr { display: grid; padding: 15px; border-top: 1px solid var(--line); }
  .data-table--queue tbody tr:first-child { border-top: 0; }
  .data-table--queue td { display: block; min-width: 0; padding: 2px 0; border: 0; overflow-wrap: anywhere; }
  .data-table--queue td:nth-child(1) { font-weight: 650; }
  .data-table--queue td:nth-child(2)::before { content: "Создана: "; color: var(--muted); }
  .data-table--queue td:nth-child(3)::before { content: "Попытки: "; color: var(--muted); }
  .data-table--queue td:nth-child(4)::before { content: "Ошибка: "; color: var(--muted); }

  .upload-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .sidebar {
    padding: 14px 16px 9px;
  }

  .brand__name {
    font-size: 15px;
  }

  .sidebar__username {
    display: none;
  }

  .sidebar__nav {
    overflow-x: auto;
    margin: 11px -3px 0;
    white-space: nowrap;
  }

  .workspace {
    padding: 28px 17px 50px;
  }

  .page-heading {
    margin-bottom: 26px;
  }

  .sync-strip,
  .source-panel {
    padding: 17px;
  }

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

  .facts-list {
    grid-template-columns: 1fr;
  }

  .media-row {
    flex-wrap: wrap;
  }

  .media-row img {
    width: 100px;
    height: 74px;
  }

  .media-row form {
    width: 100%;
    padding-left: 116px;
  }

  .login-workspace {
    padding: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
