:root {
  --page-bg: #f5efe3;
  --panel-bg: rgba(255, 252, 246, 0.88);
  --ink: #18230f;
  --muted: #5f6b58;
  --accent: #2f6f4f;
  --accent-soft: #d7ead8;
  --warning-soft: #eef4b7;
  --danger-soft: #f7c8c2;
  --info-soft: #d6e9ff;
  --line-soft: #b9e7bc;
  --border-soft: rgba(24, 35, 15, 0.1);
  --shadow-soft: 0 24px 60px rgba(76, 61, 36, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

body {
  height: 100vh;
  overflow: hidden;
  font-family: "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 223, 155, 0.6), transparent 30%),
    radial-gradient(circle at top right, rgba(171, 220, 196, 0.55), transparent 32%),
    linear-gradient(180deg, #f7f0e1 0%, #f1eadc 55%, #ece6d9 100%);
}

.page-shell {
  max-width: 1600px;
  margin: 0 auto;
  height: 100vh;
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hero-card,
.panel-card,
.scan-item {
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

.hero-card {
  border-radius: 22px;
  padding: 14px 18px;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(24, 35, 15, 0.06);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.meta-box {
  border-radius: 14px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(24, 35, 15, 0.08);
}

.meta-label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.meta-value {
  font-size: 1rem;
  font-weight: 700;
}

.panel-card {
  border-radius: var(--radius-xl);
  padding: 18px;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.section-copy {
  color: var(--muted);
  margin-bottom: 14px;
}

.form-label {
  font-weight: 700;
  margin-bottom: 8px;
}

.form-control,
.form-select {
  min-height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(24, 35, 15, 0.12);
  font-size: 1rem;
  padding: 0.85rem 1rem;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(47, 111, 79, 0.5);
  box-shadow: 0 0 0 0.2rem rgba(47, 111, 79, 0.12);
}

.input-group-text {
  border-radius: 16px 0 0 16px;
  background: #fff;
  border: 1px solid rgba(24, 35, 15, 0.12);
  border-right: 0;
  font-weight: 700;
}

.input-group > .form-control {
  border-radius: 0 16px 16px 0;
}

.btn-primary {
  min-height: 56px;
  border-radius: 18px;
  border: 0;
  background: linear-gradient(135deg, #2f6f4f 0%, #4c8a66 100%);
  font-weight: 700;
}

.btn-outline-dark {
  min-height: 56px;
  border-radius: 18px;
  font-weight: 700;
}

.filter-pill {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  background: rgba(24, 35, 15, 0.06);
  color: var(--ink);
}

.filter-pill.active {
  background: var(--ink);
  color: #fff;
}

.scan-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.scan-item {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.9fr) minmax(240px, 1.25fr) auto;
  align-items: center;
  gap: 10px;
  border-radius: 0;
  padding: 9px 8px;
  border-bottom: 1px solid rgba(24, 35, 15, 0.08);
  min-height: 38px;
}

.scan-main,
.scan-roomline,
.scan-workflow,
.scan-timeline {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.scan-code {
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.scan-roomline,
.scan-timeline {
  color: var(--muted);
  font-size: 0.8rem;
}

.room-prefix {
  font-weight: 500;
}

.room-suffix,
.room-number {
  font-weight: 800;
  color: var(--ink);
}

.scan-workflow {
  display: flex;
  align-items: center;
  gap: 6px;
}

.workflow-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.workflow-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(24, 35, 15, 0.14);
}

.workflow-dot.active {
  background: #2f6f4f;
}

.workflow-dot.error {
  background: #c85f52;
}

.workflow-label {
  color: var(--muted);
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.root-grid {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.left-column,
.right-column {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.slot-card {
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  border-radius: 22px;
  padding: 12px 14px;
}

.input-zone-card {
  flex: 1 1 auto;
  min-height: 0;
}

.input-zone-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.input-zone-header .meta-strip {
  justify-content: flex-start;
}

.input-zone-header .meta-box {
  padding: 6px 12px;
}

.input-zone-header .meta-label {
  margin-bottom: 4px;
}

.recent-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.latest-inline {
  margin-bottom: 10px;
}

.latest-inline .meta-label,
.latest-inline .meta-value {
  display: inline;
}

.latest-inline .meta-label {
  margin-right: 10px;
}

.latest-inline .meta-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.recent-panel .section-title {
  font-size: 1rem;
  margin-bottom: 0;
  white-space: nowrap;
}

.recent-panel .filter-pill {
  padding: 5px 9px;
  font-size: 0.72rem;
}

.recent-panel .scan-list {
  gap: 5px;
  overflow: auto;
  padding-right: 4px;
}

.recent-panel .scan-item {
  border-radius: 12px;
  padding: 7px 9px 6px;
}

.recent-panel .scan-code {
  font-size: 0.8rem;
  line-height: 1.1;
}

.recent-panel .workflow-dot {
  width: 7px;
  height: 7px;
}

.recent-panel .workflow-label {
  font-size: 0.64rem;
}

.recent-panel .scan-workflow {
  gap: 5px;
}

.recent-panel .scan-roomline,
.recent-panel .scan-timeline {
  font-size: 0.68rem;
  line-height: 1.15;
}

.room-filter-input {
  min-height: 30px;
  width: 112px;
  border-radius: 999px;
  border: 1px solid rgba(24, 35, 15, 0.12);
  padding: 4px 10px;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.9);
}

@media (max-width: 767.98px) {
  body,
  .page-shell {
    height: auto;
    overflow: auto;
  }

  .page-shell {
    padding-top: 14px;
  }

  .slot-card,
  .panel-card {
    padding: 16px;
  }

  .meta-strip,
  .scan-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .root-grid,
  .recent-header-row,
  .input-zone-header {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
  }
}
    

/* --- additions for the live page --- */
.workflow-dot.warn { background: #c9b400; }
.workflow-label.warn { color: #8a7a00; font-weight: 700; }
.workflow-label.error { color: #c85f52; font-weight: 700; }
.scan-item.is-local { opacity: 0.75; }
.scan-item.needs-confirm { background: var(--warning-soft); }
.scan-item.rejected { background: var(--danger-soft); }
.scan-actions { display: inline-flex; gap: 6px; }
.scan-actions button { border: 0; border-radius: 999px; padding: 2px 10px; font-size: 0.68rem; font-weight: 700; }
.btn-confirm { background: var(--ink); color: #fff; }
.btn-cancel { background: rgba(24, 35, 15, 0.08); color: var(--ink); }
.latest-inline .meta-value { font-size: 1.6rem; font-weight: 800; }
.form-feedback { min-height: 1.4em; font-size: 0.85rem; color: #c85f52; font-weight: 700; }
.form-feedback.ok { color: var(--accent); }
.net-status { font-size: 0.72rem; color: var(--muted); }
.net-status.offline { color: #c85f52; font-weight: 700; }
.station-select { min-height: 30px; border-radius: 999px; font-size: 0.72rem; padding: 4px 10px; border: 1px solid rgba(24, 35, 15, 0.12); }
.list-end { text-align: center; color: var(--muted); font-size: 0.72rem; padding: 8px; }
.staff-bar { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); margin-left: auto; }
.staff-bar button { border: 0; background: rgba(24, 35, 15, 0.06); border-radius: 999px; padding: 4px 10px; font-size: 0.72rem; }
.login-body { height: auto; overflow: auto; }
.login-shell { max-width: 420px; margin: 12vh auto; padding: 0 16px; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; background: #fff; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: #6b6b6b; font-size: .9rem; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; border-top: 1px solid #d8d2c4; }
.login-choice { text-align: left; padding: 14px 16px; font-weight: 600; }
.login-choice .app-muted { font-weight: 400; font-size: .9rem; }
.scan-item.needs-confirm .scan-workflow,
.scan-item.rejected .scan-workflow { white-space: normal; flex-wrap: wrap; }
.scan-item.needs-confirm .workflow-label,
.scan-item.rejected .workflow-label { white-space: normal; overflow: visible; }
#thaiDateTime { white-space: nowrap; }

/* Duplicate prompt sits in the form, where the operator is looking. */
.dup-prompt[hidden], .confirm-badge[hidden] { display: none !important; }
.dup-prompt { background: var(--warning-soft); border: 2px solid #c9b400; border-radius: 16px; padding: 12px 14px; }
.dup-prompt-text { font-weight: 700; color: #4d4400; margin-bottom: 10px; overflow-wrap: anywhere; }
.dup-prompt-actions { display: flex; gap: 10px; }
.dup-prompt-actions button { min-height: 44px; flex: 1 1 0; border: 0; border-radius: 14px; font-weight: 700; font-size: 1rem; }
.confirm-badge { border: 0; border-radius: 999px; min-height: 30px; padding: 4px 12px; font-size: 0.72rem; font-weight: 700; background: #c9b400; color: #18230f; }

/* The 30% + 70% columns plus the gap overflowed by 16 px at every width. */
.root-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 7fr); }
/* Staff name + logout spilled under the list panel at 1280 px; wrap onto their own line instead. */
.input-zone-header { flex-wrap: wrap; }
.staff-bar { white-space: nowrap; }
@media (pointer: coarse) { .staff-bar button, .confirm-badge { min-height: 44px; } }

/* Tablets (768–1199 px): two-line rows so tracking IDs and rooms are never squeezed out. */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .root-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .input-zone-header .meta-strip { flex-wrap: wrap; gap: 8px; }
  .recent-header-row { flex-wrap: wrap; }
  .recent-panel .scan-item {
    grid-template-columns: minmax(16ch, auto) minmax(0, 1fr);
    grid-template-areas: "code room" "flow time";
    row-gap: 3px;
  }
  .recent-panel .scan-main { grid-area: code; }
  .recent-panel .scan-roomline { grid-area: room; }
  .recent-panel .scan-workflow { grid-area: flow; }
  .recent-panel .scan-timeline { grid-area: time; text-align: right; }
  .scan-item.needs-confirm .scan-workflow,
  .scan-item.rejected .scan-workflow { grid-column: 1 / -1; grid-row: 2; }
  .scan-item.needs-confirm .scan-timeline,
  .scan-item.rejected .scan-timeline { grid-column: 1 / -1; grid-row: 3; text-align: left; }
}

@media (max-width: 767.98px) {
  .scan-item, .recent-panel .scan-item { display: grid; grid-template-columns: 1fr; gap: 2px; }
  .scan-main, .scan-roomline, .scan-workflow, .scan-timeline { white-space: normal; }
  .latest-inline .meta-value { font-size: 1.05rem; white-space: normal; word-break: break-all; }
  .recent-header-row .d-flex { width: 100%; }
  .room-filter-input { width: 96px; }
  .recent-panel .scan-list { overflow: visible; }
  /* Clock and station on one row so the form and the duplicate prompt fit on the first screen. */
  .input-zone-header { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
  .input-zone-header .meta-strip { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 8px; }
}

/* ===== UX audit #6 #11–#16 #18, camera (app-complete) ===== */
:root { --error-ink: #a63d31; --warn-ink: #6b5e00; }
.workflow-label.error, .form-feedback, .tone-error { color: var(--error-ink); }
.workflow-label.warn, .tone-warn { color: var(--warn-ink); }
.form-feedback.ok { color: var(--accent); }
.tone-ok { color: var(--ink); }
.scan-item.is-local { opacity: 1; border-left: 3px dashed var(--muted); }
.scan-item.rejected .workflow-label.error { color: #7d1f15; }
.list-end:empty { display: none; }

.net-status { padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.net-status:empty { display: none; }
.net-online { background: var(--accent-soft); color: var(--accent); }
.net-offline, .net-server { background: var(--danger-soft); color: #7d1f15; }

.staff-bar { flex-wrap: wrap; justify-content: flex-end; }
.staff-bar a { color: var(--ink); font-weight: 700; text-decoration: none; padding: 4px 10px; border-radius: 999px; background: rgba(24, 35, 15, 0.06); }

.camera-btn { min-width: 56px; border-radius: 0 16px 16px 0 !important; }
.camera-dialog { width: min(560px, 94vw); border: 0; border-radius: 22px; padding: 14px; background: #10150c; color: #fff; }
.camera-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.camera-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.camera-head .btn { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.camera-dialog video { width: 100%; max-height: 60vh; border-radius: 14px; background: #000; object-fit: cover; }
.camera-note { margin: 10px 0 0; text-align: center; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-pill.active:focus-visible { outline-color: var(--ink); }

@media (max-width: 1199.98px) {
  .recent-panel .scan-roomline, .recent-panel .scan-timeline, .recent-panel .workflow-label { font-size: 0.78rem; }
  .recent-panel .scan-code { font-size: 0.92rem; }
}
@media (pointer: coarse) {
  .filter-pill, .recent-panel .filter-pill, .station-select, .room-filter-input, .staff-bar a,
  .scan-actions button { min-height: 44px; }
  .scan-actions button { padding: 6px 16px; font-size: 0.85rem; }
}
