:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --ink: #18221f;
  --muted: #65716d;
  --line: #dfe6e3;
  --green: #0a7a5a;
  --green-dark: #075b44;
  --green-soft: #e8f6f1;
  --amber: #a96004;
  --amber-soft: #fff3dc;
  --red: #a33131;
  --shadow: 0 12px 32px rgba(22, 50, 41, .07);
  font-family: Inter, "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e0f3eb 0, var(--bg) 45%); }
.login-card { width: min(520px, 100%); text-align: center; }
.brand-mark { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 16px; font-weight: 900; font-size: 24px; color: white; background: linear-gradient(135deg, var(--green), #18a379); }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 10; top: 0; display: flex; justify-content: space-between; gap: 24px; align-items: center; padding: 18px max(24px, calc((100vw - 1440px)/2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-size: 24px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
main { width: min(1440px, calc(100% - 40px)); margin: 28px auto 48px; display: grid; gap: 22px; }
.card, .subcard { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.subcard { border-radius: 14px; padding: 18px; box-shadow: none; background: #fbfcfc; }
h1, h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 8px; font-size: 21px; }
h3 { margin-bottom: 12px; font-size: 17px; }
.eyebrow { margin-bottom: 4px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.muted { color: var(--muted); line-height: 1.65; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { padding: 20px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 30px; }
.workflow-card { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.steps { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.steps span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--green-dark); background: var(--green-soft); font-weight: 800; }
.grid { display: grid; gap: 22px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; align-content: start; gap: 15px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 14px; }
label { display: grid; gap: 7px; color: #39443f; font-size: 13px; font-weight: 650; text-align: left; }
input, textarea, select { width: 100%; border: 1px solid #ced8d4; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
textarea { resize: vertical; min-height: 74px; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(10,122,90,.12); }
button { border: 0; border-radius: 10px; padding: 11px 15px; font-weight: 750; }
.primary { color: white; background: var(--green); }
.primary:hover { background: var(--green-dark); }
.ghost { color: var(--green-dark); background: var(--green-soft); }
.ghost:hover { background: #d8eee6; }
.badge { display: inline-flex; padding: 7px 10px; border-radius: 99px; font-size: 11px; font-weight: 850; }
.badge.ok { color: var(--green-dark); background: var(--green-soft); }
.badge.wait { color: var(--amber); background: var(--amber-soft); }
.badge.level { min-width: 32px; justify-content: center; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
td strong { display: block; margin-bottom: 3px; }
td small { color: var(--muted); }
.score { font-variant-numeric: tabular-nums; font-weight: 800; }
.action-link { padding: 7px 9px; font-size: 12px; }
.list { display: grid; gap: 11px; }
.list-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.list-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; word-break: break-word; }
.code-output { max-height: 480px; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: 12px; padding: 16px; color: #dff9ef; background: #10221c; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.provider-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.provider-pill { padding: 8px 10px; border-radius: 99px; color: var(--muted); background: #eef1f0; font-size: 12px; }
.provider-pill.on { color: var(--green-dark); background: var(--green-soft); }
.flow-final-file { max-width: 220px; font-size: 12px; }
.flow-qc-panel { width: min(520px, 100%); padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; }
.flow-qc-panel summary { cursor: pointer; font-weight: 700; color: var(--green-dark); }
.flow-qc-panel .check-label { margin-top: 7px; align-items: flex-start; font-size: 12px; }
.inline-form { display: grid; grid-template-columns: auto minmax(160px, .6fr) minmax(240px, 1.5fr) auto; align-items: end; gap: 12px; }
.inline-form h3 { margin: 0; }
.small-output, .message, .error { margin: 0; min-height: 18px; color: var(--muted); font-size: 12px; word-break: break-word; }
.oneclick-card { border: 1px solid rgba(21, 126, 94, .28); background: linear-gradient(135deg, #fff, #f1fbf6); }
.oneclick-button { min-height: 52px; font-size: 16px; }
.check-label { display: flex; align-items: center; gap: 9px; justify-content: flex-start; }
.check-label input { width: auto; }
.automation-item { align-items: center; }
.automation-item > div:first-child { flex: 1; }
.automation-actions { display: flex; align-items: center; gap: 8px; }
.progress-track { width: 100%; height: 6px; margin-top: 8px; border-radius: 99px; background: #dde7e1; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: #157e5e; }
.evidence-section { align-items: start; }
.evidence-item { border-left: 4px solid #2c8b65; }
.evidence-score { display: grid; justify-items: end; gap: 4px; min-width: 92px; }
.evidence-score > strong { color: var(--green-dark); font-size: 24px; font-variant-numeric: tabular-nums; }
.evidence-score > small { color: var(--muted); font-size: 10px; }
.deep-lab { border-color: rgba(54, 92, 173, .24); background: linear-gradient(145deg, #fff, #f4f7ff); }
.template-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.template-card { min-height: 180px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfc; }
.template-card h3 { margin: 12px 0 8px; }
.template-card p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.template-card small { display: block; color: var(--green-dark); line-height: 1.55; }
.template-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.template-head span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.template-head strong { color: var(--green-dark); font-size: 12px; }
.error { color: var(--red); }
footer { padding: 22px; text-align: center; color: var(--muted); font-size: 12px; }
#toast { position: fixed; z-index: 30; right: 20px; bottom: 20px; max-width: 420px; padding: 12px 16px; border-radius: 12px; color: white; background: #17231f; box-shadow: var(--shadow); transform: translateY(130%); transition: transform .2s ease; }
#toast.show { transform: translateY(0); }
@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .workflow-card { align-items: flex-start; flex-direction: column; }
  .inline-form { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  main { width: min(100% - 24px, 1440px); margin-top: 16px; }
  .topbar { padding: 14px 12px; }
  .topbar h1 { font-size: 17px; }
  .badge { display: none; }
  .stats { gap: 8px; }
  .stat { padding: 15px; }
  .card { padding: 18px; border-radius: 15px; }
  .field-row, .field-row.three, .details-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: 1fr; }
}
