:root {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-card: #f8fafc;
  --bg-input: #ffffff;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --emerald: #059669;
  --emerald-dark: #047857;
  --emerald-bg: #ecfdf5;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --violet: #6d28d9;
  --violet-bg: #f5f3ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 11px;
  --radius-sm: 7px;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.04);
  --active-accent: #4f46e5;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.xsmall { font-size: 11px; }
.accent-green { color: var(--emerald); }
code {
  background: #eef2ff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #3730a3;
  border: 1px solid #e0e7ff;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 3px solid var(--primary);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
}
.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.25px;
  color: var(--text);
}
.brand-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-dim);
}

.nm-pill {
  background: var(--emerald-bg);
  color: var(--emerald-dark);
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.nm-pill-sm {
  background: var(--emerald-bg);
  color: var(--emerald-dark);
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.source-pill {
  background: var(--primary-soft);
  color: #3730a3;
  border: 1px solid #c7d2fe;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 999px;
}
.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.mini-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.mini-stat-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  margin-right: 5px;
}
.status-dot.licensed { background: #4f46e5; box-shadow: 0 0 8px rgba(79, 70, 229, 0.5); }

/* Game Tabs Bar */
.game-tabs-bar {
  position: sticky;
  top: 62px;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 20px 0 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.game-tabs-scroll {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 8px;
}
.game-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.game-tab:hover {
  background: #eef2ff;
  color: var(--text);
}
.game-tab.active {
  background: #ffffff;
  color: var(--text);
  border-color: var(--tab-accent, var(--primary));
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06), inset 0 -2px 0 var(--tab-accent, var(--primary));
}
.tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tab-accent, var(--primary));
}
.tab-count {
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}
.game-tab.active .tab-count {
  background: var(--tab-accent, var(--primary));
  color: #fff;
}
.tab-remove-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  color: var(--text-dim);
  opacity: 0.5;
  transition: all 0.12s ease;
}
.game-tab:hover .tab-remove-x {
  opacity: 1;
}
.tab-remove-x:hover {
  background: #fee2e2;
  color: var(--danger);
}

.btn-add-tab {
  flex-shrink: 0;
  margin-bottom: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px dashed #a5b4fc;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
}
.btn-add-tab:hover {
  border-color: var(--primary);
  background: #e0e7ff;
}

/* Workspace */
.workspace {
  max-width: 1520px;
  margin: 0 auto;
  padding: 18px 20px 60px;
}
.view-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.section-head h2 { margin: 0; font-size: 20px; color: var(--text); }
.section-head p { margin: 2px 0 0; }
.section-head-actions { display: flex; gap: 8px; }

