:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d9e0ea;
  --blue: #2563eb;
  --green: #047857;
  --red: #b91c1c;
  --amber: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  background: #111827;
  color: #fff;
}

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

.sub {
  color: #cbd5e1;
  margin-left: 12px;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

nav a {
  color: #dbeafe;
  padding: 8px 10px;
  border-radius: 6px;
}

nav a.active,
nav a:hover {
  background: #374151;
  text-decoration: none;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  border: 0;
  border-radius: 6px;
  background: #4b5563;
  color: #fff;
  cursor: pointer;
  font: inherit;
  padding: 8px 10px;
}

.container {
  max-width: 1320px;
  margin: 24px auto;
  padding: 0 20px 40px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px auto 0;
  max-width: 1280px;
  padding: 12px 16px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #075985;
}

.notice span {
  overflow-wrap: anywhere;
}

.notice a {
  white-space: nowrap;
}

.notice button {
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, .75);
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 5px 8px;
}

.notice.warning {
  background: #fff7ed;
  color: var(--amber);
}

.notice.failed {
  background: #fee2e2;
  color: var(--red);
}

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

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

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

.metric {
  padding: 18px;
}

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

.metric strong {
  font-size: 30px;
}

.compact .metric strong {
  font-size: 22px;
}

.panel {
  margin-top: 18px;
  padding: 18px;
}

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

h1,
h2 {
  margin: 0;
  font-size: 20px;
}

h2 {
  font-size: 17px;
}

.actions,
.job-grid,
.filters,
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-filter {
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.compact-filter label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.job-grid {
  align-items: center;
}

.queue-panel {
  margin: 12px 0 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.queue-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.queue-fields label {
  display: grid;
  gap: 6px;
}

.queue-fields input {
  width: 180px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.button:hover {
  text-decoration: none;
}

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

.button.secondary {
  background: #0f766e;
  border-color: #0f766e;
}

.button.ghost {
  background: #fff;
  color: var(--blue);
}

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

.hint,
.muted,
.table-meta {
  color: var(--muted);
}

.hint {
  margin: 14px 0 0;
}

.danger-text {
  color: var(--red);
}

input {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

select {
  min-height: 36px;
  min-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
}

.compact-filter select {
  min-width: 120px;
}

input[type="search"] {
  min-width: 320px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

.nowrap-table th,
.nowrap-table td {
  white-space: nowrap;
  font-size: 13px;
}

.nowrap-table .allow-wrap {
  white-space: normal;
  min-width: 320px;
  max-width: 560px;
}

.title-cell a {
  font-size: 14px;
}

.sort-link {
  color: inherit;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 650;
}

tbody tr:hover {
  background: #fbfdff;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
}

.badge.ok,
.badge.active {
  background: #dcfce7;
  color: var(--green);
}

.badge.discovered,
.badge.warning {
  background: #fef3c7;
  color: var(--amber);
}

.badge.failed {
  background: #fee2e2;
  color: var(--red);
}

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

.table-meta {
  margin: 10px 0;
}

.pager {
  align-items: center;
  margin-top: 14px;
}

.page-jump {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-jump input {
  width: 88px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.check-field input {
  min-height: 0;
}

.progress-grid {
  display: grid;
  grid-template-columns: 160px 220px 1fr 1.4fr;
  gap: 12px;
  margin-bottom: 16px;
}

.progress-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
  min-width: 0;
}

.progress-grid span {
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.progress-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.url-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1 {
  margin-bottom: 8px;
}

.login-panel form,
.login-panel label {
  display: grid;
  gap: 8px;
}

.login-panel form {
  gap: 14px;
  margin-top: 18px;
}

.login-error {
  background: #fee2e2;
  color: var(--red);
  border-radius: 6px;
  padding: 10px;
  margin-top: 14px;
}

@media (max-width: 820px) {
  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .grid.compact,
  .progress-grid {
    grid-template-columns: 1fr;
  }

  input,
  input[type="search"],
  select {
    width: 100%;
    min-width: 0;
  }
}
