:root {
  --bg: #F6F7F9; --card: #FFFFFF; --line: #E5E7EB; --ink: #111827; --muted: #4B5563;
  --blue: #1D4ED8; --orange: #EA580C; --good: #047857; --bad: #B91C1C; --track: #F1F5F9;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); font-size: 13px; }
h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; }
pre { background: #0F172A; color: #E2E8F0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 20px; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .name { font-weight: 700; font-size: 16px; }
.brand .sub { font-size: 12px; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #065F46; background: #ECFDF5; border-radius: 999px; padding: 6px 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #059669; display: inline-block; }
.seg { display: flex; background: #F3F4F6; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 8px 12px; min-height: 36px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 12px 14px; min-height: 44px; font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; }
.tabs button.on { border-color: var(--blue); color: var(--blue); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .delta { font-size: 12px; font-weight: 600; }
.delta.good { color: var(--good); } .delta.bad { color: var(--bad); }

.chart svg { width: 100%; height: 220px; display: block; margin-top: 8px; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: #6B7280; padding: 4px 2px 0; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bars .item { display: flex; flex-direction: column; gap: 4px; }
.bars .head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.bars .head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { background: var(--track); border-radius: 4px; height: 6px; }
.bars .fill { height: 6px; border-radius: 4px; background: var(--blue); }
.bars.orange .fill { background: var(--orange); }
.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

.row { display: flex; gap: 8px; align-items: center; }
.wrap-row { flex-wrap: wrap; }
input, select { font: inherit; padding: 10px 12px; border: 1px solid #D1D5DB; border-radius: 8px; min-height: 44px; background: #fff; }
#funnel-steps { flex: 1 1 320px; min-width: 0; }
button.primary { background: var(--blue); color: #fff; border: 0; border-radius: 8px; padding: 10px 14px; min-height: 44px; font: inherit; font-weight: 600; cursor: pointer; }
.step { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.step .head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.step .track { background: var(--track); border-radius: 8px; height: 32px; overflow: hidden; }
.step .fill { height: 32px; background: var(--blue); border-radius: 8px; }
.drop { font-size: 12px; color: #B45309; }

.scroll { overflow-x: auto; }
.ret { display: grid; gap: 4px; font-size: 12px; min-width: 640px; align-items: center; }
.ret .h { color: var(--muted); font-weight: 600; text-align: center; }
.ret .h.l { text-align: left; }
.ret .c { text-align: center; padding: 8px 0; border-radius: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 6px; border-bottom: 1px solid #F1F5F9; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.badge { display: inline-block; font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 3px 8px; border-radius: 6px; background: #EFF6FF; color: var(--blue); }
.badge.p { background: #ECFDF5; color: var(--good); }
.badge.c { background: #FFF7ED; color: #C2410C; }

h3 { margin: 16px 0 8px; font-size: 14px; font-weight: 600; }
.grid2.inner { gap: 16px 24px; }
.table.compact { min-width: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.insights li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.insights li i { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: #6B7280; }
.insights li.bad i { background: var(--bad); } .insights li.warn i { background: #D97706; }
.insights li.good i { background: var(--good); } .insights li.info i { background: var(--blue); }
.vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.vital { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.vital .value { font-size: 24px; font-weight: 700; }
.vital .label { color: var(--muted); font-size: 12px; }
.rate { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.rate.good { background: #ECFDF5; color: var(--good); }
.rate.needs-improvement { background: #FFFBEB; color: #B45309; }
.rate.poor { background: #FEF2F2; color: var(--bad); }
.checklist { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.chip { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
