:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #d8dee7;
  --line-strong: #b9c2cf;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --warn-bg: #fff7ed;
  --warn-line: #fdba74;
  --danger-bg: #fff1f2;
  --danger-line: #fda4af;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-y: auto;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.nav a {
  color: #374151;
  border-radius: 6px;
  padding: 8px 10px;
  white-space: nowrap;
}

.nav a.active {
  background: #e6f4f1;
  color: var(--primary-dark);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.logout-form button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 5px 9px;
  font: inherit;
  cursor: pointer;
}

.page {
  width: min(1500px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.actions,
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: #1f2933;
  font: inherit;
  cursor: pointer;
}

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

.button:hover,
button:hover {
  text-decoration: none;
  filter: brightness(0.98);
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.filters input,
.filters select {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 9px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.filters input[type="search"] {
  min-width: min(360px, 100%);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  line-height: 1.1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  overflow: visible;
}

.panel.danger {
  background: var(--danger-bg);
  border-color: var(--danger-line);
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
}

.message pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}

.message.success {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.message.warning {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.message.error {
  background: var(--danger-bg);
  border-color: var(--danger-line);
}

.message.info {
  background: #eff6ff;
  border-color: #93c5fd;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 17px;
}

.action-panel,
.doc-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-panel {
  padding: 10px;
}

.action-panel form {
  margin: 0;
}

.doc-links a {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
}

.doc-links a.disabled {
  color: var(--muted);
  pointer-events: none;
  background: #f8fafc;
}

.scraper-summary {
  display: grid;
  gap: 3px;
  min-width: 120px;
  white-space: nowrap;
}

.scraper-summary a {
  color: var(--accent);
}

.form-panel {
  max-width: 760px;
}

.auth-panel {
  max-width: 420px;
  margin: 64px auto;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
}

.field textarea {
  min-height: 92px;
}

.field small,
.field-errors,
.form-errors {
  color: var(--muted);
}

.field-errors,
.form-errors {
  color: #b91c1c;
}

.form-actions {
  margin-top: 14px;
}

.muted {
  color: var(--muted);
}

.issue-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.issue-list div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
}

.issue-list dt {
  color: var(--muted);
  font-size: 12px;
}

.issue-list dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 700;
}

.data-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #ffffff;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #eef2f6;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  position: static;
}

.table-scroll {
  overflow: auto;
  max-height: 340px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.table-scroll .data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-scroll.large {
  max-height: 58vh;
}

.table-scroll.small {
  max-height: 220px;
}

.data-table.compact th,
.data-table.compact td {
  padding: 7px 8px;
}

.data-table .num {
  text-align: right;
  white-space: nowrap;
}

.data-table .empty {
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.row-action {
  white-space: nowrap;
  text-align: right;
}

.row-action .sep {
  color: var(--line-strong);
  padding: 0 5px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  white-space: nowrap;
}

.warning-row td {
  background: var(--warn-bg);
  border-bottom-color: var(--warn-line);
}

@media (max-width: 900px) {
  .topbar,
  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    width: min(100vw - 20px, 1500px);
    margin-top: 16px;
  }

  .metric-grid,
  .split,
  .issue-list {
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select,
  .filters button {
    width: 100%;
  }

  .data-table th {
    position: static;
  }
}
