:root {
  --bg: #0b0e14;
  --panel: #121726;
  --card: #171d2b;
  --card-hover: #1d2536;
  --border: #28334d;
  --text: #e9edf5;
  --muted: #8b95ad;
  --gold: #f0b429;
  --cyan: #57c7e3;
  --danger: #e05252;
  --r-exotique: #f0b429;
  --r-legendaire: #a06bd8;
  --r-rare: #5b8fd4;
  --r-peucommun: #9aa3b5;
  --r-commun: #4da864;
  --e-cinetique: #b8c2d8;
  --e-arc: #79bbe8;
  --e-solaire: #f2721b;
  --e-abyssal: #b185df;
  --e-stase: #5aa7ff;
  --e-filobscure: #3ee07a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.logo {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #b8741a);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 20px; color: #10131c;
}
.brand-name { font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: 2px; }
.brand-sub { color: var(--muted); font-size: 11px; }

.search-box { margin-bottom: 14px; }
#search {
  width: 100%; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px; outline: none;
}
#search:focus { border-color: var(--cyan); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1; padding: 9px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  cursor: pointer; transition: all .15s;
}
.tab.active { background: var(--gold); border-color: var(--gold); color: #10131c; }
.badge {
  display: inline-block; min-width: 18px; padding: 1px 5px;
  background: rgba(0,0,0,.25); border-radius: 10px; font-size: 11px;
}

.inv-stats {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 16px; font-size: 12px; color: var(--muted);
  line-height: 1.7;
}
.inv-stats b { color: var(--gold); }

.filters { margin-bottom: 12px; }
.fgroup { margin-bottom: 14px; }
.ftitle {
  font-family: 'Rajdhani', sans-serif; font-weight: 600; font-size: 13px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--cyan);
  margin-bottom: 6px;
}
.fopt {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 6px; cursor: pointer; color: var(--text); font-size: 13px;
}
.fopt:hover { background: rgba(255,255,255,.05); }
.fopt input { accent-color: var(--gold); cursor: pointer; }
.fv { flex: 1; }
.fc { color: var(--muted); font-size: 11px; }

.btn {
  display: block; width: 100%; padding: 9px; margin-top: 6px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; text-align: center; text-decoration: none;
  transition: all .15s;
}
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--cyan); color: var(--cyan); }
.btn.danger { background: transparent; border-color: rgba(224,82,82,.4); color: var(--danger); }
.btn.danger:hover { background: rgba(224,82,82,.12); }
.btn.gold { background: var(--gold); color: #10131c; }
.btn.gold:hover { filter: brightness(1.1); }

.side-actions { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.side-title {
  font-family: 'Rajdhani', sans-serif; font-weight: 600; font-size: 13px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold);
}
.side-foot { margin-top: 16px; color: var(--muted); font-size: 10px; line-height: 1.5; }

/* ============ BUNGIE / CONFIG ============ */
.cfg {
  width: 100%; padding: 8px 10px; margin-top: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px; outline: none;
}
.cfg:focus { border-color: var(--cyan); }
.bnet-status { margin-top: 8px; font-size: 11px; color: var(--muted); min-height: 14px; line-height: 1.4; }
.bnet-status.err { color: var(--danger); }
.bnet-user {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 2px 0 6px; padding: 9px 10px 9px 12px;
  background: rgba(240,180,41,.1); border: 1px solid rgba(240,180,41,.4);
  border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--gold);
}
.bnet-x {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 2px 7px; border-radius: 5px; flex-shrink: 0;
}
.bnet-x:hover { color: var(--danger); background: rgba(224,82,82,.15); }

