:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647386;
  --line: #d9e0e8;
  --accent: #1769aa;
  --accent-strong: #0f5489;
  --danger: #b42318;
  --warn: #9a5b00;
  --success: #0f6b3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #111820;
  color: #fff;
}

.brand {
  color: #fff;
  font-weight: 700;
}

.logout {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0;
}

.logout button,
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

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

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.danger-button {
  border-color: #f4c7c3;
  color: var(--danger);
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px;
}

.login-panel {
  max-width: 380px;
  margin: 80px auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.2;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 17px;
}

h3 {
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  resize: vertical;
}

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

.metrics div,
.runline,
.panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics div {
  padding: 14px;
  min-width: 0;
}

.metrics span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.runline {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 14px;
  color: #334155;
  overflow-x: auto;
  white-space: nowrap;
}

.filters {
  display: grid;
  grid-template-columns: 160px 240px minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background: #eef2f6;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e7eef6;
  color: #24445f;
  font-size: 12px;
  font-weight: 700;
}

.pill.warn,
.pill.error,
.danger {
  color: var(--danger);
  background: #fdebea;
}

.pill.imported,
.success {
  color: var(--success);
  background: #e7f6ed;
}

.pill.rejected {
  color: #4b5563;
  background: #eceff3;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

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

.back {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.alert {
  padding: 12px 14px;
  margin: 0 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.alert.error {
  color: var(--danger);
  background: #fff3f2;
  border-color: #f4c7c3;
}

.alert.warn {
  color: var(--warn);
  background: #fff8e8;
  border-color: #f4d99b;
}

.alert.success {
  border-color: #b7e0c9;
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

dl {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

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

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.html-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfd;
  max-height: 360px;
  overflow: auto;
}

.source-row {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.source-row:first-child {
  padding-top: 0;
}

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

pre {
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  background: #0f1720;
  color: #dbe7f3;
  border-radius: 6px;
  font-size: 12px;
}

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

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

.inline-form {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .metrics,
  .filters,
  .grid {
    grid-template-columns: 1fr;
  }

  .detail-head {
    display: block;
  }
}
