/* ดูดิ work — CI: เหลืองโพสต์อิท / กรมท่า / เขียวผ่าน / แดงปากกา / ครีม */
@font-face { font-family: 'Mitr'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/mitr-600.woff') format('woff'); }
@font-face { font-family: 'Noto Sans Thai'; font-weight: 100 900; font-style: normal; font-display: swap; src: url('../fonts/noto-sans-thai-var.woff') format('woff'); }
:root {
  --yellow: #FFE27A; --yellow-shadow: #E2BE3C; --yellow-soft: #FFF0A8;
  --navy: #1F2A44; --navy-2: #3D4760; --muted: #5A6378;
  --green: #2E9E5B; --green-text: #1E7442; --green-dark: #14532F; --mint: #A8E6CF;
  --red: #E5484D; --cream: #FFF8EC; --line: #E3D9C3; --line-soft: #EFE6D2; --paper: #FFFFFF;
  --sub: #EEF0F4;
  --font-head: 'Mitr', 'Noto Sans Thai', sans-serif;
  --font-body: 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand: 'Sriracha', cursive;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--navy); font-family: var(--font-body); font-size: 16px; line-height: 1.6; }
a { color: var(--navy); }
a:hover { color: var(--green-text); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.dw-wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* header */
.dw-header { background: var(--paper); border-bottom: 1px solid var(--line-soft); }
.dw-header .dw-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.dw-logo { text-decoration: none; position: relative; display: inline-flex; flex-direction: column; align-items: center; background: var(--yellow); border-radius: 8px; padding: 4px 14px 2px; box-shadow: 0 3px 0 var(--yellow-shadow); }
.dw-logo .l1 { font-family: var(--font-head); font-weight: 600; font-size: 26px; line-height: 1.15; }
.dw-logo .l2 { font-family: var(--font-head); font-weight: 600; font-size: 13px; line-height: 1.1; letter-spacing: 1px; }
.dw-logo svg { position: absolute; right: -9px; top: -8px; }
.dw-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.dw-nav a { text-decoration: none; padding: 10px 14px; font-weight: 500; }

/* in-app banner */
.dw-inapp { background: var(--navy); color: #fff; padding: 12px 20px; font-size: 15px; }
.dw-inapp p { margin: 0 0 8px; max-width: 1160px; }
.dw-inapp b { color: var(--yellow); }
.dw-inapp-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* buttons */
.dw-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 2px solid var(--navy); background: var(--paper); color: var(--navy); font-weight: 600; text-decoration: none; cursor: pointer; }
.dw-btn:disabled { opacity: .45; cursor: not-allowed; }
.dw-btn-yellow { background: var(--yellow); border-color: var(--navy); }
.dw-btn-big { min-height: 56px; font-family: var(--font-head); font-size: 20px; box-shadow: 0 5px 0 var(--navy); }
.dw-btn-big:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--navy); }
.dw-btn-green { background: var(--green-text); color: #fff; border-color: var(--green-text); box-shadow: 0 5px 0 var(--green-dark); }
.dw-btn-ghost-light { background: transparent; color: #fff; border-color: #fff; }
.dw-link { background: none; border: 0; padding: 6px 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; text-align: left; }

/* tool page */
.dw-main { padding: 28px 0 64px; }
.dw-crumb { font-size: 14px; color: var(--muted); }
.dw-title { margin: 4px 0 6px; font-family: var(--font-head); font-weight: 600; font-size: clamp(30px, 5vw, 40px); line-height: 1.25; }
.dw-lead { margin: 0 0 20px; color: var(--navy-2); max-width: 760px; }
.dw-steps { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.dw-steps li { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px 5px 5px; color: var(--muted); font-size: 15px; }
.dw-steps li .n { width: 28px; height: 28px; border-radius: 50%; background: var(--cream); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--font-head); }
.dw-steps li.is-on { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.dw-steps li.is-on .n { background: var(--yellow); color: var(--navy); border: 0; }
.dw-steps li.is-done .n { background: var(--green); color: #fff; border: 0; }

.dw-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; background: var(--paper); border: 2px dashed var(--navy); border-radius: 18px; padding: 40px 20px; }
.dw-drop.is-drag { background: var(--yellow-soft); }
.dw-drop .big { font-family: var(--font-head); font-weight: 600; font-size: 24px; }
.dw-drop .small { font-size: 14px; color: var(--muted); }
.dw-paste { width: 100%; max-width: 640px; min-height: 90px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream); resize: vertical; }
.dw-privacy { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); justify-content: center; }

.dw-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.dw-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.dw-body { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.dw-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.dw-card h2 { margin: 0 0 4px; font-size: 18px; }
.dw-card .hint { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.dw-file { display: flex; gap: 10px; align-items: center; }
.dw-file .name { font-weight: 600; overflow-wrap: anywhere; }
.dw-file .meta { font-size: 14px; color: var(--muted); }
.dw-field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 14px; }
.dw-field select, .dw-field input[type=text] { min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); max-width: 100%; }
.dw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dw-chip { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid #C9BFA8; background: var(--paper); color: var(--navy-2); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-chip[aria-pressed=true] { background: var(--yellow); border: 2px solid var(--navy); color: var(--navy); font-weight: 600; }
.dw-check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin-top: 10px; }
.dw-check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--green-text); flex-shrink: 0; }
.dw-check input[type=text] { width: 90px; height: auto; min-height: 32px; margin: 0 4px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; accent-color: initial; }

