/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --bg:           #fff5f9;
  --bg-panel:     #ffffff;
  --bg-row-hover: #fff5f9;

  --pink:         #e91e8c;
  --pink-mid:     #f06292;
  --pink-soft:    #fce4ec;
  --pink-pale:    #fff0f6;
  --rose:         #f8bbd0;

  --positive:     #2ecc8f;
  --negative:     #f0607e;
  --neutral:      #d4a8bd;

  --text:         #3d1a2e;
  --text-sec:     #8d5a72;
  --text-muted:   #c4a0b5;
  --border:       #fad4e4;
  --shadow:       rgba(233, 30, 140, 0.08);
  --shadow-lg:    rgba(233, 30, 140, 0.15);

  --font-display: 'Fredoka One', cursive;
  --font-body:    'Nunito', sans-serif;

  --radius:       12px;
  --radius-lg:    20px;
  --radius-pill:  100px;

  --transition:   150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Polka-dot background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(233, 30, 140, 0.07) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* ─── Floating decorations ───────────────────────────────────── */
.bg-deco {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.deco {
  position: absolute;
  color: var(--pink);
  opacity: 0.1;
  animation: float-deco linear infinite;
  font-size: 1.2rem;
}

.d1 { left:  4%;  top: 12%; animation-duration: 13s; }
.d2 { left: 14%;  top: 68%; animation-duration: 16s; animation-delay: -4s; }
.d3 { left: 28%;  top: 32%; animation-duration: 19s; animation-delay: -8s; font-size: 0.9rem; }
.d4 { left: 48%;  top: 82%; animation-duration: 14s; animation-delay: -2s; }
.d5 { left: 63%;  top:  8%; animation-duration: 17s; animation-delay: -6s; font-size: 1rem; }
.d6 { left: 76%;  top: 52%; animation-duration: 12s; animation-delay: -9s; }
.d7 { left: 87%;  top: 28%; animation-duration: 15s; animation-delay: -3s; }
.d8 { left: 93%;  top: 74%; animation-duration: 18s; animation-delay: -7s; font-size: 0.85rem; }

@keyframes float-deco {
  0%   { transform: translateY(0)    rotate(0deg);   opacity: 0.07; }
  50%  { transform: translateY(-22px) rotate(180deg); opacity: 0.16; }
  100% { transform: translateY(0)    rotate(360deg); opacity: 0.07; }
}

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 66px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 2px solid var(--rose);
  box-shadow: 0 4px 24px var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-star {
  font-size: 1.1rem;
  color: var(--pink);
  animation: spin-logo 8s linear infinite;
  display: inline-block;
}

@keyframes spin-logo {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--pink);
  text-shadow: 2px 2px 0 rgba(233, 30, 140, 0.12);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.last-updated {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sec);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.status-dot.online {
  background: var(--positive);
  box-shadow: 0 0 0 3px rgba(46, 204, 143, 0.22);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

.status-dot.stale {
  background: #ffb74d;
  box-shadow: 0 0 0 3px rgba(255, 183, 77, 0.22);
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.35); }
}

.btn-sync {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 22px;
  background: var(--pink);
  border: none;
  border-radius: var(--radius-pill);
  color: white;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(233, 30, 140, 0.38);
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-sync:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(233, 30, 140, 0.48);
}

.btn-sync:active { transform: scale(0.97); }

.btn-sync.spinning .btn-icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-icon { display: inline-block; font-size: 1rem; line-height: 1; }

/* ─── Main ───────────────────────────────────────────────────── */
.main {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── Alerts Banner ──────────────────────────────────────────── */
.alerts-banner {
  background: linear-gradient(135deg, #fff0f6, #fce4ec);
  border: 2px solid var(--rose);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rose);
}

.alerts-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--pink);
}

.alerts-toggle {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-sec);
  cursor: pointer;
  transition: color var(--transition);
}

.alerts-toggle:hover { color: var(--pink); }

.alerts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
}

.alerts-chips.collapsed { display: none; }

.alert-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: white;
  border: 1.5px solid var(--rose);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.alert-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px var(--shadow-lg);
  border-color: var(--pink);
}

.alert-chip-delta.pos { color: var(--positive); }
.alert-chip-delta.neg { color: var(--negative); }

/* ─── Filter Bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 4px 18px var(--shadow);
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
}

.filter-input {
  height: 38px;
  background: var(--pink-pale);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

.filter-input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.1);
  background: white;
}

.search-input { width: 100%; padding: 0 12px 0 36px; }

.filter-select {
  padding: 0 32px 0 14px;
  min-width: 152px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23e91e8c' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filter-select option { background: white; color: var(--text); }

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.filter-checkbox input[type="checkbox"] { display: none; }

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--pink-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.filter-checkbox input:checked + .checkbox-custom {
  background: var(--pink);
  border-color: var(--pink);
}

.filter-checkbox input:checked + .checkbox-custom::after {
  content: '✓';
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
}

.checkbox-label { font-size: 0.875rem; font-weight: 700; color: var(--text-sec); white-space: nowrap; }

/* ─── Stats Bar ──────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 4px;
}

.stat-div { color: var(--pink); font-size: 0.65rem; }

/* ─── Table ──────────────────────────────────────────────────── */
.table-wrap {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px var(--shadow);
}

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

