/* Design system ported from scout.bkoventures.com (Crawler_2.0/api/static/
   index.html), the same one Recon (discrepancy-tool) already ported —
   shared CSS custom-property tokens and header/card/table/button
   conventions so this tool reads as part of the same family. */
:root {
  color-scheme: dark;
  --bg: #0a0e14;
  --surface: #11161d;
  --surface-2: #161d26;
  --border: #212b38;
  --text: #e8edf3;
  --muted: #7d8a9a;
  --accent: #da4505;
  --accent-2: #b43904;
  --danger: #ef4444;
  --danger-bg: #2a1418;
  --success: #22c55e;
  --radius: 12px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.logo {
  height: 26px;
  width: auto;
  flex-shrink: 0;
  display: block;
}

header .subtitle {
  font-size: 12px;
  color: var(--muted);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#lastUpdated {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

#statusDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

#statusDot.err {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* Controls */
.toolbar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

input,
select,
button.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

button.btn {
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}

button.btn:hover {
  background: var(--surface-2);
}

button.btn.primary {
  background: var(--accent);
  border-color: var(--accent-2);
  color: white;
}

button.btn.primary:hover {
  background: var(--accent-2);
}

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: none;
}

.card > table {
  margin: -4px -6px;
  width: calc(100% + 12px);
}

/* Status / feedback */
.status-text {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 12px;
  min-height: 1.2em;
  display: flex;
  align-items: center;
}

.error-banner {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.error-banner[hidden] {
  display: none;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 13.5px;
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
}

.login-card .logo {
  height: 36px;
  margin: 0 auto 20px;
}

.login-card h1 {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 24px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card button.btn.primary {
  width: 100%;
  padding: 9px 12px;
  margin-top: 4px;
}

@media (max-width: 600px) {
  main {
    padding: 16px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