/* ============ PAGINATION ============ */
.pager { display: flex; gap: 6px; justify-content: center; margin: 24px 0 10px; flex-wrap: wrap; }
.pg {
  min-width: 34px; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px;
  font-family: 'Rajdhani', sans-serif;
}
.pg:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.pg.act { background: var(--gold); border-color: var(--gold); color: #10131c; }
.pg:disabled { opacity: .35; cursor: default; }

/* ============ MAIN ============ */
.main { flex: 1; padding: 20px 24px; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.count { font-family: 'Rajdhani', sans-serif; font-size: 22px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.sort-label { color: var(--muted); font-size: 12px; }
#sort {
  padding: 8px 10px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; cursor: pointer;
}

.sec {
  font-family: 'Rajdhani', sans-serif; font-size: 17px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; color: var(--cyan);
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
  margin: 22px 0 12px;
}
.sec:first-child { margin-top: 0; }

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

/* ============ CARD ============ */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s;
  display: flex; flex-direction: column;
  content-visibility: auto; contain-intrinsic-size: 240px;
}
.card:hover { transform: translateY(-3px); border-color: var(--cyan); background: var(--card-hover); }
.card.owned { border-color: rgba(240,180,41,.55); box-shadow: 0 0 0 1px rgba(240,180,41,.35); }

.thumb {
  position: relative; aspect-ratio: 16/9; background: #0d1119;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 60%, rgba(255,255,255,.05), #0d1119 75%);
}
.thumb[data-r="Exotique"]   { background: radial-gradient(circle at 50% 60%, rgba(240,180,41,.22), #0d1119 78%); }
.thumb[data-r="Légendaire"] { background: radial-gradient(circle at 50% 60%, rgba(160,107,216,.2), #0d1119 78%); }
.thumb[data-r="Rare"]       { background: radial-gradient(circle at 50% 60%, rgba(91,143,212,.18), #0d1119 78%); }
.thumb img.wicon {
  width: 76px; height: 76px; display: block;
  opacity: 0; transition: opacity .25s ease, transform .2s ease;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.65));
}
.thumb img.wicon.ok { opacity: 1; }
.card:hover .wicon { transform: scale(1.07); }
.owned-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(240,180,41,.92); color: #10131c;
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 10px;
}

.body { padding: 10px 12px; flex: 1; }
.name {
  font-family: 'Rajdhani', sans-serif; font-size: 17px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wtype { color: var(--muted); font-size: 11px; margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 10px;
  background: rgba(255,255,255,.07); color: var(--text);
}
.chip img { width: 14px; height: 14px; border-radius: 3px; }
.ammo-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.ammo-dot[data-a="Principale"] { background: #e8e8e8; }
.ammo-dot[data-a="Spéciale"]   { background: #7fd069; }
.ammo-dot[data-a="Lourde"]     { background: #b47ff0; }
.fico { width: 15px; height: 15px; border-radius: 3px; }
.chip.rar[data-r="Exotique"]   { background: rgba(240,180,41,.18); color: var(--r-exotique); }
.chip.rar[data-r="Légendaire"] { background: rgba(160,107,216,.18); color: var(--r-legendaire); }
.chip.rar[data-r="Rare"]       { background: rgba(91,143,212,.18); color: var(--r-rare); }
.chip.rar[data-r="Peu commun"] { background: rgba(154,163,181,.15); color: var(--r-peucommun); }
.chip.rar[data-r="Commun"]     { background: rgba(77,168,100,.18); color: var(--r-commun); }
.chip.el[data-e="Arc"]        { color: var(--e-arc); }
.chip.el[data-e="Solaire"]    { color: var(--e-solaire); }
.chip.el[data-e="Abyssal"]    { color: var(--e-abyssal); }
.chip.el[data-e="Stase"]      { color: var(--e-stase); }
.chip.el[data-e="Filobscure"] { color: var(--e-filobscure); }
.chip.el[data-e="Cinétique"]  { color: var(--e-cinetique); }

.own {
  margin: 0 12px 12px; padding: 7px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.own:hover { border-color: var(--gold); color: var(--gold); }
.card.owned .own { background: rgba(240,180,41,.14); border-color: var(--gold); color: var(--gold); }

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

/* ============ MODAL ============ */
.modal {
  position: fixed; inset: 0; background: rgba(5,7,12,.8);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(680px, 92vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; position: relative;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  background: rgba(0,0,0,.5); border: none; color: #fff; width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; font-size: 14px;
}
.modal-img { aspect-ratio: 16/9; background: #0d1119; }
.modal-img img { width: 100%; height: 100%; object-fit: cover; transition: opacity .25s; }
.modal-body { padding: 18px 20px 20px; }
.m-head h2 { font-family: 'Rajdhani', sans-serif; font-size: 26px; }
.m-type { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.flavor { color: var(--muted); font-style: italic; margin: 12px 0; font-size: 13px; line-height: 1.5; }
.fiche { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.fiche-title {
  background: rgba(255,255,255,.04); padding: 7px 12px; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.fiche-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; font-size: 13px; gap: 10px;
}
.fiche-row + .fiche-row { border-top: 1px solid var(--border); }
.fiche-row span { color: var(--muted); }
.fiche-row b { font-weight: 600; text-align: right; }

/* ============ INVENTAIRE — colonnes par emplacement ============ */
.inv-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px; align-items: start;
}
.inv-col {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
  content-visibility: auto;
}
.inv-col h3 {
  font-family: 'Rajdhani', sans-serif; font-size: 15px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--gold); margin: 0 0 4px;
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
}
.inv-col h3 .n { color: var(--muted); font-size: 12px; font-weight: 400; }
.inv-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px;
  border-radius: 8px; cursor: pointer; transition: background .15s;
  border: 1px solid transparent;
}
.inv-item:hover { background: rgba(255,255,255,.05); }
.inv-item .i-thumb {
  width: 38px; height: 38px; border-radius: 7px; overflow: hidden; flex: none;
  border: 1px solid var(--border); background: #0d1119;
}
.inv-item .i-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.inv-item .i-thumb[data-r="Exotique"] { border-color: #ceae33; box-shadow: 0 0 6px rgba(206,174,51,.35); }
.inv-item .i-thumb[data-r="Légendaire"] { border-color: #522f65; }
.inv-item .i-nm { font-size: 13px; font-weight: 600; line-height: 1.2; }
.inv-item .i-sb { font-size: 11px; color: var(--muted); }
.inv-item .i-qty {
  margin-left: auto; flex: none; font-size: 11px; font-weight: 700;
  color: var(--cyan); background: rgba(60,200,255,.12);
  padding: 1px 7px; border-radius: 8px;
}
.i-sep {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 8px 2px 2px; border-top: 1px dashed var(--border);
  padding-top: 7px;
}
.inv-item.eq { border: 1px solid var(--gold); background: rgba(240,180,41,.08); }
.inv-item.eq .i-thumb { border-color: var(--gold); }
#inv-bar {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
#inv-bar input, #inv-bar select {
  background: var(--panel); border: 1px solid var(--border); color: var(--txt);
  border-radius: 9px; padding: 8px 12px; font-size: 13px; outline: none;
}
#inv-bar input { flex: 1; min-width: 180px; }
#inv-bar input:focus, #inv-bar select:focus { border-color: var(--cyan); }
.m-actions { display: flex; gap: 10px; margin-top: 14px; }
.m-actions .btn { margin-top: 0; width: auto; padding: 10px 18px; }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }

@media (max-width: 820px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
}
