/* =============================================================================
   All G house style, taken from the ordering system by way of
   fermentation-analytics (web/index.html, web/static/panels.css) so the three
   tools read as one family: the All G blue, the pale canvas, white cards with
   a thin line and an uppercase group heading.
   ========================================================================== */

:root {
  --bg: #f5f6fa; --card: #ffffff;
  --ink: #171a24; --ink-soft: #757d92; --ink-faint: #9aa1b2;
  --line: #e6e8f2; --line-soft: #eef0f6;
  --accent: #464FA1; --accent-soft: #eceefb; --accent-line: #d7dbf5;
  /* The title and the main buttons, in the same brand blue as everything
     else. They were a second, darker blue of their own (#0958a3), which is
     not one of the brand's two and read as a third tool's colour on a page
     that already had the right one. */
  --brand: #464FA1; --navy: #464FA1;
  /* The brand's light blue, for a second series or a secondary fill. */
  --s2: #97A7F9; --s2-soft: #eceefb; --s2-line: #d7dbf5;
  /* Traffic light: confident, worth a look, wrong. */
  --good: #2f7d4f; --good-soft: #e6f3eb;
  --flat: #8a5a00; --flat-soft: #fdf3dc;
  --bad: #b53a3a; --bad-soft: #fbe9e9;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 12% -12%, #e9ecfa 0%, rgba(233,236,250,0) 62%),
    radial-gradient(900px 460px at 95% 0%, #eef1fb 0%, rgba(238,241,251,0) 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 40px) 70px; }

/* ---- header: logo, title, the ways out ---------------------------------- */
.top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 40px);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.top img { height: 46px; }
/* THE LOGO GOES TO ALL G APPS, the way a logo does everywhere else. */
.home-link { display: inline-flex; flex: none; border-radius: 6px; }
.home-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.top h1 {
  font-size: 22px; font-weight: 600; color: var(--brand);
  margin: 0; letter-spacing: -0.02em;
}
.top .sub { font-size: 13px; color: var(--ink-soft); }
.top .spacer { flex: 1; }
.nav { display: flex; gap: 10px; align-items: center; }

.btn, button {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 10px;
  background: #fff; color: var(--navy);
  border: 0; box-shadow: inset 0 0 0 1.5px var(--navy);
  cursor: pointer; text-decoration: none;
}
.btn.primary, button.primary {
  background: var(--navy); color: #fff; box-shadow: none;
}
.btn:hover, button:hover { text-decoration: none; filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.small, button.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
button.ghost { box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-soft); }

/* ---- cards --------------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 18px;
}
/* The heading as a strip across the top of the card, pulled out to its edges. */
.card > h2 {
  margin: -16px -18px 14px -18px; padding: 10px 18px;
  background: var(--accent-soft); border-bottom: 1px solid var(--accent-line);
  border-radius: 9px 9px 0 0; color: var(--accent);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
.grouphead {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-faint); margin: 18px 0 7px;
}

label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
input[type=text], input[type=number], select, textarea, input[type=file] {
  width: 100%; padding: 9px 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 54px; }
input[type=checkbox] { accent-color: var(--accent); width: auto; }
input[type=range] { accent-color: var(--accent); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
th { color: var(--ink-faint); font-weight: 600; font-size: 12px;
     text-transform: uppercase; letter-spacing: .05em; }
td.mono, .mono { font-family: var(--mono); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px;
        font-size: 12px; font-weight: 600; }
.pill.ok  { background: var(--good-soft); color: var(--good); }
.pill.warn{ background: var(--flat-soft); color: var(--flat); }
.pill.err { background: var(--bad-soft);  color: var(--bad); }
.pill.mut { background: var(--line-soft); color: var(--ink-soft); }

.empty { color: var(--ink-soft); font-size: 14px; padding: 10px 0; }
.state-note { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

/* ---- review: the scan beside the digital version ------------------------- */
.split { display: flex; height: calc(100vh - 75px); }
.split .pane-pdf { flex: 1 1 50%; min-width: 0;
                   background: #51565c; display: flex; flex-direction: column; }

/* page controls above the scan */
.pagebar { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
           background: var(--card); border-bottom: 1px solid var(--line); flex: none; }
.pagebar .spacer { flex: 1; }
.pagebar .pagecount { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.pagebar .pagecount input { width: 56px; padding: 4px 6px; font-size: 13px;
                            text-align: right; display: inline-block; }

.pageview { flex: 1; overflow: auto; padding: 14px; text-align: center; }
.pageview img { max-width: 100%; height: auto; background: #fff;
                box-shadow: 0 2px 14px rgba(0,0,0,.35); border-radius: 2px; }
/* a brief pulse so you can see the page changed under you */
.pageview.flash img { animation: pageflash .55s ease-out; }
@keyframes pageflash {
  0%   { box-shadow: 0 0 0 4px var(--accent), 0 2px 14px rgba(0,0,0,.35); }
  100% { box-shadow: 0 0 0 0   rgba(70,79,161,0), 0 2px 14px rgba(0,0,0,.35); }
}
.split .pane-fields { flex: 1 1 48%; overflow-y: auto; padding: 16px clamp(14px, 2vw, 22px); }

.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 14px;
}
.toolbar .counts { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; }
.slider-row label { margin: 0; white-space: nowrap; }
.threshold-value { font-family: var(--mono); font-weight: 700; min-width: 46px;
                   text-align: right; font-size: 15px; color: var(--accent); }

.field {
  background: var(--card);
  border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0;
}
.field.flagged { border-left-color: var(--flat); }
.field.critical-flagged { border-left-color: var(--bad); }
.field.done { border-left-color: var(--good); opacity: .72; }
.field.hidden { display: none; }

.field .head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.field .label-zh { font-weight: 600; }
.field .label-en { color: var(--ink-soft); font-size: 13px; }
.field .step { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.field .target { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

.conf { font-family: var(--mono); font-size: 12px; font-weight: 700;
        padding: 1px 8px; border-radius: 6px; margin-left: auto; }
.conf.hi  { background: var(--good-soft); color: var(--good); }
.conf.mid { background: var(--flat-soft); color: var(--flat); }
.conf.lo  { background: var(--bad-soft);  color: var(--bad); }

.passes { display: flex; gap: 10px; margin: 8px 0; font-family: var(--mono); font-size: 13px; }
.passes div { flex: 1; padding: 6px 9px; border-radius: 8px;
              background: var(--line-soft); border: 1px solid var(--line); }
.passes div.differs { background: var(--flat-soft); border-color: #e8d4a8; }
.passes .tag { font-family: "Outfit", system-ui, sans-serif; font-size: 11px;
               color: var(--ink-soft); display: block; }

.flags { margin: 8px 0 4px; }
.flags div { font-size: 12.5px; padding: 5px 9px; border-radius: 7px; margin-bottom: 4px; }
.flags .sev-error { background: var(--bad-soft); color: var(--bad); }
.flags .sev-warn  { background: var(--flat-soft); color: var(--flat); }
.flags .sev-info  { background: var(--line-soft); color: var(--ink-soft); }

.actions { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.actions input[type=text] { font-family: var(--mono); }
.reason { margin-top: 8px; display: none; }
.reason.show { display: block; }

.banner {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 14px;
  border: 1px solid var(--line); background: var(--card); font-size: 14px;
}
.banner.working { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.banner.err { background: var(--bad-soft); border-color: #eccbc7; color: var(--bad); }

.spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 7px;
  border: 2px solid rgba(70,79,161,.3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

details.audit { margin-top: 14px; }
details.audit summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); }
details.audit table { margin-top: 10px; font-size: 13px; }

@media (max-width: 900px) {
  .split { flex-direction: column; height: auto; }
  .split .pane-pdf { height: 60vh; border-right: 0; border-bottom: 1px solid var(--line); }
}


/* ===========================================================================
   THE DIGITISED FORM
   The right pane mirrors the paper record's own grammar - 序号 / 操作 / 目标 /
   实得 - in English, so the reviewer's eye maps straight across from the scan
   instead of hunting down an alphabetical list of field names.
   ========================================================================== */

.formhead { background: var(--card); border: 1px solid var(--line);
            border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; text-align: center; }
.formhead .mast { font-weight: 600; color: var(--brand); font-size: 15px; }
.formhead .mastsub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.formhead .masttab { margin-top: 10px; font-size: 13px; }
.formhead .masttab th { width: 1%; white-space: nowrap; padding: 5px 8px;
                        text-transform: none; letter-spacing: 0; font-size: 12px; }
.formhead .masttab td { padding: 5px 8px; }

section.formsec { margin-bottom: 16px; }
section.formsec.hidden { display: none; }
.sechead { font-size: 12px; font-weight: 600; text-transform: uppercase;
           letter-spacing: .06em; color: var(--accent);
           background: var(--accent-soft); border: 1px solid var(--accent-line);
           border-bottom: 0; border-radius: 9px 9px 0 0;
           margin: 0; padding: 9px 14px; }

table.formtab { background: var(--card); border: 1px solid var(--line);
                border-radius: 0 0 9px 9px; overflow: hidden; }
table.formtab thead th { background: var(--line-soft); font-size: 11px;
                         padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.formtab td { vertical-align: top; padding: 9px 10px; }
table.formtab .c-no { width: 54px; color: var(--ink-faint); font-size: 12px; }
table.formtab .c-op { width: 34%; }
table.formtab .c-tg { width: 68px; color: var(--ink-soft); font-size: 12.5px; }
table.formtab .c-cf { width: 56px; text-align: right; }
table.formtab .c-ac input.val { font-family: var(--mono); }

/* The Chinese sits under the English, off by default. */
.zh { display: none; color: var(--ink-faint); font-size: 11.5px; margin-left: 6px; }
body.with-zh .zh { display: inline; }
body.with-zh table.formtab thead .zh,
body.with-zh .sechead .zh { display: block; margin-left: 0; }

tr.frow { border-left: 3px solid transparent; cursor: pointer; }
tr.frow > td { border-bottom: 1px solid var(--line-soft); }
tr.frow:hover > td { background: #fafbfe; }
tr.frow.flagged > td:first-child { box-shadow: inset 3px 0 0 var(--flat); }
tr.frow.critical-flagged > td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.frow.done > td:first-child { box-shadow: inset 3px 0 0 var(--good); }
tr.frow.done { opacity: .72; }
tr.frow.active > td { background: var(--accent-soft); }
tr.frow.hidden { display: none; }

/* Only the row you are working on shows its controls - otherwise the form
   becomes a wall of buttons and stops reading like a form. */
tr.frow .passes, tr.frow .flags, tr.frow .actions,
tr.frow .reason, tr.frow .state-note { display: none; }
tr.frow.flagged .passes, tr.frow.flagged .flags,
tr.frow.active .passes, tr.frow.active .flags { display: flex; }
tr.frow.flagged .flags, tr.frow.active .flags { display: block; }
tr.frow.flagged .actions, tr.frow.active .actions { display: flex; }
tr.frow.flagged .state-note, tr.frow.active .state-note,
tr.frow.done .state-note { display: block; }
tr.frow.active .reason.show, tr.frow.flagged .reason.show { display: block; }

.crit { color: var(--bad); font-size: 9px; vertical-align: 3px; margin-left: 5px; }
.pagejump { padding: 1px 7px; font-size: 11px; border-radius: 5px; margin-left: 6px;
            color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--line);
            background: #fff; font-weight: 500; vertical-align: 1px; }
.pagejump:hover { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.blankmark { display: block; font-size: 12px; color: var(--ink-faint);
             font-style: italic; margin-bottom: 4px; }

.subtab { margin-top: 10px; }
.subhead { font-size: 11.5px; color: var(--ink-faint); padding: 4px 2px;
           text-transform: uppercase; letter-spacing: .05em; }
table.formtab.rows { border-radius: 9px; }
.tiny { font-size: 11.5px; color: var(--ink-soft); word-break: break-all; }

/* the form's 目标 column: the range the batch is judged against */
table.formtab .c-tg { width: 92px; }
.tgt { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.tgt.exp { font-style: italic; }
.tgt.none { color: var(--ink-faint); }

/* -- repeating tables on the review page ----------------------------------
   These used to render as a line of raw JSON. The form draws them as a grid,
   so the review page does too: the template supplies the column order and the
   headings, and the row scrolls horizontally rather than wrapping, because a
   wrapped eleven-column equipment table is no easier to read than the JSON. */
.rowscroll { overflow-x: auto; }
table.formtab.rows { min-width: 100%; }
table.formtab.rows thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  background: var(--accent-soft);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.formtab.rows td.cell {
  padding: 6px 8px;
  font-size: 13px;
  vertical-align: top;
  white-space: nowrap;
}
table.formtab.rows td.cell.blank { color: var(--ink-faint); }
table.formtab.rows td.c-pg { white-space: nowrap; color: var(--ink-faint); }
tr.extrarow td { padding: 2px 8px 6px; color: var(--bad); }
.subhead .pill { margin-left: 8px; }

/* -- keyboard review ------------------------------------------------------
   Tab moves between value boxes only; everything else is tabindex=-1. The
   focused entry gets a visible ring because the reviewer's eye is on the scan
   on the left, not on the form, and needs to find its place again. */
.kbdhint { font-size: 12px; color: var(--ink-faint); margin-right: 14px; }
.kbdhint kbd {
  font: 500 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-soft);
}
input.val:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
tr.frow.active { background: var(--accent-soft); }


/* -- the draggable divider -------------------------------------------------
   The scan and the form compete for width, and which one needs more changes
   page by page - a cover page wants the form, an 11-column equipment table
   wants the scan. So it is a control, not a fixed 50/50. The handle is wider
   than it looks: the visible line is 1px but the grab area is 9px, because a
   1px drag target is a usability joke. */
.splitter {
  flex: 0 0 9px;
  cursor: col-resize;
  position: relative;
  background: transparent;
  border-left: 1px solid var(--line);
  touch-action: none;
}
.splitter::before {
  content: "";
  position: absolute;
  inset: 0 3px;
  border-radius: 2px;
  background: transparent;
  transition: background .12s ease;
}
.splitter:hover::before,
.splitter:focus-visible::before,
body.resizing .splitter::before { background: var(--accent); }
.splitter:focus-visible { outline: none; }
/* While dragging, stop the pointer selecting text or picking up the scan
   image - both make the divider lag behind or stop following entirely. */
body.resizing { cursor: col-resize; user-select: none; }
body.resizing img { pointer-events: none; }
.split .pane-fields { min-width: 0; }

@media (max-width: 1000px) {
  /* Stacked layout - there is no horizontal split left to drag. */
  .splitter { display: none; }
  .split .pane-pdf { flex: none !important; }
}

/* -- the form grid, after dropping the Target column -----------------------
   The target still governs validation and is quoted inside the out-of-range
   flag, where it is actually useful; as a column it was mostly an em dash.
   Section 3 of the form has a 标准要求 column instead, which is printed text
   carried by the template rather than read off the scan. */
table.formtab .c-rq {
  width: 30%;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.45;
  padding-right: 14px;
}

/* -- bulk accept ----------------------------------------------------------
   Sits under the threshold slider because it acts on exactly what the slider
   describes. The note beside it names what is being held back, so the count
   on the button is never the whole story. */
.bulkbar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.bulkbar button[disabled] { opacity: .45; cursor: not-allowed; }
.bulknote { font-size: 12px; color: var(--ink-faint); }
