:root {
  --bg: #0f1115;
  --bg2: #161a21;
  --card: #1b2029;
  --card2: #20262f;
  --line: #2b323d;
  --text: #e6e9ef;
  --muted: #9aa4b2;
  --accent: #4c8dff;
  --accent2: #2f6fe0;
  --ok: #37b26c;
  --warn: #d9a13b;
  --bad: #e05d5d;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 17px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- шапка ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 22px; }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  background: var(--card2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.pill-ok { color: var(--ok); border-color: #24543c; }
.pill-bad { color: var(--bad); border-color: #5a2b2b; }

/* ---------- раскладка ---------- */
.layout {
  display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
  gap: 16px; padding: 16px; align-items: start;
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-right { position: sticky; top: 74px; max-height: calc(100vh - 90px); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.card-grow { flex: 1; min-height: 320px; overflow: hidden; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- поля ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit;
}
input[type=file] { color: var(--muted); font-size: 12px; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { min-width: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--text); }
.check input { margin-top: 2px; }
.check span small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.hint { font-size: 11.5px; color: var(--muted); }

/* ---------- кнопки ---------- */
button {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: .12s;
}
button:hover:not(:disabled) { border-color: #3d4757; background: #262d38; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent2); }
button.danger { color: var(--bad); border-color: #4a2a2a; }
button.ghost { background: transparent; }
button.tiny { padding: 4px 8px; font-size: 11.5px; border-radius: 6px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns-right { justify-content: flex-end; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button.on { border-color: var(--accent); color: #cfe0ff; background: #1d2942; }

/* ---------- зона загрузки ---------- */
.drop {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 10px;
  text-align: center; color: var(--muted); font-size: 12px; transition: .15s;
}
.drop.hot { border-color: var(--accent); background: #17203380; color: var(--text); }
.count-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.count { font-weight: 600; color: var(--text); }
.count.bad { color: var(--bad); }

/* ---------- прогресс ---------- */
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #6fd3a3); transition: width .3s; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; font-size: 12px; color: var(--muted);
}
.chip b { color: var(--text); font-size: 13px; }
.chip.ok b { color: var(--ok); }
.chip.bad b { color: var(--bad); }
.chip.warn b { color: var(--warn); }

/* ---------- таблица ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; flex: 1; min-height: 200px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  position: sticky; top: 0; background: var(--card2); z-index: 2; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .03em; color: var(--muted); cursor: pointer; white-space: nowrap;
}
tbody tr:hover { background: #1f2531; }
tbody tr.row-error { background: #2a1e20; }
tbody tr.row-blocked { background: #2a2418; }
td.url { max-width: 320px; word-break: break-all; font-family: var(--mono); font-size: 11.5px; }
/* Список обхода: колонок много, без минимальной ширины URL сжимается в столбик по букве */
.tree-wrap table { min-width: 1480px; }
.tree-wrap td.url { min-width: 260px; max-width: 340px; }
.tree-wrap td.text { min-width: 110px; }
td.num { white-space: nowrap; color: var(--muted); }
td.text { max-width: 340px; }
.cell-title { display: block; max-height: 34px; overflow: hidden; }
.len { color: var(--muted); font-size: 11px; }
.len.bad { color: var(--bad); }
.len.warn { color: var(--warn); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.s2 { background: #1d3a28; color: var(--ok); }
.badge.s3 { background: #23364d; color: #7fb1ff; }
.badge.s4, .badge.s5 { background: #43221f; color: var(--bad); }
.badge.s0 { background: #3a3a22; color: var(--warn); }
.detail td { background: #151a22; font-size: 12px; color: var(--muted); }
.detail pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 11.5px; color: var(--text); }
.detail .k { color: var(--muted); }
.seq { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------- вкладки режимов ---------- */
.tabs { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.tab:hover { color: var(--text); background: #1d232e; }
.tab.on { background: var(--card2); color: var(--text); border-color: var(--line); font-weight: 600; }
.tab-icon { margin-right: 6px; }

/* ---------- дерево адресов ---------- */
.tree-wrap { padding: 6px 4px; }
.tree-row {
  display: flex; align-items: baseline; gap: 8px; padding: 3px 6px; border-radius: 6px;
  font-size: 12.5px; min-width: 0;
}
.tree-row:hover { background: #1f2531; }
.tree-dir { color: var(--muted); font-weight: 600; }
.tree-name { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.tree-title { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ссылки ---------- */
a { color: #cfdcf5; text-decoration: none; }
a:visited { color: #cfdcf5; }
a:hover { color: #ffffff; text-decoration: underline; }
td.url a, td.url a:visited { color: #d3dffa; }
td.url a:hover { color: #ffffff; }

/* ---------- прочее ---------- */
.spinner {
  width: 13px; height: 13px; border: 2px solid #ffffff40; border-top-color: #fff;
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 13px; }
details.group > summary {
  cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 0; list-style: none;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "▸ "; }
details.group[open] > summary::before { content: "▾ "; }
.hidden { display: none !important; }
.list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
}
.item .t { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.on { border-color: var(--accent); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text] { max-width: 220px; }
.log { font-family: var(--mono); font-size: 11.5px; color: var(--muted); max-height: 90px; overflow: auto; }
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .col-right { position: static; max-height: none; }
}
