:root {
  --bg: #0b0f14;
  --bg2: #121820;
  --panel: #151c27;
  --panel-2: #1a2332;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eef7;
  --muted: #8b9bb0;
  --primary: #5b8cff;
  --primary-2: #3d6ef5;
  --accent: #2ee6a6;
  --warn: #ffb020;
  --danger: #ff5d6c;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(91, 140, 255, 0.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(46, 230, 166, 0.1), transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.86em; }
.hidden { display: none !important; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48ch; }
.inline { display: inline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.75);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.7rem; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  box-shadow: 0 8px 24px rgba(91, 140, 255, 0.35);
}
.brand-mark.lg { width: 52px; height: 52px; font-size: 1rem; margin: 0 auto 0.8rem; }
.brand-text { font-weight: 600; }
.brand-text em { font-style: normal; color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.user-chip {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.main { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 2rem; flex: 1; }
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  transition: 0.15s ease;
}
.btn-primary {
  color: white;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px rgba(61, 110, 245, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.18); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

.badge {
  font-size: 0.75rem; font-weight: 600;
  padding: 0.28rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--border);
}
.badge-ok { color: var(--accent); background: rgba(46, 230, 166, 0.1); border-color: rgba(46, 230, 166, 0.25); }
.badge-warn { color: var(--warn); background: rgba(255, 176, 32, 0.1); border-color: rgba(255, 176, 32, 0.25); }

.auth-wrap {
  min-height: calc(100vh - 4rem);
  display: grid; place-items: center;
}
.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-head h1 { margin: 0 0 0.4rem; font-size: 1.45rem; }
.auth-head p { margin: 0; color: var(--muted); }
.stack { display: grid; gap: 0.9rem; }
label { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="url"] {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  outline: none;
}
input:focus { border-color: rgba(91, 140, 255, 0.55); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15); }

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin: 0.75rem 0;
  font-size: 0.92rem;
}
.alert-error {
  background: rgba(255, 93, 108, 0.1);
  border: 1px solid rgba(255, 93, 108, 0.3);
  color: #ffb3bb;
}

.hero-panel, .panel, .progress-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.hero-panel h1 { margin: 0 0 0.35rem; font-size: 1.6rem; }
.scan-form {
  display: flex; gap: 0.65rem; margin-top: 1.1rem; flex-wrap: wrap;
}
.url-input { flex: 1 1 280px; }

.panel-head { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.9rem; }
.panel-head h2 { margin: 0; font-size: 1.15rem; }
.empty { color: var(--muted); margin: 0.5rem 0; }

.table-wrap { overflow-x: auto; }
.jobs-table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.jobs-table th {
  text-align: left; color: var(--muted); font-weight: 500;
  padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border);
}
.jobs-table td {
  padding: 0.75rem 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.jobs-table tbody tr { cursor: pointer; transition: background 0.12s; }
.jobs-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.pill {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.pill-tiktok { color: #69c9d0; }
.pill-instagram { color: #f77737; }
.pill-facebook { color: #6ea8fe; }
.pill-youtube { color: #ff6b6b; }

.status {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--panel-2);
}
.status-queued, .status-downloading, .status-extracting, .status-transcribing, .status-branding, .status-analyzing, .status-sourcing {
  color: var(--warn);
  background: rgba(255, 176, 32, 0.12);
}
.context-box {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  color: #c5d0df;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.92rem;
}
.status-done { color: var(--accent); background: rgba(46, 230, 166, 0.12); }
.status-error { color: var(--danger); background: rgba(255, 93, 108, 0.12); }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
@media (max-width: 800px) {
  .grid-3 { grid-template-columns: 1fr; }
}
.howto article {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.howto h3 { margin: 0.4rem 0; font-size: 1rem; }
.howto p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.step {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
  background: rgba(91, 140, 255, 0.15); color: var(--primary);
}

.job-header { margin-bottom: 1rem; }
.back { color: var(--muted); font-size: 0.9rem; }
.job-title-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }
.job-title-row h1 { margin: 0; font-size: 1.5rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }
.link { font-weight: 500; }

.progress-panel {
  display: flex; gap: 1.25rem; align-items: center;
  border-color: rgba(91, 140, 255, 0.28);
  background: linear-gradient(135deg, rgba(91,140,255,0.08), rgba(46,230,166,0.05));
}
.progress-panel-done {
  border-color: rgba(46, 230, 166, 0.28);
}
.progress-ring-wrap {
  position: relative;
  width: 100px; height: 100px;
  flex: 0 0 auto;
}
.progress-ring { display: block; }
.progress-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 10;
}
.progress-ring-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.45s ease, stroke 0.3s ease;
}
.progress-ring-fg.is-done { stroke: var(--accent); }
.progress-ring-fg.is-error { stroke: var(--danger); }
.progress-ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.progress-pct {
  font-weight: 700;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.progress-pct-sub {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.progress-details { flex: 1; min-width: 0; }
.progress-details strong { font-size: 1.05rem; }
.progress-bar-track {
  margin-top: 0.65rem;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #8b5cf6, var(--accent));
  background-size: 200% 100%;
  animation: shimmer 2.2s linear infinite;
  transition: width 0.45s ease;
}
.progress-bar-fill.is-done {
  background: var(--accent);
  animation: none;
}
.progress-bar-fill.is-error {
  background: var(--danger);
  animation: none;
}
@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.progress-stages {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  margin-top: 0.75rem;
}
.stage-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0,0,0,0.15);
}
.stage-chip.is-done {
  color: var(--accent);
  border-color: rgba(46, 230, 166, 0.3);
  background: rgba(46, 230, 166, 0.08);
}
.stage-chip.is-active {
  color: #fff;
  border-color: rgba(91, 140, 255, 0.5);
  background: rgba(91, 140, 255, 0.22);
  box-shadow: 0 0 0 1px rgba(91, 140, 255, 0.15);
}
.mini-progress {
  display: flex; align-items: center; gap: 0.4rem;
}
.mini-progress-track {
  flex: 1;
  height: 6px;
  min-width: 56px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.mini-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.mini-progress-fill.is-done { background: var(--accent); }
.mini-progress-fill.is-error { background: var(--danger); }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.frames {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}
.frames img {
  width: 100%; aspect-ratio: 9/16; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border);
  background: #000;
}

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}
.product-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.product-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: start; }
.product-top h3 { margin: 0; font-size: 1.05rem; }
.conf {
  font-family: var(--mono); font-size: 0.8rem; color: var(--accent);
  background: rgba(46, 230, 166, 0.1); padding: 0.2rem 0.45rem; border-radius: 6px;
}
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.55rem 0; }
.tag {
  font-size: 0.75rem; padding: 0.15rem 0.45rem; border-radius: 6px;
  background: rgba(91, 140, 255, 0.12); color: #a9c2ff;
}
.tag-price { background: rgba(46, 230, 166, 0.1); color: var(--accent); }
.product-card p { margin: 0.35rem 0; color: #c5d0df; font-size: 0.92rem; line-height: 1.45; }
.features { margin: 0.4rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.88rem; }
.notes { font-size: 0.85rem !important; color: var(--warn) !important; }

.supplier-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.supplier-card h3 { margin: 0 0 0.25rem; }
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.55rem;
  margin-top: 0.8rem;
}
.market-link {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  text-decoration: none;
  transition: 0.15s ease;
}
.market-link:hover {
  border-color: rgba(91, 140, 255, 0.45);
  background: rgba(91, 140, 255, 0.08);
  text-decoration: none;
}
.market-link span { color: var(--muted); font-size: 0.8rem; }

