:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #262b36;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #c9a14a;
  --accent-2: #e3c878;
  --error: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2030, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 48px 20px 80px; }

header { text-align: center; margin-bottom: 28px; }
h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: 0.2px; }
.sub { color: var(--muted); margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }

select, input[type="file"] {
  width: 100%;
  padding: 12px;
  background: #10131a;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
}

button, .btn-link {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #20160a;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

.preview, .preview img, #result {
  width: 100%;
  border-radius: 10px;
}
.preview { margin-bottom: 18px; }
#result { display: block; margin-bottom: 16px; border: 1px solid var(--border); }

.bar {
  width: 100%;
  height: 12px;
  background: #10131a;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}
.status-msg { color: var(--muted); margin: 12px 0 0; font-size: 14px; }

.error { color: var(--error); margin: 10px 0 0; min-height: 18px; font-size: 14px; }
.hidden { display: none; }
h2 { margin: 0 0 16px; font-size: 18px; }

/* ===== batch + dashboard additions ===== */
.wrap.wide { max-width: 1040px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 0 0 6px; }
.nav-link {
  color: var(--accent-2); text-decoration: none; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); padding: 8px 14px; border-radius: 10px;
}
.nav-link:hover { background: #10131a; }
/* Push the title block left so the nav links group together on the right,
   regardless of how many there are (the logout control is conditional). */
.topbar > div:first-child { margin-right: auto; }
.logout-form { margin: 0; }
.logout-btn { cursor: pointer; background: transparent; font: inherit; }

.controls { display: flex; gap: 16px; flex-wrap: wrap; }
.field.inline { flex: 1 1 240px; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.row-actions { display: flex; align-items: center; gap: 12px; }
button { width: auto; padding: 11px 20px; }
button.secondary {
  background: #10131a; color: var(--text); border: 1px solid var(--border); font-weight: 600;
}
.batch-status { color: var(--muted); font-size: 14px; }

.rows { display: flex; flex-direction: column; gap: 12px; }
.job-row { display: flex; gap: 16px; align-items: center; padding: 14px; }
.job-row.failed { border-color: #5a2b2b; }
.thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #10131a; }
.job-meta { flex: 1; min-width: 0; }
.job-name { font-size: 13px; color: var(--muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-fields { display: flex; gap: 10px; margin-bottom: 10px; }
.job-fields .cat { flex: 0 0 150px; }
.job-fields .inv { flex: 1; }
.job-fields select, .job-fields input { padding: 9px; }
.job-msg { font-size: 13px; color: var(--muted); margin-top: 8px; }
.job-result { display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 96px; }
.job-result .btn-link { width: auto; padding: 7px 12px; font-size: 13px; }

/* dashboard */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-actions { display: flex; gap: 10px; }
.cards-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.cards-row .card { margin: 0; }
.stat { text-align: center; }
.stat-num { font-size: 26px; font-weight: 800; color: var(--accent-2); }
.stat-lbl { color: var(--muted); font-size: 13px; margin-top: 6px; }
.mini-breakdown { margin-bottom: 10px; font-size: 14px; }
.pill { display: inline-block; background: #10131a; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; margin: 3px; font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.jobs-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.jobs-table th, .jobs-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.jobs-table th { color: var(--muted); font-weight: 600; }
.jobs-table td.num, .jobs-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.status { text-transform: capitalize; font-weight: 600; }
.status.succeeded { color: #69d28a; }
.status.failed { color: var(--error); }
.status.processing, .status.queued { color: var(--accent-2); }
.err-small { color: var(--error); font-size: 12px; margin-top: 4px; max-width: 240px; }
.link-btn { background: none; border: none; color: var(--accent-2); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; width: auto; }
.pager { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.page-info { color: var(--muted); font-size: 13px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
/* combined selector beats `.modal` so the `hidden` class actually hides it */
.modal.hidden { display: none; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px; width: min(900px, 100%); max-height: 80vh; display: flex; flex-direction: column; padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#modalBody { width: 100%; flex: 1; min-height: 50vh; background: #10131a; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; resize: vertical; }

@media (max-width: 720px) {
  .cards-row { grid-template-columns: repeat(2, 1fr); }
  .job-row { flex-wrap: wrap; }
}

/* ===== lightbox / zoom ===== */
.thumb.zoomable { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; z-index: 100; }
.lightbox.hidden { display: none; }
.lb-img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 6px; cursor: zoom-in; transition: transform 0.08s ease-out; will-change: transform; user-select: none; }
.lb-img.zoomed { cursor: zoom-out; }
.lb-close { position: fixed; top: 18px; right: 22px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: rgba(20,22,28,0.85); color: var(--text); font-size: 18px; cursor: pointer; }
.lb-close:hover { background: #10131a; }
.lb-hint { position: fixed; bottom: 22px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; transition: opacity 0.2s; }

/* ===== output types + result tiles ===== */
.checkbox-row { display: flex; gap: 18px; flex-wrap: wrap; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.checkbox input { width: auto; }

.job-row { display: block; padding: 16px; }
.job-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.job-head .job-meta { flex: 1; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { background: #10131a; border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.tile.failed { border-color: #5a2b2b; }
.tile-label { font-size: 12px; color: var(--accent-2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
.tile .bar { margin-bottom: 8px; }
.tile-msg { font-size: 12px; color: var(--muted); min-height: 16px; margin-bottom: 8px; }
.tile .thumb.result { width: 100%; height: auto; max-height: 220px; object-fit: contain; margin-bottom: 8px; }
.tile .btn-link { width: auto; padding: 6px 12px; font-size: 12px; }

/* ===== per-row outputs + compare toggles ===== */
.src-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.row-outputs { margin-top: 4px; }
.cmp-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); cursor: pointer; }
.cmp-toggle.hidden { display: none; }
.cmp-toggle input { width: auto; }
.jobs-table .cmp-toggle { margin-left: 8px; }

/* floating compare button */
.compare-fab {
  position: fixed; bottom: 22px; right: 22px; z-index: 60;
  width: auto; padding: 12px 20px; border-radius: 999px; box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #20160a; font-weight: 800;
}
.compare-fab.hidden { display: none; }

/* ===== compare overlay ===== */
.compare { position: fixed; inset: 0; background: rgba(0,0,0,0.93); z-index: 110; display: flex; flex-direction: column; }
.compare.hidden { display: none; }
.compare-bar { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); color: var(--text); }
.compare-close { width: auto; padding: 9px 16px; background: #10131a; color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.compare-panels { flex: 1; display: flex; gap: 12px; padding: 16px; overflow: auto; align-items: stretch; }
.compare-panel { flex: 1 1 0; min-width: 300px; display: flex; flex-direction: column; gap: 8px; }
.compare-label { text-align: center; color: var(--accent-2); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
.compare-frame { flex: 1; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #0c0e13; display: flex; align-items: center; justify-content: center; }
.compare-img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; transition: transform 0.08s ease-out; will-change: transform; user-select: none; }
.compare-img.zoomed { cursor: zoom-out; }

@media (max-width: 720px) {
  .compare-panels { flex-direction: column; }
  .compare-panel { min-width: 0; }
}

/* QA badges */
.qa-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: 6px; }
.qa-badge.ok { color: #69d28a; border: 1px solid #2f5a3e; }
.qa-badge.bad { color: var(--error); border: 1px solid #5a2b2b; }
