/* css/site.css — หน้าเข้าสู่ระบบ / เมนูหลัก / หลังบ้าน ; โครงสีเดียวกับระบบย่อยที่ปรับใหม่ */
:root {
    --bg: #f4f6f3; --surface: #fff; --line: #e2e8e0;
    --ink: #1c2420; --ink-2: #4a5550; --ink-3: #66716b;
    --focus: #1d4ed8; --radius: 14px;
    --hero-1: #123f24; --hero-2: #17552f; --accent: #f2c14e;
    --primary: #2e7d32; --primary-ink: #1b5e20; --primary-soft: #e8f3e9;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Leelawadee", Tahoma, sans-serif; font-size: 16px; line-height: 1.6; }
a { color: var(--primary-ink); }
a:focus, button:focus, input:focus, select:focus, textarea:focus, summary:focus, [tabindex]:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 16px; background: #0f172a; color: #fff; font-weight: 700; border-radius: 0 0 8px 8px; text-decoration: none; }
.skip-link:focus { top: 0; }
.muted { color: var(--ink-3); }
.req { color: #b91c1c; }

/* ---------- ปุ่ม / ฟอร์ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 20px; font: inherit; font-weight: 700; border-radius: 10px; cursor: pointer; text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-ink); }
.btn-primary:disabled { opacity: .65; cursor: wait; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: #7d8a82; }
.btn-ghost:hover { background: #f1f4f1; }
.btn-block { width: 100%; }
.fld { margin-bottom: 16px; }
.fld label, .fld .lbl { display: block; margin-bottom: 4px; font-weight: 700; color: var(--ink); }
.fld input, .fld select, .fld textarea { width: 100%; min-height: 46px; padding: 8px 12px; font: inherit; font-size: 17px; color: var(--ink); background: #fff; border: 1px solid #7d8a82; border-radius: 10px; }
.fld input[aria-invalid="true"] { border: 2px solid #b91c1c; }
.hint { margin: 4px 0 0; font-size: 14px; color: var(--ink-3); }
.err-msg { margin: 4px 0 0; font-size: 14px; font-weight: 700; color: #b91c1c; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 96px; }
.pw-toggle { position: absolute; right: 6px; top: 6px; height: 34px; padding: 0 10px; font: inherit; font-size: 14px; font-weight: 700; color: var(--primary-ink); background: var(--primary-soft); border: 0; border-radius: 8px; cursor: pointer; }
.otp { letter-spacing: .3em; font-variant-numeric: tabular-nums; text-align: center; font-size: 22px !important; }

/* ---------- ข้อความแจ้ง ---------- */
.note { margin: 0 0 16px; padding: 12px 16px; border-radius: 10px; border: 2px solid; }
.note p { margin: 0; }
.note ul { margin: 0; padding-left: 20px; }
.note:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.note-error   { background: #fef2f2; border-color: #b91c1c; color: #7f1d1d; }
.note-success { background: #ecf7ee; border-color: #2e7d32; color: #1b4d20; }
.note-info    { background: #eff6ff; border-color: #1d4ed8; color: #1e3a8a; }
.note-warning { background: #fff8e6; border-color: #b7791f; color: #6b4304; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
body.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
    background: radial-gradient(circle at 15% 10%, #dcefdc 0, transparent 40%), radial-gradient(circle at 90% 90%, #e7f0e0 0, transparent 45%), var(--bg); }
.auth-card { width: 100%; max-width: 440px; padding: 28px 28px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 16px 40px rgba(18, 63, 36, .12); }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head img { width: 72px; height: 72px; }
.auth-head .eyebrow { margin: 6px 0 0; font-size: 14px; font-weight: 700; color: var(--primary-ink); }
.auth-head h1 { margin: 2px 0 0; font-size: 24px; line-height: 1.3; }
.auth-head .sub { margin: 4px 0 0; font-size: 15px; color: var(--ink-2); }
.sso-badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 3px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-size: 13px; font-weight: 700; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 14px; }
.auth-help { margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.auth-help summary { cursor: pointer; font-weight: 700; color: var(--primary-ink); }
.steps { display: flex; gap: 6px; justify-content: center; margin: 0 0 14px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-3); }
.steps li { padding: 2px 10px; border-radius: 999px; background: #f1f4f1; }
.steps li[aria-current="step"] { background: var(--primary); color: #fff; font-weight: 700; }
.qr-box { display: flex; justify-content: center; margin: 10px 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; min-height: 224px; }
.secret { display: block; margin: 6px 0 12px; padding: 10px; font-family: Consolas, "Courier New", monospace; font-size: 17px; letter-spacing: .12em; text-align: center; word-break: break-all; background: #f8faf8; border: 1px dashed #7d8a82; border-radius: 10px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 8px 0 14px; padding: 14px; list-style: none; background: #fffbea; border: 1px solid #e0b84a; border-radius: 12px; font-family: Consolas, "Courier New", monospace; font-size: 17px; }
.site-foot { margin: 22px 0 8px; text-align: center; font-size: 13px; color: var(--ink-3); }

/* ---------- แถบหัวหลังเข้าสู่ระบบ ---------- */
.topbar { background: linear-gradient(120deg, var(--hero-1), var(--hero-2)); color: #fff; }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; margin-right: auto; }
.brand img { background: #fff; border-radius: 50%; padding: 2px; }
.brand:focus { outline-color: var(--accent); }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { display: inline-block; padding: 6px 12px; border-radius: 999px; color: #fff; text-decoration: none; font-size: 15px; font-weight: 600; }
.nav a:hover { background: rgba(255, 255, 255, .14); }
.nav a[aria-current="page"] { background: #fff; color: var(--primary-ink); }
.nav a:focus { outline-color: var(--accent); }
.nav .nav-out { border: 1px solid rgba(255, 255, 255, .5); }
.who { width: 100%; margin: 0; font-size: 14px; color: rgba(255, 255, 255, .86); }
.tag { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--accent); color: #1c2420; font-size: 12px; font-weight: 800; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 18px 16px; }
.wrap > h1 { margin: 4px 0 4px; font-size: 26px; }
.lead { margin: 0 0 16px; color: var(--ink-2); }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile a { display: flex; flex-direction: column; height: 100%; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-top: 5px solid var(--primary); color: var(--ink); text-decoration: none; transition: box-shadow .15s, transform .15s; }
.tile a:hover { box-shadow: 0 10px 24px rgba(18, 63, 36, .12); transform: translateY(-2px); }
.tile .t-ico { width: 40px; height: 40px; margin-bottom: 10px; color: var(--primary-ink); }
.tile b { font-size: 18px; line-height: 1.35; }
.tile span { margin-top: 4px; font-size: 14px; color: var(--ink-2); }
.tile.t-admin a { border-top-color: #b8860b; }
.tile.t-data a { border-top-color: #256abf; }
.section-h { margin: 26px 0 10px; font-size: 18px; }
.empty { padding: 24px; text-align: center; background: #fff; border: 2px dashed #c9d3cc; border-radius: 12px; color: var(--ink-2); }

@media (max-width: 640px) {
    .auth-card { padding: 22px 18px 18px; }
    .auth-head h1 { font-size: 21px; }
    .brand span { font-size: 16px; }
    .codes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .tile a { transition: none; } }

/* ---------- เพิ่มเติม ---------- */
.setup-steps { margin: 0 0 14px; padding-left: 22px; }
.setup-steps li { margin-bottom: 8px; }
.wrap.narrow { max-width: 560px; }
.card-form { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-form .btn { margin-top: 4px; }
.auth-card h1 { font-size: 22px; }
@media print {
    .skip-link, .steps, .auth-links, form, .site-foot, button { display: none !important; }
    body.auth { background: #fff; }
    .auth-card { box-shadow: none; border: 0; }
}

/* ---------- คำขอใช้งาน (ส่วนที่ 2) ---------- */
.reqpage h1 { margin: 4px 0 8px; font-size: 26px; }
.reqpage .lead { max-width: 70ch; }
.narrow-in { max-width: 720px; }
.crumb { margin: 0; font-size: 14px; }
.form-h { margin: 0 0 12px; font-size: 19px; }
.req-form .form-h { margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--line); }
.req-form .form-h:first-of-type { border-top: 0; padding-top: 0; }
.card-form + .card-form, .card-form + section, section + .card-form { margin-top: 14px; }
.step-box { border-left: 5px solid var(--primary); }
.row2, .row3 { display: grid; gap: 0 14px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 9em 1fr 1fr; }
fieldset.choice { margin: 0 0 16px; padding: 0; border: 0; }
fieldset.choice legend { margin-bottom: 6px; padding: 0; font-weight: 700; }
fieldset.choice.has-err .choice-item { border-color: #b91c1c; }
.choice-item { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; padding: 10px 14px; background: #fff; border: 1px solid #7d8a82; border-radius: 10px; cursor: pointer; }
.choice-item input { width: 20px; height: 20px; margin: 3px 0 0; flex: none; accent-color: var(--primary); }
.choice-item span { display: flex; flex-direction: column; }
.choice-item small { font-size: 14px; color: var(--ink-2); }
.choice-item:has(input:checked) { border: 2px solid var(--primary); background: var(--primary-soft); padding: 9px 13px; }
.fld textarea { min-height: 90px; resize: vertical; }
.fld input[type=file] { min-height: 0; padding: 8px; font-size: 15px; }
.fld select[aria-invalid="true"], .fld textarea[aria-invalid="true"] { border: 2px solid #b91c1c; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.form-actions form { margin: 0; }
.submit-row { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.btn-danger { color: #991b1b; border-color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }
.btn-danger-solid { background: #b91c1c; border-color: #b91c1c; }
.btn-danger-solid:hover { background: #991b1b; }
.req-steps { flex-wrap: wrap; justify-content: flex-start; margin: 4px 0 16px; }
.req-steps li.done { background: var(--primary-soft); color: var(--primary-ink); }
.kv { display: grid; grid-template-columns: 11em 1fr; gap: 6px 14px; margin: 0 0 12px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kv dd.pre { white-space: pre-line; font-weight: 400; }
.kv-1 { margin-bottom: 10px; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; border: 1px solid; white-space: nowrap; }
.badge-info { background: #eff6ff; color: #1e3a8a; border-color: #93b4f0; }
.badge-warning { background: #fff8e6; color: #6b4304; border-color: #d9a441; }
.badge-success { background: #ecf7ee; color: #1b4d20; border-color: #7fbf84; }
.badge-error { background: #fef2f2; color: #7f1d1d; border-color: #e59a9a; }
.badge-muted { background: #f1f4f1; color: #3f4a44; border-color: #b8c2bb; }
.file-ok { padding: 8px 12px; background: var(--primary-soft); border-radius: 8px; }
.table-wrap { position: relative; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th { background: #f4f6f3; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.tbl tbody th { font-weight: 600; }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.pw-slip { margin: 0 0 16px; padding: 18px 20px; background: #fffbea; border: 2px solid #b7791f; border-radius: var(--radius); }
.pw-slip h2 { margin: 0 0 6px; font-size: 20px; }
.pw-slip:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.pw-slip .secret { display: inline-block; margin: 0; padding: 4px 14px; font-size: 22px; background: #fff; }
.req-help { margin-top: 22px; }
@media (max-width: 640px) {
    .row2, .row3 { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 0; }
    .kv dt { margin-top: 8px; font-size: 14px; }
    .reqpage h1 { font-size: 22px; }
}
@media print {
    .reqpage .topbar, .req-help, .reqpage .crumb { display: none !important; }
    body.app .topbar, body.app .site-foot { display: none !important; }
    .pw-slip { border: 2px solid #000; background: #fff; }
}
@media print {
    .slip-mode > *:not(.narrow-in), .slip-mode .narrow-in > *:not(.pw-slip) { display: none !important; }
}

/* ---------- หลังบ้าน (ส่วนที่ 3) ---------- */
.adm-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 14px; }
.adm-grid > .card-form { margin-top: 0 !important; }
.sub-h { margin: 16px 0 8px; font-size: 16px; }
.pre { white-space: pre-line; }
.decide-ok { border-top: 5px solid var(--primary); }
.decide-no { border-top: 5px solid #b91c1c; }
.tabs ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #7d8a82; background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs .n { min-width: 22px; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, .08); font-size: 13px; text-align: center; }
.tabs a[aria-current="page"] .n { background: rgba(255, 255, 255, .25); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 0 0 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.filters .fld { margin: 0; min-width: 150px; flex: 1 1 160px; }
.filters .fld input, .filters .fld select { min-height: 42px; font-size: 16px; }
.count { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; }
.pager ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 0; padding: 0; list-style: none; }
.pager a { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; border-radius: 8px; border: 1px solid #b8c2bb; background: #fff; color: var(--ink); text-decoration: none; }
.pager a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pager li[aria-hidden] { padding: 8px 4px; }
.act-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.act-row form { margin: 0; }
form.act { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form .fld { margin: 0; flex: 1 1 220px; }
.plain-list { margin: 0; padding-left: 20px; }
.plain-list li { margin-bottom: 4px; }
.nowrap { white-space: nowrap; }
.small { font-size: 13px; }
.tbl-log td { vertical-align: top; }
@media (max-width: 860px) { .adm-grid { grid-template-columns: 1fr; } }

/* บัญชีอาสาของเขต: โควตา + ช่องกรอกตัวเลขในตาราง */
.vol-quota { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; padding: 12px 16px; background: #f4f8f5; border-radius: 12px; }
.vol-quota dt { font-weight: 700; }
.vol-quota dd { margin: 0; }
.num-in { width: 6em; min-height: 40px; padding: 4px 8px; font: inherit; text-align: right; border: 1px solid #b9c7bd; border-radius: 8px; }
.num-in:focus-visible { outline: 3px solid var(--focus, #1a73e8); outline-offset: 1px; }
.vol-tbl tfoot th, .vol-tbl tfoot td { font-weight: 700; }
.btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ปุ่มในคอลัมน์จัดการของตาราง (แทนการคลิกที่ชื่อ) */
.row-act { white-space: nowrap; text-align: right; }
.row-btn { min-height: 36px; padding: 4px 14px; font-size: 14px; }
.plain-list .row-btn { margin-left: 6px; min-height: 32px; padding: 2px 10px; }

/* หน้าตั้งค่าระบบ */
.set-gap { margin-bottom: 24px; }
