:root {
  --bg: #0a0e17;
  --panel: #121a2b;
  --panel2: #1a2438;
  --border: #2a3654;
  --text: #e8edf7;
  --muted: #8b9bb8;
  --accent: #ff3d5a;
  --accent2: #7c5cff;
  --green: #22c55e;
  --red: #ef4444;
  --black: #1e293b;
  --gold: #f59e0b;
}

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

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(ellipse at 20% 0%, #1a1040 0%, var(--bg) 50%);
  color: var(--text);
  min-height: 100vh;
}

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg-glow {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(124, 92, 255, 0.35) 0%,
    rgba(255, 61, 90, 0.15) 40%,
    transparent 70%
  );
  animation: login-glow-pulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes login-glow-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

.login-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, var(--panel2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  animation: login-card-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes login-card-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-hero {
  position: relative;
  text-align: center;
  margin-bottom: 28px;
}

.login-emoji {
  position: absolute;
  font-size: 1.75rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.login-emoji-left {
  top: -4px;
  left: 0;
  animation: login-float-left 3s ease-in-out infinite;
}

.login-emoji-right {
  top: 8px;
  right: 0;
  animation: login-float-right 3.2s ease-in-out infinite 0.4s;
}

@keyframes login-float-left {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg);
  }
  50% {
    transform: translateY(-10px) rotate(6deg);
  }
}

@keyframes login-float-right {
  0%,
  100% {
    transform: translateY(0) rotate(8deg);
  }
  50% {
    transform: translateY(-12px) rotate(-8deg);
  }
}

.login-welcome {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
  animation: login-fade-up 0.6s ease 0.15s both;
}

.login-title {
  font-size: 1.65rem;
  line-height: 1.25;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35em 0.5em;
}

.login-title-word {
  background: linear-gradient(90deg, #fff 0%, #c4b5fd 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: login-fade-up 0.65s ease both;
}

.login-title-word:first-child {
  animation-delay: 0.25s;
}

.login-title-patron {
  font-size: 1.85rem;
  font-weight: 800;
  background: linear-gradient(105deg, var(--gold), #fff 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation:
    login-fade-up 0.7s ease 0.35s both,
    login-patron-shine 2.5s ease-in-out infinite 1s;
}

@keyframes login-patron-shine {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.25);
  }
}

.login-spark {
  font-size: 1.25rem;
  -webkit-text-fill-color: initial;
  animation: login-spark-spin 2.8s ease-in-out infinite;
}

@keyframes login-spark-spin {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.2) rotate(18deg);
    opacity: 1;
  }
}

.login-sub {
  color: var(--muted);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: login-fade-up 0.65s ease 0.5s both;
}

.login-chip {
  display: inline-block;
  animation: login-chip-bounce 2s ease-in-out infinite;
}

.login-chip:last-child {
  animation-delay: 0.6s;
}

@keyframes login-chip-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes login-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 16px;
  animation: login-fade-up 0.6s ease 0.55s both;
}

.login-card button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: login-fade-up 0.6s ease 0.65s both;
}

.login-card button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(255, 61, 90, 0.35);
}

.login-card .err {
  color: var(--accent);
  font-size: 0.85rem;
  margin-top: 12px;
  display: none;
}

#app {
  display: none;
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-self: stretch;
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo {
  font-weight: 600;
  font-size: 1.05rem;
  padding: 8px 12px 24px;
  color: var(--muted);
  line-height: 1.35;
}

.logo-brand {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(105deg, var(--gold), #fff 45%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-btn {
  text-align: left;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: 0.2s;
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--panel2);
  color: var(--text);
}

.nav-btn.active {
  border-left: 3px solid var(--accent);
}

.nav-btn-logout {
  margin-top: 4px;
  color: var(--muted);
  border: 1px solid var(--border);
}

.nav-btn-logout:hover {
  color: var(--accent);
  border-color: rgba(255, 61, 90, 0.45);
  background: rgba(255, 61, 90, 0.08);
}

