/* ===================================================================
   Дизайн-система «Дрова» — по стилю портала portal.belgosles.by.
   Шрифты системные: внешние файлы и CDN не подключаем
   (требование об отсутствии трансграничной передачи).
   =================================================================== */

:root {
  /* фирменная палитра портала «Леса Беларуси» */
  --brand: #346446;
  --brand-dark: #26492f;
  --brand-light: #4a7d5c;
  --surface-page: #f5fff7;
  --surface-head: #ebf5ee;
  --surface-accent: #d9eddf;
  --surface-card: #ffffff;
  --ink: #0f0f0f;
  --ink-soft: #4a5a4f;
  --ink-muted: #7b8a80;
  --line: #cfe3d6;
  --line-strong: #a9c9b5;

  --ok: #2e7d46;
  --warn: #a86a13;
  --danger: #b3261e;
  --info: #2b5d8a;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-card: 0 40px 0 0;
  --shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.12);
  --shadow-pop: 0 8px 28px rgba(15, 40, 25, 0.16);

  --gap: 16px;
  --maxw: 1280px;
  --font: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-page);
}

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 700; line-height: 1.2; }
h1 { font-size: 34px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
h4 { font-size: 17px; }
p { margin: 0 0 12px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
.container-wide { max-width: 1660px; }

/* ------------------------------------------------------------ шапка */
.site-header {
  background: var(--surface-head);
  border-bottom: 1px solid var(--line);
}
.site-header .bar {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 76px;
  padding: 12px 24px;
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 42px; height: 42px; flex: none; }
.brand-text {
  font-weight: 700;
  line-height: 1.15;
  font-size: 15px;
  color: var(--ink);
}
.brand-text span { display: block; font-weight: 500; color: var(--brand); }
.site-nav { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink);
  font-weight: 500;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--brand); text-decoration: none; }
.site-nav a.active { color: var(--brand); border-bottom-color: var(--brand); }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* --------------------------------------------------------------- hero */
.hero {
  background: var(--surface-accent);
  border-radius: var(--radius-card);
  padding: 40px;
  margin: 28px 0;
}
.hero h1 { font-size: 40px; max-width: 22ch; }
.hero p { font-size: 17px; max-width: 68ch; color: var(--ink-soft); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

/* ------------------------------------------------------------- кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 22px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
.btn:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 2px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { font-size: 16px; padding: 14px 30px; min-height: 52px; }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-ghost:hover { background: var(--surface-accent); color: var(--brand-dark); }
.btn-quiet { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--surface-head); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f1e17; }
.btn-sm { font-size: 13px; padding: 6px 14px; min-height: 34px; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------ карточки */
.card {
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-accent { background: var(--surface-accent); border-color: var(--line-strong); }
.card h2, .card h3 { margin-top: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

/* --------------------------------------------------------------- формы */
.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 24px;
  margin-bottom: 20px;
}
.form-section > legend,
.form-section .section-title {
  font-size: 19px;
  font-weight: 700;
  padding: 0;
  margin-bottom: 4px;
}
.section-hint { color: var(--ink-soft); font-size: 14px; margin-bottom: 18px; }
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  margin-right: 10px;
}
.field { margin-bottom: 18px; }
.field > label,
.field-label {
  display: block;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 6px;
}
.req { color: var(--danger); }
.hint { display: block; color: var(--ink-muted); font-size: 13px; margin-top: 6px; }

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
select, textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(52, 100, 70, .18);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(179, 38, 30, .12);
}
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; font-weight: 500; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 20;
  padding: 8px 14px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-head);
  margin-bottom: 14px;
}
.check input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}
.check label { font-size: 15px; line-height: 1.45; }

.radio-cards { display: grid; gap: 10px; }
.radio-cards.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.radio-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fff;
  cursor: pointer;
}
.radio-card:hover { border-color: var(--brand); background: var(--surface-page); }
.radio-card input { accent-color: var(--brand); width: 20px; height: 20px; margin-top: 2px; }
.radio-card.selected { border-color: var(--brand); background: var(--surface-accent); }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