/* Nav */
.nav { display: flex; gap: 0.35rem; flex-wrap: wrap; flex: 1; justify-content: center; }
.nav-link {
  color: var(--muted); font-weight: 500; font-size: 0.92rem;
  padding: 0.4rem 0.7rem; border-radius: 8px; text-decoration: none;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); text-decoration: none; }
.badge-muted { color: var(--muted); background: rgba(255,255,255,0.04); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
@media (max-width: 800px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; justify-content: flex-start; }
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.stat-label { display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.stat-card strong { font-size: 1.35rem; }
.good { color: var(--accent) !important; }
.bad { color: var(--danger) !important; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.75rem; }

.alert-ok {
  background: rgba(46, 230, 166, 0.1);
  border: 1px solid rgba(46, 230, 166, 0.3);
  color: #9ef0d0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin: 0.75rem 0;
}

.filter-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.filter {
  padding: 0.35rem 0.7rem; border-radius: 999px; font-size: 0.85rem;
  border: 1px solid var(--border); color: var(--muted); text-decoration: none;
  background: var(--panel);
}
.filter:hover { color: var(--text); text-decoration: none; }
.filter.active { color: white; background: var(--primary-2); border-color: transparent; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}
.board-card {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  transition: 0.15s ease;
  box-shadow: var(--shadow);
}
.board-card:hover {
  border-color: rgba(91, 140, 255, 0.4);
  transform: translateY(-2px);
  text-decoration: none;
}
.board-thumb {
  width: 100%; height: 150px; object-fit: cover; background: #000;
}
.board-thumb.placeholder {
  display: grid; place-items: center; font-weight: 700; color: var(--muted);
  background: var(--panel-2);
}
.board-body { padding: 0.9rem; }
.board-body h3 { margin: 0; font-size: 1rem; }
.margin-row { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0.5rem 0; font-size: 0.88rem; }
.margin.good { color: var(--accent); font-weight: 700; }
.margin.bad { color: var(--danger); font-weight: 700; }
.tiny { font-size: 0.8rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-frame {
  width: 100%; max-height: 280px; object-fit: cover;
  border-radius: 10px; margin: 0.75rem 0; border: 1px solid var(--border);
}
.margin-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
  margin: 0.75rem 0 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: grid; gap: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.form-grid select, .form-grid textarea, .form-grid input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}
.form-grid textarea { resize: vertical; min-height: 90px; }
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
}

.btn-danger {
  background: rgba(255, 93, 108, 0.15);
  color: #ffb3bb;
  border: 1px solid rgba(255, 93, 108, 0.35);
}
.btn-danger:hover { background: rgba(255, 93, 108, 0.25); }
.danger-zone { border-color: rgba(255, 93, 108, 0.2); }

.live-list { display: grid; gap: 0.5rem; margin-top: 0.6rem; }
.live-item {
  display: flex; gap: 0.7rem; align-items: center;
  padding: 0.55rem; border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  color: var(--text); text-decoration: none;
}
.live-item:hover { border-color: rgba(91,140,255,0.4); text-decoration: none; }
.live-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: #000; }
.live-item strong { display: block; font-size: 0.9rem; }
.live-item span { color: var(--muted); font-size: 0.8rem; }
.subh { margin: 1rem 0 0.3rem; font-size: 0.95rem; color: var(--muted); font-weight: 600; }

.key-card.is-ready { border-color: rgba(46, 230, 166, 0.25); }
.key-card.is-missing { border-color: rgba(255, 176, 32, 0.25); }
.steps-list { color: #c5d0df; line-height: 1.6; }
.steps-list a { font-weight: 600; }
.codeblock {
  background: #0a0e13;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #b8d4ff;
}
.plain { color: #c5d0df; line-height: 1.7; }
.inline-form { display: flex; gap: 0.35rem; align-items: center; }
.inline-form input {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.35rem 0.5rem; font: inherit; width: 140px;
}
