/* TNW Directory (web-id) — ธีมตามรูปอ้างอิง "ui pinterest": น้ำเงินอ่อน การ์ดโปร่งมุมโค้งใหญ่ เมนูแคปซูลบนสุด จัดเป็นบล็อก (bento)
 * กติกาอื่นตาม TNW: ตัวแปรเชิงความหมาย (ห้ามสีตายตัวในหน้า) · ธีมสว่าง/มืด data-theme · Prompt + Sarabun · เนื้อหา ≥ 16px
 * มือถือก่อน 360–390px · จุดแตะ ≥ 44px · breakpoint เดียว 768px · คลาส tnw- แบบ BEM · ไอคอน SVG เส้น · สถานะมีข้อความเสมอ
 * ไฟล์นี้เป็นของ web-id เอง — tools/sync-ui.py จะไม่แตะ (อยู่ใต้ assets/id/) */

:root {
  --page: #cfd7e4;
  --frame-a: #e6effc;
  --frame-b: #f5f8ff;
  --surface: rgba(255, 255, 255, .72);
  --surface-solid: #ffffff;
  --surface-sunk: #eaf1fc;
  --ink: #0f1d38;
  --muted: #55647d;
  --line: rgba(31, 86, 196, .16);
  --primary: #1f56c4;
  --primary-bright: #2f7bf5;
  --on-primary: #ffffff;
  --navy: #17408a;
  --navy-2: #1d4fa6;
  --on-navy: #ffffff;
  --hi: #ffd84d;               /* เหลือง = พื้นเน้นเท่านั้น (ตัวอักษรบนพื้นเหลืองใช้ --on-hi) */
  --on-hi: #3a2d00;
  --ok: #0b6b45;   --ok-bg: #d8f3e6;
  --warn: #8a4f00; --warn-bg: #ffecc2;
  --err: #a61b12;  --err-bg: #ffdad6;
  --info: #1f56c4; --info-bg: #dbe8ff;
  --focus: #f59e0b;
  --shadow: 0 18px 50px rgba(20, 45, 100, .16);
  --r-frame: 28px; --r-card: 24px; --r-pill: 999px; --r-ctl: 14px;
  --font-head: "Prompt", system-ui, sans-serif;
  --font-body: "Sarabun", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --page: #070c17;
  --frame-a: #0f1a30;
  --frame-b: #0b1424;
  --surface: rgba(255, 255, 255, .06);
  --surface-solid: #121d33;
  --surface-sunk: #0c1628;
  --ink: #e8eefc;
  --muted: #a3b2cf;
  --line: rgba(140, 175, 255, .22);
  --primary: #7aa9ff;
  --primary-bright: #5b94ff;
  --on-primary: #08142e;
  --navy: #14305f;
  --navy-2: #1a3d77;
  --on-navy: #eef3ff;
  --hi: #ffd84d;
  --ok: #7ee2b0;  --ok-bg: #0f3a2a;
  --warn: #ffd27a; --warn-bg: #43310a;
  --err: #ffaba3;  --err-bg: #4a1713;
  --info: #9fc0ff; --info-bg: #14305f;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #070c17; --frame-a: #0f1a30; --frame-b: #0b1424; --surface: rgba(255,255,255,.06); --surface-solid: #121d33;
    --surface-sunk: #0c1628; --ink: #e8eefc; --muted: #a3b2cf; --line: rgba(140,175,255,.22); --primary: #7aa9ff;
    --primary-bright: #5b94ff; --on-primary: #08142e; --navy: #14305f; --navy-2: #1a3d77; --on-navy: #eef3ff;
    --ok: #7ee2b0; --ok-bg: #0f3a2a; --warn: #ffd27a; --warn-bg: #43310a; --err: #ffaba3; --err-bg: #4a1713;
    --info: #9fc0ff; --info-bg: #14305f; --shadow: 0 18px 50px rgba(0,0,0,.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--page); color: var(--ink);
  font: 400 1rem/1.6 var(--font-body);
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.25; font-weight: 500; }
h1 { font-size: 1.9rem; font-weight: 400; }
h2 { font-size: 1.25rem; }
p { margin: 0; }
a { color: var(--primary); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.tnw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tnw-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- กรอบหลัก (frame) ---- */
.tnw-shell {
  max-width: 1200px; margin: 0 auto; min-height: 100vh; padding: 16px;
  background: linear-gradient(180deg, var(--frame-a), var(--frame-b));
}
.tnw-main { display: grid; gap: 16px; padding-block: 8px 40px; grid-template-columns: minmax(0, 1fr); }

/* ---- เมนูแคปซูลบนสุด ---- */
.tnw-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tnw-nav__brand { font-family: var(--font-head); font-size: 1.125rem; padding: 10px 20px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }
.tnw-nav__list { display: flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); list-style: none; margin: 0; overflow-x: auto; max-width: 100%; }
.tnw-nav__link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: var(--r-pill); text-decoration: none; color: var(--ink); white-space: nowrap; }
.tnw-nav__link[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.tnw-nav__end { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; max-width: 100%; }

/* ---- ปุ่ม / แคปซูล ---- */
.tnw-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-solid); cursor: pointer; font-family: var(--font-head); font-weight: 400; text-decoration: none; color: var(--ink); }
.tnw-btn:hover { border-color: var(--primary); }
.tnw-btn--primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.tnw-btn--primary:hover { background: var(--primary-bright); border-color: transparent; }
.tnw-btn--danger { background: var(--err-bg); color: var(--err); border-color: transparent; }
.tnw-btn--icon { width: 44px; padding: 0; }
.tnw-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- หัวเรื่อง + ตัวเลขใหญ่ ---- */
.tnw-hero { display: grid; gap: 16px; padding: 8px 4px 0; }
.tnw-hero__sub { color: var(--muted); }
.tnw-stats { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.tnw-stat { display: grid; gap: 0; }
.tnw-stat__num { font-family: var(--font-head); font-weight: 300; font-size: 3rem; line-height: 1; }
.tnw-stat__lbl { color: var(--muted); }

/* ---- แถบขั้นตอนแบบแคปซูล ---- */
.tnw-steps { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.tnw-steps__item { flex: 1 1 120px; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.tnw-steps__item[data-state="done"] { background: var(--navy); color: var(--on-navy); border-color: transparent; }
.tnw-steps__item[data-state="now"] { background: var(--primary-bright); color: var(--on-primary); border-color: transparent; }

/* ---- การ์ด (bento) ---- */
.tnw-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.tnw-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; display: grid; gap: 14px; align-content: start; backdrop-filter: blur(8px); min-width: 0; }
.tnw-card--dark { background: linear-gradient(160deg, var(--navy-2), var(--navy)); color: var(--on-navy); border-color: transparent; box-shadow: var(--shadow); }
.tnw-card--dark .tnw-card__hint { color: var(--on-navy); opacity: .8; }
.tnw-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tnw-card__hint { color: var(--muted); overflow-wrap: anywhere; }

/* ---- ฟอร์ม ---- */
.tnw-field { display: grid; gap: 4px; }
.tnw-field label { color: var(--muted); }
.tnw-input { min-height: 44px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface-solid); padding: 0 14px; width: 100%; }
.tnw-fields { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.tnw-drop { overflow-wrap: anywhere; display: grid; place-items: center; gap: 8px; text-align: center; min-height: 140px; padding: 20px; border: 2px dashed var(--primary); border-radius: var(--r-card); background: var(--surface-sunk); cursor: pointer; }
.tnw-drop[data-over="true"] { background: var(--info-bg); }
.tnw-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tnw-files__item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: var(--r-ctl); background: var(--surface-solid); border: 1px solid var(--line); }
.tnw-files__name { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }

/* ---- ป้ายสถานะ (มีข้อความเสมอ) ---- */
.tnw-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 12px; border-radius: var(--r-pill); font-size: 1rem; background: var(--info-bg); color: var(--info); overflow-wrap: anywhere; max-width: 100%; }
.tnw-badge--ok { background: var(--ok-bg); color: var(--ok); }
.tnw-badge--warn { background: var(--warn-bg); color: var(--warn); }
.tnw-badge--err { background: var(--err-bg); color: var(--err); }
.tnw-badge--hi { background: var(--hi); color: var(--on-hi); }

