:root {
  --bg: #fdeef1;
  --surface: #ffffff;
  --ink: #2a1c20;
  --muted: #7a646a;
  --line: #f1dfe3;
  --brand: #b0305a;
  --brand-dark: #8c1f44;
  --brand-soft: #fbe3ea;
  --pass: #1f8a4c;
  --pass-soft: #e4f4ea;
  --fail: #d6402b;
  --fail-soft: #fde8e4;
  --info: #3b6fb6;
  --warn: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 4px 16px rgba(16, 24, 22, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  color: var(--ink); font-size: 15px; line-height: 1.5;
  background-color: var(--bg);
  /* soft pink glow + faint safety-cross pattern */
  background-image:
    radial-gradient(900px 500px at 100% 0%, rgba(240, 128, 160, .22), transparent 60%),
    radial-gradient(700px 500px at 0% 100%, rgba(255, 170, 150, .22), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg fill='%23e6a3b4' fill-opacity='.18'%3E%3Cpath d='M26 18h8v8h8v8h-8v8h-8v-8h-8v-8h8z'/%3E%3Ccircle cx='92' cy='88' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
}
.hidden { display: none !important; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 24px; color: #fff;
  background: linear-gradient(120deg, var(--brand-dark), var(--brand) 55%, #d9577c);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.15);
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.sub { margin: 0; font-size: 13px; opacity: .8; }
.controls { display: flex; gap: 10px; align-items: center; }
.topbar .select span { color: rgba(255,255,255,.8); }
.topbar select { background: #fff; }

.select { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
select, input, textarea {
  font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; background: #fff; min-width: 0;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.btn {
  font: inherit; border-radius: 10px; padding: 8px 16px; cursor: pointer; border: 1px solid transparent;
  font-weight: 500;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: inherit; }
.topbar .btn.ghost { border-color: rgba(255,255,255,.35); color: #fff; }

.tabs {
  display: flex; gap: 4px; padding: 0 20px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
  overflow-x: auto; position: sticky; top: 0; z-index: 5;
}
.tabs button {
  font: inherit; background: none; border: 0; padding: 14px 14px 12px; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.pill { background: var(--fail); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.pill:empty { display: none; }

main { padding: 20px 24px 40px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h.wrap { align-items: center; }
.card-h h2 { margin: 0; font-size: 16px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; }
.grid2 > .card { margin-bottom: 18px; }
.grid2.evid { grid-template-columns: 2fr 3fr; }
@media (max-width: 900px) { .grid2, .grid2.evid { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi .lbl { color: var(--muted); font-size: 13px; }
.kpi .val { font-size: 28px; font-weight: 700; margin-top: 2px; }
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi.pass .val { color: var(--pass); }
.kpi.fail .val { color: var(--fail); }

.chart-wrap { position: relative; height: 300px; }
.chart-wrap.tall { height: 380px; }

.compliance { display: flex; flex-direction: column; gap: 12px; }
.comp-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.comp-item h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.comp-item .law { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.comp-branch { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 3px 0; }
.comp-branch .name { width: 90px; color: var(--muted); }
.bar { flex: 1; height: 8px; background: var(--fail-soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--pass); border-radius: 99px; }
.comp-branch .cnt { width: 170px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: #fff7f9; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; background: #fff7f9; }
.cell-pct { display: inline-block; min-width: 54px; text-align: right; font-weight: 600; }
.badge { display: inline-block; border-radius: 99px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; }
.badge.pass { background: var(--pass-soft); color: var(--pass); }
.badge.fail { background: var(--fail-soft); color: var(--fail); }
.badge.na { background: #f5eef0; color: var(--muted); }
.badge.warn { background: #fdf3e1; color: var(--warn); }
.mcell { font-variant-numeric: tabular-nums; }
.mcell.pass { color: var(--pass); }
.mcell.fail { color: var(--fail); }
.mcell small { color: var(--muted); }
.tick { color: var(--pass); font-weight: 700; }
.dash { color: #c3cbc8; }

.course-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13.5px; color: var(--muted); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters input[type=search] { flex: 1; min-width: 220px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .form-grid.three { grid-template-columns: 1fr 1fr; } }
.finder { background: #fff7f9; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.finder-label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--brand-dark); font-weight: 500; }
.finder-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 320px; overflow-y: auto; }
.finder-results:empty { display: none; margin: 0; }
.hit { display: flex; align-items: center; gap: 12px; text-align: left; font: inherit; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.hit:hover, .hit:focus { border-color: var(--brand); outline: none; background: var(--brand-soft); }
.hit .who { flex: 1; min-width: 0; }
.hit .who b { font-weight: 600; }
.hit .who span { display: block; color: var(--muted); font-size: 13px; }
.hit .have { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.chip-c { font-size: 12px; border-radius: 99px; padding: 1px 8px; background: var(--pass-soft); color: var(--pass); white-space: nowrap; }
.chip-c.none { background: #f5eef0; color: var(--muted); }
.picked { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; background: var(--brand-soft); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.picked:empty { display: none; }
.btn.sm { padding: 3px 10px; font-size: 13px; }

/* people table: top scrollbar + frozen columns */
.xbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 8px; }
.xbar .hint { margin: 0; }
.xnav { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 260px; max-width: 640px; }
.xtop { flex: 1; overflow-x: auto; overflow-y: hidden; height: 16px; border-radius: 8px; background: #fbe9ee; }
.xtop > div { height: 1px; }
.xtop::-webkit-scrollbar { height: 14px; }
.xtop::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 8px; border: 3px solid #fbe9ee; }
.xtop::-webkit-scrollbar-track { background: transparent; }
.xnav.hidden-x { visibility: hidden; }
.people-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.people-wrap::-webkit-scrollbar { height: 14px; width: 12px; }
.people-wrap::-webkit-scrollbar-thumb { background: #e3b3c2; border-radius: 8px; border: 3px solid #fff; }
.sticky-cols th { position: sticky; top: 0; z-index: 2; }
.sticky-cols td:nth-child(-n+3), .sticky-cols th:nth-child(-n+3) { position: sticky; background: #fff; z-index: 1; }
.sticky-cols th:nth-child(-n+3) { z-index: 3; background: #fff7f9; }
.sticky-cols td:nth-child(1), .sticky-cols th:nth-child(1) { left: 0; min-width: 104px; }
.sticky-cols td:nth-child(2), .sticky-cols th:nth-child(2) { left: 104px; min-width: 96px; }
.sticky-cols td:nth-child(3), .sticky-cols th:nth-child(3) { left: 200px; box-shadow: 6px 0 8px -6px rgba(176, 48, 90, .25); }
.sticky-cols tr:hover td { background: #fff7f9; }
td .btn.sm { white-space: nowrap; }
.one-status { grid-column: 1 / -1; font-size: 14px; }
.one-status:empty { display: none; }
input.auto { background: #fff7f9; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; }
.actions { display: flex; gap: 10px; margin: 14px 0; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.drop {
  border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; cursor: pointer;
  align-items: center; justify-content: center;
}
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop input { display: none; }

.howto { font-size: 13.5px; color: var(--muted); background: #fff7f9; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.howto summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.howto ol { margin: 8px 0 2px; padding-left: 20px; }
.ev-list { display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow-y: auto; }
.ev { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.ev .ic { width: 38px; height: 38px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.ev .meta { flex: 1; min-width: 0; }
.ev .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ev .meta span { color: var(--muted); font-size: 12.5px; }
.ev a { color: var(--brand); text-decoration: none; font-size: 13.5px; white-space: nowrap; }

.alert { border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.alert.error { background: var(--fail-soft); color: var(--fail); }
.alert.ok { background: var(--pass-soft); color: var(--pass); }
.alert.warn { background: #fdf3e1; color: var(--warn); }

/* hero banner */
.hero {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border-radius: var(--radius); padding: 22px 28px; margin-bottom: 18px; box-shadow: var(--shadow);
  background: linear-gradient(110deg, #fff 0%, #fff5f7 45%, #fcd9e2 100%);
}
.hero h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--brand-dark); }
.hero p { margin: 0; color: var(--muted); max-width: 520px; }
.hero .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hero .chip { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; font-size: 13px; color: var(--brand-dark); }
.hero svg { flex: none; width: 300px; height: auto; }
@media (max-width: 760px) { .hero svg { display: none; } }
.kpi { border-top: 3px solid var(--brand-soft); }
.kpi .ico { float: right; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); display: grid; place-items: center; font-size: 17px; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 0 0 24px; }
