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

/* ── Tokens ───────────────────────────────────────────────────────────────── */
:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #21262d;
  --border:   #30363d;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --faint:    #484f58;

  --blue:   #58a6ff;
  --green:  #3fb950;
  --red:    #f85149;
  --yellow: #d29922;
  --purple: #bc8cff;
  --cyan:   #39c5cf;

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;

  --sidebar: 220px;
  --ease:    0.15s ease;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sidebar-nav { padding: 10px 8px; flex: 1; }

.nav-group { margin-bottom: 4px; }
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--ease), color var(--ease);
  margin-bottom: 1px;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(88,166,255,.12); color: var(--blue); }
.nav-item .nav-icon { width: 16px; text-align: center; font-size: 14px; flex-shrink: 0; }

.sidebar-status {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: blink 2.5s ease infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Main content ─────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-meta  { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page-body { padding: 24px 28px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.card-body   { padding: 20px; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.card > .card-body:first-child { border-radius: var(--radius); }

/* ── Stat grid ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card-label { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.stat-card-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card-sub   { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-card-icon  { font-size: 18px; margin-bottom: 8px; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface2);
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(48,54,61,.6);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.015); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--ease);
  white-space: nowrap;
  line-height: 1.5;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--blue);  color: #0d1117; border-color: var(--blue); }
.btn-primary:hover { background: #79b8ff; border-color: #79b8ff; }

.btn-success { background: var(--green); color: #0d1117; border-color: var(--green); }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger  { color: var(--red); border-color: var(--border); background: transparent; }
.btn-danger:hover  { background: rgba(248,81,73,.1); border-color: var(--red); }

.btn-ghost   { color: var(--muted); border-color: var(--border); background: transparent; }
.btn-ghost:hover   { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px;  font-size: 11px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.input {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 11px;
  font-size: 13px;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
  font-family: inherit;
}
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88,166,255,.1);
}
.input::placeholder { color: var(--faint); }
select.input { cursor: pointer; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-success { background: rgba(63,185,80,.08);  border-color: rgba(63,185,80,.25);  color: #56d364; }
.alert-error   { background: rgba(248,81,73,.08);  border-color: rgba(248,81,73,.25);  color: #ff7b72; }
.alert-info    { background: rgba(88,166,255,.08); border-color: rgba(88,166,255,.25); color: var(--blue); }
.alert-warn    { background: rgba(210,153,34,.08); border-color: rgba(210,153,34,.25); color: var(--yellow); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}
.badge-blue   { background: rgba(88,166,255,.15);  color: var(--blue); }
.badge-green  { background: rgba(63,185,80,.15);   color: var(--green); }
.badge-red    { background: rgba(248,81,73,.15);   color: var(--red); }
.badge-yellow { background: rgba(210,153,34,.15);  color: var(--yellow); }
.badge-purple { background: rgba(188,140,255,.15); color: var(--purple); }
.badge-cyan   { background: rgba(57,197,207,.15);  color: var(--cyan); }
.badge-muted  { background: var(--surface2); color: var(--muted); }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress { height: 4px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--blue); border-radius: 99px; transition: width .4s ease; }
.progress-bar.green { background: var(--green); }

/* ── Inline share bars ────────────────────────────────────────────────────── */
.share-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.share-bar-track { flex: 1; height: 4px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.share-bar-fill  { height: 100%; background: var(--blue); border-radius: 99px; }

/* ── Drop zone ────────────────────────────────────────────────────────────── */
.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--blue);
  background: rgba(88,166,255,.03);
}
.dz-icon  { font-size: 28px; margin-bottom: 8px; }
.dz-label { font-size: 13px; color: var(--muted); }
.dz-label strong { color: var(--blue); font-weight: 500; }
.dz-picked { margin-top: 8px; font-size: 12px; color: var(--green); display: none; }
.dz-picked.show { display: block; }

/* ── Checkbox grid ────────────────────────────────────────────────────────── */
.db-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 8px;
}
.db-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--ease);
}
.db-item:hover { border-color: var(--blue); }
.db-item input[type=checkbox] { accent-color: var(--blue); width: 14px; height: 14px; flex-shrink: 0; }
.db-item-name  { font-size: 12.5px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-item-count { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── Log box ──────────────────────────────────────────────────────────────── */
.log-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  height: 560px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.75;
}
.log-line { display: flex; gap: 10px; align-items: baseline; }
.log-ts    { color: var(--faint); flex-shrink: 0; white-space: nowrap; }
.log-lbl {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 1px 6px;
  border-radius: 3px;
  min-width: 70px;
  text-align: center;
}
.log-msg { word-break: break-all; }
.log-line.is-error .log-msg { color: var(--red); }

/* label colours */
.lbl-init,lbl-dashboard { background: rgba(57,197,207,.12); color: var(--cyan); }
.lbl-scan,.lbl-webscan  { background: rgba(63,185,80,.12);  color: var(--green); }
.lbl-bot,.lbl-cmd       { background: rgba(88,166,255,.12); color: var(--blue); }
.lbl-doc,.lbl-download  { background: rgba(188,140,255,.12);color: var(--purple); }
.lbl-history,.lbl-sources,.lbl-settings { background: rgba(210,153,34,.12); color: var(--yellow); }
.lbl-db                 { background: rgba(57,197,207,.12); color: var(--cyan); }
.lbl-default            { background: var(--surface2); color: var(--muted); }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding-top: 16px; }
.pager {
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  transition: all var(--ease);
}
.pager:hover { background: var(--blue); color: #0d1117; border-color: var(--blue); text-decoration: none; }
.pager.active { background: var(--blue); color: #0d1117; border-color: var(--blue); }
.pager.disabled { opacity: .35; pointer-events: none; }

/* ── Scanner status ───────────────────────────────────────────────────────── */
.scan-status-wrap { max-width: 600px; margin: 0 auto; }
.scan-icon   { font-size: 42px; margin-bottom: 14px; line-height: 1; }
.scan-title  { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.scan-sub    { color: var(--muted); font-size: 13px; }
.scan-steps  { margin: 22px 0; text-align: left; }
.step-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(48,54,61,.4);
  font-size: 13px;
}
.step-row:last-child { border-bottom: none; }
.step-icon { width: 18px; text-align: center; flex-shrink: 0; }
.step-name { flex: 1; }
.step-hits { color: var(--muted); font-size: 12px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}
.result-cell {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
}
.result-cell-val { font-size: 20px; font-weight: 700; }
.result-cell-lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── History expand ───────────────────────────────────────────────────────── */
.expand-row { display: none; }
.expand-row.open { display: table-row; }
.expand-inner {
  padding: 10px 16px 14px;
  background: var(--bg);
}
.pill-list { display: flex; flex-wrap: wrap; gap: 5px; }
.pill {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill strong { color: var(--text); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 440px;
  max-width: 94vw;
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 18px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Helpers ──────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.flex     { display: flex; align-items: center; gap: 8px; }
.flex-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.between  { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.text-muted  { color: var(--muted); }
.text-small  { font-size: 12px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mono        { font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-8  { margin-top:    8px; }
.mt-16 { margin-top:   16px; }
.mb-0  { margin-bottom:  0; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(88,166,255,.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 32px; margin-bottom: 10px; }
.empty p    { font-size: 13px; }

/* ── Settings section ─────────────────────────────────────────────────────── */
.settings-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* ── Scanner tab toggle ───────────────────────────────────────────────────── */
.tab-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { background: var(--surface2); color: var(--text); }

/* ── Paste textarea ───────────────────────────────────────────────────────── */
.paste-area {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 12px;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.paste-area:focus { border-color: var(--blue); }
.paste-area::placeholder { color: var(--muted); }
