:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #1b2428;
  --muted: #627077;
  --line: #dfe6e8;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --warning: #9a5b00;
  --danger: #a83232;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  background: #102326;
  color: #f7fbfb;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 17px;
}

.topbar p {
  max-width: 760px;
  margin-top: 8px;
  color: #bfd0d2;
}

.api-field {
  display: grid;
  gap: 6px;
  min-width: min(420px, 100%);
  color: #d8e5e6;
  font-size: 13px;
}

input,
select,
button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input,
select {
  padding: 0 10px;
}

button {
  padding: 0 14px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
}

main {
  display: grid;
  gap: 18px;
  padding: 24px 32px 40px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.category-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfd;
  cursor: pointer;
}

.category-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.category-name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.category-count {
  color: var(--accent);
  font-size: 22px;
}

.category-subcounts {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.category-description {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.metric-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  font-size: 14px;
}

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

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.muted {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.item-table-wrap {
  max-height: 760px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #f0f4f5;
  color: #36484d;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.source-title {
  font-weight: 700;
}

.source-url {
  display: block;
  max-width: 360px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf2f3;
  padding: 0 9px;
  white-space: nowrap;
}

.pill.p0 {
  background: #e6f4f1;
  color: #075d56;
}

.pill.ok {
  background: #e6f4f1;
  color: #075d56;
}

.pill.p2 {
  background: #fff4df;
  color: var(--warning);
}

.pill.p3 {
  background: #fdecec;
  color: var(--danger);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.mini-button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.item-summary {
  max-width: 640px;
  margin-top: 6px;
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .topbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  main {
    padding: 16px;
  }
}
