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

:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a2e;
  --bg-card-hover: #1e1e38;
  --bg-surface: #12122a;
  --yellow: #FFCB05;
  --blue: #3B4CCA;
  --blue-light: #5566e0;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --border: #2a2a4a;
  --red: #e05555;
  --orange: #e08844;
  --green: #44c17a;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 16px; }

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

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

/* ── Header ── */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--yellow);
  text-decoration: none;
}
.logo-ball { font-size: 1.4rem; color: var(--yellow); }
.logo-ball-lg { font-size: 3rem; color: var(--yellow); display: block; margin-bottom: 0.5rem; }
.header-nav { display: flex; align-items: center; gap: 1rem; }
.nav-user { color: var(--text-muted); font-size: 0.85rem; }
.nav-link { color: var(--text-muted); font-size: 0.9rem; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-admin { color: var(--yellow) !important; }

/* ── Flash Messages ── */
.flash-container { max-width: 1400px; margin: 1rem auto; padding: 0 1.5rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.flash-success { background: rgba(68,193,122,0.15); border: 1px solid var(--green); color: var(--green); }
.flash-error { background: rgba(224,85,85,0.15); border: 1px solid var(--red); color: var(--red); }

/* ── Main ── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Page Header ── */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.count-badge {
  background: var(--blue);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  vertical-align: middle;
}
.back-link { color: var(--text-muted); font-size: 0.9rem; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ── Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
@media (max-width: 1100px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 750px)  { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .card-grid { grid-template-columns: 1fr; } }

.card-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.card-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  background: var(--bg-card-hover);
  text-decoration: none;
}

.card-thumb-wrap { position: relative; aspect-ratio: 2.5/3.5; overflow: hidden; background: #111; }
.card-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 0.85rem;
}

.id-badge {
  position: absolute; bottom: 8px; right: 8px;
  font-size: 0.65rem; font-weight: 600; padding: 0.18rem 0.45rem;
  border-radius: 99px; text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap; max-width: calc(100% - 16px);
  overflow: hidden; text-overflow: ellipsis;
}
.id-badge-ok { background: rgba(68,193,122,0.9); color: #fff; }
.id-badge-pending { background: rgba(224,136,68,0.9); color: #fff; }
.id-badge-warn { background: rgba(255,203,5,0.95); color: #111; }
.id-badge-lg { position: static; font-size: 0.8rem; padding: 0.25rem 0.7rem; max-width: none; overflow: visible; }

.card-info { padding: 0.9rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.card-name { font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.card-set { display: block; font-weight: 400; font-size: 0.8rem; color: var(--text-muted); }
.card-unidentified { color: var(--text-muted); font-style: italic; }
.card-meta { font-size: 0.78rem; color: var(--text-muted); }
.meta-sep { margin: 0 0.2rem; }
.scan-num { color: var(--yellow); font-weight: 600; }

.card-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.4rem; }
.price-label { font-size: 0.78rem; color: var(--text-muted); }
.price-date { color: var(--text-muted); font-size: 0.72rem; }
.price-na { color: var(--text-muted); font-style: italic; }
.price-value { font-size: 1rem; font-weight: 700; color: var(--green); }

.card-links { display: flex; gap: 0.5rem; font-size: 0.75rem; flex-wrap: wrap; }
.card-links a { color: var(--blue-light); }

/* ── Grade Pills ── */
.grade-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.grade-green  { background: rgba(68,193,122,0.2); color: var(--green); border: 1px solid var(--green); }
.grade-yellow { background: rgba(255,203,5,0.15); color: var(--yellow); border: 1px solid var(--yellow); }
.grade-red    { background: rgba(224,85,85,0.2); color: var(--red); border: 1px solid var(--red); }
.grade-grey   { background: rgba(136,136,170,0.15); color: var(--text-muted); border: 1px solid var(--border); }
.grade-pill-lg { font-size: 0.9rem; padding: 0.3rem 0.8rem; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state p { margin-bottom: 1.5rem; font-size: 1.1rem; }

/* ── Auth Pages ── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
}
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.75rem; }
.error-card { border-color: var(--red); }
.error-ball { color: var(--red); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { opacity: 0.88; text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--bg-surface); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-danger { background: rgba(224,85,85,0.15); color: var(--red); border: 1px solid var(--red); }
.btn-google { background: #fff; color: #333; font-weight: 600; width: 100%; border: 1px solid #ddd; }
.btn-full { width: 100%; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ── Forms ── */
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue-light);
}
.form-select option { background: var(--bg-card); }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.form-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--yellow); }
.form-actions { display: flex; gap: 0.75rem; }

/* ── Detail Page ── */
.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem; flex-wrap: wrap; gap: 0.75rem;
}
.detail-header-right { display: flex; align-items: center; gap: 0.75rem; }
.detail-layout { display: grid; grid-template-columns: auto 1fr; gap: 3rem; align-items: start; }
@media (max-width: 800px) { .detail-layout { grid-template-columns: 1fr; } }
.detail-images { display: flex; flex-direction: column; gap: 1.5rem; }
.detail-image-group { display: flex; gap: 1rem; flex-wrap: wrap; }
.detail-img-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.detail-img { width: 220px; border-radius: var(--radius); border: 1px solid var(--border); }
.detail-img.card-thumb-placeholder { height: 308px; background: var(--bg-surface); font-size: 0.82rem; }
.detail-img-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.detail-tcg-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.detail-tcg-img { width: 180px; border-radius: var(--radius); border: 1px solid var(--border); opacity: 0.85; }
.detail-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 1.5rem; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.5rem; }
.meta-list dt { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; white-space: nowrap; }
.meta-list dd { color: var(--text); }
.grade-notes { margin-top: 0.4rem; font-size: 0.85rem; color: var(--text-muted); font-style: italic; }
.detail-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 2rem; }
.mt-sm { margin-top: 0.5rem; }
.ml-sm { margin-left: 0.5rem; }