/* ---- รายการตรวจ (การ์ดเข้ม) ---- */
.tnw-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tnw-checks__item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, .1); }
.tnw-checks__mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-bright); color: #fff; flex: none; }
.tnw-checks__item[data-state="bad"] .tnw-checks__mark { background: var(--err-bg); color: var(--err); }
.tnw-checks__item[data-state="wait"] .tnw-checks__mark { background: rgba(255,255,255,.25); }

/* ---- แท็บ ---- */
.tnw-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tnw-tab { min-height: 44px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-solid); cursor: pointer; }
.tnw-tab[aria-selected="true"] { background: var(--primary); color: var(--on-primary); border-color: transparent; }

/* ---- ตาราง → การ์ดบนมือถือ ---- */
.tnw-table { width: 100%; border-collapse: collapse; }
.tnw-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tnw-table tr { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 18px; margin-bottom: 10px; background: var(--surface-solid); }
.tnw-table td { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; padding: 0; overflow-wrap: anywhere; }
.tnw-table td::before { content: attr(data-label); color: var(--muted); flex: none; }
.tnw-table td:first-child::before { content: none; }
.tnw-table__scroll { max-height: 640px; overflow: auto; }
.tnw-check { width: 24px; height: 24px; accent-color: var(--primary); }

/* ---- ความคืบหน้า / ข้อความสถานะ ---- */
.tnw-progress { height: 14px; border-radius: var(--r-pill); background: var(--surface-sunk); overflow: hidden; border: 1px solid var(--line); }
.tnw-progress__bar { height: 100%; width: 0; background: var(--primary-bright); transition: width .3s; }
.tnw-note { padding: 12px 16px; border-radius: 16px; background: var(--info-bg); color: var(--info); }
.tnw-note--warn { background: var(--warn-bg); color: var(--warn); }
.tnw-note--err { background: var(--err-bg); color: var(--err); }
.tnw-note--ok { background: var(--ok-bg); color: var(--ok); }
.tnw-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; }
.tnw-dialog { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface-solid); color: var(--ink); padding: 24px; max-width: min(92vw, 460px); }
.tnw-dialog::backdrop { background: rgba(8, 20, 46, .55); }
.tnw-dialog__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.tnw-hidden { display: none !important; }

