/* ระบบ Checklist ช่างซ่อมบำรุง — ใช้ร่วมกันทั้งแอปช่าง หลังบ้าน และหน้าเข้าสู่ระบบ */
:root {
  --navy: #1f3864;
  --navy-2: #2b4a80;
  --navy-soft: #e8eef8;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --line: #dde2ea;
  --line-strong: #c4ccd8;
  --text: #1b2330;
  --text-2: #4a5566;
  --muted: #7a8596;
  --good: #1a7f43;
  --good-bg: #e3f4ea;
  --bad: #c42b2b;
  --bad-bg: #fde8e8;
  --warn: #9a5b00;
  --warn-bg: #fff1d6;
  --caution: #7a6000;
  --caution-bg: #fff8cc;
  --info: #1d5fa8;
  --info-bg: #e3eefb;
  --na: #5d6878;
  --na-bg: #e9ecf1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.06), 0 2px 8px rgba(20, 30, 50, 0.05);
  --font: "Noto Sans Thai", "Leelawadee UI", "Segoe UI", Tahoma, -apple-system, BlinkMacSystemFont, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.6em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.76rem; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #7aa7e6; outline-offset: 1px;
}
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { background: var(--surface); border-color: #e3a3a3; color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 0.88rem; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- ฟอร์ม ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search],
select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input[readonly], textarea[readonly], select[disabled], input[disabled], textarea[disabled] { background: var(--surface-2); color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 36px; }
.check input { width: 20px; height: 20px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.error-text { color: var(--bad); font-size: 0.88rem; }
.req::after { content: " *"; color: var(--bad); }

/* ---------- การ์ด / ป้าย ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 16px; }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; white-space: nowrap; line-height: 1.6;
}
.tone-good { background: var(--good-bg); color: var(--good); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-caution { background: var(--caution-bg); color: var(--caution); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-muted { background: var(--na-bg); color: var(--na); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--navy-soft); color: var(--navy); font-size: 0.78rem; font-weight: 700; }
.crit { color: var(--bad); font-weight: 800; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; }
.alert.bad { background: var(--bad-bg); border-color: #f1b5b5; color: #8d1d1d; }
.alert.warn { background: var(--warn-bg); border-color: #f0cf8e; color: #6b4000; }
.alert.info { background: var(--info-bg); border-color: #b5cdee; color: #12406f; }
.alert.good { background: var(--good-bg); border-color: #a9d9bb; color: #13562f; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.progress { height: 8px; border-radius: 99px; background: var(--na-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.progress.good > i { background: var(--good); }

/* ---------- toast / modal ---------- */
#toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 10px; background: #1b2330; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-weight: 600; animation: toast-in .18s ease-out; }
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(94vw, 560px); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.modal::backdrop { background: rgba(15, 22, 36, 0.5); }
dialog.modal.wide { width: min(96vw, 900px); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px; overflow: auto; max-height: calc(92vh - 130px); }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- ตาราง ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-size: 0.82rem; color: var(--text-2); font-weight: 700; position: sticky; top: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f4f7fc; }
table.data tr.inactive td { color: var(--muted); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---------- ลายเซ็น ---------- */
.sig-box { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); min-height: 110px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.sig-box img { max-width: 100%; max-height: 120px; }
.sig-pad { width: 100%; height: 220px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; touch-action: none; display: block; }

/* =====================================================================
   หน้าเข้าสู่ระบบ
   ===================================================================== */
.auth-wrap { min-height: 100vh; display: grid; place-items: start center; padding: 56px 16px 24px; background: linear-gradient(180deg, var(--navy) 0 300px, var(--bg) 300px); }
.auth-card { width: min(100%, 400px); }
.auth-brand { color: #fff; text-align: center; margin-bottom: 18px; }
.auth-brand img { width: 64px; height: 64px; border-radius: 16px; }
.auth-brand h1 { font-size: 1.3rem; margin-top: 8px; }
.auth-brand p { opacity: .85; margin: 4px 0 0; font-size: .92rem; }
input.pin { letter-spacing: 0.4em; font-size: 1.3rem; text-align: center; }

/* =====================================================================
   แอปช่าง (มือถือ)
   ===================================================================== */
.m-top {
  position: sticky; top: 0; z-index: 50; background: var(--navy); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px; display: flex; align-items: center; gap: 8px;
}
.m-top .title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-top .btn { min-height: 40px; color: #fff; border-color: rgba(255,255,255,.35); background: transparent; }
.m-top .btn:hover { background: rgba(255,255,255,.1); }
.save-state { font-size: 0.76rem; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.15); white-space: nowrap; }
.save-state.offline { background: #f0b429; color: #3b2a00; }
.save-state.error { background: #ff8a8a; color: #4d0000; }
.m-main { max-width: 760px; margin: 0 auto; padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); }
.m-main > * + * { margin-top: 12px; }

.tabs { display: flex; gap: 6px; background: #e3e8f0; padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; min-height: 42px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-weight: 700; color: var(--text-2); cursor: pointer; }
.tabs button[aria-selected=true] { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.tabs .count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--navy); color: #fff; font-size: .75rem; }

.job-card { display: block; padding: 14px; text-decoration: none; color: inherit; }
.job-card + .job-card { margin-top: 10px; }
.job-card .line1 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.job-card .machine { font-weight: 700; font-size: 1.02rem; margin-top: 6px; }
.job-card .symptom { color: var(--text-2); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job-card .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.job-card .meta .late { color: var(--bad); font-weight: 700; }

.pick-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pick { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick input { margin-top: 4px; width: 20px; height: 20px; }
.pick:has(input:checked) { background: var(--navy-soft); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-opt { position: relative; }
.type-opt input { position: absolute; opacity: 0; }
.type-opt span { display: block; padding: 10px; border: 2px solid var(--line); border-radius: 10px; text-align: center; font-weight: 700; cursor: pointer; background: #fff; }
.type-opt small { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; }
.type-opt input:checked + span { border-color: var(--navy); background: var(--navy-soft); color: var(--navy); }
.type-opt input:focus-visible + span { outline: 3px solid #7aa7e6; }

/* หัวใบงาน + สรุป */
.job-head h1 { font-size: 1.12rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.sumbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.sumbar div { padding: 6px 2px; border-radius: 8px; background: var(--surface-2); }
.sumbar b { display: block; font-size: 1.15rem; }
.sumbar span { font-size: .74rem; color: var(--muted); }

/* ส่วนของ checklist */
.sec { overflow: hidden; }
.sec > summary { list-style: none; padding: 14px 16px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .num { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--navy-soft); color: var(--navy); font-weight: 800; font-size: .9rem; }
.sec > summary .num.done { background: var(--good); color: #fff; }
.sec > summary .num.bad { background: var(--bad); color: #fff; }
.sec > summary .stitle { flex: 1; min-width: 0; font-weight: 700; }
.sec > summary .prog { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.sec > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.sec[open] > summary::after { transform: rotate(180deg); }
.sec[open] > summary { border-bottom: 1px solid var(--line); }
.sec .sec-body { padding: 4px 12px 12px; }
.sec.locked > summary { opacity: .6; }
.gate-note { margin: 8px 4px; }

.item { padding: 14px 4px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .ihead { display: flex; gap: 8px; align-items: flex-start; }
.item .code { flex: none; font-weight: 800; color: var(--navy); min-width: 2.2em; }
.item .text { font-weight: 600; }
.item .criteria { font-size: .84rem; color: var(--text-2); margin: 6px 0 0 calc(2.2em + 8px); }
.item .method { font-size: .78rem; color: var(--muted); margin: 4px 0 0 calc(2.2em + 8px); }
.item .controls { margin: 10px 0 0 calc(2.2em + 8px); }
.item.need-note .note-input { border-color: var(--bad); background: #fff8f8; }
.item.is-ng { background: linear-gradient(90deg, var(--bad-bg), transparent 70%); border-radius: 8px; }

.seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.seg button { min-height: 48px; border: 2px solid var(--line-strong); border-radius: 10px; background: #fff; font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; color: var(--text-2); }
.seg button[aria-pressed=true][data-r="OK"] { background: var(--good); border-color: var(--good); color: #fff; }
.seg button[aria-pressed=true][data-r="NG"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button[aria-pressed=true][data-r="N/A"] { background: var(--na); border-color: var(--na); color: #fff; }
.seg button:disabled { cursor: not-allowed; opacity: .55; }
.seg button[aria-pressed=true]:disabled { opacity: 1; }
.item-extra { display: grid; grid-template-columns: 1fr 2fr; gap: 6px; margin-top: 8px; }
.item-extra input { min-height: 40px; padding: 7px 10px; font-size: .92rem; }

.time-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: end; }
.time-row + .time-row { margin-top: 12px; }
.time-row .btn { white-space: nowrap; }
.dur { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.dur div { flex: 1; min-width: 130px; padding: 10px; border-radius: 10px; background: var(--navy-soft); }
.dur b { font-size: 1.2rem; color: var(--navy); }

.part-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.part-row + .part-row { margin-top: 8px; }
.part-row .full { grid-column: 1 / -1; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--na-bg); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; background: rgba(0,0,0,.55); color: #fff; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo .del { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 1rem; cursor: pointer; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center;
  box-shadow: 0 -4px 16px rgba(20,30,50,.06);
}
.bottom-bar .inner { max-width: 760px; margin: 0 auto; width: 100%; display: flex; gap: 8px; align-items: center; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 2000; display: grid; place-items: center; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 90vh; }
.lightbox button { position: absolute; top: 12px; right: 12px; }

/* =====================================================================
   หลังบ้าน (เดสก์ท็อป)
   ===================================================================== */
.a-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.a-side { background: var(--navy); color: #dfe7f5; padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.a-brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; color: #fff; font-weight: 800; line-height: 1.25; }
.a-brand img { width: 36px; height: 36px; border-radius: 9px; }
.a-brand small { display: block; font-weight: 400; opacity: .7; font-size: .76rem; }
.a-nav a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 9px; color: inherit; text-decoration: none; font-weight: 600; }
.a-nav a:hover { background: rgba(255,255,255,.08); }
.a-nav a[aria-current=page] { background: #fff; color: var(--navy); }
.a-nav .ico { width: 20px; text-align: center; }
.a-nav .count { margin-left: auto; background: #f0b429; color: #3b2a00; border-radius: 99px; padding: 0 8px; font-size: .75rem; font-weight: 800; }
.a-user { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.15); font-size: .88rem; }
.a-user .btn { color: #fff; border-color: rgba(255,255,255,.3); background: transparent; }
.a-main { padding: 22px 26px 40px; min-width: 0; }
.a-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.a-head .sub { color: var(--muted); font-size: .9rem; }
.a-menu-btn { display: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 1.9rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.kpi.alert-kpi .value { color: var(--bad); }
.kpi a { text-decoration: none; color: inherit; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-top: 14px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.bar-row .track { height: 12px; background: var(--na-bg); border-radius: 99px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.list-plain li:last-child { border-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { width: auto; flex: 0 1 auto; min-width: 140px; }
.filters input[type=search] { flex: 1 1 220px; }

.result-cell { font-weight: 800; text-align: center; white-space: nowrap; }
.r-OK { color: var(--good); }
.r-NG { color: var(--bad); }
.r-NA { color: var(--na); }
tr.ng-row td { background: #fff6f6; }
.sec-title-row td { background: var(--navy-soft) !important; font-weight: 800; color: var(--navy); }

.tpl-sec { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-top: 14px; }
.tpl-sec .tpl-sec-head { padding: 12px; display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.tpl-item { display: grid; grid-template-columns: 52px 1.3fr 1.6fr 1fr 70px auto; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: start; }
.tpl-item textarea { min-height: 64px; font-size: .9rem; }
.tpl-item input { font-size: .9rem; }
.tpl-item .code { font-weight: 800; color: var(--navy); padding-top: 10px; }
.tpl-item .tools { display: flex; flex-direction: column; gap: 4px; }
.tpl-head-row { display: grid; grid-template-columns: 52px 1.3fr 1.6fr 1fr 70px auto; gap: 8px; padding: 8px 12px; font-size: .78rem; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); }

@media (max-width: 900px) {
  .a-shell { grid-template-columns: 1fr; }
  .a-side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 300; transform: translateX(-100%); transition: transform .2s; }
  .a-side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .a-menu-btn { display: inline-flex; }
  .a-main { padding: 14px 12px 40px; }
  .tpl-item, .tpl-head-row { grid-template-columns: 1fr; }
  .tpl-head-row { display: none; }
}
@media (max-width: 420px) {
  .sumbar b { font-size: 1rem; }
  .item .criteria, .item .method, .item .controls { margin-left: 0; }
  .item-extra { grid-template-columns: 1fr; }
}

/* =====================================================================
   ฉบับพิมพ์
   ===================================================================== */
.print-page { max-width: 1050px; margin: 0 auto; padding: 18px; background: #fff; color: #000; font-size: 12px; line-height: 1.45; }
.print-page h1 { font-size: 17px; }
.print-page table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.print-page th, .print-page td { border: 1px solid #888; padding: 4px 6px; vertical-align: top; }
.print-page th { background: #dce4f2; }
.print-page .ptitle { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; padding: 8px 12px; }
.print-page .sec-row td { background: #e8eef8; font-weight: 700; }
.print-page .sig-cell { height: 92px; text-align: center; vertical-align: bottom; }
.print-page .sig-cell img { max-height: 70px; max-width: 100%; display: block; margin: 0 auto 4px; }
.print-toolbar { position: sticky; top: 0; background: var(--surface-2); padding: 10px; display: flex; gap: 8px; justify-content: center; border-bottom: 1px solid var(--line); }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  .print-toolbar { display: none; }
  .print-page { padding: 0; max-width: none; }
  .print-page .ptitle, .print-page th, .print-page .sec-row td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { break-inside: avoid; }
}

/* =====================================================================
   กราฟแนวโน้ม + PM Compliance
   ===================================================================== */
.colchart { width: 100%; height: auto; display: block; overflow: visible; }
.colchart .col { fill: #b9c4d8; }
.colchart .col.is-current { fill: var(--navy); }
.colchart .grid { stroke: #e6e9ef; stroke-width: 1; }
.colchart .target { stroke: var(--good); stroke-width: 1.5; }
.colchart .yl { font-size: 12px; fill: var(--muted); text-anchor: end; font-variant-numeric: tabular-nums; }
.colchart .xl { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.colchart .xl.is-current { fill: var(--text); font-weight: 700; }
.colchart .tl { font-size: 12px; fill: var(--text-2); text-anchor: start; }
.colchart .hit { fill: transparent; cursor: default; outline: none; }
.colchart .hit:hover, .colchart .hit:focus-visible { fill: rgba(31, 56, 100, 0.07); }
.chart-tip { position: fixed; z-index: 1500; pointer-events: none; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; box-shadow: 0 6px 20px rgba(20,30,50,.15); font-size: .85rem; line-height: 1.35; }
.chart-tip b { display: block; font-size: 1rem; }
.chart-tip span { color: var(--text-2); }
.trend-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.trend-card .card-body { padding: 12px 14px 8px; }
.trend-card h3 { font-size: .95rem; }
.trend-card .now { font-size: .85rem; color: var(--text-2); margin-top: 2px; }
.trend-card .now b { color: var(--text); font-size: 1.05rem; }

.pm-tile { display: grid; gap: 16px; grid-template-columns: minmax(200px, 260px) 1fr; align-items: center; }
.pm-tile .big { font-size: 3rem; font-weight: 800; line-height: 1; }
.pm-tile .big small { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.meter { position: relative; height: 12px; border-radius: 99px; background: #dfe5ef; margin-top: 10px; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--navy); }
.meter > .goal { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--good); }
.pm-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.pm-split a, .pm-split div { display: block; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); text-decoration: none; color: inherit; }
.pm-split b { display: block; font-size: 1.4rem; }
.pm-split span { font-size: .82rem; color: var(--text-2); }
@media (max-width: 700px) { .pm-tile { grid-template-columns: 1fr; } }
