:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #172026;
  --muted: #66717d;
  --border: #d8e0e7;
  --border-strong: #c4ced8;
  --accent: #008c7a;
  --accent-dark: #006f61;
  --danger: #d92727;
  --danger-bg: #fff1f1;
  --sidebar: #10202a;
  --sidebar-soft: #1b303d;
  --shadow: 0 12px 34px rgba(16, 32, 42, 0.08);
  --shadow-soft: 0 6px 18px rgba(16, 32, 42, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #eef4f3 0, var(--bg) 280px),
    var(--bg);
  color: var(--text);
  font-family:
    "IBM Plex Sans",
    "Segoe UI",
    system-ui,
    sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background:
    linear-gradient(160deg, rgba(0, 140, 122, 0.14), transparent 42%),
    var(--sidebar);
  color: #eff7f6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 16px;
  font-weight: 700;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 3px solid #22c7b3;
  border-radius: 50%;
  box-shadow: 8px 8px 0 -5px #22c7b3;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  padding: 11px 12px;
  border-radius: 7px;
  color: #d6e2e7;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.sidebar-foot {
  margin-top: auto;
  color: #aebcc3;
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.scan-control {
  display: grid;
  gap: 5px;
  justify-items: end;
}

.scan-status {
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-align: right;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  font-weight: 730;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 5px;
  color: var(--muted);
}

.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #f2c7c7;
  border-radius: 7px;
  background: var(--danger-bg);
  color: #8d1717;
}

.source-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) repeat(2, minmax(330px, 1.15fr));
  gap: 12px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.source-panel {
  display: flex;
  min-width: 0;
  min-height: 400px;
  flex-direction: column;
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.avito-dot {
  background: #00aaff;
  box-shadow:
    -9px 0 0 #8e38ff,
    0 9px 0 #ffc400;
}

.vk-dot {
  background: #2787f5;
}

.telegram-dot {
  background: #2aa8e8;
}

.source-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-all {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 640;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 140, 122, 0.12);
}

button:focus-visible {
  outline: 2px solid rgba(0, 140, 122, 0.35);
  outline-offset: 2px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 720;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ghost-button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.source-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eef2f4;
}

.source-row:last-child {
  border-bottom: 0;
}

.source-title {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover {
  border-color: #f0bbbb;
  background: var(--danger-bg);
  color: var(--danger);
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  margin-top: 12px;
}

.results-panel,
.detail-panel {
  min-height: 430px;
  padding: 14px;
}

.detail-panel {
  position: sticky;
  top: 16px;
  align-self: start;
}

.results-head {
  align-items: flex-start;
}

.segments {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.segment {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 720;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--accent);
  color: #ffffff;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(220px, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.result-table {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.result-row,
.result-header {
  display: grid;
  grid-template-columns: 110px 132px minmax(0, 1fr) 76px 108px;
  gap: 12px;
  align-items: center;
  min-width: 640px;
  min-height: 46px;
  padding: 9px 12px;
}

.result-header {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.result-row {
  width: 100%;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-top: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.result-row:hover,
.result-row.active {
  background: #f1fbf9;
}

.result-row:focus-visible {
  outline: 2px solid rgba(0, 140, 122, 0.35);
  outline-offset: -2px;
}

.result-title {
  overflow: hidden;
}

.result-title strong,
.detail-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-title span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  border: 1px solid #9edbcf;
  border-radius: 5px;
  color: #007c6c;
  padding: 3px 7px;
  font-weight: 760;
}

.status {
  display: inline-flex;
  justify-content: center;
  border: 1px solid #b8d6ff;
  border-radius: 5px;
  color: #1269d3;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 720;
}

.detail-empty {
  display: grid;
  min-height: 320px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-content {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.detail-line {
  display: grid;
  gap: 3px;
}

.detail-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.detail-line a {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 4px 0;
  padding: 24px 12px;
  border: 1px dashed var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .source-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 780px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-foot {
    display: none;
  }

  .content {
    padding: 14px;
  }

  .topbar,
  .results-head {
    flex-direction: column;
  }

  .topbar-actions,
  .scan-control {
    width: 100%;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .scan-control {
    justify-items: stretch;
  }

  .scan-status {
    max-width: none;
    text-align: left;
  }

  .two-column,
  .filters,
  .result-row,
  .result-header {
    grid-template-columns: 1fr;
  }

  .result-header {
    display: none;
  }

  .result-row {
    min-width: 0;
    gap: 8px;
    align-items: stretch;
  }

  .result-row > span {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
  }

  .result-row > span::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 720;
  }

  .segments {
    width: 100%;
  }

  .segment {
    flex: 1;
  }
}