/* Game Banner */
.game-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--active-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.game-banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.game-badge-lg {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--active-accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
}
.game-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.game-title-row h2 { margin: 0; font-size: 19px; color: var(--text); }
.game-banner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.45px;
  font-weight: 700;
}
.kpi-val {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--text);
}
.kpi-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Panels */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-header h3 { margin: 0; font-size: 15.5px; color: var(--text); }
.panel-header p { margin: 2px 0 0; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.28);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary {
  background: #ffffff;
  color: #1e293b;
  border-color: var(--border-light);
}
.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.btn-accent {
  background: var(--emerald-bg);
  color: var(--emerald-dark);
  border-color: #6ee7b7;
}
.btn-accent:hover:not(:disabled) {
  background: #d1fae5;
  border-color: #34d399;
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-danger-ghost {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-bg); border-color: #f87171; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; }
.btn-full { width: 100%; }

.input {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
.input-lg { padding: 9px 13px; font-size: 14px; }
.input-sm { padding: 6px 9px; font-size: 12.5px; width: auto; }
.input-xs { padding: 4px 7px; font-size: 12px; width: 125px; }
.num-xs { width: 64px; text-align: right; }
.input-color { padding: 2px; height: 36px; cursor: pointer; }

/* Search Toolbar */
.search-toolbar {
  display: grid;
  grid-template-columns: 1fr 240px 190px auto;
  gap: 10px;
  margin-bottom: 10px;
}
.search-toolbar-3 {
  grid-template-columns: 1fr 290px auto;
}
.ext-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.ext-link:hover { text-decoration: underline; }
@media (max-width: 980px) {
  .search-toolbar { grid-template-columns: 1fr 1fr; }
}
.intake-defaults-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 9px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.search-meta { margin-left: auto; }

/* Catalog Results Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 14px;
  max-height: 540px;
  overflow-y: auto;
  padding: 2px 4px 4px 2px;
}
.catalog-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.catalog-card:hover {
  border-color: #a5b4fc;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.10);
  transform: translateY(-2px);
}
.catalog-img-wrap {
  position: relative;
  height: 235px;
  background: linear-gradient(180deg, #f1f5f9 0%, #e7edf6 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  cursor: zoom-in;
}
.catalog-img-wrap img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
}
.catalog-source-tag {
  position: absolute;
  top: 7px;
  right: 7px;
  background: rgba(255, 255, 255, 0.92);
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
.catalog-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}
.catalog-name {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.25;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.catalog-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.catalog-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--emerald-bg);
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  color: #065f46;
}
.catalog-price-val {
  font-weight: 800;
  color: var(--emerald-dark);
  font-size: 13.5px;
}
.catalog-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.catalog-controls .full { grid-column: 1 / -1; }
.mini-input {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 12px;
  width: 100%;
}
.mini-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.14); }
.catalog-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.empty-icon {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid #c7d2fe;
  color: #3730a3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* Inventory Filter Bar & Bulk Bar */
.inv-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 14px;
  margin-bottom: 12px;
  background: var(--primary-soft);
  border: 1px solid #c7d2fe;
  color: #312e81;
  border-radius: var(--radius-sm);
}
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Inventory Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
}
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.inv-table thead th {
  text-align: left;
  padding: 10px 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.inv-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.inv-table tbody tr:hover {
  background: #f8faff;
}
.inv-table .num { text-align: right; white-space: nowrap; }
.inv-table .check-col { width: 34px; text-align: center; }
.inv-table .actions-col { width: 120px; text-align: right; white-space: nowrap; }

.card-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}
.card-thumb {
  width: 38px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  cursor: zoom-in;
  flex-shrink: 0;
}
.card-thumb-empty {
  width: 38px;
  height: 52px;
  border-radius: 4px;
  background: #f8fafc;
  border: 1px dashed var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.card-title-cell {
  font-weight: 700;
  color: var(--text);
}
.card-sku-cell {
  font-size: 11px;
  color: var(--text-dim);
}

.finish-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--violet-bg);
  color: var(--violet);
  border: 1px solid #ddd6fe;
  white-space: nowrap;
}
.game-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

/* Inline Table Editors */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
}
.qty-btn {
  background: #f8fafc;
  color: #334155;
  border: none;
  width: 24px;
  height: 26px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}