/* -------------------------------------------------------------- таблицы */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; vertical-align: top; }
table.data thead th {
  background: var(--surface-head);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:hover { background: var(--surface-page); }
table.data tbody tr:last-child { border-bottom: none; }
table.data td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-link { color: var(--brand); font-weight: 600; }

/* --------------------------------------------------------------- статусы */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-new { background: #e8f0fb; color: #23507f; border-color: #c3d8f2; }
.badge-sent { background: #e6f2ea; color: #24603c; border-color: #bcdcc8; }
.badge-in_work { background: #fdf1dc; color: #8a5a10; border-color: #f0d8ac; }
.badge-done { background: #dff2e4; color: #1e6b36; border-color: #b3ddc0; }
.badge-rejected { background: #fbe6e5; color: #9b241d; border-color: #f0c2bf; }
.badge-cancelled { background: #eceff0; color: #59636a; border-color: #d5dcdf; }
.badge-send_error { background: #fdece6; color: #9c4a1a; border-color: #f3ceb9; }
.badge-quiet { background: var(--surface-head); color: var(--ink-soft); border-color: var(--line); }

/* -------------------------------------------------------------- плашки */
.alert {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface-head);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.alert-ok { border-left-color: var(--ok); background: #edf7f0; }
.alert-warn { border-left-color: var(--warn); background: #fdf6e8; }
.alert-error { border-left-color: var(--danger); background: #fbeceb; }
.alert h3 { margin-bottom: 6px; }
.alert p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------- показатели */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat .value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.stat.accent { background: var(--surface-accent); border-color: var(--line-strong); }

/* ---------------------------------------------------------- определения */
dl.kv { margin: 0; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 8px 16px; }
dl.kv dt { color: var(--ink-soft); font-size: 14px; }
dl.kv dd { margin: 0; font-size: 15px; word-break: break-word; }

/* ------------------------------------------------------------- лента */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 24px;
  border-left: 2px solid var(--line);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand);
}
.timeline .when { font-size: 13px; color: var(--ink-muted); }
.timeline .what { font-weight: 500; }
.timeline .who { font-size: 13px; color: var(--ink-soft); }
.timeline .details { font-size: 14px; white-space: pre-wrap; }

/* ------------------------------------------------------------- фильтры */
.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}
.filters .field { margin-bottom: 0; }
.filters .actions { display: flex; gap: 8px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 18px 0; flex-wrap: wrap; }
.pager .page {
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}
.pager .page.current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager .page:hover { text-decoration: none; border-color: var(--brand); }

/* --------------------------------------------------------------- прочее */
.muted { color: var(--ink-muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.track-code {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--brand);
  background: var(--surface-accent);
  border-radius: var(--radius);
  padding: 10px 18px;
  display: inline-block;
}
.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 16px;
  color: var(--ink);
  font-weight: 500;
  margin: 0 10px 10px 0;
}
.doc-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

main { padding-bottom: 48px; min-height: 60vh; }
.page-title { margin: 24px 0 18px; }
.breadcrumbs { font-size: 14px; color: var(--ink-muted); margin: 18px 0 6px; }
.breadcrumbs a { color: var(--ink-soft); }

/* ---------------------------------------------------------------- подвал */
.site-footer {
  background: var(--brand);
  color: #fff;
  padding: 32px 0 24px;
  margin-top: 40px;
}
.site-footer a { color: #fff; text-decoration: underline; }
.site-footer .cols { display: grid; gap: 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.site-footer h4 { color: #fff; font-size: 15px; }
.site-footer p, .site-footer li { font-size: 14px; opacity: .92; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.footer-note {
  border-top: 1px solid rgba(255, 255, 255, .25);
  margin-top: 22px;
  padding-top: 14px;
  font-size: 13px;
  opacity: .85;
}

/* ------------------------------------------------------------ адаптив */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 780px) {
  h1 { font-size: 27px; }
  .hero { padding: 24px; border-radius: 0 24px 0 0; }
  .hero h1 { font-size: 28px; }
  .grid-2, .grid-3, .grid-4, .stat-grid, .radio-cards.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .site-footer .cols { grid-template-columns: minmax(0, 1fr); }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  dl.kv dd { margin-bottom: 10px; }
  .site-header .bar { flex-wrap: wrap; min-height: 0; }
  .site-nav { margin-left: 0; width: 100%; gap: 14px; }
  .container { padding: 0 16px; }
}

@media print {
  .site-header, .site-footer, .office-side, .office-top, .no-print { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
}

/* Мелкие уточнения вёрстки */
.opt { color: var(--ink-muted); font-weight: 400; font-size: 13px; }
.brand-text { line-height: 1.25; }
.brand-text strong { display: block; white-space: nowrap; }
.brand-text span { display: block; white-space: nowrap; }
.stat > span { display: block; color: var(--ink-soft); font-size: 14px; }
.stat > strong { display: block; font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.brand-block .brand-text strong { font-weight: 700; }
.check label .req { white-space: nowrap; }
