:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.25rem; margin: 0; }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  padding: 16px 20px 0;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}
.stat-card .num { font-size: 1.4rem; font-weight: 700; }
.stat-card .label { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.stat-card.active { background: var(--primary); border-color: var(--primary); }
.stat-card.active .num, .stat-card.active .label { color: white; }

.app-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px 20px 40px;
}

.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 12px;
  cursor: pointer;
}
.app-card img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
.app-card .info { flex: 1; min-width: 0; }
.app-card .name { font-weight: 600; }
.app-card .pkg { font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.app-card .badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.badge { font-size: 0.72rem; padding: 3px 8px; border-radius: 12px; font-weight: 600; }
.badge.status-in_review { background: #fef3c7; color: var(--amber); }
.badge.status-published { background: #dcfce7; color: var(--green); }
.badge.status-rejected { background: #fee2e2; color: var(--red); }
.badge.pay-paid { background: #dcfce7; color: var(--green); }
.badge.pay-pending { background: #fee2e2; color: var(--red); }
.app-card a { font-size: 0.8rem; color: var(--primary); text-decoration: none; }

.empty { color: var(--muted); padding: 40px; text-align: center; grid-column: 1/-1; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal h2 { margin: 0 0 6px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.modal input, .modal select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal h3 { margin: 8px 0 0; font-size: 0.9rem; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--bg); }
.modal img { cursor: zoom-in; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out; z-index: 100;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }

@media (max-width: 480px) {
  .topbar h1 { font-size: 1.05rem; }
  .app-list { grid-template-columns: 1fr; padding: 12px; }
}
