/* Операторская панель — дизайн-система «Матрёшка», тема «Липа» (data-theme="lipa" на <html>).
   Блок токенов ниже скопирован из docs/design/matryoshka-handoff/design-system/tokens.css и
   DESIGN.md (Modal backdrop) — единственное место с литеральными цветами; дальше только var(). */
:root,
[data-theme="lipa"] {
  --bg: #f6efe2;
  --surface-100: #fffaf0;
  --surface-200: #eee3cf;
  --line: #d8cab2;
  --line-strong: #8c7b68;
  --ink: #1d1512;
  --ink-muted: #65554a;
  --kinovar: #c02a1a;
  --kinovar-text: #b12616;
  --kinovar-soft: #f7dccf;
  --on-kinovar: #fff6e8;
  --zoloto: #e3a93a;
  --zoloto-text: #855a07;
  --zoloto-soft: #f5e4bd;
  --on-zoloto: #1d1512;
  --malakhit: #18704a;
  --malakhit-soft: #d7eedf;
  --gzhel: #2a55c8;
  --gzhel-soft: #dde6fb;
  --focus: #2a55c8;
  --shadow-panel: 0 20px 40px -18px rgba(60, 32, 16, 0.28);
  --overlay: rgba(8, 6, 5, 0.62);
}
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 999px;
  --font-display: Unbounded, "Arial Black", sans-serif;
  --font-sans: Manrope, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

/* Базовые правила */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  color-scheme: light;
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px / 22px var(--font-sans);
}
a {
  color: var(--gzhel);
}
a:hover {
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-12));
  padding: var(--space-2) var(--space-3);
  background: var(--surface-100);
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  top: var(--space-4);
  z-index: 2;
}

/* Каркас: AdminSidebar + main */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 248px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--surface-100);
  border-right: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--space-2) 20px;
  color: var(--ink);
  text-decoration: none;
}
.brand svg {
  width: auto;
  height: 26px;
  flex-shrink: 0;
}
.brand b {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 20px;
}
.brand small {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 17px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px var(--space-3);
  border-radius: 12px; /* из макета AdminSidebar */
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--surface-200);
  color: var(--ink);
}
.nav svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.sidebar-user {
  margin-top: auto;
  padding: var(--space-3);
  border-radius: 12px; /* из макета AdminSidebar */
  background: var(--surface-200);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.sidebar-user b {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.main {
  flex-grow: 1;
  min-width: 0;
  padding: 28px var(--space-8);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.page-head {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 34px;
  font-weight: 700;
}
.lead {
  margin: 0;
  max-width: 640px;
  color: var(--ink-muted);
}
.caption {
  font-size: 12px;
  line-height: 17px;
}
.sidebar-user .caption {
  color: var(--ink-muted);
}
.note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 17px;
}
.eyebrow {
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

/* Card */
.card {
  background: var(--surface-100);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.dispute-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) 340px;
  gap: var(--space-4);
  align-items: start;
}
.column {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  flex-wrap: wrap;
}

/* Поля: TextField / Select / Textarea */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: var(--surface-200);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  font: 500 15px / 22px var(--font-sans);
  letter-spacing: 0;
}
.field input.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.field textarea {
  padding: var(--space-3) 14px;
  min-height: 88px;
  resize: vertical;
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--ink-muted);
  font-weight: 500;
}
.toolbar .field {
  flex: 1 1 320px;
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
fieldset:disabled .field {
  opacity: 0.6;
}

/* Button: primary (киноварь, одна на экран) и secondary */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-200);
  color: var(--ink);
  font: 700 15px / 20px var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
button:hover,
.btn:hover {
  border-color: var(--ink-muted);
  color: var(--ink);
}
button:active,
.btn:active {
  transform: translateY(1px);
}
.primary {
  background: var(--kinovar);
  color: var(--on-kinovar);
  border-color: transparent;
}
.primary:hover {
  filter: brightness(1.08);
  border-color: transparent;
  color: var(--on-kinovar);
}
.block {
  display: flex;
  width: 100%;
}
button:disabled {
  background: var(--surface-200);
  color: var(--ink-muted);
  border-color: var(--line);
  cursor: not-allowed;
  filter: none;
  transform: none;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.sidebar-user button {
  margin-top: var(--space-2);
  background: transparent;
  border-color: var(--line-strong);
}

/* Пары «подпись — значение» (карточка сделки, сводка операции) */
.details {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}
.details dt {
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.details dd {
  margin: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.details dd.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  line-height: 20px;
}

/* StatusBadge: иконка 14px + слово, подложка *-soft, текст одноимённым цветом */
.status-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 18px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-200);
  color: var(--ink-muted);
}
.status-badge:empty {
  display: none;
}
.status-badge::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: var(--radius-full);
  font: 700 10px / 11px var(--font-sans);
  text-align: center;
}
.status-pending {
  background: var(--zoloto-soft);
  color: var(--zoloto-text);
}
.status-pending::after {
  /* стрелки часов внутри кольца */
  content: "";
  position: absolute;
  left: 14px;
  top: 7px;
  width: 4px;
  height: 5px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}
