/* ===========================================================================
   SCAN DESK — the theme.

   The metaphor is a verification desk, not a document viewer: a scan lying on
   a dark mat under a lamp, and a clean sheet beside it where the values are
   being written out. So the two halves are deliberately different materials.

   - The mat is a warm near-black. A scanned page is off-white and anything
     lighter than this behind it makes the paper look grey, which is the one
     thing that makes a scan look like a bad scan.
   - The data side is paper white and hard-edged. Nothing floats, nothing is
     rounded much: this is a form being filled in.
   - Three inks and only three. Indigo is the system's own writing. Highlighter
     yellow is "look here". Red is a correction, in the way a checker's pen is
     red - it means a human disagreed with the machine.
   - Confidence is drawn, never described. A bar under every value, and the
     eye sorts them faster than any percentage does.

   The typeface pairing is doing work: the printed parts of the scanned form
   are a serif, the filled-in parts are a handwriting stack, and the extracted
   values on the right are monospace. Three different kinds of writing for
   three different authors - the department, the applicant, and the machine.
   =========================================================================== */
:root{
  --mat:#1A1C20;
  --mat-2:#24272C;
  --paper:#FFFFFF;
  --paper-2:#F7F8FA;
  --scan:#FBF9F3;              /* the colour of a photocopied page */
  --ink:#16181D;
  --ink-2:#4A5058;
  --mut:#6A717B;
  --line:#DFE3E8;
  --line-2:#C2C9D2;
  --pen:#25348C;               /* the system's ink */
  --pen-soft:#EDEFF9;
  --mark:#FFE27A;              /* highlighter */
  --mark-2:#FFF6D6;
  --red:#BE2B31;               /* the checker's pen */
  --red-soft:#FBEEEF;
  --grn:#166B45;
  --grn-soft:#E9F5EF;
  --amb:#8A5A00;
  --amb-soft:#FDF3E0;
  --ui:var(--f-text);
  --mono:var(--f-data);
  --serif:var(--f-serif);
  --hand:"Segoe Script","Bradley Hand","Lucida Handwriting","Comic Sans MS",cursive;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;height:100vh;display:flex;flex-direction:column;overflow:hidden;
  color:var(--ink);font:14px/1.5 var(--ui);
  /* GROUND: the desk under the work - a warm wash falling from the lamp above
     the mat, over a 24px ruled grid at 2%, which is the cutting mat. */
  background:
    radial-gradient(70% 40% at 24% 0%,rgba(37,52,140,.045),transparent 62%),
    repeating-linear-gradient(0deg,rgba(35,26,28,.022) 0 1px,transparent 1px 24px),
    repeating-linear-gradient(90deg,rgba(35,26,28,.022) 0 1px,transparent 1px 24px),
    var(--paper);
  -webkit-font-smoothing:antialiased;
}
button,input,select{font:inherit;color:inherit}

#desk{flex:1;min-height:0;display:flex;flex-direction:column}

/* ------------------------------------------------------------------- head */
.head{
  flex:none;display:flex;align-items:center;gap:18px;padding:12px 20px;
  border-bottom:1px solid var(--line);background:var(--paper);
}
.head h1,.head .h{margin:0;font-size:16px;font-weight:650;letter-spacing:-.015em}
.head .sub{font-size:12.5px;color:var(--mut)}
.head .prog{margin-left:auto;display:flex;align-items:center;gap:13px}
.pbar{width:152px;height:5px;background:var(--line);border-radius:3px;overflow:hidden}
.pbar i{display:block;height:100%;background:var(--pen);width:0;transition:width .3s}
.head .cnt{font:600 12.5px var(--mono);color:var(--ink-2);
  font-variant-numeric:tabular-nums;white-space:nowrap}
.hbtn{
  height:34px;padding:0 14px;border:1px solid var(--line-2);background:var(--paper);
  border-radius:5px;cursor:pointer;font-size:13px;font-weight:600;white-space:nowrap;
  display:inline-flex;align-items:center;gap:7px;transition:.14s;
}
.hbtn:hover:not(:disabled){background:var(--paper-2);border-color:var(--mut)}
.hbtn:disabled{color:var(--mut);cursor:default;background:var(--paper-2)}
.hbtn.pri{background:var(--pen);border-color:var(--pen);color:#fff}
.hbtn.pri:hover:not(:disabled){filter:brightness(1.12)}
.hbtn svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}

/* ------------------------------------------------------------------ split */
.split{flex:1;min-height:0;display:grid;grid-template-columns:1fr 480px}

/* -------------------------------------------------------------- the light
   table: the scan on a dark mat, with the boxes drawn over it */
