/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f14;
  --surface:   #151820;
  --surface2:  #1c2030;
  --border:    #252a3a;
  --accent:    #5b6af0;
  --accent-h:  #7b8afe;
  --danger:    #e05252;
  --danger-h:  #f07070;
  --success:   #3ecf8e;
  --warning:   #f5a623;
  --text:      #e8eaf0;
  --text-muted:#8891a8;
  --radius:    10px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

/* ── App shell ────────────────────────────────────────────── */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 22px; }

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.logo-sub {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(91, 106, 240, 0.15);
  border: 1px solid rgba(91, 106, 240, 0.4);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-h);
}

#badge-count { font-size: 15px; }

/* ── Controls card ────────────────────────────────────────── */
.controls-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.controls-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  flex: 1 1 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 200px;
}

.field-sm { flex: 0 1 130px; }
.field-md { flex: 0 1 190px; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}

.help-dot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(136, 145, 168, 0.45);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  outline: none;
}

.help-dot:hover,
.help-dot:focus-visible {
  border-color: var(--accent-h);
  color: var(--accent-h);
}

.help-dot::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: 260px;
  max-width: min(260px, calc(100vw - 32px));
  padding: 9px 11px;
  background: #10131b;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.help-dot::before {
  content: '';
  position: absolute;
  right: 5px;
  bottom: calc(100% + 3px);
  z-index: 31;
  width: 8px;
  height: 8px;
  background: #10131b;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: rotate(45deg) translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.help-dot:hover::after,
.help-dot:focus-visible::after,
.help-dot:hover::before,
.help-dot:focus-visible::before {
  opacity: 1;
  transform: translateY(0);
}

.help-dot:hover::before,
.help-dot:focus-visible::before {
  transform: rotate(45deg) translateY(0);
}

input[type="text"],
input[type="number"],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
}

select option { background: var(--surface2); }

/* ── Buttons ──────────────────────────────────────────────── */
.controls-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

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

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled)  { background: var(--danger-h); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-prospector {
  background: linear-gradient(135deg, #5b6af0, #3ecf8e);
  color: #fff;
  font-weight: 700;
}
.btn-prospector:hover:not(:disabled) { opacity: 0.88; }
.btn-prospector:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-icon { font-size: 11px; }

/* ── Progress section ─────────────────────────────────────── */
.progress-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Status pill */
.status-pill {
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 3px 10px;
  border-radius: 12px;
  display: inline-block;
  width: fit-content;
}

.status-running  { background: rgba(62,207,142,0.15); color: var(--success); }
.status-completed{ background: rgba(91,106,240,0.15); color: var(--accent-h); }
.status-stopped  { background: rgba(240,118,112,0.15); color: var(--danger-h); }
.status-pending  { background: rgba(137,145,168,0.15); color: var(--text-muted); }
.status-error    { background: rgba(240,118,112,0.2);  color: var(--danger-h); }

/* Progress bar */
.progress-bar-wrap {
  height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-h));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* ── Table ────────────────────────────────────────────────── */
.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody tr.new-row {
  animation: fadeIn 0.3s ease;
}

tbody td {
  padding: 11px 16px;
  color: var(--text);
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px !important;
  white-space: normal !important;
}

/* Rating pill */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.rating-high { background: rgba(62,207,142,0.12); color: var(--success); }
.rating-mid  { background: rgba(245,166,35,0.12);  color: var(--warning); }
.rating-low  { background: rgba(240,118,112,0.12); color: var(--danger-h); }

/* Website link */
td a {
  color: var(--accent-h);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

td a:hover { text-decoration: underline; }

/* ── Source toggle ────────────────────────────────────────── */
.source-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-top: 4px;
}

.source-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.src-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.src-btn:hover { border-color: var(--accent); color: var(--text); }

.src-active {
  background: rgba(91,106,240,0.15);
  border-color: rgba(91,106,240,0.5);
  color: var(--accent-h);
}

.src-free {
  font-size: 10px;
  font-weight: 700;
  background: rgba(62,207,142,0.2);
  color: var(--success);
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.3px;
}

/* ── Helpers ──────────────────────────────────────────────── */
.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
