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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warn: #d97706;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
header h1 { font-size: 1.2rem; font-weight: 700; }
header .badge {
  font-size: .72rem; background: rgba(255,255,255,.2);
  padding: .15rem .5rem; border-radius: 99px;
}

/* ── Tabs ── */
.tabs { display: flex; background: var(--surface); border-bottom: 2px solid var(--border); }
.tab-btn {
  flex: 1; padding: .85rem 1rem; border: none; background: none;
  font-size: .95rem; font-weight: 500; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { background: var(--bg); }

/* ── Panels ── */
.panel { display: none; padding: 1.5rem; max-width: 960px; margin: 0 auto; }
.panel.active { display: block; }

/* ── Drop zone ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; padding: 2rem 1rem; cursor: pointer; transition: border-color .2s, background .2s;
  min-height: 220px; position: relative;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: #eff6ff; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .icon { font-size: 2.5rem; }
.dropzone p { color: var(--muted); font-size: .9rem; }
.dropzone img { max-width: 100%; max-height: 200px; border-radius: 6px; object-fit: contain; }

/* ── Result card ── */
.result-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.result-card.flagged { border-left: 5px solid var(--danger); }
.result-card.safe    { border-left: 5px solid var(--success); }
.result-card.suspect { border-left: 5px solid var(--warn); }

.status-label {
  font-size: 1.2rem; font-weight: 700; margin-bottom: .8rem;
}
.status-label.flagged { color: var(--danger); }
.status-label.safe    { color: var(--success); }
.status-label.suspect { color: var(--warn); }

.result-meta { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .88rem; }
.result-meta dt { color: var(--muted); font-weight: 500; }
.result-meta dd { }

.match-thumb { width: 80px; height: 80px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 7px; border: none; cursor: pointer;
  font-size: .9rem; font-weight: 500; transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: var(--danger-hover); }
.btn-outline {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Layout rows ── */
.check-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
}
@media (max-width: 640px) { .check-layout { grid-template-columns: 1fr; } }

/* ── Blacklist toolbar ── */
.bl-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}
.bl-count { margin-left: auto; color: var(--muted); font-size: .88rem; }

/* ── Thumbnail grid ── */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 1rem;
}
.thumb-card {
  position: relative; background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .15s;
}
.thumb-card:hover { transform: translateY(-2px); }
.thumb-card img { width: 100%; height: 128px; object-fit: cover; display: block; }
.thumb-card .card-info {
  padding: .4rem .5rem; font-size: .75rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb-card .del-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(220,38,38,.85); color: #fff;
  border: none; border-radius: 50%; width: 22px; height: 22px;
  font-size: .75rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.thumb-card:hover .del-btn { opacity: 1; }

.thumb-card .reupload-btn {
  position: absolute; top: 4px; left: 4px;
  background: rgba(37,99,235,.85); color: #fff;
  border: none; border-radius: 50%; width: 22px; height: 22px;
  font-size: .75rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.thumb-card:hover .reupload-btn { opacity: 1; }

/* ── Pagination ── */
.pagination {
  display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1.2rem;
}
.pagination button {
  padding: .35rem .75rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: .85rem;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 1.5rem;
  width: min(480px, 92vw); box-shadow: 0 8px 32px rgba(0,0,0,.18);
  transform: translateY(-12px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: none; }
.modal h3 { margin-bottom: 1rem; font-size: 1.05rem; }
.modal .form-row { margin-bottom: .85rem; }
.modal label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; color: var(--muted); }
.modal input[type=text] {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .9rem;
}
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ── Spinner ── */
.spinner { display: none; }
.spinner.show { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin-icon {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}

/* ── Misc ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: .5rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: .85rem; }