.mat{
  position:relative;min-width:0;background:
    radial-gradient(120% 90% at 50% 8%,var(--mat-2),var(--mat) 72%);
  display:flex;flex-direction:column;
}
.mtabs{
  flex:none;display:flex;gap:2px;padding:9px 14px 0;overflow-x:auto;
}
.mtabs button{
  border:0;background:rgba(255,255,255,.06);color:#B8C0CC;padding:7px 14px;
  font-size:12.5px;font-weight:600;cursor:pointer;border-radius:5px 5px 0 0;
  white-space:nowrap;display:inline-flex;align-items:center;gap:7px;
}
.mtabs button:hover{background:rgba(255,255,255,.11);color:#fff}
.mtabs button[aria-selected=true]{background:var(--scan);color:var(--ink)}
.mtabs .dot{width:7px;height:7px;border-radius:50%;flex:none}
.d-ok{background:#3FBB84}.d-warn{background:#E8B54A}.d-bad{background:#E8666D}
.stage{flex:1;min-height:0;overflow:auto;padding:0 14px 16px;display:flex;
  justify-content:center}
.page{
  position:relative;background:var(--scan);width:min(720px,100%);flex:none;
  box-shadow:0 14px 44px rgba(0,0,0,.5);align-self:flex-start;
}
.page svg{display:block;width:100%;height:auto}
/* the extraction boxes sit over the scan in its own coordinate space */
.boxes{position:absolute;inset:0}
.bx{
  position:absolute;border:1.6px solid rgba(37,52,140,.42);border-radius:2px;
  cursor:pointer;transition:.14s;background:rgba(37,52,140,.05);
}
.bx:hover{background:rgba(37,52,140,.13)}
.bx.low{border-color:rgba(190,43,49,.62);background:rgba(190,43,49,.08)}
.bx.on{border-color:#C79A00;background:rgba(255,226,122,.42);
  box-shadow:0 0 0 3px rgba(255,226,122,.35)}
.bx.done{border-color:rgba(22,107,69,.5);background:rgba(22,107,69,.07)}
.bx .t{
  position:absolute;left:0;bottom:100%;margin-bottom:3px;white-space:nowrap;
  font:600 10.5px var(--ui);letter-spacing:.06em;text-transform:uppercase;
  background:var(--pen);color:#fff;padding:2px 5px;border-radius:2px;
  opacity:0;transition:opacity .14s;pointer-events:none;
}
.bx:hover .t,.bx.on .t{opacity:1}
.bx.on .t{background:#8A6A00}
.matfoot{
  flex:none;padding:8px 16px;color:#8994A3;font-size:11.5px;text-align:center;
  border-top:1px solid rgba(255,255,255,.07);
}

/* -------------------------------------------------------------- the sheet */
.sheet{min-width:0;border-left:1px solid var(--line);display:flex;
  flex-direction:column;background:var(--paper);overflow-y:auto}
.who{padding:15px 18px 13px;border-bottom:1px solid var(--line)}
.who h2{margin:0 0 2px;font-size:17px;font-weight:650;letter-spacing:-.02em}
.who p{margin:0;font-size:12.5px;color:var(--mut)}
.who .chips{display:flex;gap:6px;flex-wrap:wrap;margin-top:9px}
.chip{
  font:600 11px var(--ui);padding:3px 8px;border-radius:3px;letter-spacing:.02em;
  border:1px solid;
}
.c-ok{background:var(--grn-soft);border-color:#B6DCC9;color:var(--grn)}
.c-warn{background:var(--amb-soft);border-color:#E6CC96;color:var(--amb)}
.c-bad{background:var(--red-soft);border-color:#E7B7B9;color:var(--red)}
.c-mut{background:var(--paper-2);border-color:var(--line-2);color:var(--ink-2)}

.sec{padding:13px 18px;border-bottom:1px solid var(--line)}
.sec>h3{
  margin:0 0 10px;font-size:11px;letter-spacing:.13em;text-transform:uppercase;
  color:var(--mut);font-weight:700;display:flex;align-items:center;gap:8px;
}
.sec>h3 .n{margin-left:auto;font-family:var(--mono);letter-spacing:0}

/* one extracted field */
.fld{
  display:grid;grid-template-columns:1fr auto;gap:2px 11px;padding:9px 10px;
  border:1px solid var(--line);border-radius:5px;margin-bottom:7px;cursor:pointer;
  background:var(--paper);transition:.13s;
}
.fld:hover{border-color:var(--line-2);background:var(--paper-2)}
.fld.on{border-color:#C79A00;background:var(--mark-2);
  box-shadow:0 0 0 2px rgba(255,226,122,.5)}
.fld.low{border-left:3px solid var(--red)}
.fld.done{border-left:3px solid var(--grn)}
.fld .k{font-size:11.5px;color:var(--mut);font-weight:600;letter-spacing:.02em}
.fld .v{
  grid-column:1;font-family:var(--mono);font-size:14px;font-weight:600;
  color:var(--ink);word-break:break-word;line-height:1.35;
}
.fld .v.edited{color:var(--red)}
.fld .conf{grid-row:1/3;align-self:center;text-align:right;min-width:52px}
.fld .conf b{font:700 12.5px var(--mono);font-variant-numeric:tabular-nums;
  display:block}
.fld .conf .cb{height:3px;background:var(--line);border-radius:2px;margin-top:4px;
  overflow:hidden}
.fld .conf .cb i{display:block;height:100%;background:var(--grn)}
.fld.low .conf b{color:var(--red)}
.fld.low .conf .cb i{background:var(--red)}
.fld.done .conf b{color:var(--grn)}
.fld .edit{grid-column:1/-1;margin-top:7px;display:flex;gap:6px}
.fld .edit input{
  flex:1;min-width:0;height:32px;border:1px solid var(--pen);border-radius:4px;
  padding:0 9px;font-family:var(--mono);font-size:13.5px;
}
.fld .edit input:focus{outline:2px solid var(--pen);outline-offset:1px}
.fld .edit button{
  height:32px;padding:0 11px;border:1px solid var(--pen);background:var(--pen);
  color:#fff;border-radius:4px;cursor:pointer;font-size:12.5px;font-weight:600;
}
.fld .edit button.gh{background:var(--paper);color:var(--pen)}
.fld .by{grid-column:1/-1;font-size:11px;color:var(--grn);margin-top:4px;
  font-weight:600}

/* ------------------------------------------------------------ the checks
   The part that matters. OCR confidence says how sure the machine is that it
   READ the characters. These say whether the document makes sense. */
.chk{
  display:flex;gap:10px;padding:10px 11px;border-radius:5px;margin-bottom:7px;
  border:1px solid;align-items:flex-start;
}
.chk svg{width:16px;height:16px;flex:none;margin-top:1px;fill:none;
  stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.chk .tx{min-width:0;flex:1}
.chk b{display:block;font-size:12.5px;font-weight:650;margin-bottom:2px}
.chk span{font-size:12px;line-height:1.5;color:var(--ink-2);display:block}
.chk code{font-family:var(--mono);font-size:11.5px;background:rgba(0,0,0,.05);
  padding:1px 4px;border-radius:2px}
.chk.pass{background:var(--grn-soft);border-color:#C4E3D3;color:var(--grn)}
.chk.warn{background:var(--amb-soft);border-color:#EDD6A6;color:var(--amb)}
.chk.fail{background:var(--red-soft);border-color:#EEC3C5;color:var(--red)}

/* -------------------------------------------------------------- decisions */
.dec{padding:14px 18px;display:flex;gap:9px;flex-wrap:wrap;
  border-top:1px solid var(--line);position:sticky;bottom:0;background:var(--paper)}
.dec .hbtn{flex:1;justify-content:center;height:40px;font-size:13.5px}
.dec .note{flex:1 1 100%;font-size:11.5px;color:var(--mut);line-height:1.5;
  margin:0 0 2px}
.dec .note b{color:var(--ink-2)}

.done-card{padding:30px 22px;text-align:center}
.done-card h2{margin:0 0 7px;font-size:19px;letter-spacing:-.02em}
.done-card p{margin:0 auto 16px;font-size:13.5px;color:var(--ink-2);max-width:330px;
  line-height:1.6}
.done-card .big{font:700 42px/1 var(--mono);color:var(--pen);margin-bottom:5px}
.tally{display:grid;grid-template-columns:repeat(3,1fr);gap:9px;margin:16px 0;
  text-align:left}
.tally div{border:1px solid var(--line);border-radius:6px;padding:10px}
.tally b{display:block;font:700 20px/1 var(--mono);margin-bottom:3px}
.tally span{font-size:11px;color:var(--mut);letter-spacing:.04em;
  text-transform:uppercase;font-weight:650}

/* ----------------------------------------------------------------- narrow */
@media(max-width:1120px){
  .split{grid-template-columns:1fr 400px}
}
@media(max-width:940px){
  body{height:auto;overflow:auto;display:block}
  #desk{height:auto}
  .split{grid-template-columns:1fr}
  .sheet{border-left:0;border-top:1px solid var(--line);overflow:visible}
  .stage{max-height:none}
  .dec{position:static}
  .head{flex-wrap:wrap;gap:10px 16px}
  .head .prog{margin-left:0;width:100%;flex-wrap:wrap}
}
@media(max-width:560px){
  .head{padding:11px 14px}
  .sec,.who{padding-left:14px;padding-right:14px}
  .dec{padding:13px 14px}
  .tally{grid-template-columns:1fr}
  .pbar{width:100px}
}
@media(prefers-reduced-motion:reduce){
  *{transition:none!important}
}

/* ------------------------------------------------------- touch, on a phone */
@media(max-width:620px) and (pointer:coarse){
  .hbtn{min-height:44px}
  .mtabs button{min-height:44px}
  .fld .edit button,.fld .edit input{min-height:44px}
  .dec .hbtn{height:48px}
}
