/* Utility bill OCR -- the whole stylesheet.
 *
 * No framework and no build step: the page is one form, one table and a column
 * of page images, and it is served straight off disk by the same process that
 * runs the OCR.
 */

:root {
  --line: #d8dde3;
  --muted: #6b7480;
  --ink: #1b1f24;
  --bg: #f6f7f9;
  --accent: #1f6feb;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
header {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 14px 20px; display: flex; align-items: baseline; gap: 12px;
}
header h1 { font-size: 16px; margin: 0; }
header .sub { color: var(--muted); font-size: 12px; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 9px 18px; font-size: 14px; cursor: pointer;
}
button:disabled { background: #aab4c0; cursor: default; }
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
input[type=file] { font-size: 13px; }
.pick { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pick select {
  font: inherit; font-size: 13px; color: var(--ink); padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

.status { margin-top: 12px; color: var(--muted); font-size: 13px; min-height: 20px; }
.status.error { color: #b3261e; }
.bar { height: 4px; background: #e6eaef; border-radius: 2px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; width: 30%; background: var(--accent); animation: slide 1.2s infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

.split { display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; }
.split.with-pages { grid-template-columns: minmax(0,1fr) minmax(280px, 420px); }
.pages img {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  margin-bottom: 10px; display: block; background: #fff;
}
.pages .cap { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td {
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 6px 9px; white-space: nowrap; text-align: left;
}
th {
  background: #eef1f5; position: sticky; top: 0; font-weight: 600; z-index: 1;
  cursor: pointer; user-select: none;
}
/* A column whose values were set by hand, so it is not mistaken for what the
   page said. The marker is on screen only -- the CSV carries the value. */
th.overridden::after { content: " •"; color: var(--accent); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { color: #b9c0c8; }
/* A cell being typed into. The padding goes so the input can fill the box, and
   the outline is the only thing that makes an empty editor visible at all. */
td.editing { padding: 0; outline: 2px solid var(--accent); outline-offset: -2px; }
td.editing input {
  font: inherit; font-size: 13px; color: var(--ink);
  padding: 6px 9px; border: 0; background: #fff8e6;
}
/* An edit the server refused. The cell keeps its old value, so the tint is the
   only sign it did not take; the message is in the tooltip. */
td.failed { background: #fde7e6; }
.counts { font-size: 12px; color: var(--muted); margin-top: 10px; }
.counts b { color: var(--ink); font-weight: 600; }
.warn {
  margin-top: 10px; padding: 10px 12px; border-radius: 6px; font-size: 12px;
  background: #fff8e6; border: 1px solid #f0dca8; color: #6b5316; white-space: pre-wrap;
}
/* The header picker: fixed, because inside the table it would be clipped by
   .tablewrap's overflow. z-index 10 clears the sticky header's 1. */
.popover {
  position: fixed; z-index: 10; min-width: 260px; max-width: 360px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(27, 31, 36, .18);
}
.popover .ph { font-weight: 600; margin-bottom: 2px; overflow-wrap: anywhere; }
.popover .pd { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.popover button.opt {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; margin-bottom: 6px;
}
.popover button.opt:hover { border-color: var(--accent); }
.popover button.opt .v { overflow-wrap: anywhere; }
.popover button.opt .n { flex: none; color: var(--muted); font-size: 12px; }
/* The looked-up column's options carry an address under the project name,
   which the single-line flex shape cannot hold inside max-width: 360px.
   Placed explicitly rather than left to auto-flow, which would put the
   address beside the name and the score on a row of its own. */
.popover button.opt.wide {
  display: grid; grid-template-columns: 1fr auto; row-gap: 2px;
}
.popover button.opt.wide .v { grid-area: 1 / 1; }
.popover button.opt.wide .n { grid-area: 1 / 2; }
.popover button.opt.wide .a {
  grid-area: 2 / 1 / 3 / 3;
  color: var(--muted); font-size: 12px; overflow-wrap: anywhere;
}
.popover .cust { display: flex; gap: 6px; }
/* .pick select is scoped to .pick, which this popover is not inside of. */
.popover .cust input {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; color: var(--ink);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff;
}
.popover .cust button { padding: 7px 12px; font-size: 13px; }
.popover .revert { width: 100%; margin-top: 8px; padding: 6px 9px; font-size: 12px; }
.popover .perr { color: #b3261e; font-size: 12px; margin-top: 8px; }

/* What a second pass did. Its own box rather than a line in the warnings:
   the cells the two passes read differently are the only place a value kept
   from the first pass is visible at all. */
.merge {
  margin-top: 10px; padding: 10px 12px; border-radius: 6px; font-size: 12px;
  background: #eef4ff; border: 1px solid #c7d8f7; color: #1b3a6b;
}
.merge div { white-space: pre-wrap; }

.escalate {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 12px; border-radius: 6px;
  background: #fff; border: 1px solid var(--line); font-size: 13px;
}
.escalate span { color: var(--muted); }

.hidden { display: none; }