.main {
  padding: 28px 32px;
  overflow-y: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.hero h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.hero p {
  color: var(--muted);
  margin-bottom: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.stat-card .val {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
}

.stat-card .lbl {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.home-tables {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.home-table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.home-table-card h3 {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
}

.home-table-card .val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
}

.home-table-card .lbl {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
  margin-bottom: 12px;
}

.home-table-card .home-seq {
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
}

@media (max-width: 900px) {
  .home-tables {
    grid-template-columns: 1fr;
  }
}

.search-box {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.search-box input#search-input {
  width: 120px;
  padding: 16px;
  font-size: 1.5rem;
  text-align: center;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}

.search-box input#search-limit {
  width: 110px;
  padding: 16px 12px;
  font-size: 1rem;
  text-align: center;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.search-hint {
  margin: -18px 0 24px;
  font-size: 0.78rem;
  color: var(--muted);
}

.search-box button {
  padding: 16px 28px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    min-height: 0;
    height: auto;
    align-self: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px 14px;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .logo {
    padding: 0;
    margin: 0;
    margin-right: auto;
    flex-shrink: 0;
    font-size: 0.9rem;
  }

  .logo-brand {
    display: inline;
    font-size: 1.15rem;
    margin-left: 0.25em;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .nav-btn {
    padding: 8px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .nav-btn.active {
    border-left: none;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 6px;
  }

  .nav-btn-logout {
    margin-top: 0;
  }

  .main {
    padding: 20px 16px;
  }
}

@media (max-width: 520px) {
  .sidebar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .logo {
    width: 100%;
    margin-right: 0;
  }

  .sidebar-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-btn {
    flex: 1;
    text-align: center;
    min-width: 0;
    padding: 8px 6px;
    font-size: 0.78rem;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel h3 {
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.bar-row .label {
  width: 90px;
  font-size: 0.85rem;
  color: var(--muted);
}

.bar-row .track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}

.bar-row .fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}

.bar-row .pct {
  width: 48px;
  text-align: right;
  font-weight: 600;
  font-size: 0.9rem;
}

.fill-red {
  background: var(--red);
}
.fill-black {
  background: #475569;
}
.fill-green {
  background: var(--green);
}
.fill-accent {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.hero.compact h2 {
  margin-bottom: 4px;
}

.hero.compact p {
  display: none;
}

.result-head {
  margin-bottom: 20px;
}

.result-head h3 {
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.result-head .recent-seq {
  margin-bottom: 10px;
}

.followers-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.followers-inline .chip {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.triplet-top {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.triplet-middle {
  margin-top: 10px;
}

.triplet-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.triplet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.9rem;
}

.triplet-rank {
  color: var(--gold);
  font-weight: 700;
  width: 1.2rem;
}

.triplet-series {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.04em;
}

.triplet-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: auto;
}

.wheel-panel {
  text-align: center;
  margin-bottom: 16px;
}

.heat-scale {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.heat-scale .scale-bar {
  width: 140px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #172554, #2563eb, #7c3aed, #ef4444);
}

.wheel-hint {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.wheel-sector-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
  margin-top: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.wheel-sector-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wheel-sector-legend .leg {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}

.wheel-sector-legend .leg.zero {
  background: rgba(34, 197, 94, 0.55);
}

.wheel-sector-legend .leg.voisins {
  background: rgba(59, 130, 246, 0.55);
}

.wheel-sector-legend .leg.tier {
  background: rgba(168, 85, 247, 0.55);
}

.wheel-sector-legend .leg.orph {
  background: rgba(245, 158, 11, 0.55);
}

#wheel-wrap {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

#wheel-svg {
  max-width: min(440px, 100%);
  height: auto;
  filter: drop-shadow(0 8px 32px rgba(0, 0, 0, 0.45));
}

.stats-panel h3 {
  margin-bottom: 12px;
}

.stats-matrix {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 28px;
}

@media (max-width: 700px) {
  .stats-matrix {
    grid-template-columns: 1fr;
  }
}

.stat-block h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-block-wide {
  grid-column: 1 / -1;
}

.stats-panel .bar-row {
  margin-bottom: 6px;
}

.stats-panel .bar-row .label {
  width: 72px;
  font-size: 0.8rem;
}

.stats-panel .panel {
  margin-bottom: 0;
}

.wheel-num {
  cursor: default;
  transition: 0.3s;
}

.followers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  background: var(--panel2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.chip strong {
  color: var(--gold);
}

.loading,
.error-msg {
  color: var(--muted);
  padding: 20px;
}

.error-msg {
  color: var(--accent);
}

.recent-seq {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.6;
}
