[hidden] { display: none !important; }
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b1f2a;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #004b8d;     /* Duo AI navy */
  --accent-2: #e6eef7;
  --orange: #fd6f3b;     /* Duo AI orange */
  --orange-2: #fff0ea;
  --ok: #12805c;
  --warn: #b54708;
  --err: #c0362c;
  --ai: #fd6f3b;
  --sys: #0e7490;
  --human: #004b8d;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 "IBM Plex Sans Thai", system-ui, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.7rem; line-height: 1.3; margin: .2em 0; }
h2 { font-size: 1.15rem; margin: 0 0 .7em; }
h3 { font-size: 1rem; margin: 1em 0 .4em; }
.muted { color: var(--muted); }
.small, small { font-size: .85em; }
.err { color: var(--err); }
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 40px; }
.wrap.narrow { max-width: 420px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--muted); text-decoration: none; font-size: .9rem; }
.brand img { height: 34px; width: auto; }
.brand span { padding-left: 12px; border-left: 1px solid var(--line); }
.topbar nav a { margin-left: 14px; color: var(--muted); text-decoration: none; font-size: .9rem; }

.hero { margin: 8px 0 18px; }
.eyebrow { font-size: .75rem; letter-spacing: .12em; color: var(--accent); font-weight: 600; margin: 0; }

/* panels & forms */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid .full { grid-column: 1 / -1; }
label, fieldset legend, .label { display: block; font-weight: 500; font-size: .92rem; }
label > input, label > select, label > textarea, fieldset > input { margin-top: 6px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; }
.edit-form label { margin-bottom: 12px; }
.q { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; background: var(--accent-2); color: var(--accent); font-size: .75rem; font-weight: 600; margin-right: 6px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip input { position: absolute; opacity: 0; width: 1px; }
.chip span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 400; cursor: pointer; font-size: .88rem; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }

