:root {
  --bg: #0b0e14;
  --surface: #121722;
  --surface-2: #192030;
  --border: #252f42;
  --text: #eef2f8;
  --muted: #93a1b8;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top right, #161f33 0%, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small-note {
  font-size: 0.85rem;
  margin: 0;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-card h1 {
  margin: 10px 0 6px;
  font-size: 1.5rem;
}

.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #0b0e14;
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
}

.field span {
  color: var(--muted);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
.select-input,
.text-input {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  outline: none;
}

input:focus,
.select-input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #111827;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--muted);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
  padding: 11px 16px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 14, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-logo {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-logo span {
  color: var(--accent);
  margin-left: 4px;
  font-weight: 600;
}

.worker-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.worker-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.worker-pill.busy .dot {
  background: var(--warn);
}

.worker-pill.down .dot {
  background: var(--danger);
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
}

.stat-value.ok {
  color: var(--ok);
}

.stat-value.warn {
  color: var(--warn);
}

.stat-value.accent {
  color: var(--info);
}

/* Active Banner */
.active-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.14), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.active-job-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}

.progress-track {
  width: 180px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* Tabs & Toolbar */
.tabs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #111827;
}

.toolbar-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 300px;
  flex: 1;
  max-width: 560px;
}

.toolbar-inputs select {
  flex: 1 1 200px;
}

.toolbar-inputs input {
  flex: 1.4 1 220px;
}

/* Clips Grid */
.clips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.clip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.video-wrap {
  position: relative;
  background: #000;
  aspect-ratio: 9 / 16;
  max-height: 460px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.clip-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.clip-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.badge.score {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.badge.qa-pending {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.4);
}

.badge.qa-approved {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
}

.badge.qa-posted {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

.badge.qa-rejected {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

.hook-line {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  text-transform: uppercase;
}

.clip-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.caption-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.83rem;
  color: #d4dce8;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.hashtags {
  font-size: 0.8rem;
  color: var(--info);
  margin-top: 6px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qa-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.qa-btn {
  flex: 1 1 auto;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.qa-btn.active.approved {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--ok);
  color: #6ee7b7;
}

.qa-btn.active.posted {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--info);
  color: #7dd3fc;
}

.qa-btn.active.rejected {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: #fca5a5;
}

.qa-btn.active.pending {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--warn);
  color: #fde68a;
}

/* Jobs list */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.job-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 240px;
  flex: 1;
}

.job-url {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
  text-decoration: none;
}

.job-url:hover {
  color: var(--accent);
}

.job-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Empty & Modal */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* Toast */
#toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1f2937;
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.86rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.toast.error {
  border-left-color: var(--danger);
}
