:root {
  --ink: #17352e;
  --ink-soft: #55706a;
  --field: #e9efeb;
  --sheet: #ffffff;
  --line: #c9d5cf;
  --bus: #f2b705;
  --red: #b42318;
  --red-bg: #fbeae8;
  --green: #1c7048;
  --green-bg: #e4f2ea;
  --amber-bg: #fdf4d3;
  --serif: "Geeza Pro", "Noto Naskh Arabic", "Times New Roman", serif;
  --sans: -apple-system, "SF Arabic", "Segoe UI", Tahoma, sans-serif;
  --plate: "DIN Alternate", "DIN Condensed", "Arial Narrow", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--field); color: var(--ink); font: 16px/1.6 var(--sans); display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.25; margin: 0; }
h1 { font-size: 34px; }
h2 { font-size: 23px; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--bus); outline-offset: 2px; }
#view { flex: 1; min-height: 0; outline: none; display: flex; flex-direction: column; overflow-y: auto; }

.bar { background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; flex: none; }
.brand { font: 700 20px var(--serif); text-decoration: none; }
.bar-note { font-size: 13px; color: #c4d6cf; }

.page { width: 100%; max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; display: flex; flex-direction: column; gap: 32px; }
.lead { color: var(--ink-soft); max-width: 62ch; }

.login { max-width: 420px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.login input { font: inherit; border: 1px solid var(--ink-soft); border-radius: 4px; padding: 8px 10px; }
.bar-user { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.bar-user a { color: #fff; }
.login-form { max-width: 460px; }
.login-form label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.login-form input:not([type=checkbox]) { font: inherit; border: 1px solid var(--ink-soft); border-radius: 4px; padding: 8px 10px; }
.bar-user button { background: none; border: 1px solid #c4d6cf; color: #fff; border-radius: 4px; padding: 3px 10px; cursor: pointer; font: inherit; }
.drop { background: var(--sheet); border: 2px dashed var(--ink-soft); border-radius: 6px; padding: 40px 24px; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.drop.over { border-color: var(--ink); background: var(--amber-bg); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.btn { background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 4px; padding: 9px 18px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; }
.btn:hover { background: #0e2620; }
.btn.quiet { background: transparent; color: var(--ink); }
.btn.quiet:hover { background: var(--sheet); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }

table { border-collapse: collapse; width: 100%; background: var(--sheet); }
th, td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: center; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--amber-bg); }
td.cell-bad a { color: var(--red); font-weight: 700; }
.scroll { overflow-x: auto; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.facts div { background: var(--sheet); padding: 12px 16px; }
.facts b { display: block; font: 700 26px var(--plate); }
.facts span { font-size: 14px; color: var(--ink-soft); }

.panel { background: var(--sheet); border: 1px solid var(--line); padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.warn { background: var(--amber-bg); border-inline-start: 4px solid var(--bus); padding: 12px 16px; }
.error { background: var(--red-bg); border-inline-start: 4px solid var(--red); padding: 12px 16px; }
.error ul { margin: 8px 0 0; padding-inline-start: 22px; }
label.check { display: flex; gap: 10px; align-items: flex-start; }
label.check input { margin-top: 6px; }
.field-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
input[type=date], input[type=search], select, textarea { background: #fff; border: 1px solid var(--ink-soft); border-radius: 4px; padding: 7px 10px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { color: var(--ink-soft); }
.steps li.now { color: var(--ink); font-weight: 700; }
.steps li.done { color: var(--green); }
progress { width: 100%; height: 10px; accent-color: var(--ink); }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head h1 { overflow-wrap: anywhere; font-size: 26px; }
.big-line { font: 700 30px/1.3 var(--serif); }
.bucket { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; align-items: baseline; padding: 12px 16px; background: var(--sheet); border-bottom: 1px solid var(--line); text-decoration: none; }
.bucket:hover { background: var(--amber-bg); }
.bucket b { font: 700 24px var(--plate); text-align: center; }
.bucket em { font-style: normal; color: var(--ink-soft); font-size: 14px; }
.buckets { border: 1px solid var(--line); border-bottom: 0; }
.tag { font-size: 13px; padding: 1px 8px; border-radius: 3px; background: var(--field); white-space: nowrap; }
.tag.High { background: var(--red-bg); color: var(--red); }
.tag.Rule { background: var(--amber-bg); }
details.chk { background: var(--sheet); border-bottom: 1px solid var(--line); }
details.chk summary { padding: 11px 16px; cursor: pointer; display: grid; grid-template-columns: 90px 1fr 60px; gap: 12px; align-items: baseline; }
details.chk > div { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-soft); }
details.chk table { font-size: 14px; color: var(--ink); }

/* review */
.review { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px 400px 1fr; }
.queue { background: var(--sheet); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.queue-tools { padding: 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.queue-tools select, .queue-tools input[type=search] { width: 100%; }
.bulk summary { cursor: pointer; font-size: 14px; }
.bulk .field-row { margin-top: 8px; }
.bulk .btn { padding: 6px 12px; font-size: 14px; }
.queue-count { font-size: 13px; color: var(--ink-soft); }
.queue ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.queue button { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: right; padding: 9px 12px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.queue button:hover { background: var(--field); }
.queue button[aria-current=true] { background: var(--amber-bg); box-shadow: inset -5px 0 0 var(--bus); }
.queue button.finished { color: var(--ink-soft); }
.queue small { color: var(--ink-soft); grid-column: 1 / -1; font-size: 13px; }
.queue .tick { color: var(--green); font-weight: 700; }

.compare { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; border-inline-end: 1px solid var(--line); }
.who { display: flex; gap: 14px; align-items: center; }
.who p { color: var(--ink-soft); font-size: 14px; }

/* The one loud object: a vehicle's plate, drawn as a plate */
.plate { direction: rtl; display: inline-grid; grid-template-columns: auto auto 22px; background: #fff; border: 3px solid #111; border-radius: 7px; font: 700 30px/1 var(--plate); min-height: 62px; flex: none; }
.plate .p-letters, .plate .p-digits { padding: 13px 13px; display: flex; align-items: center; }
.plate .p-letters { letter-spacing: 3px; border-inline-end: 2px solid #111; font-family: var(--sans); font-size: 26px; }
.plate .p-digits { letter-spacing: 2px; direction: ltr; }
.plate .p-ksa { background: var(--ink); color: #fff; font: 700 10px/1.1 var(--sans); writing-mode: vertical-rl; text-align: center; display: flex; align-items: center; justify-content: center; border-radius: 3px 0 0 3px; }

.result { background: var(--sheet); border: 1px solid var(--line); display: flex; flex-direction: column; }
.result.is-open { border-color: var(--ink-soft); }
.result header { padding: 10px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-bottom: 1px solid var(--line); }
.status-bad { color: var(--red); font-weight: 700; }
.status-good { color: var(--green); font-weight: 700; }
.vs { display: grid; grid-template-columns: 1fr 1fr; }
.vs > div { padding: 10px 14px; min-width: 0; }
.vs > div + div { border-inline-start: 1px solid var(--line); }
.vs span { font-size: 13px; color: var(--ink-soft); display: block; }
.vs b { font: 700 21px var(--plate); direction: ltr; unicode-bidi: isolate; display: inline-block; overflow-wrap: anywhere; }
.vs b.words { font: 700 16px var(--sans); direction: rtl; }
.status-open { font-weight: 600; }
.result .why { padding: 0 14px 10px; font-size: 14px; color: var(--ink-soft); }
.decide { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; }
.decide button { background: #fff; border: 1px solid var(--ink-soft); border-radius: 4px; padding: 5px 10px; cursor: pointer; font-size: 14px; }
.decide button:hover { background: var(--field); }
.decide button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.decide kbd { font: 12px var(--plate); opacity: .7; margin-inline-end: 4px; }
.note-reopen { background: var(--amber-bg); padding: 6px 14px; font-size: 14px; }
.hint { font-size: 13px; color: var(--ink-soft); }

.viewer { background: #5c6b66; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.view-tools { background: var(--sheet); border-bottom: 1px solid var(--line); padding: 6px 10px; display: flex; gap: 6px; align-items: center; font-size: 14px; }
.view-tools button { width: 34px; height: 34px; background: #fff; border: 1px solid var(--ink-soft); border-radius: 4px; cursor: pointer; font-size: 18px; line-height: 1; }
.view-tools a { margin-inline-start: auto; padding: 5px 12px; font-size: 14px; }
.pages { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pages img { background: #fff; display: block; max-width: none; width: 100%; box-shadow: 0 1px 3px #0005; }
.pages[data-zoom="50"] img { width: 50%; } .pages[data-zoom="75"] img { width: 75%; } .pages[data-zoom="125"] img { width: 125%; }
.pages[data-zoom="150"] img { width: 150%; } .pages[data-zoom="175"] img { width: 175%; } .pages[data-zoom="200"] img { width: 200%; }
.viewer .empty { margin: auto; color: #fff; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.viewer .empty .btn { background: #fff; }

.empty-state { padding: 28px; text-align: center; color: var(--ink-soft); background: var(--sheet); border: 1px solid var(--line); }
#toast { position: fixed; inset-block-end: 20px; inset-inline-start: 20px; background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity .15s; }
#toast.show { opacity: 1; }

@media (max-width: 1100px) {
  .review { display: block; flex: none; }
  .queue, .compare { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .queue ul { max-height: 240px; }
  .compare { overflow: visible; }
  .viewer { height: 80vh; }
}
@media (max-width: 700px) {
  .vs { grid-template-columns: 1fr; }
  .vs > div + div { border-inline-start: 0; border-top: 1px solid var(--line); }
  h1 { font-size: 27px; }
  .bar-note { display: none; }
  .page { padding: 20px 16px 48px; }
  .bucket { grid-template-columns: 52px 1fr; }
  .bucket em { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