@media (min-width: 768px) {
  .tnw-shell { margin: 24px auto; min-height: 0; padding: 28px; border-radius: var(--r-frame); box-shadow: var(--shadow); }
  h1 { font-size: 2.4rem; }
  .tnw-hero { grid-template-columns: 1fr auto; align-items: end; }
  .tnw-stat__num { font-size: 3.6rem; }
  .tnw-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .tnw-span-3 { grid-column: span 3; } .tnw-span-4 { grid-column: span 4; } .tnw-span-5 { grid-column: span 5; } .tnw-span-6 { grid-column: span 6; }
  .tnw-span-7 { grid-column: span 7; } .tnw-span-8 { grid-column: span 8; } .tnw-span-12 { grid-column: span 12; }
  .tnw-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }   /* กี่คอลัมน์ขึ้นกับความกว้างการ์ดจริง กันช่องล้นการ์ดแคบ */
  .tnw-table thead { position: static; width: auto; height: auto; clip: auto; }
  .tnw-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; margin: 0; background: transparent; }
  .tnw-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 8px 10px; position: sticky; top: 0; background: var(--surface-solid); }
  .tnw-table td { display: table-cell; padding: 10px; border-top: 1px solid var(--line); vertical-align: top; }
  .tnw-table td::before { content: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
