/*
  Admin dashboard theme — sibling to ../styles/app.css, not an override.
  Matches the mockup's near-black / blue-accent dark UI, which is a
  different shape (dense table + tabs) from app.css's centered hero
  capture flow. Reuses app.css's --success/--warning/--danger tokens
  where semantically identical; everything else is scoped under .admin.
*/

.admin {
  --a-bg:        #0a0e14;
  --a-panel:     #10151f;
  --a-panel-2:   #0d1219;
  --a-border:    rgba(255, 255, 255, 0.08);
  --a-text:      #e7ecf5;
  --a-muted:     rgba(231, 236, 245, 0.55);
  --a-accent:    #3b82f6;
  --a-accent-2:  #60a5fa;
  --a-mono:      'Courier New', ui-monospace, Consolas, monospace;

  min-height: 100vh;
  background: var(--a-bg);
  color: var(--a-text);
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  padding: 24px;
}

.admin * { box-sizing: border-box; }

.admin a { color: var(--a-accent-2); text-decoration: none; }

.admin-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-topbar h1 {
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.admin-topbar .sub {
  color: var(--a-muted);
  font-size: 0.85rem;
}

.admin-btn {
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.admin-btn:hover { border-color: var(--a-accent); }

.admin-btn.primary {
  background: var(--a-accent);
  border-color: var(--a-accent);
  color: #05070c;
  font-weight: 600;
}

.admin-btn.danger {
  border-color: rgba(255, 85, 117, 0.4);
  color: #ff5575;
}

.admin-btn.danger:hover {
  background: rgba(255, 85, 117, 0.1);
  border-color: #ff5575;
}

.admin-btn.small {
  padding: 5px 12px;
  font-size: 0.78rem;
}

/* ── Review actions (detail topbar) ───────────────────────────────────── */

.review-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.review-actions input[type="text"] {
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
}

.edit-input {
  width: 100%;
  background: var(--a-panel);
  border: 1px solid var(--a-accent);
  color: var(--a-text);
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
}

/* ── Inline form errors ────────────────────────────────────────────────── */

.admin-error-banner {
  display: none;
  background: rgba(255, 85, 117, 0.1);
  border: 1px solid rgba(255, 85, 117, 0.35);
  color: #ff5575;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.admin-error-banner.show { display: block; }

.input-error {
  border-color: #ff5575 !important;
  box-shadow: 0 0 0 3px rgba(255, 85, 117, 0.18);
}

@keyframes admin-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.shake { animation: admin-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

/* ── Skeleton loaders ──────────────────────────────────────────────────── */

@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skel {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.13) 37%,
    rgba(255, 255, 255, 0.06) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skel-text        { height: 0.9em; width: 100%; }
.skel-text.short   { width: 40%; }
.skel-text.medium  { width: 65%; }

.skel-label {
  height: 0.6em;
  width: 55%;
  margin-bottom: 8px;
}

.skel-badge { height: 1.4em; width: 90px; border-radius: 999px; }

.skel-row td { padding: 14px; }

.skel-image { aspect-ratio: 4/3; border-radius: 10px; }

.skel-field-card .skel-text { height: 1rem; }

/* ── Login ─────────────────────────────────────────────────────────────── */

.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-login-card {
  width: min(360px, 100%);
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  border-radius: 14px;
  padding: 32px;
}

.admin-login-card h1 {
  font-size: 1.1rem;
  margin: 0 0 4px;
}

.admin-login-card p {
  color: var(--a-muted);
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.admin-login-card input {
  width: 100%;
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.admin-login-card .error {
  color: #ff5575;
  font-size: 0.82rem;
  margin: -6px 0 12px;
  min-height: 1em;
}

/* ── Filter bar ────────────────────────────────────────────────────────── */

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.admin-filters input,
.admin-filters select {
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-family: inherit;
}

.admin-filters input[type="text"] { min-width: 200px; flex: 1; }

.admin-filters .ac-wrap { flex: 1; min-width: 200px; display: flex; }
.admin-filters .ac-wrap input[type="text"] { min-width: 0; }

/* ── Autocomplete dropdown ─────────────────────────────────────────────── */

.ac-wrap { position: relative; }

.ac-list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.ac-list.is-open { display: block; }

.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.83rem;
}

.ac-item:hover,
.ac-item.active { background: rgba(59, 130, 246, 0.14); }

.ac-item-flag { font-size: 1.15rem; line-height: 1; }
.ac-item-main { flex: 1; color: var(--a-text); }
.ac-item-main mark { background: transparent; color: var(--a-accent-2); font-weight: 700; }
.ac-item-sub  { color: var(--a-muted); font-size: 0.72rem; font-family: var(--a-mono); white-space: nowrap; }

.ac-empty {
  padding: 10px;
  color: var(--a-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ── Table ─────────────────────────────────────────────────────────────── */

.admin-table-wrap {
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  overflow: hidden;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

.admin-table th {
  text-align: left;
  padding: 12px 14px;
  color: var(--a-muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--a-border);
}

.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--a-border);
}

.admin-table tbody tr { cursor: pointer; }
.admin-table tbody tr:hover { background: rgba(59, 130, 246, 0.06); }
.admin-table tbody tr:last-child td { border-bottom: none; }

/* Soft-deleted row — still visible/clickable during the retention window
   (see RETENTION_DAYS in admin.py), just visually de-emphasized. */
.admin-table tbody tr.row-deleted { opacity: 0.4; }
.admin-table tbody tr.row-deleted:hover { opacity: 0.7; }

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

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  font-size: 0.82rem;
  color: var(--a-muted);
}

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.green  { background: rgba(92, 250, 142, 0.12); color: #5cfa8e; }
.badge.red    { background: rgba(255, 85, 117, 0.12); color: #ff5575; }
.badge.amber  { background: rgba(255, 189, 89, 0.12); color: #ffbd59; }
.badge.gray   { background: rgba(255, 255, 255, 0.08); color: var(--a-muted); }
.badge.blue   { background: rgba(59, 130, 246, 0.14); color: var(--a-accent-2); }

/* ── Tabs (detail page) ────────────────────────────────────────────────── */

.admin-tabbar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  padding: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.admin-tab {
  flex: none;
  padding: 9px 16px;
  border-radius: 8px;
  color: var(--a-muted);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.admin-tab.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--a-accent-2);
  font-weight: 600;
}

.admin-panel {
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.admin-panel h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.admin-note {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.82rem;
  color: var(--a-muted);
  margin-bottom: 14px;
}

.mrz-block {
  background: #05070c;
  border: 1px solid var(--a-border);
  border-radius: 10px;
  padding: 16px;
  font-family: var(--a-mono);
  font-size: 0.85rem;
  color: #5cfa8e;
  letter-spacing: 0.04em;
  overflow-x: auto;
  white-space: pre;
}

.code-block {
  background: #05070c;
  border: 1px solid var(--a-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--a-mono);
  font-size: 0.8rem;
  color: var(--a-text);
  letter-spacing: 0.01em;
  overflow-x: auto;
  white-space: pre;
  margin: 10px 0 16px;
}

.docs-section { margin-top: 28px; }
.docs-section h4 { font-size: 0.85rem; margin: 18px 0 4px; }
.docs-section p { color: var(--a-muted); font-size: 0.85rem; line-height: 1.6; max-width: 68ch; }
.docs-section table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 10px 0 16px; }
.docs-section th, .docs-section td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--a-border); }
.docs-section th { color: var(--a-muted); font-weight: 600; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.05em; }
.docs-section code { font-family: var(--a-mono); background: rgba(255,255,255,0.06); padding: 0.1em 0.4em; border-radius: 3px; font-size: 0.9em; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.field-card {
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  padding: 12px 14px;
}

.field-card .label {
  font-size: 0.68rem;
  color: var(--a-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.field-card .value { font-size: 0.95rem; font-weight: 600; }

.cross-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.cross-table th {
  text-align: left; padding: 10px; color: var(--a-muted);
  font-size: 0.68rem; text-transform: uppercase; border-bottom: 1px solid var(--a-border);
}
.cross-table td { padding: 10px; border-bottom: 1px solid var(--a-border); vertical-align: top; }
.cross-table td.mono { font-family: var(--a-mono); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.image-grid figure {
  margin: 0;
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}

.image-grid figure:hover {
  border-color: var(--a-accent);
  transform: translateY(-1px);
}

.image-grid figure.selected {
  border-color: var(--a-accent);
  outline: 2px solid var(--a-accent);
  outline-offset: -2px;
}

.image-grid figure.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--a-accent);
  color: #05070c;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-grid img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }

.image-grid figcaption {
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--a-muted);
}

/* ── Image lightbox / compare modal ───────────────────────────────────── */

.img-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.img-modal.show { display: flex; }

.img-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 12, 0.85);
}

.img-modal-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  max-width: 92vw;
  max-height: 88vh;
  padding: 20px;
}

.img-modal-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.img-modal-pane img {
  max-width: min(80vw, 640px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--a-border);
  background: #05070c;
}

.img-modal-pane figcaption {
  color: var(--a-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.img-modal-close {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 2;
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
}

.img-modal-close:hover { border-color: var(--a-accent); }

.risk-flags { list-style: none; padding: 0; margin: 10px 0 0; }
.risk-flags li {
  padding: 8px 10px;
  background: rgba(255, 189, 89, 0.08);
  border: 1px solid rgba(255, 189, 89, 0.2);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.82rem;
}

.pep-banner {
  text-align: center;
  padding: 22px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.pep-banner.clean   { background: rgba(92, 250, 142, 0.08); color: #5cfa8e; border: 1px solid rgba(92,250,142,0.25); }
.pep-banner.warn    { background: rgba(255, 189, 89, 0.08); color: #ffbd59; border: 1px solid rgba(255,189,89,0.25); }
.pep-banner.unavail { background: rgba(255, 255, 255, 0.05); color: var(--a-muted); border: 1px solid var(--a-border); }

/* ── Databases registry page ──────────────────────────────────────────── */

.db-registry-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.db-registry-tab {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  padding: 14px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
}

.db-registry-tab:hover { border-color: var(--a-accent); }

.db-registry-tab.active {
  background: var(--a-accent);
  border-color: var(--a-accent);
  color: #05070c;
}

.db-registry-tab .count {
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.db-registry-tab.active .count { background: rgba(5, 7, 12, 0.18); }

.db-registry-tab .count.hit { background: rgba(255, 85, 117, 0.22); color: #ff5575; }
.db-registry-tab.active .count.hit { background: rgba(5, 7, 12, 0.32); color: #ff5575; }

.db-registry-search {
  width: 100%;
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  color: var(--a-text);
  padding: 12px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.db-registry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.db-registry-card {
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  padding: 18px;
}

.db-registry-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.db-registry-card h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.db-registry-card .agency {
  color: var(--a-muted);
  font-size: 0.82rem;
  margin-bottom: 14px;
}

.db-registry-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--a-muted);
  margin-top: 8px;
}

/* ── Match profile cards (PEP / KYB result matches) ──────────────────────── */

.match-card {
  background: var(--a-panel-2);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}
.match-card:last-child { margin-bottom: 0; }

.match-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.match-header .match-name { font-size: 1.05rem; font-weight: 700; }
.match-header .match-score { font-size: 0.82rem; color: var(--a-muted); white-space: nowrap; }

.match-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.match-notes {
  font-size: 0.85rem;
  color: var(--a-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.match-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.match-links a.admin-btn { font-size: 0.78rem; padding: 6px 12px; }

.match-raw {
  margin-top: 10px;
}
.match-raw summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--a-muted);
}
.match-raw summary:hover { color: var(--a-accent-2); }
.match-raw .match-raw-body {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--a-muted);
  line-height: 1.6;
  word-break: break-word;
}
