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

:root {
  --bg:        #0f0f11;
  --surface:   #1a1a1f;
  --border:    #2a2a32;
  --text:      #e4e4e7;
  --muted:     #71717a;
  --primary:   #3b82f6;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --radius:    8px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-title h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.header-icon { font-size: 1.3rem; }

.header-actions { display: flex; gap: 0.5rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */

.btn {
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: 0.85; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.btn-retry {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--warning);
  background: transparent;
  color: var(--warning);
  cursor: pointer;
}
.btn-retry:hover { background: var(--warning); color: #000; }

.hidden { display: none !important; }

/* ── Main ────────────────────────────────────────────────────────────────────── */

.main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

/* ── Stats ───────────────────────────────────────────────────────────────────── */

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-value.uploaded { color: var(--success); }
.stat-value.stat-small { font-size: 1rem; padding-top: 0.5rem; }

.stat-label {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Sections ────────────────────────────────────────────────────────────────── */

.section { margin-bottom: 2rem; }

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-count {
  background: var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
}

.empty { color: var(--muted); font-size: 0.875rem; padding: 1rem 0; }

/* ── Job Table ───────────────────────────────────────────────────────────────── */

.job-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.82rem;
}

.job-table th {
  text-align: left;
  padding: 0.6rem 1rem;
  background: var(--border);
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.job-table td {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text);
}

.count-ok { color: var(--success); font-weight: 600; }
.count-err { color: var(--danger); font-weight: 600; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-pending    { background: #1e3a5f; color: #93c5fd; }
.badge-downloading { background: #3b2900; color: #fbbf24; }
.badge-uploaded   { background: #14401f; color: #86efac; }
.badge-failed     { background: #3b0f0f; color: #fca5a5; }
.badge-sync       { background: #1e3a5f; color: #93c5fd; }
.badge-download   { background: #14401f; color: #86efac; }

/* ── Reel Grid ───────────────────────────────────────────────────────────────── */

.reel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.reel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.reel-card:hover { border-color: #3a3a46; }

.reel-thumb {
  aspect-ratio: 9/16;
  max-height: 200px;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.reel-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-placeholder {
  font-size: 2rem;
  color: var(--muted);
}

.reel-body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }

.reel-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reel-user { font-weight: 600; font-size: 0.85rem; color: var(--primary); }

.reel-caption {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.tags-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  color: var(--text);
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.15s;
}
.tags-input:focus { border-color: var(--primary); }
.tags-input::placeholder { color: var(--muted); }

.reel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.reel-link {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}
.reel-link:hover { color: var(--primary); }

/* ── Toast ───────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 100;
  transition: opacity 0.3s;
}
.toast.toast-error { border-color: var(--danger); color: var(--danger); }
