:root {
  --bg: #0f1226;
  --bg-soft: #171a35;
  --card: #1e2243;
  --card-2: #252a52;
  --text: #eef0ff;
  --muted: #9aa0c7;
  --line: #2c3160;
  --green: #2ecc71;
  --green-d: #1f9d57;
  --amber: #f5a623;
  --amber-d: #c97f0a;
  --red: #ff5e7e;
  --blue: #4f7cff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 50% -200px, #232a5e 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 60px;
}

/* LOGIN */
.login-screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(900px 500px at 50% -150px, #2a317a 0%, var(--bg) 65%);
  z-index: 100;
}
.login-screen.show { display: flex; }
.login-box {
  width: 100%; max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.login-badge {
  font-size: 34px;
  width: 64px; height: 64px;
  display: grid; place-items: center;
  background: linear-gradient(120deg, #4f7cff, #14b8a6);
  border-radius: 18px;
  margin-bottom: 14px;
}
.login-box h1 { font-size: 21px; font-weight: 800; }
.login-sub { color: var(--muted); font-size: 14px; margin: 6px 0 20px; }
.login-box input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
}
.login-box input:focus { border-color: var(--blue); }
.login-btn {
  width: 100%;
  background: linear-gradient(120deg, #4f7cff, #14b8a6);
  border: none;
  color: #fff;
  padding: 13px;
  border-radius: 12px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}
.login-btn:hover { filter: brightness(1.06); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* HERO */
.hero {
  background: linear-gradient(120deg, #3a2bd1 0%, #4f7cff 50%, #14b8a6 100%);
  box-shadow: var(--shadow);
}
.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.hero-text { flex: 1; }
.logout-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.25); }
.hero-badge {
  font-size: 40px;
  width: 70px; height: 70px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  backdrop-filter: blur(6px);
}
.hero h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.hero p { color: rgba(255, 255, 255, 0.85); font-size: 15px; margin-top: 4px; }

.container { max-width: 1100px; margin: 0 auto; padding: 26px 24px; }

/* STATS */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 30px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.ok .stat-value { color: var(--green); }
.stat-card.miss .stat-value { color: var(--red); }
.stat-card.dup .stat-value { color: var(--amber); }

/* PROGRESS */
.progress-wrap { margin: 20px 0 8px; display: flex; align-items: center; gap: 14px; }
.progress-bar {
  flex: 1; height: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), #6fe0a0);
  border-radius: 999px;
  transition: width 0.5s ease;
}
.progress-text { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }

/* TOOLBAR */
.toolbar {
  margin: 22px 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
#search {
  flex: 1; min-width: 180px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
}
#search:focus { border-color: var(--blue); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.filter:hover { color: var(--text); }
.filter.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-trade {
  background: linear-gradient(120deg, var(--amber), #ffd166);
  border: none;
  color: #2a1a00;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-trade:hover { filter: brightness(1.05); }
.btn-import {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.btn-import:hover { border-color: var(--blue); }

.modal-desc { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.modal-example {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
  white-space: pre;
  overflow-x: auto;
}
#import-file {
  width: 100%;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}
#import-file::file-selector-button {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
}
#import-text {
  width: 100%; height: 120px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.modal-warning { color: var(--amber); font-size: 13px; margin: 10px 0; font-weight: 600; }
.btn-confirm {
  flex: 1;
  background: var(--green);
  color: #06351b;
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700; font-size: 15px;
  cursor: pointer;
}
.btn-confirm:hover { filter: brightness(1.05); }
#import-result { font-size: 14px; color: var(--text); }
#import-result .res-ok { color: var(--green); font-weight: 600; }
#import-result .res-warn { color: var(--amber); font-size: 13px; margin-top: 6px; }

.hint { color: var(--muted); font-size: 13px; margin: 14px 2px; }

/* ALBUM */
.section { margin-bottom: 26px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.section-title { font-size: 17px; font-weight: 700; }
.section-code {
  font-size: 12px; font-weight: 700;
  color: var(--blue);
  background: rgba(79,124,255,0.12);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.section-meta { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1.15;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: scale(0.96); }
.tile .num { font-size: 20px; font-weight: 800; }
.tile .state { font-size: 11px; color: var(--muted); margin-top: 2px; }

.tile.have {
  background: linear-gradient(160deg, rgba(46,204,113,0.18), var(--card));
  border-color: var(--green-d);
}
.tile.have .state { color: var(--green); }
.tile.dup {
  background: linear-gradient(160deg, rgba(245,166,35,0.2), var(--card));
  border-color: var(--amber-d);
}
.tile.dup .state { color: var(--amber); }

.tile .badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--amber);
  color: #2a1a00;
  font-size: 12px; font-weight: 800;
  min-width: 22px; height: 22px;
  border-radius: 999px;
  display: grid; place-items: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.tile .minus {
  position: absolute;
  bottom: -7px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  width: 26px; height: 22px;
  border-radius: 8px;
  font-size: 15px; line-height: 1;
  display: none;
  align-items: center; justify-content: center;
  cursor: pointer;
}
.tile.have .minus, .tile.dup .minus { display: flex; }
.tile .minus:hover { color: var(--red); border-color: var(--red); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: 100%; max-width: 520px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 20px; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer;
}
#trade-text {
  width: 100%; height: 220px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn-copy, .btn-whats {
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700; font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  border: none;
}
.btn-copy { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn-whats { background: #25d366; color: #06351b; }

/* TOAST */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.3s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 22px; }
}
