/* ตรวจเอกสาร PSC — สไตล์ (โทนเดียวกับมอคอัพที่เลือก: B + V3 + P1 + D1 + H1/S1) */
:root {
  --bg: #F5F4F0; --surface: #FFFFFF; --line: #E3E1DA; --line2: #EEEDE8; --ink: #1C1B19; --muted: #5F5C55; --muted2: #898781;
  --teal: #0E6F6A; --teal-soft: #E1F0EE; --teal-ink: #0B5652;
  --ok: #1F7A3A; --ok-soft: #E3F3E8; --ok-ink: #155F2C; --ok-line: #BFE3CB;
  --warn: #9A5B00; --warn-soft: #FCEFD9; --warn-ink: #7A4800; --warn-line: #F3D9A8;
  --bad: #B4232C; --bad-soft: #FBE7E8; --bad-ink: #8F1B22; --bad-line: #F2C1C4;
  --info-soft: #E4ECF8; --info-ink: #24487F; --info-line: #C5D5EE;
  --blue: #2a78d6; --orange: #eb6834;
  --top: 56px; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
h1, h2, h3, h4 { font-family: 'Prompt', 'IBM Plex Sans Thai', sans-serif; margin: 0; font-weight: 600; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-family: 'Prompt', 'IBM Plex Sans Thai', sans-serif; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 12px; } .b { font-weight: 600; } .r { text-align: right; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 16px; background: #1C1B19; color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Prompt', sans-serif; font-weight: 600; font-size: 16px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--teal); display: inline-flex; align-items: center; justify-content: center; }
.nav { display: flex; gap: 2px; margin-left: 4px; }
.nav a { color: #CFCBC2; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.nav a:hover { color: #fff; } .nav a.on { background: #3A3833; color: #fff; }
.cnt { background: var(--teal); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px; }
.cnt.warn { background: var(--warn); } .cnt.bad { background: var(--bad); }
.topright { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 12px; color: #CFCBC2; }
.dataage { white-space: nowrap; }
.timerchip { display: inline-flex; align-items: center; gap: 8px; background: #3A3833; color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; font-size: 12px; }
.timerchip.live { background: var(--teal); }
.timerchip svg { width: 14px; height: 14px; }
.iconbtn { background: transparent; border: 1px solid #5F5C55; color: #fff; width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.menubtn { display: none; background: transparent; border: 0; color: #fff; width: 36px; height: 36px; border-radius: 8px; align-items: center; justify-content: center; cursor: pointer; }
.menubtn svg { width: 20px; height: 20px; }

/* ---------- generic ---------- */
.view { max-width: 1400px; margin: 0 auto; padding: 14px 16px 90px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn { font-weight: 500; border: 1px solid #D9D6CE; background: #fff; color: var(--ink); border-radius: 8px; padding: 0 14px; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #FAF9F6; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; } .btn.primary:hover { background: #0B5652; }
.btn.pass { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.fail { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { background: #fff; border-color: #C98A2E; color: var(--warn-ink); }
.btn.ghost { background: transparent; } .btn.ghost:hover { background: #EEEDE8; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.big { min-height: 56px; font-size: 17px; padding: 0 18px; border-radius: 10px; justify-content: center; }
.btn.big.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; line-height: 1.4; }
.chip svg { width: 13px; height: 13px; }
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-line); }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-line); }
.chip.bad { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad-line); }
.chip.info { background: var(--info-soft); color: var(--info-ink); border-color: var(--info-line); }
.chip.grey { background: #EEEDE8; color: #4E4B45; border-color: #DDDAD1; }
.chip.teal { background: var(--teal-soft); color: var(--teal-ink); border-color: #BFDDD9; }
.chip.dark, .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.pick { cursor: pointer; font-size: 13px; padding: 6px 12px; min-height: 34px; }
.chip.pick:hover { filter: brightness(.96); }
.kbd { font-family: 'Prompt', sans-serif; font-size: 11px; border: 1px solid #D9D6CE; border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; background: #fff; color: #4E4B45; line-height: 16px; }
.btn.pass .kbd, .btn.fail .kbd, .btn.primary .kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.4); color: #fff; }
.field { border: 1px solid #D9D6CE; border-radius: 8px; padding: 8px 10px; min-height: 40px; background: #fff; width: 100%; }
.field:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.field.sm { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.fieldrow { display: flex; align-items: center; gap: 8px; border: 1px solid #D9D6CE; border-radius: 8px; padding: 0 10px; min-height: 40px; background: #fff; color: var(--muted); }
.fieldrow input { border: 0; outline: 0; flex: 1; min-width: 0; background: transparent; color: var(--ink); }
.fieldrow.sm { min-height: 32px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid #D9D6CE; border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { font-weight: 500; border: 0; background: #fff; padding: 0 12px; min-height: 36px; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button + button { border-left: 1px solid #D9D6CE; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.on.pass { background: var(--ok); } .seg button.on.fail { background: var(--bad); } .seg button.on.warn { background: var(--warn); }
.seg.sm button { min-height: 30px; padding: 0 9px; font-size: 12px; }
.kv { font-size: 12px; color: var(--muted); } .kv b { color: var(--ink); font-weight: 600; }
.sw { width: 44px; height: 26px; border-radius: 999px; background: #D9D6CE; position: relative; border: 0; cursor: pointer; flex: none; padding: 0; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.sw.on { background: var(--teal); } .sw.on::after { left: 21px; }
.cb { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; flex: none; }
table { border-collapse: collapse; width: 100%; }
th { font-weight: 600; font-size: 12px; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #FAF9F6; white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr.p0 td { background: #FFF7E8; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.tile.ok { border-color: var(--ok-line); background: #F3FAF5; } .tile.warn { border-color: var(--warn-line); background: #FFFBF2; } .tile.bad { border-color: var(--bad-line); background: #FEF5F5; }
.tile .lab { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.tile .val { font-weight: 600; font-size: 14px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h2 { font-size: 20px; margin-bottom: 6px; color: var(--ink); }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 13px; border-radius: 10px; }
.banner.bad { background: var(--bad-soft); color: var(--bad-ink); border: 1px solid var(--bad-line); }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.banner.info { background: var(--teal-soft); color: var(--teal-ink); border: 1px solid #BFDDD9; }

/* ---------- queue (B focus) ---------- */
.strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.progress { flex: 1; min-width: 120px; height: 8px; border-radius: 999px; background: #E3E1DA; overflow: hidden; }
.progress > div { height: 8px; background: var(--teal); border-radius: 999px; transition: width .2s; }
.queuewrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.rail { position: sticky; top: calc(var(--top) + 12px); max-height: calc(100vh - var(--top) - 30px); display: flex; flex-direction: column; overflow: hidden; }
.rail .list { overflow: auto; }
.docrow { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--line2); text-decoration: none; color: inherit; border-left: 3px solid transparent; cursor: pointer; background: transparent; border-top: 0; border-right: 0; width: 100%; text-align: left; }
.docrow:hover { background: #FAF9F6; } .docrow.on { background: var(--teal-soft); border-left-color: var(--teal); }
.docrow .t { display: flex; justify-content: space-between; gap: 6px; }
.docrow .n { font-size: 12px; color: #4E4B45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doccard { display: flex; flex-direction: column; overflow: hidden; }
.dochead { padding: 14px 18px 12px; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.dochead h1 { font-size: 26px; }
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; flex: 1 1 380px; min-width: 0; }
.itemswrap { border-bottom: 1px solid var(--line2); overflow: auto; }
.verdicts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pairbox { margin: 12px 18px 0; padding: 12px 14px; border-radius: 10px; border: 1px solid #BFDDD9; background: var(--teal-soft); display: flex; flex-direction: column; gap: 8px; }
.pairbox.off { background: #FAF9F6; border-color: var(--line); }
.compare { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 8px; align-items: center; }
.compare .box { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; background: #fff; }
.kbdhints { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; padding: 10px; font-size: 12px; color: var(--muted); }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; }

/* ---------- KPI / dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.kpi { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.kpi .lab { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .val { display: flex; align-items: baseline; gap: 6px; } .kpi .val b { font-family: 'Prompt', sans-serif; font-size: 28px; font-weight: 600; line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.ok .val b { color: var(--ok-ink); } .kpi.warn .val b { color: var(--warn-ink); } .kpi.bad .val b { color: var(--bad-ink); }
.charts { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.charts2 { display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; margin-top: 12px; }
.chart { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart h3 { font-size: 14px; }
.bars { display: flex; align-items: flex-end; gap: 4px; padding-top: 20px; border-bottom: 1px solid #c3c2b7; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .plot { position: relative; height: 150px; display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; }
.bars .bar { width: 14px; background: var(--blue); border-radius: 4px 4px 0 0; } .bars .bar2 { width: 6px; background: var(--orange); border-radius: 3px 3px 0 0; }
.bars .lbl { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: #52514e; }
.bars .x { font-size: 11px; color: var(--muted2); }
.hbar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 36px; align-items: center; gap: 8px; font-size: 12px; }
.hbar .track { height: 14px; background: #EEEDE8; border-radius: 4px; overflow: hidden; } .hbar .track > div { height: 14px; background: var(--blue); }
.legend { display: flex; gap: 10px; font-size: 12px; color: var(--muted); } .legend span { display: inline-flex; align-items: center; gap: 4px; } .legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.timeline { position: relative; height: 52px; border-bottom: 1px solid #c3c2b7; }
.timeline .blk { position: absolute; top: 8px; height: 22px; background: var(--blue); border-radius: 4px; }
.timeline .now { position: absolute; top: 0; height: 38px; border-left: 2px dashed var(--orange); }
.timeline .tick { position: absolute; top: 34px; font-size: 11px; color: var(--muted2); transform: translateX(-50%); }
.stat3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 12px; } .stat3 b { font-family: 'Prompt', sans-serif; font-size: 16px; display: block; }

/* ---------- history / receive / settings ---------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 10px; }
.selbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--teal-soft); border: 1px solid #BFDDD9; border-radius: 10px; margin-bottom: 10px; font-size: 13px; }
.tablewrap { overflow: auto; }
.tablewrap table { font-size: 13px; min-width: 900px; }
.tablewrap td.nw { white-space: nowrap; }
.histwrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.rules { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.rule { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; } .rule .cb { margin-top: 3px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.ocard { padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; }
.settingswrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.sec { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; } .sec h3 { font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 12px; align-items: center; font-size: 13px; }
.numf { width: 72px; min-height: 34px; padding: 4px 8px; text-align: center; }
.typetable td, .typetable th { padding: 6px 8px; } .typetable td:nth-child(n+3) { text-align: center; }

/* ---------- misc ---------- */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(28,27,25,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modalbox { background: #fff; border-radius: 14px; padding: 18px 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.loading { position: fixed; inset: 0; background: rgba(245,244,240,.8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 60; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #E3E1DA; border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bottomnav { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts { grid-template-columns: 1fr 1fr; } .charts2 { grid-template-columns: 1fr; }
  .cols3 { grid-template-columns: 1fr 1fr; }
  .settingswrap { grid-template-columns: 1fr; }
  .histwrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .nav { display: none; } .menubtn { display: inline-flex; } .dataage { display: none; }
  .queuewrap { grid-template-columns: 1fr; } .rail { position: static; max-height: none; } .rail .list { max-height: 210px; } .rail.collapsed .list { display: none; }
  .verdicts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checks { grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; flex: 1 1 100%; }
  .dochead h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: 1fr; } .cols3 { grid-template-columns: 1fr; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 60px; background: #fff; border-top: 1px solid var(--line); padding: 0 6px 4px; z-index: 30; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
  .bottomnav a.on { color: var(--teal); font-weight: 600; } .bottomnav a svg { width: 20px; height: 20px; }
  .view { padding: 12px 12px 90px; }
  .kbdhints { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .verdicts { grid-template-columns: 1fr; }
  .btn.big { min-height: 50px; font-size: 15px; }
  .top { padding: 0 10px; } .brand span.txt { display: none; }
}
@media print {
  .top, .bottomnav, .strip, .rail, .filters, .kbdhints, .selbar { display: none !important; }
  .view { padding: 0; max-width: none; }
}
