:root {
  --color-none: #e5e7eb;
  --color-have: #dcfce7;
  --color-have-border: #16a34a;
  --color-repeated: #fff7ed;
  --color-repeated-border: #ea580c;
  --color-shield: #fef9c3;
  --color-intro: #eff6ff;
  --radius: 8px;
  --transition: 0.15s ease;
  --header-h: 48px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f9fafb;
  color: #111827;
  font-size: 14px;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
  background: #16a34a;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* ── Stats bar ── */
.stats-bar {
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #166534;
  text-align: center;
}

/* ── Filter bar ── */
.filter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  background: #fff;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}
#search:focus { border-color: #16a34a; }

.status-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.chip.active {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  font-weight: 600;
}

.select-row {
  display: flex;
  gap: 8px;
}
.select-row select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #6b7280;
}
.filter-summary.hidden { display: none; }

#btn-clear-filters {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}

/* ── Main content ── */
.app-content {
  padding: 8px 12px 32px;
}

/* ── Group section ── */
.group-section {
  margin-bottom: 12px;
}

.group-heading {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 0 4px;
}

/* ── Team accordion ── */
.team-details {
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
  background: #fff;
}

.team-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.team-summary::-webkit-details-marker { display: none; }
.team-summary::marker { display: none; }

.team-name {
  font-weight: 600;
  font-size: 14px;
}

.team-progress {
  font-size: 12px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 999px;
}

.team-details[open] .team-summary {
  border-bottom: 1px solid #e5e7eb;
}

/* ── Sticker grid ── */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
}

/* ── Sticker card ── */
.sticker-card {
  border-radius: var(--radius);
  border: 2px solid var(--color-none);
  background: var(--color-none);
  padding: 6px 4px;
  text-align: center;
  font-size: 10px;
  cursor: default;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  opacity: 0.55;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
}

.sticker-card .card-id {
  font-size: 9px;
  font-weight: 700;
  color: #6b7280;
  line-height: 1;
}
.sticker-card .card-name {
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  padding: 0 2px;
}
.sticker-card .card-badge {
  font-size: 9px;
  font-weight: 700;
  margin-top: 2px;
}

.sticker-card.status-none {
  opacity: 0.5;
  background: var(--color-none);
  border-color: var(--color-none);
}
.sticker-card.status-have {
  background: var(--color-have);
  border-color: var(--color-have-border);
  opacity: 1;
}
.sticker-card.status-have .card-badge { color: var(--color-have-border); }

.sticker-card.status-repeated {
  background: var(--color-repeated);
  border-color: var(--color-repeated-border);
  opacity: 1;
}
.sticker-card.status-repeated .card-badge { color: var(--color-repeated-border); }

.sticker-card.type-shield {
  background: var(--color-shield);
  border-color: #ca8a04;
}
.sticker-card.type-special {
  background: var(--color-intro);
  border-color: #93c5fd;
}

/* Admin: cards são clicáveis */
.is-admin .sticker-card {
  cursor: pointer;
}
.is-admin .sticker-card:hover {
  transform: scale(1.05);
  z-index: 1;
}
.is-admin .sticker-card:active {
  transform: scale(0.97);
}

/* Highlight (busca exata) */
.sticker-card.highlight {
  box-shadow: 0 0 0 3px #f59e0b;
  opacity: 1;
}

/* Remove button — visível só no modo admin em cards marcados */
.card-remove {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.18);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.is-admin .sticker-card.status-have .card-remove,
.is-admin .sticker-card.status-repeated .card-remove {
  display: flex;
}
.card-remove:hover { background: rgba(220,38,38,0.7); }

/* Repeated count controls */
.count-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
}
.count-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--color-repeated-border);
  background: #fff;
  color: var(--color-repeated-border);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.count-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-repeated-border);
  min-width: 20px;
  text-align: center;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-box h2 {
  font-size: 18px;
  font-weight: 700;
}
.modal-box input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 16px;
  width: 100%;
}
.modal-box button {
  padding: 10px;
  border-radius: var(--radius);
  border: none;
  background: #16a34a;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-link {
  background: none !important;
  color: #6b7280 !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  padding: 4px !important;
}

.error {
  color: #dc2626;
  font-size: 13px;
}
.error.hidden { display: none; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Hidden utility ── */
.hidden { display: none !important; }

@media (min-width: 768px) {
  .app-content { max-width: 900px; margin: 0 auto; }
}
