@charset "UTF-8";
/* stamp-mark: one small stylesheet, no build step. Colours follow the main Nuva site (ink, violet accent). */

:root {
  color-scheme: light;
  --ink: #0e0e10;
  --ink-2: #3c3c43;
  --muted: #5b5f78;
  --page: #f6f6fa;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --line: #e5e7eb;
  --line-2: #cfd3da;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-weak: #f1ecff;
  --ring: rgba(124, 58, 237, 0.4);
  --ok-fg: #047857;
  --ok-bg: #e4faf0;
  --warn-fg: #92400e;
  --warn-bg: #fef3c7;
  --warn-line: #f59e0b;
  --err-fg: #b91c1c;
  --err-bg: #fee2e2;
  --err-line: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Noto Sans Thai", "Noto Sans", "Leelawadee UI", "Sukhumvit Set", Thonburi, Tahoma, system-ui, -apple-system,
    "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
code, .code { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0.01em; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
main:focus { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 10; padding: 8px 14px; background: var(--ink); color: #fff; border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; color: #fff; }

.muted { color: var(--muted); }
.stack > * + * { margin-top: 16px; }

/* ---------- header ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 24px;
  min-height: 64px; display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: block; height: 24px; width: auto; }
.brand-product { padding-left: 12px; border-left: 1px solid var(--line-2); color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  padding: 8px 14px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--accent-weak); color: var(--accent-hover); font-weight: 600; }
.logout { margin: 0; }

/* ---------- layout ---------- */

.container { max-width: 1320px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { margin-bottom: 24px; }
.page-head .lead { margin-top: 6px; color: var(--muted); max-width: 70ch; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }

.stamp-grid { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 980px) {
  .stamp-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- forms ---------- */

.fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.fs + .fs { margin-top: 28px; }
.fs-title { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 700; padding: 0; margin-bottom: 14px; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 0.85rem; font-weight: 700;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field, .row-2 + .field, .process + .row-2 { margin-top: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-2 > .field + .field { margin-top: 0; }
@media (max-width: 420px) { .row-2 { grid-template-columns: 1fr; } }
label { font-weight: 600; font-size: 0.95rem; }
.optional { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"], textarea {
  width: 100%; min-height: 44px; padding: 9px 12px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
}
textarea { resize: vertical; min-height: 88px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--err-line); }
.hint { font-size: 0.85rem; color: var(--muted); }
.field-error { font-size: 0.875rem; color: var(--err-fg); font-weight: 500; }
.field-error:empty, .form-msg:empty { display: none; }
.form-msg { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--err-bg); color: var(--err-fg); font-weight: 500; }
.process { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.process-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.process-value { font-weight: 600; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px;
  font: inherit; font-weight: 600; line-height: 1.3; text-decoration: none; white-space: nowrap;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--err-fg); border-color: var(--err-fg); color: #fff; }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; color: #fff; }
.btn-danger-ghost { color: var(--err-fg); border-color: #f3c4c4; }
.btn-danger-ghost:hover { background: var(--err-bg); color: var(--err-fg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 5px 12px; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover, .btn.is-disabled:hover { background: inherit; }
.btn-primary:disabled:hover { background: var(--accent); }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions-end { justify-content: flex-end; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- stamp page ---------- */

.job-info { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--ok-bg); border: 1px solid #b7ebd3; }
.job-info > * + * { margin-top: 6px; }
.job-title { font-weight: 600; color: var(--ok-fg); }
.job-meta { color: var(--ink-2); }
.job-info .btn { margin-top: 12px; }
/* TUX-10: whose name the job is recorded under, shown clearly (on a shared PC it may not be yours). */
.job-admin-line { padding: 8px 12px; background: var(--surface); border: 1px solid #b7ebd3; border-radius: var(--radius-sm); }
.job-admin-label { color: var(--ink-2); margin-right: 4px; }
.job-admin { font-size: 1.25rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
/* Decision 4 (30 Oct): the stamped photos go to the person as files. */
.handover { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-weak); border-left: 3px solid var(--accent); font-size: 0.9rem; }
.handover-title { font-weight: 700; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 32px 20px; border: 2px dashed var(--line-2); border-radius: var(--radius);
  background: #fcfcfe; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-weak); }
.dz-title { font-size: 1.1rem; font-weight: 600; }
.dz-or { color: var(--muted); font-size: 0.9rem; }
.dz-hint { color: var(--muted); font-size: 0.875rem; margin-top: 4px; }
.dz-locked { display: none; color: var(--muted); font-size: 0.875rem; }
.dropzone.is-disabled { cursor: not-allowed; background: var(--surface-2); }
.dropzone.is-disabled:hover { border-color: var(--line-2); background: var(--surface-2); }
.dropzone.is-disabled .dz-title, .dropzone.is-disabled .dz-or, .dropzone.is-disabled .dz-hint { opacity: 0.5; }
.dropzone.is-disabled .dz-locked { display: block; font-weight: 600; color: var(--ink-2); }
.note { margin-top: 12px; font-size: 0.875rem; color: var(--muted); }

.files-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.summary { color: var(--muted); font-size: 0.9rem; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--line); container-type: inline-size; }
.file-list:empty { border-top: 0; }
.file-list:empty::before { content: "ยังไม่มีไฟล์"; display: block; padding: 14px 0; color: var(--muted); font-size: 0.9rem; }
.file-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 104px minmax(150px, 190px) 120px;
  gap: 6px 16px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.fr-main { display: flex; flex-direction: column; min-width: 0; }
.fr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-meta { font-size: 0.85rem; color: var(--muted); }
.fr-code .code { font-size: 0.9rem; }
.fr-action { text-align: right; }
.fr-notes { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.fr-notes:empty { display: none; }
.fr-error, .fr-warning { font-size: 0.875rem; padding: 6px 10px; border-radius: var(--radius-sm); }
.fr-error { background: var(--err-bg); color: var(--err-fg); }
.fr-warning, .warn-tag { background: var(--warn-bg); color: var(--warn-fg); border-left: 3px solid var(--warn-line); }
.file-row.is-done .fr-action .btn:not(.btn-primary) { color: var(--muted); }
/* A narrow list (a tablet beside the form, a phone): the name gets its own line, status, code and button below it. */
@container (max-width: 640px) {
  .file-row { grid-template-columns: 104px minmax(0, 1fr) auto; }
  .fr-main { grid-column: 1 / -1; }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.chip-wait { background: var(--surface-2); color: var(--muted); }
.chip-busy { background: var(--accent-weak); color: var(--accent-hover); }
.chip-busy::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite;
}
.chip-done { background: var(--ok-bg); color: var(--ok-fg); }
.chip-error { background: var(--err-bg); color: var(--err-fg); }

@media (prefers-reduced-motion: reduce) {
  .chip-busy::before, .btn[aria-busy="true"]::after { animation: none; }
}

/* ---------- check page ---------- */

/* One column (pick, result, crop); from 1100 px the result sits on the right of the pick and crop panels. */
.check-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  .check-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr;
    grid-template-areas: "pick result" "crop result";
  }
  .check-pick { grid-area: pick; }
  .check-result { grid-area: result; }
  .crop-panel { grid-area: crop; }
}
.tips { margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.875rem; }
.tips li + li { margin-top: 4px; }
.result-empty { padding: 20px 24px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface); }
.result-empty h2 { font-size: 1rem; color: var(--muted); margin-bottom: 12px; }
.meanings { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 14px; }
.meanings dt { font-weight: 600; }
.meanings dd { margin: 0; color: var(--ink-2); }
@media (max-width: 560px) { .meanings { grid-template-columns: minmax(0, 1fr); gap: 2px; } .meanings dd { margin-bottom: 8px; } }
.meaning { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-weak); border-left: 3px solid var(--accent); }
.meaning-notfound { background: var(--surface-2); border-left-color: var(--muted); }
.meaning-title { font-weight: 700; }
.meaning ul { margin: 4px 0 8px; padding-left: 20px; }
.meaning ul:last-child { margin-bottom: 0; }
.meaning li + li { margin-top: 2px; }
.meaning .btn { margin: 4px 0; }
.crop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.crop-head .muted { font-size: 0.875rem; overflow-wrap: anywhere; }
.crop-panel > .hint { margin-top: 8px; }
.crop-stage { margin-top: 14px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); text-align: center; }
/* The frame wraps the picture exactly, so the box's percentages are the picture's. */
.crop-frame { position: relative; display: inline-block; max-width: 100%; vertical-align: top; overflow: hidden; user-select: none; -webkit-user-select: none; }
.crop-frame img { display: block; max-width: 100%; max-height: 520px; width: auto; height: auto; -webkit-user-drag: none; }
.crop-frame.is-drawing { cursor: crosshair; touch-action: none; }
.crop-box { position: absolute; border: 2px solid var(--accent); background: rgba(124, 58, 237, 0.1); box-shadow: 0 0 0 9999px rgba(14, 14, 16, 0.4); }
.crop-box:focus { outline: none; }
.crop-box:focus-visible { border-color: #fff; outline: 3px solid var(--accent); outline-offset: -5px; }
.crop-box.is-small { border-style: dashed; }
.crop-note { margin-top: 10px; font-size: 0.875rem; color: var(--ink-2); }
.crop-note:empty { display: none; }
.btn[aria-pressed="true"] { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-hover); }
.check-status { margin-top: 14px; font-weight: 500; }
.check-status:empty { display: none; }
.check-status[data-state="error"] { color: var(--err-fg); }
.check-status[data-state="busy"]::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: spin 0.8s linear infinite;
}
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 24px; border-left: 6px solid var(--line-2); }
.result-ok .result-head { background: var(--ok-bg); border-left-color: var(--ok-fg); }
.result-warn .result-head { background: var(--warn-bg); border-left-color: var(--warn-line); }
.result-danger .result-head { background: var(--err-bg); border-left-color: var(--err-line); }
.result-neutral .result-head { background: var(--surface-2); border-left-color: var(--muted); }
.result-ok h2 { color: var(--ok-fg); }
.result-warn h2 { color: var(--warn-fg); }
.result-danger h2 { color: var(--err-fg); }
.code-lg { font-size: 1.1rem; font-weight: 700; padding: 4px 10px; background: var(--surface); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.result-lead { padding: 18px 24px 0; display: flex; flex-direction: column; gap: 8px; }
.result-lead .links { display: flex; flex-direction: column; gap: 4px; }
.note-warn { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); border-left: 3px solid var(--warn-line); }
.result-section { padding: 18px 24px; }
.result-section + .result-section { border-top: 1px solid var(--line); }
.result-section h3 { margin-bottom: 10px; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.statement { font-size: 0.9rem; }
@media (max-width: 560px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: 8px; } }
.void-banner { margin: 18px 24px 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--err-bg); color: var(--err-fg); border: 1px solid #f5b5b5; }
.void-banner > * + * { margin-top: 2px; }
.void-title { font-weight: 700; }

/* ---------- history page ---------- */

.search { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.search input { flex: 1 1 320px; width: auto; }
.result-count { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
/* position: relative keeps absolutely positioned descendants (.visually-hidden) inside the scroll box. */
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.history { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.history th, .history td { padding: 9px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.history th:first-child, .history td:first-child { padding-left: 14px; }
.history th:last-child, .history td:last-child { padding-right: 14px; }
.history th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.history tbody tr:last-child td { border-bottom: 0; }
.history tbody tr:hover td { background: #fafafd; }
.history tr.is-voided td { color: var(--muted); }
.history tr.is-voided .c-code .code { text-decoration: line-through; }
.c-code, .c-phone, .c-fmt, .c-size { white-space: nowrap; }
.c-time { min-width: 108px; }
.c-email, .c-file { overflow-wrap: anywhere; min-width: 130px; }
.c-email { overflow-wrap: break-word; } /* history.html offers a break before the "@" */
.c-person, .c-admin { min-width: 80px; }
.c-warn { min-width: 112px; }
.c-state { min-width: 120px; }
/* The status column, with its void button, stays in view when the table scrolls sideways (a tablet). */
.history th:last-child, .history td:last-child {
  position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: inset 1px 0 0 var(--line);
}
.history th:last-child { background: var(--surface-2); }
.btn-void { display: flex; width: fit-content; margin-top: 8px; min-height: 32px; padding: 3px 10px; font-size: 0.82rem; }
.sub { display: block; font-size: 0.8rem; color: var(--muted); }
.warn-tag { display: block; padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; }
.warn-tag + .warn-tag { margin-top: 4px; }
/* The warnings again under the status, which stays in view while the table scrolls sideways: only when it is wider
   than its box (a tablet, or a desktop under 1280 px). history.js marks the box .is-wide; the media query covers a
   page without its script. */
.warn-tag-state { display: none; }
.c-state .badge + .warn-tag-state, .c-state .warn-list-state .warn-tag-state:first-child { margin-top: 6px; }
@media (max-width: 1279px) { .warn-tag-state { display: block; } }
.table-wrap.is-wide .warn-tag-state { display: block; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-void { background: var(--err-bg); color: var(--err-fg); }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pager-pos { color: var(--muted); font-size: 0.9rem; }

.dialog { width: min(520px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(14, 14, 16, 0.25); color: var(--ink); }
.dialog::backdrop { background: rgba(14, 14, 16, 0.45); }
.void-target { font-family: var(--mono); font-size: 0.9rem; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.fs-plain { border: 0; padding: 0; margin: 0; }
.fs-plain legend { font-weight: 600; font-size: 0.95rem; padding: 0; margin-bottom: 6px; }
.radio { display: flex; align-items: center; gap: 10px; font-weight: 400; padding: 4px 0; }
.radio input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- login ---------- */

.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 220px); }
.login-card { width: min(400px, 100%); }
.login-card h1 { font-size: 1.4rem; }
.login-card .muted { margin-top: 6px; font-size: 0.9rem; }
.login-msg:empty { display: none; }
.login-msg { margin-top: 16px; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 500; }
.alert-error { background: var(--err-bg); color: var(--err-fg); }
#login-form { margin-top: 20px; }

@media (max-width: 720px) {
  .topbar-inner { padding: 10px 16px; gap: 10px 16px; }
  .mainnav { order: 3; flex-basis: 100%; }
  .container { padding: 20px 16px 48px; }
  .panel { padding: 18px; }
}