.pet-table thead {
  background: linear-gradient(135deg, #fff0f6 0%, #fce4ec 100%);
  border-bottom: 2px solid var(--rose);
}

.pet-table th {
  padding: 13px 14px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--pink);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.pet-table th[data-sort] { cursor: pointer; transition: color var(--transition); }
.pet-table th[data-sort]:hover { color: #c2185b; }

.col-img    { width: 52px; }
.col-name   { min-width: 160px; }
.col-rarity { min-width: 130px; }
.col-val    { width: 90px;  text-align: right; }
.col-delta  { width: 76px;  text-align: right; }

.pet-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #fff0f5;
  font-size: 0.875rem;
  vertical-align: middle;
}

.pet-table tbody tr {
  background: white;
  cursor: pointer;
  transition: background var(--transition);
  animation: row-in 0.22s ease both;
}

@keyframes row-in {
  from { opacity: 0; transform: translateX(-5px); }
  to   { opacity: 1; transform: translateX(0); }
}

.pet-table tbody tr:hover { background: var(--bg-row-hover); }
.pet-table tbody tr:last-child td { border-bottom: none; }

.pet-table tbody tr.row-changed { border-left: 3px solid var(--pink); }
.pet-table tbody tr.row-changed td:first-child { padding-left: 11px; }

/* Image cell */
.pet-img-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--pink-soft);
  border: 1.5px solid var(--rose);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pet-img { width: 100%; height: 100%; object-fit: contain; }
.pet-img-placeholder { font-size: 18px; line-height: 1; }

/* Name */
.pet-name { font-weight: 800; color: var(--text); }

/* Rarity badges */
.rarity-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.rarity-common                    { background: #f5f5f5;         color: #9e9e9e; border: 1px solid #e0e0e0; }
.rarity-uncommon                  { background: #e8f5e9;         color: #388e3c; border: 1px solid #c8e6c9; }
.rarity-rare                      { background: #e3f2fd;         color: #1976d2; border: 1px solid #bbdefb; }
.rarity-ultra-rare,
.rarity-ultra_rare                { background: #f3e5f5;         color: #7b1fa2; border: 1px solid #e1bee7; }
.rarity-legendary                 { background: #fffde7;         color: #f57f17; border: 1px solid #fff9c4; }
.rarity-event,
.rarity-exotic,
.rarity-limited                   { background: var(--pink-soft); color: var(--pink); border: 1px solid var(--rose); }

/* Value cells */
.val-cell {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Delta cells */
.delta-cell {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.delta-pos  { color: var(--positive); }
.delta-neg  { color: var(--negative); }
.delta-zero { color: var(--neutral);  }

/* Loading / empty */
.loading-row td, .empty-row td {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-sec);
}

.spinner-ring {
  width: 34px;
  height: 34px;
  border: 3px solid var(--rose);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ─── Infinite scroll sentinel ──────────────────────────────── */
#scrollSentinel td { padding: 0; border: none; }
.sentinel-inner    { height: 1px; }

/* ─── Chart Dialog ───────────────────────────────────────────── */
dialog {
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  background: transparent;
  max-width: 760px;
  width: calc(100vw - 40px);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

dialog::backdrop {
  background: rgba(61, 26, 46, 0.45);
  backdrop-filter: blur(8px);
}

.dialog-inner {
  background: white;
  border: 2px solid var(--rose);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(233, 30, 140, 0.18), 0 8px 24px var(--shadow);
  animation: dialog-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dialog-pop {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  background: linear-gradient(135deg, #fff0f6, #fce4ec);
  border-bottom: 1.5px solid var(--rose);
}

.dialog-pet-info { display: flex; align-items: center; gap: 14px; }

.dialog-pet-img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--pink-soft);
  border: 2px solid var(--rose);
  object-fit: contain;
}

.dialog-pet-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--pink);
  margin-bottom: 4px;
}

.dialog-pet-rarity { font-size: 0.78rem; font-weight: 700; text-transform: capitalize; }

.dialog-close {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--rose);
  border-radius: 50%;
  background: white;
  color: var(--text-sec);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dialog-close:hover {
  background: var(--negative);
  border-color: var(--negative);
  color: white;
  transform: rotate(90deg) scale(1.1);
}

.dialog-values { display: flex; gap: 1px; background: var(--border); }

.dialog-val-item {
  flex: 1;
  padding: 16px 18px;
  background: white;
  text-align: center;
}

.dialog-val-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.dialog-val-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dialog-val-delta {
  font-size: 0.75rem;
  font-weight: 800;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.chart-container { padding: 20px; height: 300px; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

.dialog-footer {
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  background: #fff5f9;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--rose); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--pink-mid); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .header { padding: 0 16px; }
  .main { padding: 14px 14px 40px; }
  .col-rarity, .col-delta { display: none; }
  .filter-select { min-width: 120px; }
  .filter-bar { padding: 10px 12px; }
}
