* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 system-ui, sans-serif; color: #111; background: #fff; }
body { display: flex; }
#panel { width: 320px; flex: none; overflow-y: auto; padding: 8px 12px; border-right: 1px solid #ccc; }
#panel h1 { font-size: 18px; margin: 4px 0 8px; }
#panel h2 { font-size: 15px; margin: 12px 0 8px; }
#panel select, #panel input[type=file] { max-width: 100%; }
section { border-top: 1px solid #eee; }
/* The panel's steps (1. Document, Legend, 2. Page, ...): a clear line and
   room above each, so what belongs together reads together. */
#panel > section, #panel > details { border-top: 2px solid #aab1bc; margin-top: 18px; padding-bottom: 4px; }
.banner { background: #fff3cd; border: 1px solid #e0c060; padding: 6px; font-size: 13px; }
.muted { color: #666; }
.status { min-height: 1.4em; margin: 4px 0; }
.status.error, .error { color: #b00020; }
.status.ok { color: #1b6e20; }
.pages { display: flex; flex-wrap: wrap; gap: 4px; }
.pages button[aria-pressed=true] { font-weight: bold; outline: 2px solid #333; }
#failures .failure { border: 1px solid #b00020; padding: 4px; margin: 4px 0; font-size: 13px; }
#pin-actions button { margin: 2px 2px 2px 0; }
#missed-btn.active { background: #8a5a00; border-color: #8a5a00; color: #fff; }
#pin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
#pin-table td, #pin-table th { text-align: left; padding: 2px 4px; border-bottom: 1px solid #eee; }
#pin-table tr.selected { background: #e6f0ff; }
#pin-table tr { cursor: pointer; }
a.disabled { color: #999; pointer-events: none; }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 6px 8px; border-bottom: 1px solid #ccc; }
#toolbar .group { display: inline-flex; gap: 6px; align-items: center; }
#zoom-label { min-width: 4em; text-align: center; display: inline-block; }
/* The view and, when shown, the legend beside it (web/legend.css #legend-side). */
#stage { position: relative; flex: 1; display: flex; min-height: 0; }
/* What Pinny is doing (web/activity.js): a bar over the top of the drawing,
   green while working (moving stripe, or how far it got), green with a tick
   when done, red for a problem. Clicks go through it to the drawing. */
.activity { position: absolute; z-index: 4; left: 0; right: 0; top: 0; display: flex; flex-wrap: wrap; gap: 6px 12px;
  align-items: center; padding: 9px 14px; font-size: 15px; font-weight: 600; line-height: 1.35; color: #fff;
  background: #15803d; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); pointer-events: none; }
.activity[hidden] { display: none; }
.activity.error { background: #b00020; pointer-events: auto; }
.activity-icon { flex: none; width: 18px; height: 18px; box-sizing: border-box; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: activity-spin .8s linear infinite; }
.activity.done .activity-icon, .activity.error .activity-icon { animation: none; border: none; text-align: center;
  font-size: 16px; line-height: 18px; }
.activity.done .activity-icon::before { content: "\2713"; }
.activity.error .activity-icon::before { content: "!"; }
#activity-text { flex: 0 1 auto; min-width: 0; }
.activity-more { font-weight: 400; opacity: .9; }
.activity-more:empty { display: none; }
.activity-track { position: relative; flex: 1 1 140px; min-width: 100px; max-width: 360px; height: 10px;
  border-radius: 5px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.activity-track[hidden] { display: none; }
#activity-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #fff; border-radius: 5px;
  transition: width .2s; }
.activity-track.unknown #activity-fill { width: 35%; animation: activity-slide 1.2s ease-in-out infinite; }
#activity-close { margin-left: auto; pointer-events: auto; font: inherit; font-size: 13px; padding: 2px 10px;
  color: #b00020; background: #fff; border: 0; border-radius: 4px; cursor: pointer; }
@keyframes activity-spin { to { transform: rotate(360deg); } }
@keyframes activity-slide { from { left: -35%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .activity-icon, .activity-track.unknown #activity-fill { animation: none; }
}
#viewport { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #d8d8d8; outline: none; touch-action: none; }
#viewport:focus-visible { box-shadow: inset 0 0 0 2px #2a6df4; }
#viewport.mode-pan { cursor: grab; }
#viewport.mode-pan.dragging { cursor: grabbing; }
#viewport.mode-template, #viewport.mode-add { cursor: crosshair; }
#canvas { position: absolute; left: 0; top: 0; }
.view-message { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: #fff; padding: 8px 12px; border: 1px solid #aaa; max-width: 80%; }
.view-message:empty { display: none; }
/* Review buttons next to the selected pin (placed by app.js positionPinPop). */
.pin-pop { position: absolute; z-index: 2; display: flex; gap: 4px; align-items: center; padding: 4px;
  background: #fff; border: 1px solid #888; border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  white-space: nowrap; touch-action: manipulation;
  pointer-events: none; /* only its buttons take clicks: pins under the popup stay clickable */ }
.pin-pop[hidden] { display: none; }
.pin-pop button { min-height: 36px; min-width: 44px; padding: 4px 10px; font-size: 14px; pointer-events: auto; }
.pin-pop-ok:not(:disabled) { background: #1e7e34; border-color: #1e7e34; color: #fff; }
.pin-pop-wrong:not(:disabled) { background: #b00020; border-color: #b00020; color: #fff; }
/* Always on the drawing once it is scanned: a missed device has no pin to click. */
.missed-fab { position: absolute; z-index: 2; left: 12px; bottom: 12px; min-height: 44px; min-width: 44px;
  padding: 6px 16px; font-size: 15px; background: #8a5a00; border: 1px solid #8a5a00; color: #fff;
  border-radius: 22px; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.missed-fab[hidden] { display: none; }
.missed-fab.active { background: #fff; color: #8a5a00; }
.pin-pop-state { font-size: 12px; color: #444; padding: 0 4px; }
.pin-pop-state:empty { display: none; }
.view-message.error { color: #b00020; border-color: #b00020; }
/* Fixed width, so the toolbar never re-wraps (and moves the canvas) when the
   cursor readout appears mid-drag. */
#cursor-pos { display: inline-block; width: 17em; min-height: 1.4em; white-space: nowrap; overflow: hidden; }
#mode-info { margin: 4px 0; }
#batch-start { margin-top: 6px; }
#batch-start input { width: 100%; margin: 2px 0 4px; }
#batch-progress { width: 100%; }
#batch-actions button { margin: 2px 2px 2px 0; }
#batch-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
#batch-table td, #batch-table th { text-align: left; padding: 2px 4px; border-bottom: 1px solid #eee; }
#batch-table tr[data-page] { cursor: pointer; }
#batch-table tr.current { background: #e6f0ff; }
#batch-table .failed { color: #b00020; }
/* Batch state on the page buttons. */
.pages button[data-badge]::after { content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; margin-left: 4px; vertical-align: middle; background: #bbb; }
.pages button[data-badge=scanning]::after { background: #2a6df4; }
.pages button[data-badge=review]::after { background: #ff8c00; }
.pages button[data-badge=reviewed]::after { background: #0a8f2a; }
.pages button[data-badge=failed]::after { background: #b00020; }
#user-bar { margin: 0 0 6px; font-size: 13px; }
#delete-doc-btn { margin-top: 4px; color: #b00020; }
#members-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
#members-table td, #members-table th { text-align: left; padding: 2px 4px; border-bottom: 1px solid #eee; word-break: break-all; }
#member-add input { width: 100%; margin-bottom: 4px; }
#setup-link-box input, #password-form input { width: 100%; margin-bottom: 4px; }
button.link { background: none; border: none; padding: 0; color: #2a6df4; text-decoration: underline; cursor: pointer; font: inherit; }
/* Sign-in and set-password pages. */
body.auth { display: block; background: #f4f4f4; }
.auth-box { max-width: 360px; margin: 12vh auto 0; background: #fff; border: 1px solid #ccc; padding: 16px 20px; }
.auth-box h1 { font-size: 20px; margin: 0 0 12px; }
.auth-box label { display: block; margin: 8px 0 2px; }
.auth-box input { width: 100%; padding: 6px; font: inherit; }
.auth-box button { margin-top: 12px; padding: 6px 14px; font: inherit; }
/* Links between the viewer and the training pages (web/training.html). */
.site-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; font-size: 13px; }
.site-nav a { color: #2a6df4; }
.site-nav a[aria-current=page] { color: #111; font-weight: bold; text-decoration: none; }
#manual-scan > summary { font-weight: bold; font-size: 15px; margin: 12px 0 8px; cursor: pointer; }
#manual-scan[open] > summary .muted { display: none; }
#manual-scan > section { border-top: none; }
#manual-scan > section:first-of-type > h2 { display: none; }
/* A part of a step (Scan's Batch): a lighter line, still in its step. */
#manual-scan > #batch-section { border-top: 1px dashed #c9cdd4; margin-top: 12px; }
#batch-section > h2 { font-size: 14px; }
#sheet-info-result td.guess { font-style: italic; color: #8a5a00; }
#sheet-info-result th { text-align: left; padding-right: 0.5em; }