.btn, .btn-ghost {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 18px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn { background: var(--accent); color: #fff; border: 0; }
.btn:disabled { opacity: .6; }
.btn-ghost { background: #fff; color: var(--accent); border: 1px solid var(--line); padding: 8px 14px; font-weight: 500; }
.btn-link { background: none; border: 0; color: var(--err); cursor: pointer; font: inherit; padding: 0; }

/* stepper */
.stepper { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); cursor: pointer; font-size: .9rem; }
.stepper li span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--line); font-size: .8rem; font-weight: 600; }
.stepper li.active { border-color: var(--accent); color: var(--ink); }
.stepper li.active span, .stepper li.done span { background: var(--accent); color: #fff; }
.form-nav { display: flex; align-items: center; gap: 10px; }
.form-nav.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.spacer { flex: 1; }
.draft-note { background: var(--accent-2); padding: 8px 12px; border-radius: 8px; font-size: .9rem; }
.draft-note .btn-link { color: var(--accent); text-decoration: underline; }

/* workflow card */
.wf-card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; background: #fcfcfd; }
.wf-head { display: flex; justify-content: space-between; align-items: center; }
.wf-head h3 { margin: 0 0 10px; }
h4.sub { margin: 20px 0 10px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: .95rem; }
.steps-block { margin-top: 16px; }
.step-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.step-row .n { flex: 0 0 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-2); color: var(--accent); font-size: .8rem; font-weight: 600; }
.step-del { flex: 0 0 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.1rem; }
.flow-preview { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; }
.flow-preview span { background: #fff; border: 1px solid var(--line); padding: 3px 9px; border-radius: 6px; }
.flow-preview b { color: var(--muted); }

/* report */
.notice { background: #fff7e6; border: 1px solid #fde3b0; padding: 10px 14px; border-radius: 8px; }
.admin-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.badge { font-size: .78rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.badge.ok { background: #e7f6ef; color: var(--ok); }
.badge.warn { background: #fff1e6; color: var(--warn); }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.meta { color: var(--muted); margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; font-size: .8rem; color: var(--muted); }
.kpi b { font-size: 2rem; line-height: 1.2; }
.kpi b small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.kpi b.sm { font-size: 1rem; display: block; margin-top: 4px; }
.lead { font-size: 1.02rem; }
.facts { display: grid; gap: 8px; margin: 12px 0 0; }
.facts div { display: grid; grid-template-columns: 170px 1fr; gap: 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
.grid-2 ul { padding-left: 1.2em; margin: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: .82rem; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.q-win { background: #e7f6ef; color: var(--ok); }
.q-strat { background: var(--accent-2); color: var(--accent); }
.q-easy { background: #e6f6fa; color: var(--sys); }
.q-fix { background: #fff1e6; color: var(--warn); }

.matrix { width: 100%; max-width: 420px; height: auto; }
.matrix .qz { stroke: #fff; stroke-width: 2; }
.matrix .qz-win { fill: #e7f6ef; } .matrix .qz-strat { fill: #eef0ff; }
.matrix .qz-easy { fill: #e6f6fa; } .matrix .qz-fix { fill: #fff4eb; }
.matrix .ql { font-size: 10px; fill: var(--muted); font-weight: 600; }
.matrix .ax { stroke: #98a2b3; }
.matrix .al { font-size: 10px; fill: var(--muted); }
.matrix .pt circle { fill: var(--orange); stroke: #fff; stroke-width: 2; }
.matrix .pt text { fill: #fff; font-size: 12px; font-weight: 700; }

.wf-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.wf-title h2 { margin: 0; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .9rem; margin-right: 4px; }
.bar { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; font-size: .88rem; }
.bar-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-fill.hi { background: var(--ok); } .bar-fill.mid { background: #e0a100; } .bar-fill.lo { background: #d9534f; }
.est { background: #fafafb; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.est div { margin-bottom: 8px; }
.est span { display: block; font-size: .8rem; color: var(--muted); }
.est b { font-size: 1.1rem; }
.est b.sm { font-size: .92rem; font-weight: 500; }

.flows { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 8px; }
.flow { list-style: none; padding: 0; margin: 0; }
.flow-step { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 18px; font-size: .92rem; }
.flow-step:not(:last-child)::after { content: "↓"; position: absolute; left: 50%; bottom: -18px; color: #98a2b3; font-size: .8rem; transform: translateX(-50%); }
.flow-step .n { flex: 0 0 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--line); font-size: .75rem; font-weight: 600; }
.flow-step em { margin-left: auto; font-style: normal; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.flow-step.bottleneck { border-color: #f3b4ae; background: #fff6f5; }
.flow-step.bottleneck em { background: #fde3e0; color: var(--err); }
.actor-ai { border-left: 4px solid var(--ai); } .actor-ai em { background: var(--orange-2); color: #c2410c; }
.actor-sys { border-left: 4px solid var(--sys); } .actor-sys em { background: #e6f6fa; color: var(--sys); }
.actor-human { border-left: 4px solid var(--human); } .actor-human em { background: var(--accent-2); color: var(--human); }
.legend { font-weight: 400; color: var(--muted); margin-left: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: -1px; }
.legend i.ai { background: var(--ai); } .legend i.sys { background: var(--sys); } .legend i.human { background: var(--human); }
.next { border-color: var(--accent); }
.internal { border-style: dashed; background: #fcfcfd; }
.disclaimer { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 20px; }

.loading { text-align: center; padding: 48px 20px; }
.spinner { width: 42px; height: 42px; margin: 0 auto 16px; border: 4px solid var(--accent-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.powered { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 18px 16px 28px; color: var(--muted); font-size: .85rem; }
.powered img { height: 30px; width: auto; }

/* brand in report */
.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.head-logo { height: 44px; width: auto; }

/* form additions */
.q.new { background: var(--orange-2); color: #c2410c; min-width: 30px; }
.inline { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.inline span { white-space: nowrap; }
.inline input[type=number] { max-width: 140px; }
.step-row input.min { flex: 0 0 84px; width: 84px; }

/* impact (ตัวเลขหลัก) */
.impact { border-top: 4px solid var(--orange); }
.impact h2 { margin: 0; }
.basis { font-size: .78rem; padding: 3px 10px; border-radius: 99px; background: #fff1e6; color: var(--warn); }
.basis.ok { background: #e7f6ef; color: var(--ok); }
.impact-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.imp { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.imp.wide { grid-column: span 2; }
.imp .k { font-size: .82rem; color: var(--muted); line-height: 1.35; }
.imp b { font-size: 1.75rem; line-height: 1.15; color: var(--accent); font-variant-numeric: tabular-nums; }
.imp b small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.imp b.sm { font-size: 1rem; }
.imp .s { font-size: .8rem; color: var(--muted); }
.imp.hl { background: var(--orange-2); border-color: #fcd2c0; }
.imp.hl b { color: #c2410c; }
.down { color: var(--ok); font-weight: 600; white-space: nowrap; }
.ba { display: grid; gap: 8px; margin: 4px 0 12px; }
.ba-row { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 10px; font-size: .85rem; }
.ba-track { background: #f2f4f7; border-radius: 6px; overflow: hidden; }
.ba-fill { padding: 5px 10px; color: #fff; font-size: .8rem; font-weight: 600; white-space: nowrap; border-radius: 6px; }
.ba-fill.now { background: var(--accent); }
.ba-fill.after { background: var(--orange); }
.net { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; background: #fafafb; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.net span { display: block; font-size: .8rem; color: var(--muted); }
.net b.pos { color: var(--ok); } .net b.neg { color: var(--err); }
.est .d { display: block; font-size: .78rem; }
.flow-step .txt { flex: 1; }
.flow-step em.lv { margin-left: 6px; }
.lv-auto { background: var(--orange-2); color: #c2410c; }
.lv-assist { background: #e6f6fa; color: var(--sys); }
.lv-human { background: var(--accent-2); color: var(--human); }
.levels { margin: 6px 0 14px; }
.lv-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lv-row .n { flex: 0 0 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-2); color: var(--accent); font-size: .78rem; font-weight: 600; }
.lv-row .txt { flex: 1; }
.lv-row select { width: 170px; }
.lv-row input.after { flex: 1 1 100%; margin-left: 34px; }
.lv-row { flex-wrap: wrap; }

/* quick / detailed mode */
form:not(.detailed) .detail, form:not(.detailed) .step-row input.min, form:not(.detailed) .detail-inline { display: none !important; }
.detail-toggle { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin: 4px 0 14px; border: 1px dashed var(--orange); background: var(--orange-2); border-radius: 10px; font-weight: 400; cursor: pointer; }
.detail-toggle input { width: auto; margin-top: 5px; }
.hint { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.fraud-block { display: grid; gap: 12px; padding: 12px 14px; border: 1px solid #fcd2c0; background: #fffaf7; border-radius: 10px; }
.fraud-block[hidden] { display: none; }

/* hire compare + leak */
.imp .own { color: var(--accent); font-weight: 600; }
.hire { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin: 4px 0 12px; }
.hire-col { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.hire-col .k, .leak .k { font-size: .82rem; color: var(--muted); }
.hire-col b { font-size: 1.4rem; color: var(--ink); }
.hire-col b small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.hire-col .s { font-size: .78rem; color: var(--muted); }
.hire-col.ai { border-color: #fcd2c0; background: var(--orange-2); }
.hire-col.ai b { color: #c2410c; }
.hire-vs { display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.leak { border-top: 4px solid var(--accent); }
.leak-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.chips.static { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.chip-s { font-size: .8rem; padding: 3px 10px; border-radius: 99px; background: var(--accent-2); color: var(--accent); }

/* step compare */
.cmp-title { margin-top: 18px; }
.legend-line { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); margin-bottom: 10px; }
.legend-line em, .cmp em.lv, em.bn { font-style: normal; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
em.bn { background: #fde3e0; color: var(--err); }
.cmp { display: grid; gap: 8px; }
.cmp-head, .cmp-row { display: grid; grid-template-columns: 1fr 28px 1.15fr; gap: 8px; align-items: stretch; }
.cmp-head span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.cmp-now, .cmp-after { border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: #fff; font-size: .9rem; }
.cmp-now { display: flex; gap: 10px; align-items: flex-start; }
.cmp-now .n { flex: 0 0 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--line); font-size: .75rem; font-weight: 600; }
.cmp-now b { font-weight: 500; display: block; }
.cmp small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.cmp-row.bottleneck .cmp-now { border-color: #f3b4ae; background: #fff6f5; }
.cmp-arrow { display: grid; place-items: center; color: #98a2b3; }
.cmp-after { display: flex; flex-direction: column; gap: 4px; border-left-width: 4px; }
.cmp-after em.lv { align-self: flex-start; }
.lv-b-auto { border-left-color: var(--orange); }
.lv-b-assist { border-left-color: var(--sys); }
.lv-b-human { border-left-color: var(--accent); }

@media (max-width: 720px) {
  .cmp-head { display: none; }
  .hire, .leak-grid { grid-template-columns: 1fr; }
  .hire-vs { height: 18px; }
  .cmp-row { grid-template-columns: 1fr; gap: 0; }
  .cmp-arrow { transform: rotate(90deg); height: 20px; }
  .impact-grid, .net { grid-template-columns: 1fr 1fr; }
  .imp b { font-size: 1.35rem; }
  .brand span { display: none; }
  .head-right { align-items: flex-start; }
  .lv-row { flex-wrap: wrap; } .lv-row select { width: 100%; }
  .inline { flex-wrap: wrap; }
  .grid, .two-col, .grid-2, .flows { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .facts div { grid-template-columns: 1fr; gap: 0; }
  .stepper li { font-size: .8rem; padding: 8px; }
  h1 { font-size: 1.4rem; }
}
@media print {
  body { background: #fff; font-size: 12px; }
  .no-print, .topbar { display: none !important; }
  .panel, .kpi, .imp { break-inside: avoid; border-color: #ddd; }
  .wf-report { break-before: page; }
  .wrap { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
