:root {
  --background: #f6f7fb;
  --surface: #ffffff;
  --surfaceMuted: #eef0f7;
  --border: #dcdfea;
  --text: #171a22;
  --textMuted: #656b7e;
  --accent: #4f46e5;
  --accentSoft: #e8e7fd;
  --win: #0f8a5f;
  --winSoft: #dcf5ea;
  --loss: #c2384a;
  --lossSoft: #fbe3e7;
  --fair: #8a6d13;
  --fairSoft: #fbf1d6;
  --shadow: 0 1px 2px rgba(16, 18, 28, .06), 0 4px 12px rgba(16, 18, 28, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0e1017;
    --surface: #171a24;
    --surfaceMuted: #1f2331;
    --border: #2a2f40;
    --text: #eceef5;
    --textMuted: #9aa1b6;
    --accent: #8b85ff;
    --accentSoft: #262347;
    --win: #4ade9e;
    --winSoft: #12301f;
    --loss: #ff8b9c;
    --lossSoft: #33161c;
    --fair: #e8c766;
    --fairSoft: #302713;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}

.headerTop {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }

.meta { color: var(--textMuted); font-size: 13px; }

nav { display: flex; gap: 4px; margin-left: auto; }

nav a {
  color: var(--textMuted);
  text-decoration: none;
  font-size: 14px;
  padding: 5px 11px;
  border-radius: 8px;
}

nav a:hover { background: var(--surfaceMuted); color: var(--text); }
nav a[aria-current="page"] { background: var(--accentSoft); color: var(--accent); font-weight: 600; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input[type="search"], input[type="text"], input[type="number"], select {
  background: var(--surfaceMuted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

input[type="search"] { min-width: 220px; flex: 1 1 220px; }

button {
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surfaceMuted);
  color: var(--text);
  padding: 7px 12px;
}

button:hover { border-color: var(--accent); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

button.primary:hover { filter: brightness(1.08); }

button.danger { color: var(--loss); }
button.danger:hover { border-color: var(--loss); }

button.ghost { background: transparent; border-color: transparent; color: var(--textMuted); }
button.ghost:hover { background: var(--surfaceMuted); color: var(--text); border-color: transparent; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

.segmented button {
  background: var(--surfaceMuted);
  color: var(--textMuted);
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 7px 12px;
}

.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--accentSoft); color: var(--accent); font-weight: 600; }

main { padding: 18px 20px 60px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.tag {
  font-size: 11px;
  text-transform: capitalize;
  color: var(--textMuted);
  background: var(--surfaceMuted);
  border-radius: 999px;
  padding: 2px 8px;
}

.tag.flyRide { color: var(--accent); background: var(--accentSoft); }

.empty { color: var(--textMuted); padding: 40px 0; text-align: center; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.card img { width: 72px; height: 72px; object-fit: contain; }
.card .noImage { width: 72px; height: 72px; border-radius: 8px; background: var(--surfaceMuted); }
.cardName { font-weight: 600; font-size: 14px; line-height: 1.25; }
.cardValue { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.cardValue.missing { color: var(--textMuted); font-size: 15px; font-weight: 500; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
