:root {
  --bg: #0f1621;
  --panel: #162132;
  --panel-2: #1c2a3f;
  --line: #2f4562;
  --text: #e8ecf1;
  --muted: #8fa3b8;
  --accent: #3b82f6;
  --before: #f59e0b;
  --after: #22c55e;
  --danger: #ef4444;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #141c27;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 700; letter-spacing: 0.04em; }
.brand span { color: var(--muted); font-weight: 500; margin-left: 8px; }
.meta { color: var(--muted); font-size: 13px; }
.btn, .ghost {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn { background: var(--accent); color: #fff; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.55; cursor: wait; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.field label, .checkset legend {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.checkset {
  grid-column: 1 / -1;
  border: 0;
  padding: 0;
  margin: 4px 0 0;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
}
.field-wide { grid-column: span 2; }
.hits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.hits .ghost {
  font-size: 12px;
  padding: 6px 10px;
}
.hits .ghost.selected {
  border-color: var(--accent);
  color: #fff;
  background: #1d4ed8;
}

.results { margin-top: 18px; }
.shift-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.shift-row:last-child { border-bottom: 0; }
.store { font-size: 22px; font-weight: 800; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.empty, .error { color: var(--muted); padding: 18px 0; }
.error { color: #fca5a5; }

.match-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
}
.match-toggle .ghost.selected {
  border-color: var(--accent);
  color: #fff;
  background: #1d4ed8;
}
.section {
  margin: 22px 0 8px;
}
.section h2 {
  margin: 0 0 10px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.cat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.cat-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.pair-head, .pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.pair-head {
  position: sticky;
  top: 52px;
  z-index: 10;
  background: #101927;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.pair-head span, .shot {
  padding: 10px 12px;
}
.pair-head .b { color: var(--before); }
.pair-head .a { color: var(--after); }
.pair { border-top: 1px solid var(--line); }
.shot {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0c131d;
}
.shot img {
  width: 100%;
  height: min(52vh, 520px);
  object-fit: contain;
  background: #000;
  border-radius: 8px;
  cursor: zoom-in;
}
.cap { font-size: 12px; color: var(--muted); }
.missing {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: #64748b;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login .card { width: min(420px, 100%); }
.login h1 { margin: 0 0 8px; }
.login p { color: var(--muted); margin: 0 0 16px; }
.login .field { margin-bottom: 12px; }
.login .btn { width: 100%; }

.lb {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 24px;
}
.lb.open { display: grid; }
.lb img { max-width: 96vw; max-height: 92vh; object-fit: contain; }
.lb .close {
  position: absolute;
  top: 16px;
  right: 16px;
}

@media (max-width: 860px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .pair-head, .pair { grid-template-columns: 1fr; }
  .pair-head { top: 48px; }
  .shot img { height: 42vh; }
}
