:root {
  --bg: #07070d;
  --bg-raise: #0d0d17;
  --bg-card: #10101c;
  --line: #1e1e2f;
  --line-soft: #16162399;
  --text: #e8e6f0;
  --text-dim: #8a87a0;
  --text-faint: #55526b;
  --moon: #edc985;
  --moon-deep: #b8924e;
  --cyan: #8ad8ff;
  --green: #7fe0a7;
  --red: #ff8a80;
  --font-display: 'Unbounded', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

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

/* L'attribut hidden doit toujours l'emporter sur les display: des composants. */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 60% 40% at 85% -10%, #edc98511, transparent),
    radial-gradient(ellipse 40% 30% at 10% 110%, #8ad8ff09, transparent);
  background-attachment: fixed;
}

/* étoiles */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, #ffffff30, transparent),
    radial-gradient(1px 1px at 78% 12%, #ffffff25, transparent),
    radial-gradient(1.5px 1.5px at 45% 8%, #edc98530, transparent),
    radial-gradient(1px 1px at 92% 45%, #ffffff20, transparent),
    radial-gradient(1px 1px at 30% 65%, #ffffff15, transparent),
    radial-gradient(1.5px 1.5px at 65% 85%, #8ad8ff20, transparent);
  z-index: 0;
}

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

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px 0 22px;
  border-bottom: 1px solid var(--line);
}

.moon-icon { border-radius: 50%; flex-shrink: 0; display: block; }
header .moon-icon {
  width: 40px; height: 40px;
  filter: drop-shadow(0 0 14px rgba(237, 201, 133, 0.28));
}

header .brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 0; flex-wrap: nowrap;
}
header .brand .moon-logo { height: 19px; width: auto; }
header .brand .brand-x { color: var(--text-faint); font-size: 16px; font-weight: 300; }
header .brand .brand-teuf {
  font-family: var(--font-display); font-weight: 500;
  font-size: 17px; letter-spacing: 0.04em; color: var(--moon);
}

.sync-pill {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-dim);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.sync-dot.err { background: var(--red); box-shadow: 0 0 8px var(--red); }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); }
.user-chip button {
  background: none; border: none; color: var(--text-faint);
  font-family: var(--font-mono); font-size: 11px; cursor: pointer;
}
.user-chip button:hover { color: var(--red); }

/* ---------- stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 26px 0;
}
.tile {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 14px;
  position: relative;
  overflow: hidden;
}
.tile::after {
  content: '';
  position: absolute; top: 0; left: 18px; right: 18px; height: 1px;
  background: linear-gradient(90deg, transparent, #edc98540, transparent);
}
.tile .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-faint); margin-bottom: 8px;
}
.tile .value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 500;
  color: var(--text);
}
.tile .value.gold { color: var(--moon); }
.tile .sub { font-size: 10px; color: var(--text-dim); margin-top: 4px; }
.tile.hot { border-color: #8ad8ff44; }
.tile.hot .value { color: var(--cyan); }

/* ---------- controls ---------- */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.camp-tabs { display: flex; gap: 6px; }
.camp-tab {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-raise); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; cursor: pointer;
  transition: all .15s;
}
.camp-tab.active { background: #edc98518; color: var(--moon); border-color: #edc98555; }

.search {
  flex: 1; min-width: 220px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono); font-size: 13px;
  padding: 10px 16px;
  outline: none;
}
.search:focus { border-color: #edc98566; box-shadow: 0 0 0 3px #edc98511; }
.search::placeholder { color: var(--text-faint); }

.btn {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-raise); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 16px; cursor: pointer;
  transition: all .15s;
}
.btn:hover { color: var(--text); border-color: var(--text-faint); }
.btn.primary { background: var(--moon); color: #0a0805; border-color: var(--moon); font-weight: 600; }
.btn.primary:hover { background: #f5d89f; }
.btn:disabled { opacity: .5; cursor: wait; }

/* ---------- layout ---------- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 1000px) { .main-grid { grid-template-columns: 1fr; } }

/* ---------- table ---------- */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.table-scroll { overflow-x: auto; max-height: 70vh; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0;
  background: var(--bg-raise);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-faint);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:hover { color: var(--moon); }
thead th .arrow { color: var(--moon); margin-left: 4px; }
tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  font-size: 13px;
}
tbody tr:hover td { background: #edc98508; }
td.name { color: var(--text); font-weight: 500; }
td.num { font-variant-numeric: tabular-nums; color: var(--text-dim); }
td .usd { color: var(--text); }
td .usd.zero { color: var(--text-faint); }

.badge {
  display: inline-block;
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 5px; padding: 2px 7px; margin-left: 8px;
  vertical-align: 1px;
}
.badge.new { background: #8ad8ff1c; color: var(--cyan); border: 1px solid #8ad8ff40; }
.badge.ftd { background: #edc9851c; color: var(--moon); border: 1px solid #edc98540; }

.count-line {
  padding: 10px 16px;
  font-size: 11px; color: var(--text-faint);
  border-top: 1px solid var(--line);
}

/* ---------- events feed ---------- */
.feed-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  max-height: 74vh;
  overflow-y: auto;
}
.feed-card h2 {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.event {
  display: flex; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}
.event:last-child { border-bottom: none; }
.event .ico { flex-shrink: 0; }
.event .who { color: var(--text); font-weight: 500; }
.event .what { color: var(--text-dim); }
.event .when { margin-left: auto; color: var(--text-faint); font-size: 10px; white-space: nowrap; }
.event.new .ico { color: var(--cyan); }
.event.ftd .ico { color: var(--moon); }
.event.deposit .ico { color: var(--green); }
.feed-empty { color: var(--text-faint); font-size: 12px; padding: 12px 0; }

/* ---------- token warning ---------- */
.warn {
  background: #ff8a8014;
  border: 1px solid #ff8a8045;
  color: var(--red);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 18px 0 0;
  font-size: 13px;
  display: flex; align-items: center; gap: 12px;
}
.warn button { margin-left: auto; }

/* ---------- modal ---------- */
dialog {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  padding: 28px;
  width: min(520px, 92vw);
}
dialog::backdrop { background: #030308cc; backdrop-filter: blur(4px); }
dialog h2 {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 500;
  margin-bottom: 18px;
}
dialog label { display: block; font-size: 11px; color: var(--text-dim); margin: 14px 0 6px; letter-spacing: 0.08em; text-transform: uppercase; }
dialog textarea, dialog input {
  width: 100%;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono); font-size: 12px;
  padding: 10px 12px;
  outline: none;
}
dialog textarea { min-height: 80px; resize: vertical; }
dialog textarea:focus, dialog input:focus { border-color: #edc98566; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.camp-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12px; }
.camp-row .cid { color: var(--text-faint); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.camp-row button { background: none; border: none; color: var(--red); cursor: pointer; font-size: 14px; }
.hint { font-size: 11px; color: var(--text-faint); line-height: 1.5; margin-top: 6px; }

/* ---------- login ---------- */
.login-body {
  display: grid; place-items: center;
  min-height: 100vh;
}
.login-box { text-align: center; padding: 20px; }
.login-box .moon-icon {
  width: 120px; height: 120px;
  margin: 0 auto 30px;
  filter: drop-shadow(0 0 34px rgba(237, 201, 133, 0.3));
  animation: float 7s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.brand {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 14px;
  margin-bottom: 10px;
}
.brand .moon-logo { height: 30px; width: auto; }
.brand-x { color: var(--text-faint); font-size: 22px; font-weight: 300; }
.brand-teuf {
  font-family: var(--font-display); font-weight: 500;
  font-size: 24px; letter-spacing: 0.02em;
  color: var(--moon);
}
.login-box p { color: var(--text-dim); font-size: 13px; margin-bottom: 34px; }

/* Bouton officiel "Se connecter avec Google" (gsi-material-button) */
.gsi-material-button {
  -moz-user-select: none; -webkit-user-select: none; user-select: none;
  -webkit-appearance: none;
  background-color: #fff;
  background-image: none;
  border: 1px solid #747775;
  border-radius: 20px;
  box-sizing: border-box;
  color: #1f1f1f;
  cursor: pointer;
  font-family: 'Roboto', arial, sans-serif;
  font-size: 14px;
  height: 40px;
  letter-spacing: 0.25px;
  outline: none;
  overflow: hidden;
  padding: 0 12px;
  position: relative;
  text-align: center;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
  vertical-align: middle;
  white-space: nowrap;
  max-width: 400px;
  min-width: min-content;
  display: inline-block;
  text-decoration: none;
}
.gsi-material-button .gsi-material-button-icon {
  height: 20px; margin-right: 12px; min-width: 20px; width: 20px;
  display: flex; align-items: center;
}
.gsi-material-button .gsi-material-button-content-wrapper {
  align-items: center; display: flex; flex-direction: row;
  flex-wrap: nowrap; height: 100%; justify-content: space-between;
  position: relative; width: 100%;
}
.gsi-material-button .gsi-material-button-contents {
  flex-grow: 1; font-family: 'Roboto', arial, sans-serif;
  font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  vertical-align: top;
}
.gsi-material-button .gsi-material-button-state {
  transition: opacity .218s;
  bottom: 0; left: 0; opacity: 0; position: absolute; right: 0; top: 0;
}
.gsi-material-button:hover { box-shadow: 0 1px 2px 0 rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15); }
.gsi-material-button:hover .gsi-material-button-state { background-color: #303030; opacity: .08; }
.gsi-material-button:active .gsi-material-button-state { background-color: #303030; opacity: .12; }
.login-err {
  margin-top: 24px;
  color: var(--red);
  font-size: 12px;
  background: #ff8a8012;
  border: 1px solid #ff8a8040;
  border-radius: 10px;
  padding: 10px 18px;
  display: inline-block;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
