:root {
    --ink: #1c2b33;          /* น้ำเงินหมึกเข้ม */
    --teal: #0e6e5c;         /* เขียวสาธารณสุข */
    --teal-dark: #0a4f42;
    --paper: #f6f7f4;        /* กระดาษ */
    --card: #ffffff;
    --line: #dde3de;
    --err: #b3261e;
    --err-bg: #fdeceb;
    --warn: #9a5b00;
    --warn-bg: #fdf3e0;
    --info: #245f8a;
    --info-bg: #eaf3fa;
    --ok: #0e6e5c;
    --ok-bg: #e8f4ef;
    --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Sarabun", "TH SarabunPSK", sans-serif;
    font-size: 16px;
    color: var(--ink);
    background:
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(14, 110, 92, 0.04) 31px 32px),
        var(--paper);
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

code { font-family: var(--mono); font-size: 0.88em; background: #eef1ee; padding: 1px 5px; border-radius: 4px; }

/* ---------- topbar ---------- */
.topbar {
    background: var(--teal-dark);
    color: #fff;
    border-bottom: 4px solid var(--teal);
}
.topbar-inner { display: flex; align-items: center; gap: 14px; padding: 14px 20px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
    font-family: var(--mono);
    font-weight: 600;
    letter-spacing: 2px;
    background: #fff;
    color: var(--teal-dark);
    padding: 6px 10px;
    border-radius: 6px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text small { opacity: 0.75; }

/* ---------- upload ---------- */
.upload-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px;
    margin: 28px 0;
}
.upload-card h1 { margin: 0 0 8px; font-size: 1.5rem; }
.lede { color: #47555c; max-width: 62ch; margin-top: 0; }

.upload-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.file-drop {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    border: 2px dashed var(--teal);
    border-radius: 10px;
    padding: 30px 16px;
    cursor: pointer;
    background: var(--ok-bg);
    transition: background 0.15s ease;
    text-align: center;
}
.file-drop.over, .file-drop:hover { background: #d9ece4; }
.file-drop input { display: none; }
.file-drop-icon { font-size: 1.6rem; color: var(--teal); }
.file-drop-text { font-weight: 600; }
.file-drop-hint { color: #5a6a63; font-size: 0.85rem; }

.btn-primary {
    align-self: flex-start;
    background: var(--teal);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    padding: 11px 28px;
    cursor: pointer;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:focus-visible, .file-drop:focus-within { outline: 3px solid #7fc6b4; outline-offset: 2px; }
.form-error { color: var(--err); }
.form-error ul { margin: 0; padding-left: 18px; }

/* ---------- report ---------- */
.report {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px 28px 28px;
    margin: 0 0 32px;
}
.report-head { display: flex; gap: 20px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.report-title h2 { margin: 0 0 4px; font-size: 1.15rem; word-break: break-all; }
.report-meta { color: #5a6a63; font-size: 0.88rem; }

/* ตราประทับผลตรวจ */
.verdict-stamp {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 14px 18px;
    border: 3px double currentColor;
    border-radius: 8px;
    transform: rotate(-4deg);
    user-select: none;
}
.verdict-stamp.ok { color: var(--ok); background: var(--ok-bg); }
.verdict-stamp.bad { color: var(--err); background: var(--err-bg); }

.counts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pill { border-radius: 999px; padding: 2px 12px; font-size: 0.85rem; font-weight: 600; }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }

/* ---------- claim summary ---------- */
.claim-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 24px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}
.claim-summary small { display: block; color: #5a6a63; font-size: 0.8rem; }
.claim-summary b { font-weight: 600; }

/* ---------- section checklist ---------- */
.block-title { margin: 24px 0 12px; font-size: 1.02rem; color: var(--teal-dark); }
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.section-card {
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}
.section-card.pass { border-left-color: var(--ok); }
.section-card.warn { border-left-color: var(--warn); }
.section-card.fail { border-left-color: var(--err); background: #fffafa; }
.section-status {
    width: 24px; height: 24px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 50%;
    font-weight: 700; font-size: 0.85rem;
    color: #fff;
}
.section-card.pass .section-status { background: var(--ok); }
.section-card.warn .section-status { background: var(--warn); }
.section-card.fail .section-status { background: var(--err); }
.section-name { font-weight: 600; }
.section-desc { color: #5a6a63; font-size: 0.82rem; }
.section-counts { margin-top: 4px; display: flex; gap: 6px; }

.mini { font-size: 0.78rem; font-weight: 600; border-radius: 4px; padding: 1px 7px; }
.mini.err { background: var(--err-bg); color: var(--err); }
.mini.warn { background: var(--warn-bg); color: var(--warn); }
.mini.info { background: var(--info-bg); color: var(--info); }

/* ---------- issues ---------- */
.issue-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    background: #fff;
    overflow: hidden;
}
.issue-group summary {
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer;
    padding: 10px 16px;
    font-weight: 600;
    background: #f2f5f2;
    list-style: none;
}
.issue-group summary::-webkit-details-marker { display: none; }
.issue-group summary::before { content: "▸ "; color: var(--teal); }
.issue-group[open] summary::before { content: "▾ "; }
.group-counts { display: flex; gap: 6px; }

.issue-list { list-style: none; margin: 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.issue {
    display: flex; gap: 12px; align-items: flex-start;
    border-radius: 8px;
    padding: 10px 12px;
}
.issue.error { background: var(--err-bg); }
.issue.warning { background: var(--warn-bg); }
.issue.info { background: var(--info-bg); }
.issue .sev {
    flex-shrink: 0;
    font-size: 0.78rem; font-weight: 700;
    padding: 2px 9px; border-radius: 4px;
    color: #fff; margin-top: 2px;
    white-space: nowrap;
}
.issue.error .sev { background: var(--err); }
.issue.warning .sev { background: var(--warn); }
.issue.info .sev { background: var(--info); }

.issue-msg { font-weight: 500; }
.fld { margin-right: 6px; background: rgba(0,0,0,0.07); }
.issue-detail { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; font-size: 0.88rem; }
.tag {
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
    padding: 0 8px;
    font-family: var(--mono);
    font-size: 0.8rem;
}
.kv b { font-weight: 600; }
.specref { margin-top: 4px; font-size: 0.8rem; color: #5a6a63; font-style: italic; }

.all-clear { color: var(--ok); font-weight: 600; }

/* ---------- zip ---------- */
.zip-head { margin-bottom: 20px; }
.zip-head h2 { font-size: 1.15rem; }
.zip-count { color: #5a6a63; }

/* ---------- footer ---------- */
.footer {
    margin-top: 40px;
    padding: 18px 0 26px;
    color: #6b7a73;
    font-size: 0.85rem;
    border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
    .report-head { flex-direction: column; align-items: flex-start; }
    .verdict-stamp { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
