/* OuvreTonPokemon — coffre-fort de scellés.
   Dark raffiné, accent rouge pokéball, typographies à caractère. */

:root {
  --bg: #0e1014;
  --bg-raise: #14171d;
  --bg-hover: #191d25;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #e8e6e1;
  --ink-dim: #8b8e98;
  --ink-faint: #565a66;
  --red: #ff4554;
  --red-soft: rgba(255, 69, 84, 0.12);
  --up: #3ecf8e;
  --down: #ff6b5e;
  --gold: #e8c468;
  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body: "Schibsted Grotesk", sans-serif;
  --font-mono: "Spline Sans Mono", monospace;
}

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

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}

/* grain + vignette d'ambiance */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 69, 84, 0.05), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(110, 130, 255, 0.04), transparent 60%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.halftone {
  position: fixed;
  top: -40px;
  right: -40px;
  width: 320px;
  height: 320px;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.10) 1px, transparent 1.5px);
  background-size: 14px 14px;
  mask-image: radial-gradient(circle at top right, black, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at top right, black, transparent 70%);
}

/* ------------------------------------------------ pokéball motifs */

.ball-divider {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 auto 18px;
  width: 120px;
}
.ball-divider::before,
.ball-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-strong);
}
.ball-ring {
  width: 14px;
  height: 14px;
  border: 2px solid var(--red);
  border-radius: 50%;
  margin: 0 8px;
  position: relative;
  flex-shrink: 0;
}
.ball-ring::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.55;
}

/* ------------------------------------------------ login */

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 44px 40px 40px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  text-align: center;
  letter-spacing: -0.02em;
}
.login-title span { color: var(--red); }

.login-sub {
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  margin: 4px 0 30px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 18px 0 6px;
}

.login-card input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.login-card button {
  width: 100%;
  margin-top: 26px;
  background: var(--red);
  border: none;
  border-radius: 10px;
  padding: 12px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}
.login-card button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.login-card button:disabled { opacity: 0.6; cursor: wait; }

.login-error { color: var(--down); font-size: 13px; margin-top: 12px; text-align: center; }

.shake { animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

/* ------------------------------------------------ layout app */

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 28px 80px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand span.accent { color: var(--red); }
.brand .ball-ring { width: 12px; height: 12px; margin: 0; }

.top-actions { display: flex; align-items: center; gap: 14px; }

.quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  cursor: help;
}
.quota-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  flex-shrink: 0;
  transition: background 0.3s;
}
.quota-pill.warn .quota-dot { background: var(--gold); }
.quota-pill.blocked { border-color: rgba(255, 107, 94, 0.4); color: var(--down); }
.quota-pill.blocked .quota-dot {
  background: var(--down);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% { opacity: 0.35; }
}

.ghost-btn {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--ink-dim);
  border-radius: 9px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.ghost-btn:disabled { opacity: 0.45; cursor: wait; }
.ghost-btn.spin .icon { display: inline-block; animation: rotate 1s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

/* ------------------------------------------------ hero / total */

.hero {
  margin: 44px 0 36px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.hero-value {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(44px, 7vw, 68px);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-value .cents { font-size: 0.45em; color: var(--ink-dim); }

.hero-meta {
  text-align: right;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.9;
}
.hero-meta b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------ add bar */

.addbar { position: relative; margin-bottom: 26px; }

.addbar-input {
  width: 100%;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 15px 18px 15px 48px;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.addbar-input::placeholder { color: var(--ink-faint); }
.addbar-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}
.addbar .search-ico {
  position: absolute;
  left: 17px;
  top: 50%;
  translate: 0 -50%;
  color: var(--ink-faint);
  pointer-events: none;
}

.ac-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  z-index: 30;
  max-height: 420px;
  overflow-y: auto;
}
.ac-panel:empty { display: none; }

.ac-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.sel { background: var(--bg-hover); }
.ac-item img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.ac-item .ac-name { font-weight: 500; font-size: 14px; }
.ac-item .ac-sub { color: var(--ink-faint); font-size: 12px; }
.ac-item .ac-flag {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-faint);
  border: 1px solid var(--line-strong);
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}
.ac-item.added { opacity: 0.45; cursor: default; }
.ac-empty { padding: 16px; color: var(--ink-faint); font-size: 13px; text-align: center; }

/* ------------------------------------------------ table */

.board {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: right;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line-strong);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:first-child { text-align: left; padding-left: 20px; }
thead th.sorted { color: var(--ink); }
thead th .arr { color: var(--red); }

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr {
  transition: background 0.12s;
  position: relative;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--red); }

td.cell-product {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-left: 20px;
  white-space: normal;
}
.thumb {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  flex-shrink: 0;
}
.p-name { font-weight: 500; font-size: 14px; line-height: 1.3; }
.p-sub { color: var(--ink-faint); font-size: 12px; margin-top: 2px; }

.mono { font-family: var(--font-mono); font-size: 13.5px; }
.price-main { font-weight: 500; color: var(--ink); }
.price-dim { color: var(--ink-dim); }
.cell-value { font-weight: 600; color: var(--gold); }

.delta { font-family: var(--font-mono); font-size: 12.5px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--ink-faint); }

.qty-ctl {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.qty-ctl button {
  background: none;
  border: none;
  color: var(--ink-faint);
  width: 24px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.12s, background 0.12s;
}
.qty-ctl button:hover { color: var(--ink); background: var(--bg-hover); }
.qty-ctl .qty-n {
  min-width: 22px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
}

.spark { display: block; }
.spark polyline { fill: none; stroke-width: 1.6; }
.spark .area { stroke: none; opacity: 0.13; }

.del-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  transition: color 0.12s, background 0.12s;
  opacity: 0;
}
tbody tr:hover .del-btn { opacity: 1; }
.del-btn:hover { color: var(--down); background: rgba(255, 107, 94, 0.1); }
.del-btn.armed {
  opacity: 1;
  color: #fff;
  background: var(--down);
  font-size: 10.5px;
  width: auto;
  padding: 0 9px;
}

.row-loading td { color: var(--ink-faint); }

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-faint);
}
.empty-state .ball-divider { margin-bottom: 22px; }

.footnote {
  margin-top: 18px;
  color: var(--ink-faint);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.footnote a { color: var(--ink-dim); }

/* toast */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  translate: -50% 0;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 11px 20px;
  font-size: 13.5px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, translate 0.25s;
}
#toast.show { opacity: 1; translate: -50% -6px; }
#toast.err { border-color: var(--down); color: var(--down); }

/* reveal anim */
tbody tr { animation: rowin 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes rowin { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 900px) {
  .hide-md { display: none; }
  .wrap { padding: 22px 14px 60px; }
}