.qty-btn:hover { background: #e2e8f0; color: var(--text); }
.inline-num {
  width: 46px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  outline: none;
}
.inline-price {
  width: 76px;
  background: #f8fafc;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text);
  text-align: right;
  padding: 4px 6px;
  font-size: 13px;
}
.inline-price:hover { border-color: var(--border-light); background: #fff; }
.inline-price:focus { border-color: var(--primary); outline: none; background: #ffffff; box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.14); }
.inline-loc {
  width: 120px;
  background: #f8fafc;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text);
  padding: 4px 7px;
  font-size: 12.5px;
}
.inline-loc:hover { border-color: var(--border-light); background: #fff; }
.inline-loc:focus { border-color: var(--primary); outline: none; background: #fff; }
.saved-flash {
  animation: flashSave 0.7s ease;
}
@keyframes flashSave {
  0% { background: #dcfce7; }
  100% { background: transparent; }
}

/* Overview Game Cards */
.game-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.game-ov-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-accent, var(--primary));
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
  box-shadow: var(--shadow-sm);
}
.game-ov-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-accent, var(--primary));
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.game-ov-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.game-ov-title { font-weight: 700; font-size: 14.5px; color: var(--text); }
.game-ov-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.game-ov-stat-label { font-size: 11px; color: var(--text-dim); }
.game-ov-stat-val { font-size: 15px; font-weight: 700; color: var(--text); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-md { max-width: 580px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 920px; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; color: var(--text); }
.modal-header p { margin: 3px 0 0; }
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.btn-close:hover { color: var(--text); }
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Edit Card Modal Layout */
.edit-card-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
}
@media (max-width: 720px) {
  .edit-card-layout { grid-template-columns: 1fr; }
}
.edit-card-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.preview-img-box {
  height: 265px;
  background: linear-gradient(180deg, #f1f5f9 0%, #e7edf6 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
}
.preview-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 5px;
}
.preview-placeholder { color: var(--text-dim); font-size: 12px; }
.nm-locked-box {
  background: var(--emerald-bg);
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12.5px;
  color: #065f46;
}
.edit-card-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field > span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.span-2 { grid-column: span 2; }
@media (max-width: 700px) {
  .form-grid-3, .form-grid-4 { grid-template-columns: 1fr 1fr; }
}

/* Add / Manage Game Catalog List */
.tabs-inline {
  display: flex;
  gap: 8px;
}
.tab-pill {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tab-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.tcg-catalog-list {
  margin-top: 10px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
}
.tcg-catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
}
.tcg-catalog-item:last-child { border-bottom: none; }
.tcg-catalog-item:hover { background: #f8faff; }

/* License Cards */
.license-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.license-card.free-card {
  border-color: #a7f3d0;
  background: #f0fdf9;
}
.license-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.license-card-head h4, .license-card h4 { margin: 0; font-size: 14.5px; color: var(--text); }
.license-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 3px;
}
.rec-tag {
  font-size: 10.5px;
  background: var(--primary-soft);
  color: #3730a3;
  border: 1px solid #c7d2fe;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.secret-row { display: flex; gap: 6px; }
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.license-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.test-output.ok { color: var(--emerald-dark); font-weight: 600; }
.test-output.err { color: var(--danger); font-weight: 600; }

/* Backup */
.stack-gap { display: flex; flex-direction: column; gap: 14px; }
.backup-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.backup-box h4 { margin: 0 0 4px; color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.upload-label { cursor: pointer; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox-inner {
  text-align: center;
  max-width: 90vw;
  max-height: 90vh;
}
.lightbox-inner img {
  max-height: 80vh;
  max-width: 85vw;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.lightbox-caption {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--primary);
  padding: 11px 15px;
  border-radius: 9px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  font-size: 13px;
  font-weight: 500;
  max-width: 380px;
  animation: toastIn 0.18s ease;
}
.toast.ok { border-left-color: var(--emerald); }
.toast.err { border-left-color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.inline-controls { display: flex; align-items: center; gap: 8px; }
a.btn { text-decoration: none; }

/* Admin Orders, Buylist & Shipping Editor */
.orders-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.orders-list {
  display: flex; flex-direction: column; gap: 12px;
}
.order-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.order-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.order-num-title { font-size: 15.5px; font-weight: 800; color: var(--text); }
.order-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px; font-size: 12.5px;
}
.order-items-mini {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
.order-item-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px;
}
.order-item-line:last-child { border-bottom: none; padding-bottom: 0; }
.loc-tag {
  background: var(--primary-soft); color: #3730a3;
  border: 1px solid #c7d2fe;
  padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700;
}
.order-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; padding-top: 6px;
}
.shipping-editor-list { display: flex; flex-direction: column; gap: 8px; }
.ship-edit-row {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 88px 92px auto auto auto;
  gap: 8px; align-items: center;
  background: #ffffff; border: 1px solid var(--border);
  padding: 9px 10px; border-radius: 8px;
}
@media (max-width: 900px) { .ship-edit-row { grid-template-columns: 1fr 1fr; } }

/* AI Card Scanner Studio & Manual Inspection Queue */
.scanner-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 860px) { .scanner-layout { grid-template-columns: 1fr; } }
.scanner-viewport {
  position: relative;
  height: 310px;
  border-radius: 11px;
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  border: 1.5px solid var(--border-light);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 20px;
  max-width: 310px;
  color: var(--text);
}
.scanner-guide-frame {
  position: absolute;
  width: 176px;
  height: 248px;
  border: 2.5px dashed rgba(79, 70, 229, 0.78);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.14);
}
.scanner-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  min-height: 260px;
  padding: 26px 20px;
  border: 2px dashed #a5b4fc;
  border-radius: 12px;
  background: #f8faff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.scanner-dropzone:hover, .scanner-dropzone.dragover {
  background: #eef2ff;
  border-color: var(--primary);
}
.insp-card {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 16px;
  background: #ffffff;
  border: 1.5px solid #fcd34d;
  border-left: 5px solid #d97706;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 720px) { .insp-card { grid-template-columns: 1fr; } }
.insp-thumb {
  width: 100%;
  height: 196px;
  object-fit: contain;
  background: linear-gradient(180deg, #f1f5f9 0%, #e7edf6 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: zoom-in;
  padding: 4px;
}
.row-flagged {
  background: #fffbeb !important;
}
.flag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  margin-top: 3px;
}

/* Staff Authentication Gate & User Chip */
.staff-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: linear-gradient(145deg, #eef2ff 0%, #f4f6fb 55%, #ecfdf5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.staff-auth-card {
  width: 100%;
  max-width: 470px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 16px;
  padding: 24px 26px;
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.12);
}
.staff-auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}
.auth-err {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 12.5px;
  font-weight: 600;
}
.staff-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border-light);
}
.staff-role-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}
.staff-role-badge.master {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}
