:root {
  --bg: #0f1115;
  --panel: #1b1e24;
  --panel-soft: #14161c;
  --border-subtle: rgba(255,255,255,0.06);
  --border-strong: #2a2e35;
  --field: #1e2127;
  --field-border: #33383f;
  --text: #f5f7fa;
  --muted: #9ba3b5;
  --accent: #57B2C7;
  --accent-soft: rgba(87,178,199,0.2);
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Inter", BlinkMacSystemFont, "Segoe UI Emoji";
  background: radial-gradient(circle at top, #171a22 0, #05060a 55%, #020306 100%);
  color: var(--text);
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top Navigation */
.topbar {
  background: linear-gradient(90deg,#181b22,#11131a);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title {
  display:flex;
  flex-direction:column;
  gap:4px;
}
.topbar-title h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.topbar-title span {
  font-size: 11px;
  color: var(--muted);
}
.topbar-controls {
  display: flex;
  gap: 18px;
  align-items: flex-end;
}
.input-group {
  display:flex;
  flex-direction:column;
  gap:4px;
}
.input-group label {
  font-size: 11px;
  opacity: .7;
}
.input-group input[type="file"] {
  background: var(--field);
  border: 1px solid var(--field-border);
  padding: 6px 10px;
  color: var(--text);
  border-radius: 7px;
  font-size: 12px;
}

/* Filter/Search Panel */
.filters {
  padding: 14px 26px 16px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
}
.filter-group {
  min-width: 160px;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.filter-group label {
  font-size: 11px;
  color: var(--muted);
}
.filter-group select,
.filter-group input[type="text"] {
  padding: 7px 9px;
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
}
.filter-group input::placeholder {
  color: #616977;
}

.filters-right {
  margin-left:auto;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:4px;
  font-size:11px;
  color:var(--muted);
}
.badge-count {
  padding:3px 7px;
  border-radius:999px;
  background:var(--accent-soft);
  color:var(--accent);
  font-size:11px;
}

/* Main layout */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
  min-height: 0;
}

@media (max-width: 980px) {
  .main { grid-template-columns: minmax(0,1fr); }
  .side-panel { display:none; }
}

.grid-wrap {
  padding: 22px 26px 12px;
  overflow: auto;
}

.status-bar {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

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

.empty-state {
  padding: 40px 0;
  text-align:center;
  font-size:13px;
  color:var(--muted);
}

/* Card */
.card {
  background: radial-gradient(circle at top left,#262a33,#171a22 55%,#11141b 100%);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.02);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.45);
  border-color: rgba(134,190,255,0.55);
  cursor: pointer;
}

.card-image {
  margin-bottom: 8px;
  border-radius: 10px;
  overflow: hidden;
  max-height: 150px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#06070a;
}
.card-image img {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
  display:block;
}

.team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.team-name {
  font-size: 16px;
  font-weight: 600;
}
.league-tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #262a33;
  border: 1px solid #32363f;
  color: #d8dde9;
}

.meta {
  margin-top: 4px;
  display:flex;
  flex-direction:column;
  gap:2px;
  font-size:12px;
}
.meta-row {
  display:flex;
  justify-content:space-between;
  gap:8px;
}
.meta-row span:first-child {
  color:var(--muted);
}
.meta-row span:last-child {
  text-align:right;
}

/* Trade Dress Section */
.trade-dress {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255,255,255,0.06);
}
.trade-dress h4 {
  margin: 0 0 5px 0;
  font-size: 12px;
  color:var(--muted);
}
.color-swatches {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
  flex-wrap:wrap;
}
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.25);
}
.color-labels {
  font-size: 11px;
  color: var(--muted);
}
.mascot {
  font-size: 12px;
  margin-top: 4px;
}

/* Side panel (selection / export) */
.side-panel {
  border-left: 1px solid var(--border-subtle);
  background: linear-gradient(180deg,#171922,#101219);
  padding: 18px 20px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.side-panel h2 {
  font-size: 14px;
  margin: 0 0 4px;
}
.side-panel p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}
.side-panel .hint {
  font-size: 11px;
  color: var(--muted);
}

.selection-list {
  flex:1;
  min-height:0;
  overflow:auto;           /* scroll when list is taller than panel */
  border-radius:10px;
  border:1px solid var(--border-subtle);
  background:#11141b;
  padding:8px 10px;
  font-size:12px;
}
.selection-item {
  padding:6px 4px;
  border-bottom:1px solid rgba(255,255,255,0.04);
  display:flex;
  flex-direction:column;
  gap:4px;
}
.selection-item:last-child {
  border-bottom:none;
}
.selection-item label {
  font-size:11px;
  color:var(--muted);
}
.selection-item input[type="text"] {
  width:100%;
  padding:4px 6px;
  border-radius:6px;
  border:1px solid var(--field-border);
  background:#05070c;
  color:#f5f7fa;
  font-size:11px;
}

.export-panel {
  margin-top:6px;
  display:flex;
  flex-direction:column;
  gap:4px;
}

.btn {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: #22252f;
  color: var(--text);
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color:#031017;
  font-weight:500;
}
.btn.danger {
  border-color: rgba(255,107,107,0.6);
  color: #ffdada;
}

.card-actions {
  margin-top: 6px;
  display:flex;
  justify-content:flex-end;
  gap:6px;
}
.card-actions .btn {
  font-size: 10px;
  padding: 4px 8px;
}

footer {
  padding: 10px 20px 14px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  border-top:1px solid var(--border-subtle);
  background:#07080d;
}

/* -------- Lightbox – v5-style, larger -------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display:flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* hidden state (JS uses aria-hidden) */
.lightbox[aria-hidden="true"] {
  display:none;
}

.lightbox .inner {
  position: relative;
  width: min(900px, 90vw);
  max-height: 90vh;
  background:#020617;
  border-radius:14px;
  padding:16px 16px 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  display:flex;
  flex-direction:column;
  gap:12px;
}

.lightbox img {
  display:block;
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.lightbox .close {
  position:absolute;
  top:10px;
  right:12px;
  background:#111827;
  border:1px solid rgba(148,163,184,.7);
  color:#e5e7eb;
  border-radius:8px;
  padding:6px 10px;
  cursor:pointer;
  font-size:11px;
}

/* Viewer + magnifier */
.lb-viewer-shell {
  border-radius: 10px;
  background: #020617;
  border:1px solid rgba(148,163,184,0.35);
  padding:10px;
}
.lb-viewer-inner {
  position:relative;
  overflow:hidden;
  border-radius:8px;
  background:#020617;
  min-height:260px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.lb-viewer-inner img {
  max-width:100%;
  max-height:60vh;
  object-fit:contain;
  transform-origin:center center;
  transition: transform 0.12s ease-out;
}
.lb-lens {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 10px 25px rgba(0,0,0,0.45);
  display:none;
  z-index:4;
  background-repeat:no-repeat;
}

/* Controls row */
.lb-controls {
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  padding:4px 2px 0;
  font-size:12px;
}
.lb-control-group {
  display:flex;
  flex-direction:column;
  gap:4px;
}
.lb-label {
  font-size:11px;
  color:var(--muted);
}
.lb-slider-row {
  display:flex;
  gap:6px;
  align-items:center;
}
.lb-slider-row input[type="range"] {
  flex:1;
}
.lb-slider-value {
  min-width:3rem;
  text-align:right;
  font-size:11px;
  color:var(--muted);
}
