:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6a7280;
  --line: #dfe3e8;
  --accent: #1e88e5;
  --accent-ink: #ffffff;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b42318;
  --bad-bg: #fee4e2;
  --good: #067647;
  --good-bg: #d1fadf;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --ink: #e8eaed;
    --muted: #9aa3ad;
    --line: #2c313a;
    --accent: #4ea1f0;
    --accent-ink: #0b0d10;
    --warn: #fbbf24;
    --warn-bg: #3a2f10;
    --bad: #fda29b;
    --bad-bg: #43201d;
    --good: #6ce9a6;
    --good-bg: #10301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-weight: 650; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }

.topbar nav { display: flex; gap: 4px; margin-right: auto; }

.topbar nav a {
  padding: 5px 11px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}

.topbar nav a:hover { background: var(--bg); color: var(--ink); }
.topbar nav a.here { background: var(--accent); color: var(--accent-ink); }

.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); font-size: 13px; text-decoration: none; }
.who:hover { color: var(--ink); text-decoration: underline; }

.logout button {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 5px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.logout button:hover { color: var(--ink); border-color: var(--muted); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }

/* ---- flashes ---- */

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.flash.notice { background: var(--good-bg); color: var(--good); }
.flash.error { background: var(--bad-bg); color: var(--bad); }

.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.015em; }
.summary { margin: 0; color: var(--muted); font-size: 14px; }
.pending { color: var(--accent); }
.warn { color: var(--warn); }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 9px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 550;
}

/* ---- gallery ---- */

.report { margin-bottom: 36px; }

.report h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.count {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  letter-spacing: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 14px;
}

.shot { margin: 0; }

.shot .open {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}

.shot .open:hover { transform: translateY(-2px); border-color: var(--accent); }
.shot .open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shot img { display: block; width: 100%; height: auto; }

.shot figcaption {
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

/* ---- viewer ---- */

#viewer {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  overflow: visible;
}

#viewer::backdrop { background: rgba(8, 10, 14, .82); }

#viewer figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }

#viewer img {
  max-width: min(94vw, 520px);
  max-height: 84vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
}

#viewer figcaption {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: #fff;
  font-size: 13px;
}

#viewer-report { font-weight: 600; }
#viewer-label { opacity: .75; }

#viewer .close,
#viewer .nav {
  position: fixed;
  border: none;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
}

#viewer .close { top: 18px; right: 18px; width: 38px; height: 38px; font-size: 22px; }

#viewer .nav {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  font-size: 26px;
}

#viewer .prev { left: 16px; }
#viewer .next { right: 16px; }
#viewer .nav:hover, #viewer .close:hover { background: rgba(255, 255, 255, .24); }
#viewer .nav:disabled { opacity: .2; cursor: default; }

/* ---- forms / cards ---- */

body.centred { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(100%, 380px);
  box-shadow: var(--shadow);
}

.card h1 { margin: 0 0 2px; font-size: 15px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.card h2 { margin: 0 0 18px; font-size: 20px; letter-spacing: -.015em; }

label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); font-weight: 500; }

input[type=text], input[type=password], input[type=email], input[type=date], select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

button[type=submit] {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.hint { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

/* ---- panels, tables ---- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.panel h2 { margin: 0 0 14px; font-size: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.token-box {
  background: var(--good-bg);
  border: 1px solid var(--good);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.token-box p { margin: 0 0 8px; color: var(--good); font-size: 13px; }

.token-box input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

/* ---- upload ---- */

/* Sticky, above the dropzone: with 50+ tiles below it, progress is the one
   thing that must not scroll away. */
.progress {
  position: sticky;
  top: 61px;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
  opacity: 0;
  transition: opacity .2s ease;
}

.progress.busy .progress-bar { opacity: 1; }

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width .25s ease;
}

.progress-line { margin: 0; color: var(--muted); font-size: 14px; }
.progress.busy .progress-line { margin-top: 9px; color: var(--ink); font-weight: 550; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--panel);
  min-height: 200px;
  padding: 26px;
  cursor: pointer;
}

.dropzone.dz-drag-hover { border-color: var(--accent); background: var(--bg); }
.dz-message { text-align: center; color: var(--muted); }
.dz-message strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.dz-preview {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 104px;
  margin: 12px 10px 0 0;
  vertical-align: top;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  text-align: center;
}

.dz-preview img { width: 100%; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); }
.dz-preview .name, .dz-preview .state { display: block; width: 100%; }
.dz-preview .state { font-weight: 600; }
.dz-preview.done .state { color: var(--good); }
.dz-preview.dupe .state { color: var(--muted); }
.dz-preview.bad .state { color: var(--bad); }

/* ---- review ---- */

.review-item { display: flex; gap: 20px; align-items: flex-start; }
.review-item img { width: 150px; border-radius: 8px; border: 1px solid var(--line); }
.review-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.review-fields label { margin-bottom: 0; }
.review-fields label[hidden] { display: none; }
.ocr { background: var(--bg); border-radius: 7px; padding: 9px 11px; margin: 0 0 14px; }
