/* Nyxfall design system: tokens and the components shared by the panel and the public page. */
:root {
  color-scheme: dark;
  /* Surfaces, darkest to lightest */
  --bg: #0a0811;
  --surface-1: #110e1a;
  --surface-2: #171324;
  --surface-3: #1f1a2f;
  --surface-4: #29223d;
  --border: #2a2340;
  --border-strong: #3b3257;
  /* Text */
  --text: #eeeaf7;
  --text-2: #bdb4d1;
  --muted: #8d84a6;
  /* Brand and states */
  --accent: #7b2ff7;
  --accent-hover: #8d4bff;
  --accent-soft: #7b2ff724;
  --accent-text: #c4a6ff;
  --magenta: #ff3fb4;
  --magenta-soft: #ff3fb41f;
  --success: #3ccf7a;
  --success-soft: #3ccf7a1c;
  --warning: #f2b13c;
  --warning-soft: #f2b13c1c;
  --danger: #ff5470;
  --danger-soft: #ff54701f;
  --gold: #ffd36a;
  /* Chart series (dataviz reference palette, dark steps) */
  --series-1: #3987e5;
  --series-2: #d95926;
  /* Shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 10px 30px #0009;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-hover);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: .1em .4em; border-radius: 4px; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.positive { color: var(--success); }
.negative { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; flex-shrink: 0; vertical-align: -.15em; }

/* Layout helpers */
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.spacer { flex: 1; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }

/* Cards */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
}
.card + .card, .card + .grid-2, .grid-2 + .card, .stats + .card, .card + .stats { margin-top: 1rem; }
.card-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem; }
.card-head h2 { flex: 1; min-width: 0; }
.card-head .sub { flex-basis: 100%; color: var(--muted); font-size: .85rem; margin-top: -.5rem; }
.card-foot { margin-top: .9rem; color: var(--muted); font-size: .8rem; }

/* Stat tiles */
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.stat {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem 1rem; min-width: 0;
}
.stat .label { color: var(--muted); font-size: .75rem; font-weight: 600; letter-spacing: .03em; display: flex;
  align-items: center; gap: .35rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: .15rem; overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: .78rem; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 650; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-strong);
}
.badge.success { background: var(--success-soft); color: var(--success); border-color: #3ccf7a55; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #ff547055; }
.badge.warning { background: var(--warning-soft); color: var(--warning); border-color: #f2b13c55; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: #7b2ff766; }
.badge.magenta { background: var(--magenta-soft); color: var(--magenta); border-color: #ff3fb455; }
.badge.gold { background: #ffd36a1a; color: var(--gold); border-color: #ffd36a55; }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; display: inline-block; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  background: var(--accent); color: #fff; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .5rem .95rem; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .12s, border-color .12s;
}
.button:hover { background: var(--accent-hover); text-decoration: none; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.secondary { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.button.secondary:hover { background: var(--surface-4); }
.button.ghost { background: transparent; color: var(--text-2); }
.button.ghost:hover { background: var(--surface-3); color: var(--text); }
.button.danger { background: var(--danger); }
.button.danger:hover { background: #ff6d85; }
.button.danger-outline { background: transparent; color: var(--danger); border-color: #ff547066; }
.button.danger-outline:hover { background: var(--danger-soft); }
.button.small { padding: .28rem .6rem; font-size: .82rem; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; flex-shrink: 0;
  background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: var(--radius-sm);
  cursor: pointer; padding: 0;
}
.icon-button:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.icon-button.danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.icon-button:disabled { opacity: .3; cursor: default; }

/* Segmented tabs */
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; flex-wrap: wrap; }
.segmented button {
  background: transparent; border: 0; color: var(--text-2); padding: .3rem .75rem; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: .85rem; font-weight: 600;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-4); color: var(--text); box-shadow: 0 1px 2px #0006; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .75rem; letter-spacing: .03em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.clickable:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: -2px; box-shadow: none; }
.rank { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6rem; height: 1.6rem;
  border-radius: 50%; font-weight: 700; font-size: .8rem; background: var(--surface-3); color: var(--text-2); }
.rank.r1 { background: #ffd36a26; color: var(--gold); }
.rank.r2 { background: #d6dbe826; color: #d6dbe8; }
.rank.r3 { background: #e0975726; color: #e09757; }

/* Empty and loading states */
.empty { text-align: center; padding: 1.75rem 1rem; color: var(--muted); }
.empty .icon { width: 1.8rem; height: 1.8rem; margin-bottom: .4rem; opacity: .7; }
.empty strong { display: block; color: var(--text-2); margin-bottom: .2rem; }
.skeleton { height: .9rem; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3),
  var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: .5rem 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Banners */
.banner {
  display: flex; gap: .6rem; align-items: flex-start; border-radius: var(--radius); padding: .7rem .9rem;
  border: 1px solid; font-size: .9rem;
}
.banner > .icon { margin-top: .15rem; }
.banner > div { flex: 1; min-width: 0; }
.banner.info { background: var(--accent-soft); border-color: #7b2ff766; color: var(--text); }
.banner.warning { background: var(--warning-soft); border-color: #f2b13c66; color: #ffe0a3; }
.banner.danger { background: var(--danger-soft); border-color: #ff547066; color: #ffc2cc; }
.banner.success { background: var(--success-soft); border-color: #3ccf7a66; color: #bff3d4; }
.banner + .banner, .banner + .card, .banner + .stats { margin-top: .75rem; }

/* Progress bar */
.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--magenta)); border-radius: 999px;
  transition: width .4s; }

/* Language switch */
.lang-switch { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.lang-switch select { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .2rem .4rem; font: inherit; font-size: .8rem; width: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.grid-2 > *, .stack > * { margin: 0 !important; }
.grid-2 > .card { align-self: stretch; }
