:root {
  --pt-primary: #1d4ed8;
  --pt-primary-dark: #1e3a8a;
  --pt-accent: #f59e0b;
  --pt-bg: #f3f5fa;
  --pt-ink: #1f2937;
  --pt-muted: #6b7280;
  --pt-border: #e3e7ef;
  --bs-primary: #1d4ed8;
  --bs-primary-rgb: 29, 78, 216;
  --bs-link-color: #1d4ed8;
  --bs-link-color-rgb: 29, 78, 216;
}

body {
  font-family: 'Sarabun', system-ui, sans-serif;
  background: var(--pt-bg);
  color: var(--pt-ink);
  font-size: 1.02rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
h1, h2, h3, h4, h5, h6, .navbar-brand, .btn, .nav-link, .badge, .brand-title, th {
  font-family: 'Prompt', 'Sarabun', sans-serif;
}
h1, h2, h3, h4, h5 { font-weight: 600; }

.btn-primary {
  --bs-btn-bg: var(--pt-primary);
  --bs-btn-border-color: var(--pt-primary);
  --bs-btn-hover-bg: var(--pt-primary-dark);
  --bs-btn-hover-border-color: var(--pt-primary-dark);
  --bs-btn-active-bg: var(--pt-primary-dark);
}

/* ---------- แถบหัว ---------- */
.pt-navbar { background: linear-gradient(90deg, var(--pt-primary-dark), var(--pt-primary)); }
.pt-navbar .nav-link.active { background: rgba(255,255,255,.16); border-radius: .5rem; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--pt-accent); color: #1e1b4b;
  font-family: 'Prompt', sans-serif; font-weight: 600; letter-spacing: .5px;
}
.brand-sub { font-size: .72rem; opacity: .85; font-weight: 400; }
.pt-public-header { background: linear-gradient(90deg, var(--pt-primary-dark), var(--pt-primary)); color: #fff; }
.brand-title { font-size: 1.15rem; }

.pt-footer { color: var(--pt-muted); padding: 1.5rem 0; border-top: 1px solid var(--pt-border); margin-top: 2rem; background: #fff; }

/* ---------- การ์ด ---------- */
.card { border: 1px solid var(--pt-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--pt-border); font-family: 'Prompt', sans-serif; font-weight: 500; border-radius: 14px 14px 0 0 !important; }

.kpi { padding: 1.1rem 1.25rem; }
.kpi .kpi-label { color: var(--pt-muted); font-size: .9rem; }
.kpi .kpi-value { font-family: 'Prompt', sans-serif; font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.kpi .kpi-icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem;
}
.ic-blue { background: #dbeafe; color: #1d4ed8; }
.ic-green { background: #dcfce7; color: #15803d; }
.ic-amber { background: #fef3c7; color: #b45309; }
.ic-violet { background: #ede9fe; color: #6d28d9; }

.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.text-muted-2 { color: var(--pt-muted); }

.table > :not(caption) > * > * { vertical-align: middle; }
.table thead th { background: #f8fafc; font-weight: 500; font-size: .92rem; white-space: nowrap; }

/* ระดับความพึงพอใจ */
.lv { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.lv-5 { background: #dcfce7; color: #166534; }
.lv-4 { background: #dbeafe; color: #1e40af; }
.lv-3 { background: #fef9c3; color: #854d0e; }
.lv-2 { background: #ffedd5; color: #9a3412; }
.lv-1 { background: #fee2e2; color: #991b1b; }
.lv-none { background: #f1f5f9; color: #64748b; }

.mini-bar { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; min-width: 80px; }
.mini-bar > span { display: block; height: 100%; background: var(--pt-primary); border-radius: 99px; }

/* ---------- หน้าบ้าน ---------- */
.hero {
  background: linear-gradient(135deg, var(--pt-primary-dark) 0%, var(--pt-primary) 60%, #3b82f6 100%);
  color: #fff; padding: 3rem 0 4.5rem;
}
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
.hero p { opacity: .9; }
.hero-overlap { margin-top: -3rem; }
.project-card { transition: transform .15s, box-shadow .15s; height: 100%; }
.project-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(30,58,138,.12); }
.project-card .meta { color: var(--pt-muted); font-size: .92rem; }
.step-ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto .5rem; }

/* ---------- แบบประเมิน ---------- */
.eval-wrap { max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.eval-head { border-top: 6px solid var(--pt-accent); }
.section-title {
  display: flex; align-items: center; gap: .6rem;
  font-size: 1.1rem; margin: 0;
}
.section-no {
  background: var(--pt-primary); color: #fff; border-radius: 8px; padding: .1rem .6rem; font-size: .85rem; white-space: nowrap;
}
.group-title { font-family: 'Prompt', sans-serif; font-weight: 500; color: var(--pt-primary-dark); background: #eff6ff; padding: .5rem .9rem; border-radius: 10px; margin: 1.1rem 0 .5rem; }
.q-item { padding: .9rem 0; border-bottom: 1px dashed var(--pt-border); }
.q-item:last-child { border-bottom: 0; }
.q-text { font-weight: 500; margin-bottom: .55rem; }
.q-text .req { color: #dc2626; }
.q-item.has-error .q-text { color: #b91c1c; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
/* สีตามระดับ: 5 เขียวเข้ม → 1 แดง */
.scale-btn.s5 { --c: #15803d; --tint: #f0fdf4; --line: #bbf7d0; }
.scale-btn.s4 { --c: #4d7c0f; --tint: #f7fee7; --line: #d9f99d; }
.scale-btn.s3 { --c: #b45309; --tint: #fffbeb; --line: #fde68a; }
.scale-btn.s2 { --c: #c2410c; --tint: #fff7ed; --line: #fed7aa; }
.scale-btn.s1 { --c: #b91c1c; --tint: #fef2f2; --line: #fecaca; }
.scale-btn {
  --c: var(--pt-primary); --tint: #fff; --line: var(--pt-border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); border-radius: 10px; padding: .45rem .2rem; background: var(--tint);
  color: var(--c); line-height: 1.1; min-height: 56px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s, opacity .15s;
}
.scale-btn b { font-family: 'Prompt', sans-serif; font-size: 1.15rem; }
.scale-btn small { font-size: .72rem; color: var(--c); opacity: .8; }
.scale-btn:hover { border-color: var(--c); }
.scale:has(.btn-check:checked) .scale-btn { opacity: .55; }
.btn-check:checked + .scale-btn {
  background: var(--c); border-color: var(--c); color: #fff; opacity: 1;
  box-shadow: 0 4px 12px -4px var(--c); transform: translateY(-1px);
}
.btn-check:checked + .scale-btn small { color: #fff; opacity: .9; }
.btn-check:focus-visible + .scale-btn { outline: 3px solid #93c5fd; outline-offset: 1px; }
.pp-row { display: grid; grid-template-columns: 90px 1fr; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.pp-label { font-size: .9rem; font-weight: 600; color: var(--pt-muted); }

.choice-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.choice-btn { border: 1.5px solid var(--pt-border); border-radius: 999px; padding: .35rem .95rem; background: #fff; }
.btn-check:checked + .choice-btn { background: var(--pt-primary); border-color: var(--pt-primary); color: #fff; }

.legend-scale { font-size: .85rem; color: var(--pt-muted); }
.hp-field { position: absolute; left: -9999px; }

@media (max-width: 575.98px) {
  .scale-btn small { display: none; }
  .scale-btn { min-height: 46px; }
  .pp-row { grid-template-columns: 1fr; gap: .25rem; }
}

/* ---------- รายงาน ---------- */
.report-table td.num, .report-table th.num { text-align: center; white-space: nowrap; }
.report-table tr.group-row td { background: #eff6ff; font-weight: 600; }
.report-table tr.total-row td { background: #1e3a8a; color: #fff; font-weight: 600; }
.comment-list li { padding: .45rem 0; border-bottom: 1px dashed var(--pt-border); }

.qr-box { display: inline-block; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--pt-border); }
.qr-box img, .qr-box canvas { display: block; }

.login-wrap { max-width: 420px; margin: 3rem auto; padding: 0 1rem; }

@media print {
  body { background: #fff; font-size: 14px; }
  .card { border: 0; box-shadow: none; }
  .card-header { padding-left: 0; }
  .no-print { display: none !important; }
  .report-table tr.total-row td { background: #ddd !important; color: #000 !important; }
  .page-break { page-break-before: always; }
  a { text-decoration: none; color: inherit; }
}

.pt-dev { color: var(--pt-ink); }
.pt-dev strong { color: var(--pt-primary-dark); font-family: 'Prompt', sans-serif; font-weight: 500; }

/* ---------- แชร์ QR ---------- */
.share-bar { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.share-bar .btn { display: inline-flex; align-items: center; gap: .35rem; }
.btn-line { --bs-btn-bg: #06c755; --bs-btn-border-color: #06c755; --bs-btn-color: #fff; --bs-btn-hover-bg: #05a948; --bs-btn-hover-border-color: #05a948; --bs-btn-hover-color: #fff; }
.btn-fb { --bs-btn-bg: #1877f2; --bs-btn-border-color: #1877f2; --bs-btn-color: #fff; --bs-btn-hover-bg: #0f5fcc; --bs-btn-hover-border-color: #0f5fcc; --bs-btn-hover-color: #fff; }
.pt-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: #111827; color: #fff; padding: .6rem 1.1rem; border-radius: 999px; font-size: .95rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 2000; transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); text-align: center;
}
.pt-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- รายงาน: ข้อมูลทั่วไป ---------- */
.demo-card {
  --accent: var(--pt-primary);
  border: 1px solid var(--pt-border); border-radius: 12px; overflow: hidden; background: #fff;
  border-top: 4px solid var(--accent);
}
.demo-head { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; }
.demo-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); font-size: 1.05rem;
}
.demo-title { font-family: 'Prompt', sans-serif; font-weight: 500; flex: 1; }
.demo-n { font-size: .82rem; color: var(--pt-muted); background: #f3f4f6; padding: .1rem .55rem; border-radius: 999px; white-space: nowrap; }
.demo-table thead th { background: #f8fafc; color: var(--pt-muted); font-size: .8rem; font-weight: 500; border-top: 1px solid var(--pt-border); }
.demo-table td, .demo-table th { padding: .45rem .9rem; }
.demo-table td.num, .demo-table th.num { text-align: center; width: 70px; color: var(--pt-muted); }
.demo-table .pct-col { width: 46%; }
.pct-cell { display: flex; align-items: center; gap: .6rem; }
.demo-bar { flex: 1; height: 10px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.demo-bar > span { display: block; height: 100%; background: color-mix(in srgb, var(--accent) 55%, #fff); border-radius: 4px; }
.demo-bar-spacer { flex: 1; }
.pct-val { min-width: 3.6em; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; color: var(--pt-ink); }
.demo-table tr.is-top td { font-weight: 600; }
.demo-table tr.is-top .demo-bar > span { background: var(--accent); }
.demo-table tr.is-top td.num { color: var(--pt-ink); }
.top-chip {
  font-size: .7rem; font-weight: 500; padding: .05rem .45rem; border-radius: 999px; margin-left: .25rem; white-space: nowrap;
  background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--pt-ink); border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff);
}
.demo-table tbody tr:hover td { background: #fafbfd; }
.demo-table tfoot td { background: color-mix(in srgb, var(--accent) 7%, #fff); font-weight: 600; border-bottom: 0; color: var(--pt-ink); }
.demo-table tfoot td.num { color: var(--pt-ink); }
@media print {
  .demo-card { border: 1px solid #ccc; border-top: 3px solid var(--accent); break-inside: avoid; }
  .demo-table .pct-col { width: 20%; }
}

/* ---------- PDPA ---------- */
.pdpa-box { border-left: 4px solid var(--pt-primary); }
.pdpa-box.has-error { border-color: #dc2626; background: #fef2f2; }
.privacy h2 { font-size: 1.15rem; margin: 1.75rem 0 .6rem; color: var(--pt-primary-dark); }
.privacy h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.privacy p, .privacy li { line-height: 1.75; }
.cookie-bar {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1500; max-width: 720px; margin: 0 auto;
  background: #111827; color: #f9fafb; border-radius: 14px; padding: .8rem 1rem;
  display: flex; gap: .75rem; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: .92rem;
}
.cookie-bar a { color: #93c5fd; }
.cookie-bar .btn { white-space: nowrap; }
@media (max-width: 575.98px) { .cookie-bar { flex-direction: column; align-items: stretch; text-align: center; } }
.cookie-bar[hidden] { display: none; }

/* ชื่อระบบบนหน้าแรก */
.hero-name { font-size: clamp(2.2rem, 6vw, 3.4rem); font-weight: 600; letter-spacing: .5px; line-height: 1.1; }
.hero-en {
  display: inline-block; font-family: 'Prompt', sans-serif; font-size: clamp(.95rem, 2.2vw, 1.2rem);
  color: #1e1b4b; background: var(--pt-accent); padding: .2rem .8rem; border-radius: 999px;
}
.hero .hero-th { font-size: clamp(1.25rem, 3.2vw, 1.75rem); font-weight: 500; opacity: .95; }
