:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #67707e;
  --line: #e4e8ee;
  --accent: #2563eb;
  --accent-soft: #eaf1fe;
  --ok: #16a34a;
  --ok-soft: #e8f6ed;
  --err: #dc2626;
  --err-soft: #fdecec;
  --code-bg: #f0f3f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
       "Helvetica Neue", Arial, sans-serif;
}

/* ---------- шапка ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.brand span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--code-bg);
  padding: 2px 8px;
  border-radius: 999px;
}
nav { display: flex; gap: 4px; margin-left: auto; }
nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
}
nav a:hover { background: var(--code-bg); color: var(--ink); }
nav a.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- каркас ---------- */
.container {
  max-width: 1000px;
  margin: 24px auto 48px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(20, 30, 50, .06);
}
.card h1 { margin: 0 0 12px; font-size: 21px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.hint { color: var(--muted); margin: 0 0 14px; }

/* ---------- формы ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; }
textarea, .find-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font: inherit;
  background: #fbfcfe;
  color: var(--ink);
}
textarea:focus, .find-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.find-form { display: flex; gap: 8px; }
.find-form input { flex: 1; }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: #c9d2de; background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* ---------- оповещения ---------- */
.banner {
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 500;
}
.banner.error { background: var(--err-soft); color: var(--err); }

/* ---------- результат классификации ---------- */
.best-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.code-big { font-size: 26px; font-weight: 700; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.prob-big { margin-left: auto; font-size: 22px; font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--code-bg);
  color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.soft { background: var(--accent-soft); color: var(--accent); }

.path { margin: 6px 0; color: var(--muted); line-height: 1.45; display: flex; flex-wrap: wrap; gap: 2px; align-items: baseline; }
.path .lvl {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  display: inline-block;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.path .lvl:hover { text-decoration: underline; }
.path .arrow { color: #b6bec9; flex-shrink: 0; }

.desc { margin: 4px 0 10px; font-size: 16px; }
.meta { color: var(--muted); margin: 6px 0; }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.code-link {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-decoration: none;
}
.code-link:hover { text-decoration: underline; }
.name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-side { display: flex; align-items: center; gap: 10px; width: 260px; flex-shrink: 0; }
.bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #e9edf3;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.pct { width: 52px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- дерево ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 0 4px; line-height: 1.35; }
.crumbs a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  display: inline-block;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: #b6bec9; margin: 0 1px; flex-shrink: 0; }

.node-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

.tree-list { display: flex; flex-direction: column; gap: 4px; }
.tree-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.tree-row:last-child { border-bottom: none; }
.tree-row:hover { background: var(--accent-soft); }
.tree-row.current {
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
  position: relative;
  z-index: 1;
}
.tree-code {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-tariff { color: var(--muted); font-size: 13px; flex-shrink: 0; }

/* ---------- примечания ---------- */
.notes { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; background: #fbfcfe; }
.notes summary { cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--accent); }
.note-line { margin: 5px 0; line-height: 1.5; }
.note-h {
  margin: 12px 0 4px;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: .4px;
  color: var(--ink);
}
.note-hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.tnved-code {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 1px 5px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: .92em;
  white-space: nowrap;
}

/* ---------- сокращение ---------- */
.short-out { font-size: 19px; font-weight: 600; margin: 6px 0 12px; }

.tok-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tok-table th { text-align: left; color: var(--muted); font-size: 13px; padding: 4px 6px; }
.tok-table td { padding: 3px 6px; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line); }
.tok-table td.keep { color: var(--ok); font-weight: 600; }
.tok-table td.drop { color: #a5adba; text-decoration: line-through; }

.footer {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 20px 28px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .row { flex-direction: column; align-items: stretch; gap: 8px; }
  .row-side { width: 100%; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
}

/* ---------- API docs ---------- */
.api-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.api-table th, .api-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.api-table th { background: #f2f5fa; }
.api-pre {
  background: #0f172a;
  color: #dbeafe;
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
}
.api-list { margin: 6px 0; padding-left: 18px; }
.api-list li { margin: 4px 0; }