/* ── Admin Dashboard ── */
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.admin-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.tab-bar { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted); font-size: 0.9rem;
  border: 1px solid transparent;
  border-bottom: none;
  text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab-active { background: var(--bg-card); border-color: var(--border); color: var(--yellow); }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th, .admin-table td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--bg-surface); color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }
.admin-thumb { width: 48px; height: 64px; object-fit: cover; border-radius: 4px; }
.action-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.empty-cell { text-align: center; color: var(--text-muted); padding: 2rem !important; }

/* ── TCG Search ── */
.tcg-search-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.tcg-search-panel h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.tcg-search-row { display: flex; gap: 0.5rem; }
.tcg-search-row .form-input { flex: 1; }
.tcg-results { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.tcg-result-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.9rem;
  cursor: pointer; transition: border-color 0.15s;
  max-width: 280px;
}
.tcg-result-item:hover { border-color: var(--blue-light); }
.tcg-result-img { width: 48px; border-radius: 4px; }
.tcg-result-info { font-size: 0.82rem; }
.select-hint { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.no-results { color: var(--text-muted); font-size: 0.85rem; }
.selected-card { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; padding: 0.6rem 0.8rem; background: rgba(59,76,202,0.15); border: 1px solid var(--blue); border-radius: var(--radius-sm); font-size: 0.9rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 640px;
  max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card);
}
.modal-header h3 { font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }

/* ── Edit Page ── */
.edit-layout { display: grid; grid-template-columns: auto 1fr; gap: 2.5rem; align-items: start; }
@media (max-width: 700px) { .edit-layout { grid-template-columns: 1fr; } }
.edit-preview { display: flex; flex-direction: column; gap: 0.75rem; }
.edit-preview-img { width: 160px; border-radius: var(--radius); border: 1px solid var(--border); }
.edit-form { flex: 1; }

/* ── Task status bar ── */
.task-status-bar { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 1rem; margin-bottom: 1rem; font-size: 0.85rem; color: var(--text-muted); }

/* ── Rotate button ── */
.rotate-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.55); color: #fff;
  border: none; border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; cursor: pointer; line-height: 1;
  opacity: 0; transition: opacity 0.15s; z-index: 10;
  user-select: none;
}
.card-thumb-wrap:hover .rotate-btn,
.detail-img-wrap:hover .rotate-btn { opacity: 1; }
.rotate-btn:hover { background: rgba(59,76,202,0.85); }
.rotate-btn.rotating { animation: spin 0.4s linear; }
@keyframes spin { to { transform: rotate(360deg); } }
.detail-img-wrap { position: relative; }

/* ── Swap sides button ── */
.swap-btn-wrap {
  display: flex; align-items: center; justify-content: center;
  align-self: center;
}
.swap-btn {
  background: rgba(0,0,0,0.55); color: #fff;
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; cursor: pointer; line-height: 1;
  transition: background 0.15s; user-select: none;
}
.swap-btn:hover { background: rgba(59,76,202,0.85); }