.dw-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.dw-stat { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.dw-stat .k { font-size: 14px; color: var(--muted); }
.dw-stat .v { font-family: var(--font-head); font-weight: 600; font-size: 26px; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.dw-stat.ok { border: 2px solid var(--green); }
.dw-stat.warn { border: 2px solid var(--red); }

.dw-table-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.dw-table-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.dw-legend { display: flex; gap: 14px; color: var(--navy-2); flex-wrap: wrap; }
.dw-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dw-legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.dw-scroll { overflow: auto; max-height: 560px; }
.dw-table { width: 100%; border-collapse: collapse; font-size: 15px; white-space: nowrap; }
.dw-table th { position: sticky; top: 0; z-index: 1; padding: 0; background: #F7F3EA; border-bottom: 2px solid var(--line); text-align: left; font-weight: 500; }
.dw-table th button { width: 100%; min-height: 44px; padding: 8px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; font-weight: inherit; }
.dw-table th.is-sel { background: var(--yellow); border-bottom-color: var(--navy); font-weight: 700; }
.dw-table td { padding: 7px 12px; border-bottom: 1px solid #F0EADC; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.dw-table td.num { text-align: right; }
.dw-table td.is-fill { background: var(--yellow-soft); }
.dw-table tr.is-sub td { background: var(--sub); color: var(--navy-2); font-weight: 600; }
.dw-table td.rn { color: #9AA1B2; font-size: 13px; text-align: right; padding-right: 8px; }

.dw-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.dw-note { font-size: 14px; color: var(--muted); }
.dw-error { background: #FFF1F1; border: 2px solid var(--red); border-radius: 14px; padding: 14px 16px; }
.dw-error b { color: #B42318; }
.dw-diag { width: 100%; min-height: 160px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--cream); }
.dw-busy { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--navy-2); }
.dw-busy::before { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: dwspin 0.8s linear infinite; }
@keyframes dwspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dw-busy::before { animation: none; } }

.dw-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); }
.dw-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.dw-footer { border-top: 1px solid var(--line-soft); margin-top: 40px; }
.dw-footer .dw-wrap { padding-top: 24px; padding-bottom: 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); }
.dw-footer .sig { font-family: var(--font-head); font-weight: 600; font-size: 20px; color: var(--navy); }
.hint-tight { margin: 0 0 6px !important; }
.hint-block { display: block; }
.noshrink { flex-shrink: 0; }
.dw-go { width: 100%; margin-top: 16px; }
.dw-mt8 { margin-top: 8px; }
.lg-fill { background: var(--yellow-soft); border: 1px solid var(--yellow-shadow); }
.lg-sub { background: var(--sub); }
.offscreen { position: fixed; left: -9999px; top: 0; }
[hidden] { display: none !important; }

/* T2 รวมไฟล์ / ชีท */
.dw-count { font-family: var(--font-body); font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.dw-drop-mini.is-drag { background: var(--yellow-soft); outline: 2px dashed var(--navy); outline-offset: -6px; }
.dw-src-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dw-src { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--cream); display: flex; flex-direction: column; gap: 8px; }
.dw-src.is-off { opacity: .6; background: var(--paper); }
.dw-src-top { display: flex; gap: 10px; align-items: flex-start; }
.dw-src-top input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--green-text); flex-shrink: 0; }
.dw-src-name { flex: 1 1 auto; min-width: 0; }
.dw-src-name .name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.35; }
.dw-src-name .meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.dw-src select, .dw-map-act select { min-height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); max-width: 100%; width: 100%; font-size: 14px; }
.dw-src-rm { flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.dw-src-rm:hover { color: var(--red); border-color: var(--red); }
.dw-add-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.dw-paste-sm { min-height: 56px; margin-top: 10px; font-size: 14px; }
.dw-sub-box { margin: 8px 0 0 30px; }
.dw-warn-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--yellow-soft); border: 1px solid var(--yellow-shadow); font-size: 14px; color: var(--navy); }
.dw-card > .dw-warn-note { margin: 0 0 12px; }
.dw-map-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.dw-map { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dw-map.is-partial { border: 2px solid var(--yellow-shadow); background: #FFFBEA; }
.dw-map.is-drop { opacity: .55; background: var(--sub); }
.dw-map-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dw-map-name b { overflow-wrap: anywhere; }
.dw-map-info { font-size: 13px; color: var(--navy-2); overflow-wrap: anywhere; }
.dw-map-act { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.dw-map-act select { flex: 1 1 auto; min-width: 0; width: auto; }
.dw-badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--sub); color: var(--navy-2); white-space: nowrap; }
.dw-badge.warn { background: var(--yellow); color: var(--navy); }
.dw-btn-sm { min-height: 40px; padding: 0 12px; font-size: 14px; flex-shrink: 0; }
.dw-err-list { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.dw-err-list li b { color: var(--navy); }
.dw-scroll-sm { max-height: 480px; }
.dw-stats-tight { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.dw-stats-tight .dw-stat .v { font-size: 24px; }
.dw-table th.num { text-align: right; }
.dw-table th .th-txt { display: block; padding: 10px 12px; }
.dw-table th.is-src, .dw-table td.is-src { color: var(--muted); }
.dw-table th.is-src { background: #EFEAE0; }
.dw-table tr.is-total td { font-weight: 700; background: #F7F3EA; border-top: 2px solid var(--line); }

/* T3 จับคู่ 2 ตาราง */
.dw-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.dw-drop-side { padding: 28px 18px; gap: 10px; }
.dw-drop-side .dw-paste { min-height: 56px; }
.dw-drop-side.is-done { border-style: solid; border-color: var(--green); background: #F2FBF5; }
.dw-side-tag { width: 44px; height: 44px; border-radius: 12px; background: var(--navy); color: var(--yellow); display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 600; font-size: 24px; }
.dw-side-done { margin: 0; font-weight: 600; color: var(--green-text); overflow-wrap: anywhere; }
.dw-tag { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px; margin-right: 8px; border-radius: 7px; background: var(--navy); color: var(--yellow); font-family: var(--font-head); font-weight: 600; font-size: 15px; line-height: 1; vertical-align: 2px; }
.dw-key-list { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dw-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--cream); }
.dw-key select { flex: 1 1 160px; min-width: 0; min-height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); margin-right: 6px; }
.dw-key .dw-tag { margin-right: 2px; }
.dw-key-eq { font-family: var(--font-head); font-size: 20px; padding: 0 6px 0 0; }
.dw-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line-soft); }
.dw-filter .dw-chip { min-height: 38px; font-size: 14px; padding: 0 12px; }
.dw-stat.st-found { border-left: 6px solid var(--green); }
.dw-stat.st-miss { border-left: 6px solid #E89A9C; }
.dw-stat.st-dup { border-left: 6px solid var(--yellow-shadow); }
.dw-table th.is-key { background: var(--yellow); }
.dw-table th.is-take { background: #DDF3E7; }
.dw-table th.is-status { background: #E7E9F0; }
.dw-table td.is-key { font-weight: 600; }
.dw-table tr.is-miss td { background: #FDECEC; }
.dw-table tr.is-dup td { background: var(--yellow-soft); }
.dw-table td.dw-empty-row { text-align: center; color: var(--muted); padding: 18px; }
.lg-miss { background: #FDECEC; border: 1px solid #E89A9C; }
.lg-dup { background: var(--yellow-soft); border: 1px solid var(--yellow-shadow); }
