:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #646b78;
  --border: #dde1e7;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok: #1d8a4e;
  --warn: #b26a00;
  --bad: #c2362f;
  --tile: #eceff3;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2c313a;
    --accent: #5b8ef5;
    --ok: #4cc28a;
    --warn: #e0a341;
    --bad: #f06b63;
    --tile: #23272f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.top, main { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 28px; }
h1 { margin: 0 0 4px; font-size: 1.5rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.fields { display: grid; grid-template-columns: 160px 1fr; gap: 12px; margin-top: 12px; }
.fields input { width: 100%; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }

input, select, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 9px 12px;
  background: var(--card);
  color: var(--text);
}
input { flex: 1 1 320px; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button { cursor: pointer; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button:disabled { opacity: .6; cursor: progress; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--bad); margin: 8px 0 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.job-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.job-head > div:first-child { min-width: 0; }
.status-line { display: flex; gap: 10px; align-items: center; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.badge {
  font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor;
}
.badge.queued, .badge.running { color: var(--accent); }
.badge.done { color: var(--ok); }
.badge.failed { color: var(--bad); }
.badge.cancelled { color: var(--warn); }
.status-line + .status-line { margin-top: 4px; }

/* Page links (Extract / DB View) */
.nav { display: flex; gap: 16px; margin-bottom: 8px; font-size: .9rem; }
.nav a { color: var(--muted); text-decoration: none; padding-bottom: 2px; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }


.progress { height: 4px; background: var(--tile); border-radius: 4px; margin: 12px 0; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress.indeterminate #bar { width: 30%; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: transparent; color: var(--text); border-color: var(--border); padding: 4px 10px; font-size: .85rem; }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  padding-bottom: 40px;
}
.tile {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tile.failed { border-color: var(--bad); }
.preview {
  display: block; aspect-ratio: 4 / 3; background: var(--tile);
  position: relative; color: var(--muted); overflow: hidden;
}
/* Absolute so portrait photos never stretch the tile. */
.preview img, .preview video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.preview .label {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; padding: 8px; text-align: center;
}
.preview .kind {
  position: absolute; top: 6px; left: 6px; font-size: .7rem; font-weight: 700;
  background: rgba(0, 0, 0, .6); color: #fff; padding: 1px 6px; border-radius: 4px;
}
figcaption { display: flex; gap: 8px; align-items: center; padding: 6px 8px; font-size: .8rem; }
figcaption .name { flex: 1; min-width: 0; }
.dl { color: var(--accent); text-decoration: none; font-weight: 600; flex-shrink: 0; }
.dl:hover { text-decoration: underline; }
.dl[aria-disabled="true"] { color: var(--muted); pointer-events: none; }

@media (max-width: 600px) { .job-head { flex-direction: column; } }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }

/* Shared by DB View */
h2 { font-size: 1.1rem; margin: 0; }
.small-btn { padding: 4px 10px; font-size: .85rem; }
code { font-size: .85em; background: var(--tile); padding: 0 4px; border-radius: 4px; }