.status-success {
  background: var(--malakhit-soft);
  color: var(--malakhit);
}
.status-success::before {
  width: 5px;
  height: 9px;
  border-width: 0 1.75px 1.75px 0;
  border-radius: 0;
  transform: rotate(45deg);
  margin: 0 5px 2px 4px;
}
.status-fail {
  background: var(--kinovar-soft);
  color: var(--kinovar-text);
}
.status-fail::before {
  content: "!";
}
.status-info,
.status-unknown {
  background: var(--gzhel-soft);
  color: var(--gzhel);
}
.status-info::before,
.status-neutral::before {
  content: "i";
}
.status-neutral {
  background: var(--surface-200);
  color: var(--ink-muted);
}
.status-unknown::before {
  /* слои */
  height: 1.5px;
  border: 0;
  border-radius: 0;
  background: currentColor;
  box-shadow:
    0 -4px 0 currentColor,
    0 4px 0 currentColor;
}

/* Notice: мягкая подложка со значком, без полосы слева */
#notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--gzhel-soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}
#notice:empty {
  display: none;
}
#notice::before {
  content: "i";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1.5px solid var(--gzhel);
  border-radius: var(--radius-full);
  color: var(--gzhel);
  font: 700 11px / 15px var(--font-sans);
  text-align: center;
}
#notice.error {
  background: var(--kinovar-soft);
}
#notice.error::before {
  content: "!";
  border-color: var(--kinovar-text);
  color: var(--kinovar-text);
}
#pending-status:empty {
  display: none;
}
#pending-status {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-200);
  font-size: 14px;
  line-height: 20px;
}

/* Переписка и доказательства */
.conversation-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}
.conversation-columns article {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.conversation-columns h3 {
  margin: 0;
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.conversation-entry {
  display: grid;
  grid-template-columns: 6em minmax(0, 1fr);
  gap: 2px var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.conversation-entry p {
  margin: 0;
  grid-column: 2;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 20px;
}
.conversation-entry .entry-time {
  grid-column: 1;
  grid-row: 1;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 20px;
  white-space: normal;
}
.conversation-entry .entry-author {
  grid-row: 1;
  font-weight: 700;
  color: var(--ink);
}
.conversation-entry .entry-author small {
  display: block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 17px;
  font-weight: 500;
  color: var(--ink-muted);
}
.conversation-entry a {
  grid-column: 2;
  justify-self: start;
  font-size: 14px;
  font-weight: 700;
}
.conversation-entry .entry-hash {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 17px;
}

/* DataTable (остановки) */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table caption {
  caption-side: top;
  text-align: left;
  padding: 0 0 var(--space-2);
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 16px;
}
.table th {
  text-align: left;
  padding: 10px var(--space-4);
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}
.table td:first-child {
  font-weight: 700;
}
.table td:nth-child(4) {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-muted);
}
.table th:last-child,
.table td:last-child {
  text-align: right;
}
.table td button {
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  font-size: 14px;
  white-space: nowrap;
}

/* Modal (dialog остановки) */
dialog {
  width: min(440px, calc(100vw - var(--space-8)));
  padding: var(--space-6);
  background: var(--surface-100);
  color: var(--ink);
  border: 2px solid var(--kinovar);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}
dialog::backdrop {
  background: var(--overlay);
}
.dialog form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.dialog h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
}
.dialog h2::before {
  content: "!";
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 1.75px solid var(--kinovar-text);
  border-radius: var(--radius-full);
  color: var(--kinovar-text);
  font: 700 12px / 17px var(--font-sans);
  text-align: center;
}
.dialog p {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}
#halt-dialog-scope {
  font-weight: 700;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.dialog-actions .primary {
  flex-grow: 1;
}

/* Подвал */
footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 17px;
}

/* Адаптив: ≤1024 — сайдбар сверху, одна колонка; ≤640 — таблица в карточки, модалка снизу */
@media (max-width: 1024px) {
  .shell {
    flex-direction: column;
  }
  .sidebar {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    padding: 0;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-user {
    margin-top: 0;
    margin-left: auto;
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
  }
  .sidebar-user button {
    margin-top: 0;
  }
  .main {
    padding: var(--space-6) var(--space-4);
  }
  .dispute-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .sidebar-user {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }
  .table thead {
    display: none;
  }
  .table tr {
    display: block;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
  }
  .table td {
    display: block;
    border: 0;
    padding: var(--space-1) 0;
    text-align: left;
  }
  .table td:last-child {
    text-align: left;
    padding-top: var(--space-2);
  }
  .table td[data-heading]::before {
    content: attr(data-heading) ": ";
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-sans);
  }
  dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-width: 2px 0 0;
  }
}
/* Скрытые элементы: (0,2,0) перекрывает display у любых классов без !important. */
[hidden][hidden] {
  display: none;
}
