:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --primary: #5460e6;
  --muted: #eef2f7;
  --muted-foreground: #64748b;
  --border: #dbe3ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--background);
  color: var(--foreground);
}

.layout {
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-secondary {
  background: var(--muted);
  color: var(--foreground);
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.enrichment-status {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.enrichment-line {
  margin: 0;
  font-size: 13px;
  color: var(--muted-foreground);
}

.search-input,
.select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--card);
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-input {
  width: 100%;
  padding-right: 36px;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.search-clear:hover {
  background: var(--muted);
  color: var(--foreground);
}

.search-meta {
  margin: -8px 0 0;
  font-size: 13px;
  color: var(--muted-foreground);
}

.select {
  min-width: 140px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.table-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  position: sticky;
  top: 0;
  background: var(--muted);
  z-index: 1;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.stat-col,
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  background: #e2e8f0;
}

th.sortable::after {
  content: "↕";
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted-foreground);
  opacity: 0.45;
}

th.sortable.sorted-asc::after {
  content: "↑";
  opacity: 1;
  color: var(--primary);
}

th.sortable.sorted-desc::after {
  content: "↓";
  opacity: 1;
  color: var(--primary);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f1f5f9;
}

tbody tr.selected {
  background: #e8ebff;
}

.creator-cell {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--muted);
}

.creator-name {
  font-weight: 600;
}

.creator-handle {
  color: var(--muted-foreground);
  font-size: 12px;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.status-done {
  background: #dcfce7;
  color: #166534;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-queued {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-failed {
  background: #fee2e2;
  color: #991b1b;
}

.status-links-none {
  background: #fee2e2;
  color: #991b1b;
}

.status-links-partial {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-links-all {
  background: #dcfce7;
  color: #166534;
}

.detail-status-note {
  color: var(--muted-foreground);
  font-size: 12px;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 220px);
}

.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  margin: 0;
  font-size: 18px;
}

.detail-header-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--primary);
  font-size: 13px;
}

.detail-meta {
  padding: 12px 16px;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
}

.detail-videos {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.detail-videos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 0;
}

.detail-videos-header h3 {
  margin: 0;
  font-size: 15px;
}

.detail-videos-summary {
  margin: 8px 16px 0;
  font-size: 12px;
  color: var(--muted-foreground);
}

.detail-videos-list {
  margin: 8px 0 0;
  padding: 0 16px 16px 36px;
  overflow: auto;
  flex: 1;
  max-height: 320px;
}

.detail-videos-list li {
  margin-bottom: 10px;
}

.detail-video-link {
  color: var(--primary);
  font-size: 13px;
  word-break: break-all;
}

.detail-video-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.detail-json {
  margin: 0;
  padding: 16px;
  overflow: auto;
  max-height: 240px;
  font-size: 12px;
  line-height: 1.5;
  background: #0f172a;
  color: #e2e8f0;
}

.actions-col {
  width: 1%;
  white-space: nowrap;
}

tbody tr td.actions-cell {
  cursor: default;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-danger:hover {
  background: #fecaca;
}

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

.btn-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--card);
  color: var(--foreground);
}

.btn-row:hover {
  background: var(--muted);
}

.btn-row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-row-danger {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff1f2;
}

.btn-row-danger:hover {
  background: #fee2e2;
}

.btn-row-primary {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.btn-row-primary:hover {
  background: #dbeafe;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted-foreground);
}

.hidden {
  display: none;
}

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