:root {
  --bg: #f6f7f9;
  --text: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --panel: #ffffff;
  --ink: #243447;
  --green: #1f8a5b;
  --red: #b42318;
  --amber: #b76e00;
  --blue: #2563a9;
  --teal: #087f8c;
}

* {
  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;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #1f4e79;
  background: #1f4e79;
  color: #fff;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: #1f4e79;
}

button.danger {
  border-color: var(--red);
  background: var(--red);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

main {
  padding: 18px 24px 28px;
}

.status-band,
.actions-band,
.kpi-grid,
.workspace,
.json-panel {
  max-width: 1500px;
  margin: 0 auto 16px;
}

.status-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--panel);
}

.status-item {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.status-item:last-child {
  border-right: 0;
}

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

.status-item strong,
.kpi strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: 0;
}

.actions-band {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 0.9fr;
  gap: 12px;
}

.action-group {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.action-group.compact {
  grid-template-columns: auto 80px auto auto;
}

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

.check input {
  min-height: auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-left: 4px solid var(--blue);
}

.kpi.success {
  border-left-color: var(--green);
}

.kpi.error {
  border-left-color: var(--red);
}

.kpi.warn {
  border-left-color: var(--amber);
}

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

.main-panel,
.side-panel,
.json-panel {
  border: 1px solid var(--line);
  background: var(--panel);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.filters {
  display: flex;
  gap: 8px;
}

.filters input {
  width: 260px;
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #edf1f5;
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
  z-index: 1;
}

td {
  font-size: 14px;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: #e9edf2;
  color: var(--ink);
}

.badge.success {
  background: #e7f5ee;
  color: var(--green);
}

.badge.error {
  background: #fde8e7;
  color: var(--red);
}

.badge.duplicate,
.badge.not_found {
  background: #fff2d6;
  color: var(--amber);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.blocking-list,
.logs-list {
  padding: 12px;
  max-height: 260px;
  overflow: auto;
}

.logs-head {
  border-top: 1px solid var(--line);
}

.block-item,
.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.block-item:last-child,
.log-item:last-child {
  border-bottom: 0;
}

.block-item strong,
.log-item strong {
  display: block;
  font-size: 14px;
}

.block-item span,
.log-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}

.json-panel pre {
  margin: 0;
  min-height: 220px;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  background: #101828;
  color: #e6edf3;
  font-size: 13px;
  line-height: 1.5;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.16);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .status-band,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  main {
    padding: 12px;
  }

  .status-band,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .status-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-item:last-child {
    border-bottom: 0;
  }

  .action-group,
  .action-group.compact {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .filters {
    flex-direction: column;
    width: 100%;
  }

  .filters input {
    width: 100%;
  }
}

