:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e7eef7;
  --muted: #8b9bb0;
  --accent: #3d9cf0;
  --line: #2a3544;
  --ok: #3ecf8e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2a3d, var(--bg));
  color: var(--text);
  min-height: 100vh;
}
.top {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15,20,25,.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}
.brand {
  font-weight: 700;
  letter-spacing: .04em;
  font-size: 1.25rem;
}
nav { display: flex; gap: 1rem; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: .35rem .6rem;
  border-radius: 6px;
}
nav a.active, nav a:hover { color: var(--text); background: var(--panel); }
main {
  padding: 1.25rem 1.5rem 2rem;
  max-width: min(1800px, 100%);
  margin: 0 auto;
  width: 100%;
}
.hidden { display: none; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 1rem; }
.subhead {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 .75rem;
  color: var(--text);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stats-5 { grid-template-columns: repeat(5, 1fr); }
.stats-6 { grid-template-columns: repeat(6, 1fr); }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
}
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; margin-top: .35rem; font-variant-numeric: tabular-nums; line-height: 1.25; }
#st-done { font-size: 1.25rem; }
.stats-5 .stat .value { font-size: 1.35rem; }
.bar {
  margin-top: 1rem;
  height: 10px;
  background: var(--panel);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width .4s ease;
}
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.grid {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
.grid th, .grid td {
  text-align: left;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
  vertical-align: top;
}
.grid th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.grid td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: rgba(61,156,240,.08); }
.grid tbody tr:last-child td { border-bottom: 0; }
.btn {
  margin-top: 1rem;
  background: var(--accent);
  color: #041018;
  border: 0;
  border-radius: 8px;
  padding: .55rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.search-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-row input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: .6rem .8rem;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121820;
  color: var(--text);
  width: min(900px, 92vw);
  padding: 1rem 1.2rem;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
}
#detail-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .82rem;
  max-height: 70vh;
  overflow: auto;
  background: #0c1016;
  padding: 1rem;
  border-radius: 8px;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1rem;
}
.crawl-state {
  min-width: 7rem;
  padding: .35rem .7rem;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.crawl-state.running { color: var(--ok); border-color: var(--ok); }
.crawl-state.stopped { color: #e8a45c; border-color: #e8a45c; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.controls .btn { margin-top: 0; }
.lanes-wrap { margin-top: .25rem; }
.workers-wrap { margin-top: .25rem; }
.grid.lanes { min-width: 900px; }
.grid.lanes tbody tr { cursor: default; }
.grid.workers { min-width: 640px; }
.grid.workers tbody tr { cursor: default; }
.grid td.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .85rem;
  word-break: break-all;
}
.muted { color: var(--muted); }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.25rem;
  margin-bottom: .75rem;
}
.page-head h1 { margin: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.toolbar .btn { margin-top: 0; }
.bottom-toolbar { margin-top: 1rem; }
.pager-meta {
  color: var(--muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  margin-left: .25rem;
}
.page-note {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.45;
  margin: 0 0 1rem;
  max-width: 70rem;
}
.page-note code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .85em;
  color: var(--text);
  background: rgba(61,156,240,.12);
  padding: .1rem .35rem;
  border-radius: 4px;
}
.domains-summary { margin-bottom: 1rem; }
.stat .value-sm { font-size: 1.15rem; }
.stat .hint {
  color: var(--muted);
  font-size: .8rem;
  margin-top: .4rem;
  line-height: 1.35;
}
.sticky-head { max-height: min(70vh, 900px); overflow: auto; }
.sticky-head thead th {
  position: sticky;
  top: 0;
  background: #1e2833;
  z-index: 1;
  box-shadow: 0 1px 0 var(--line);
}
.skip-box { margin: .75rem 0 1rem; }
.skip-box > .label { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .9rem; }
.skip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: .35rem .75rem;
  max-width: 56rem;
}
.skip-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .88rem;
  color: var(--text);
}
.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: .65rem 1.25rem;
  max-width: 56rem;
  margin-bottom: 2rem;
}
.settings-form .subhead {
  grid-column: 1 / -1;
  margin: .75rem 0 .15rem;
  font-size: 1rem;
  font-weight: 600;
}
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .88rem;
  color: var(--muted);
}
.settings-form label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: .5rem;
}
.settings-form .controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .5rem;
}
.settings-form .input { width: 100%; }
.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin: .5rem 0;
}
@media (max-width: 1100px) {
  .stats-5, .stats-6 { grid-template-columns: repeat(3, 1fr); }
  .stats-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .stats, .stats-3, .stats-4, .stats-5, .stats-6 { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}

.input.narrow { width: 5.5rem; }
.analyze-opts { flex-wrap: wrap; gap: .75rem 1rem; }
.prompt-label {
  display: block;
  margin: 1rem 0 .4rem;
  color: var(--muted);
  font-size: .9rem;
}
.prompt-area {
  width: 100%;
  min-height: 14rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .82rem;
  line-height: 1.4;
  resize: vertical;
  margin-bottom: 1rem;
}
#analyze-workers-table { min-width: 480px; }
#analyze-recent-table { min-width: 900px; }

.sql-term {
  margin-top: .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #0d1117;
}
.sql-output {
  margin: 0;
  padding: .75rem 1rem;
  background: #0d1117;
  color: #e6edf3;
  min-height: 18rem;
  max-height: 36rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .82rem;
  line-height: 1.35;
  border: none;
  border-radius: 0;
}
.sql-cmdline {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem;
  background: #0d1117;
  border-top: 1px solid #30363d;
  color: #e6edf3;
}
.sql-prompt {
  color: #3fb950;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem;
  flex-shrink: 0;
}
.sql-input-line {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #e6edf3;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem;
  line-height: 1.4;
  padding: 0;
  box-shadow: none;
}
.sql-input-line::placeholder { color: #6e7681; }

.targets-panel {
  margin: 1rem 0;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.targets-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}
.targets-actions { display: flex; gap: .5rem; align-items: center; }
#analyze-targets-table { min-width: 980px; }
#analyze-targets-table td.mono { font-size: .8rem; }
#analyze-targets-table .tgt-status-ok { color: var(--ok, #2a7); }
#analyze-targets-table .tgt-status-busy { color: var(--accent, #06c); }
#analyze-targets-table .tgt-status-unreachable,
#analyze-targets-table .tgt-status-error { color: var(--err, #c33); }
#analyze-targets-table .tgt-status-idle { color: var(--muted, #888); }
.target-editor {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--border);
}
.btn-sm { padding: .15rem .45rem; font-size: .85rem; min-width: auto; }

/* эмбеддинги и поиск по смыслу */
#embed-recent-table { min-width: 900px; }
#semantic-table { min-width: 1000px; }
#page-search input[type="range"] { width: 12rem; vertical-align: middle; }
#semantic-share-link { min-height: 1.2em; }
#semantic-share-link a { color: var(--accent); }
#semantic-share-history { min-width: 960px; }
#semantic-share-history .share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  white-space: nowrap;
}
.share-download-footer {
  display: flex;
  justify-content: center;
  margin: 1.25rem 0 0.5rem;
}
.share-download-btn {
  margin-top: 0;
  min-width: 16rem;
  padding: 0.9rem 2rem;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  border-radius: 12px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.share-download-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 45%, transparent);
}
.share-download-btn:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.site-type-groups { display: flex; flex-direction: column; gap: .65rem; }
.site-type-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .45rem .6rem .55rem;
  background: color-mix(in srgb, var(--bg) 92%, var(--border));
}
.site-type-group-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem;
  margin-bottom: .35rem;
}
.site-type-group-title { font-weight: 600; }
.site-type-group-count { color: var(--muted, #888); font-size: .9em; }
.site-type-group-actions { display: flex; flex-wrap: wrap; gap: .25rem; margin-left: auto; }
.site-type-group .skip-grid { margin: 0; }
#semantic-min-score:disabled { opacity: .45; }
.user-actions { display: flex; flex-wrap: wrap; gap: .25rem; }
#users-table { min-width: 900px; }
#user-shares-table { min-width: 700px; }
.field-filters { display: flex; flex-direction: column; gap: .45rem; }
.field-filter-row {
  display: grid;
  grid-template-columns: 8rem 1fr 1fr;
  gap: .4rem .6rem;
  align-items: center;
}
.field-filter-row .ff-name { font-weight: 500; }
@media (max-width: 720px) {
  .field-filter-row { grid-template-columns: 1fr; }
}