/* ── Search bar ── */
.search-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.search-input { flex: 1; min-width: 200px; }
.search-select { width: auto; min-width: 140px; }
.search-info { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.search-info strong { color: var(--text); }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.page-info { color: var(--text-muted); font-size: 0.9rem; }
.btn-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── Category chips (catalog tiles) ── */
.card-cats { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.2rem; }
.cat-chip {
  background: rgba(59,76,202,0.2); border: 1px solid var(--blue);
  color: var(--blue-light); font-size: 0.7rem;
  padding: 0.1rem 0.45rem; border-radius: 99px;
}

/* ── Category section (detail page) ── */
.category-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.category-section h3 {
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem;
}
.category-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; min-height: 1.75rem; align-items: center; }
.cat-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: rgba(59,76,202,0.2); border: 1px solid var(--blue);
  color: var(--blue-light); font-size: 0.8rem;
  padding: 0.2rem 0.5rem 0.2rem 0.65rem; border-radius: 99px;
}
.cat-remove {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0; line-height: 1; font-size: 0.9rem;
  display: flex; align-items: center;
}
.cat-remove:hover { color: var(--red); }
.cat-none { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }
.category-add-row { display: flex; gap: 0.5rem; align-items: center; }

/* ── Auth form additions ── */
.auth-error {
  background: rgba(224,85,85,0.12);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
  text-align: left;
}
.auth-footer { margin-top: 1.25rem; font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { color: var(--yellow); }
.code-input {
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Access Control page ── */
.access-warning {
  background: rgba(224,136,68,0.12);
  border: 1px solid var(--orange);
  color: var(--orange);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}
.access-notice {
  background: rgba(136,136,170,0.1);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}
.access-add-form { max-width: 480px; margin-top: 1.5rem; }
.self-badge {
  display: inline-block;
  background: rgba(59,76,202,0.2);
  border: 1px solid var(--blue);
  color: var(--blue-light);
  font-size: 0.68rem;
  padding: 0.05rem 0.4rem;
  border-radius: 99px;
  vertical-align: middle;
  margin-left: 0.35rem;
}

/* ── Edit Identity section ── */
.edit-identity-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.edit-identity-section h3 {
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem;
}
.edit-identity-fields { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.75rem; }

/* ── Flash warning ── */
.flash-warning { background: rgba(255,203,5,0.1); border: 1px solid var(--yellow); color: var(--yellow); }

/* ── Examiner Confirmed badge (gold) ── */
.id-badge-confirmed { background: rgba(212,160,23,0.95); color: #111; }

/* ══════════════════════════════════════════════════════
   AFIS EXAMINATION WORKSPACE
   ══════════════════════════════════════════════════════ */

.btn-afis {
  font-family: monospace;
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  background: #0f1827;
  border: 1px solid #00e5ff66;
  color: #00e5ff;
  padding: 0.3rem 0.65rem;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-afis:hover { background: #162035; border-color: #00e5ff; }

.afis-workspace {
  display: none;
  flex-direction: column;
  height: calc(100vh - 110px);
  background: #0a0f1a;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #1e2d4a;
}

.afis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #0d1828;
  border-bottom: 1px solid #00e5ff22;
  flex-shrink: 0;
}
.afis-title {
  font-family: monospace;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #00e5ff;
}
.afis-close {
  font-family: monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  background: transparent;
  border: 1px solid #e53e3e55;
  color: #e53e3e;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}
.afis-close:hover { background: rgba(229,62,62,0.15); }

.afis-panels {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Left: Unknown panel ── */
.afis-panel-unknown {
  width: 270px;
  flex-shrink: 0;
  background: #0d1424;
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  overflow-y: auto;
  position: relative;
}
.afis-panel-unknown::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(0,229,255,0.018) 3px,
    rgba(0,229,255,0.018) 4px
  );
  pointer-events: none;
}

.afis-panel-label {
  font-family: monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  color: #00e5ff;
  text-transform: uppercase;
  border-bottom: 1px solid #00e5ff22;
  padding-bottom: 0.35rem;
  position: relative;
  z-index: 1;
}

.afis-unknown-img-wrap {
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.afis-unknown-img {
  width: 190px;
  border-radius: 4px;
  border: 1px solid #00e5ff33;
  box-shadow: 0 0 24px rgba(0,229,255,0.1);
}
.afis-no-image {
  width: 190px;
  height: 260px;
  background: #060d18;
  border: 1px solid #1e2d4a;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.65rem;
  color: #4a5568;
  letter-spacing: 0.1em;
}

.afis-features {
  position: relative;
  z-index: 1;
  font-family: monospace;
  font-size: 0.72rem;
  background: #060d18;
  border: 1px solid #1a2a3e;
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
}
.afis-features-label {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: #00e5ff55;
  margin-bottom: 0.5rem;
}
.afis-feature { display: flex; gap: 0.4rem; margin-bottom: 0.3rem; line-height: 1.4; }
.afis-fk { color: #4a90d9; flex-shrink: 0; }
.afis-fv { color: #c8d0e0; word-break: break-all; }

.afis-conf-badge {
  font-size: 0.6rem;
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.07em;
  font-weight: 700;
  vertical-align: middle;
}
.conf-high   { background: #1c4532; color: #9ae6b4; }
.conf-medium { background: #5c3317; color: #fbd38d; }
.conf-low    { background: #63171b; color: #fc8181; }

/* ── Center divider ── */
.afis-divider {
  width: 32px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #0a0f1a;
}
.afis-divider-line {
  width: 1px;
  flex: 1;
  background: linear-gradient(to bottom, transparent, #00e5ff33 30%, #00e5ff33 70%, transparent);
}
.afis-crosshair {
  color: #00e5ff66;
  font-size: 1rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

/* ── Right: Candidates panel ── */
.afis-panel-candidates {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.afis-panel-candidates .afis-panel-label {
  padding: 0.6rem 1rem;
  margin: 0;
  border-bottom: 1px solid #1e2d4a;
  flex-shrink: 0;
}
#afisCandidateList {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* ── Hit card ── */
.afis-hit-card {
  background: #0f1827;
  border: 1px solid #1e2d4a;
  border-radius: 5px;
  padding: 0.75rem 0.875rem;
  transition: border-color 0.15s;
}
.afis-hit-card:hover { border-color: #00e5ff33; }

.afis-hit-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}
.afis-hit-rank {
  font-family: monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: #00e5ff99;
  white-space: nowrap;
  min-width: 44px;
}
.afis-score-bar {
  flex: 1;
  height: 5px;
  background: #1e2d4a;
  border-radius: 3px;
  overflow: hidden;
}
.afis-bar-fill {
  height: 100%;
  border-radius: 3px;
  width: 0%;
  transition: width 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar-green  { background: linear-gradient(to right, #276749, #68d391); }
.bar-yellow { background: linear-gradient(to right, #975a16, #f6e05e); }
.bar-red    { background: linear-gradient(to right, #822727, #fc8181); }
.afis-score-num {
  font-family: monospace;
  font-size: 0.65rem;
  color: #4a5568;
  white-space: nowrap;
}

.afis-match-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.afis-match-tag {
  font-family: monospace;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: #162035;
  color: #63b3ed;
  border: 1px solid #2c4a6e;
  text-transform: uppercase;
}
.tag-none { color: #4a5568; border-color: #2d3748; background: #131c2e; }

.afis-hit-body { display: flex; gap: 0.75rem; }

.afis-tcg-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.afis-tcg-img { width: 100px; border-radius: 4px; border: 1px solid #1e2d4a; }
.afis-no-tcg-img {
  width: 100px;
  height: 140px;
  background: #060d18;
  border: 1px solid #1e2d4a;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.55rem;
  color: #4a5568;
}
.afis-examine-link {
  font-family: monospace;
  font-size: 0.58rem;
  color: #4a90d9;
  text-decoration: none;
  letter-spacing: 0.05em;
}
.afis-examine-link:hover { color: #63b3ed; }

.afis-hit-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.afis-hit-name { font-size: 0.9rem; font-weight: 600; color: #e2e8f0; }
.afis-hit-set  { font-size: 0.75rem; color: #718096; }
.afis-hit-date { font-size: 0.72rem; color: #4a5568; }
.afis-hit-price { font-size: 0.82rem; color: #68d391; font-weight: 600; margin-top: 0.2rem; }
.afis-hit-id   { font-size: 0.68rem; color: #4a5568; margin-top: 0.1rem; }

.btn-confirm {
  margin-top: 0.6rem;
  padding: 0.55rem 0.9rem;
  background: #1c4532;
  color: #9ae6b4;
  border: 1px solid #276749;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.15s, box-shadow 0.15s;
  width: 100%;
}
.btn-confirm:hover:not(:disabled) {
  background: #22543d;
  box-shadow: 0 0 14px rgba(56,161,105,0.35);
}
.btn-confirm:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-confirm-success {
  background: #14352a !important;
  color: #68d391 !important;
  border-color: #1c4532 !important;
}

/* ── AFIS loading / empty states ── */
.afis-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  font-family: monospace;
  font-size: 0.75rem;
  letter-spacing: 0.13em;
  color: #00e5ff66;
}
.afis-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid #00e5ff1a;
  border-top-color: #00e5ff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.afis-no-hits, .afis-error {
  font-family: monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: #fc8181;
  text-align: center;
  padding: 3rem 1rem;
}

@media (max-width: 680px) {
  .afis-workspace { height: auto; min-height: calc(100vh - 110px); }
  .afis-panels { flex-direction: column; overflow: visible; }
  .afis-panel-unknown { width: auto; }
  .afis-divider { flex-direction: row; width: auto; height: 28px; }
  .afis-divider-line { width: auto; height: 1px; flex: 1;
    background: linear-gradient(to right, transparent, #00e5ff33 30%, #00e5ff33 70%, transparent); }
  #afisCandidateList { max-height: 60vh; }
}
