* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', -apple-system, 'Segoe UI', sans-serif;
    background: #f5f6fa;
    color: #1f2330;
    line-height: 1.55;
}

a { color: #1565c0; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.topbar {
    background: linear-gradient(120deg, #133e7c, #0d6efd);
    color: #fff;
    padding: 18px 0;
}
.topbar .container { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
    background: #fff;
    color: #0d47a1;
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    font-weight: 700;
}
.brand-name { font-size: 18px; font-weight: 600; }
.brand-tag { font-size: 13px; opacity: .85; }

.hero {
    padding: 32px 0 8px;
}
.hero h1 { margin: 0 0 8px; font-size: 28px; font-weight: 600; }
.hero .lead { margin: 0; color: #4a5160; max-width: 860px; }

.card {
    background: #fff;
    border: 1px solid #e2e6ee;
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 1px 2px rgba(15, 30, 80, .03);
}
.card h2 { margin: 0 0 16px; font-size: 18px; font-weight: 600; }

.upload-tabs {
    display: flex;
    gap: 4px;
    margin: 24px 0 0;
    border-bottom: 2px solid #e2e6ee;
}
.tab-btn {
    background: transparent;
    border: 0;
    padding: 10px 20px;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    color: #6b7383;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: #1565c0; }
.tab-btn.active { color: #0d47a1; border-bottom-color: #1565c0; font-weight: 600; }
.upload-pane.hidden { display: none; }

.upload-form { display: flex; flex-direction: column; gap: 16px; }
.file-drop {
    border: 2px dashed #b3bccd;
    border-radius: 12px;
    padding: 36px;
    text-align: center;
    background: #fafbfd;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-drop:hover { border-color: #1565c0; background: #f0f6ff; }
.file-drop input[type=file] { display: block; margin: 0 auto 12px; }
.file-drop-title { font-size: 15px; font-weight: 600; display: block; }
.file-drop-sub { font-size: 13px; color: #6b7383; display: block; margin-top: 4px; }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid;
}
.alert-error { background: #fff1f0; color: #a8071a; border-color: #ffa39e; }

.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.btn-primary {
    background: #1565c0;
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}
.btn-primary:hover { background: #0d47a1; }

.btn-secondary {
    background: #fff;
    color: #1565c0;
    border: 1px solid #1565c0;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    display: inline-block;
}
.btn-secondary:hover { background: #f0f6ff; text-decoration: none; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 20px 0 40px;
}
.info-item {
    background: #fff;
    border: 1px solid #e2e6ee;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 14px;
}
.info-num {
    background: #e3efff;
    color: #0d47a1;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.info-item h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.info-item p { margin: 0; font-size: 13px; color: #6b7383; }

.result-summary {
    display: flex; align-items: center; gap: 22px;
    padding: 24px;
    border-radius: 12px;
    margin: 20px 0;
    color: #fff;
    flex-wrap: wrap;
}
.result-summary.ok { background: linear-gradient(120deg, #1d7d3a, #2e9e4f); }
.result-summary.fail { background: linear-gradient(120deg, #a8071a, #cf1322); }
.result-summary h1 { margin: 0; font-size: 22px; }
.result-summary p { margin: 6px 0; opacity: .92; font-size: 14px; }
.result-summary-icon {
    font-size: 36px; font-weight: 700;
    width: 56px; height: 56px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.result-summary .btn-secondary { background: rgba(255,255,255,.95); border-color: transparent; color: #1f2330; }
.result-summary .counters { font-size: 13px; }
.result-summary .counters span { margin-right: 10px; padding: 3px 8px; background: rgba(255,255,255,.18); border-radius: 6px; }

.phase-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 12px 0 20px;
}
.phase {
    padding: 14px 16px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e6ee;
    display: flex; justify-content: space-between; align-items: center;
}
.phase.ok { border-left: 4px solid #2e9e4f; }
.phase.fail { border-left: 4px solid #cf1322; }
.phase.warn { border-left: 4px solid #faad14; }
.phase strong { font-weight: 700; }
.phase.ok strong { color: #2e9e4f; }
.phase.fail strong { color: #cf1322; }
.phase.warn strong { color: #d48806; }

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 8px 24px;
}
.kv {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed #e8ebf2;
}
.kv-wide { grid-column: 1 / -1; }
.kv span { color: #6b7383; font-size: 13px; }
.kv strong { font-weight: 500; text-align: right; }

.parties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 14px;
    margin: 20px 0;
}
.party-card { margin: 0; }
.party-card h2 {
    font-size: 14px; font-weight: 600; color: #6b7383;
    margin: 0 0 12px; padding-bottom: 8px;
    border-bottom: 1px solid #eef0f6;
    text-transform: uppercase; letter-spacing: .5px;
}
.party-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.party-taxid { font-size: 13px; color: #4a5160; }
.party-taxid .mono { background: #f7f9fc; padding: 1px 6px; border-radius: 4px; }
.party-address { margin-top: 10px; font-size: 13.5px; color: #4a5160; line-height: 1.6; }
.party-contact { margin-top: 8px; font-size: 13px; color: #4a5160; display: flex; gap: 16px; flex-wrap: wrap; }
.badge-scheme {
    display: inline-block;
    padding: 1px 8px;
    background: #e3efff;
    color: #0d47a1;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.lines-result {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.lines-result th, .lines-result td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef0f6;
    text-align: left;
    vertical-align: top;
}
.lines-result th.num, .lines-result td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lines-result thead { background: #f7f9fc; }
.lines-result thead th { font-size: 12.5px; color: #4a5160; font-weight: 600; }
.lines-result .line-desc { font-size: 12px; margin-top: 2px; }
.lines-result .unit-code {
    margin-left: 6px;
    font-size: 11px;
    background: #f0f2f7;
    padding: 1px 6px;
    border-radius: 4px;
}
.lines-result tfoot td { background: #fafbfd; font-size: 13px; }
.lines-result tfoot tr.grand-total td {
    background: #e3efff;
    border-top: 2px solid #1565c0;
    font-size: 14px;
}

.findings {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.findings th, .findings td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef0f6;
    vertical-align: top;
    text-align: left;
}
.findings thead { background: #f7f9fc; }
.findings tr.sev-error { background: #fff5f5; }
.findings tr.sev-warning { background: #fffbe6; }
.findings tr.sev-info { background: #f0f8ff; }
.findings .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}
.findings .sev-error .badge { background: #ffa39e; color: #5c0011; }
.findings .sev-warning .badge { background: #ffe58f; color: #614700; }
.findings .sev-info .badge { background: #bae0ff; color: #003a8c; }

.mono { font-family: ui-monospace, 'Consolas', monospace; }
.muted { color: #6b7383; font-size: 14px; }

.footer {
    margin-top: 40px;
    padding: 20px 0 30px;
    color: #6b7383;
    font-size: 13px;
    border-top: 1px solid #e2e6ee;
}
.footer-sep { margin: 0 8px; }
.footer-meta { margin-top: 6px; }

/* ── e-Tax Validator (public site) ───────────────────────────── */
.file-drop.dragging { border-color: #1565c0; background: #e3efff; }
.form-actions { align-items: center; }
.privacy-note { margin-right: auto; font-size: 13px; }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.bottom-actions { text-align: center; margin: 24px 0 8px; }
.bottom-actions .btn-primary { display: inline-block; color: #fff; }
.bottom-actions .btn-primary:hover { text-decoration: none; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.parties-grid { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.kv-grid { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }

.doc-block { margin-top: 28px; }
.doc-source { font-size: 13px; margin-bottom: -8px; }
.doc-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.doc-type { font-size: 20px; font-weight: 600; }
.doc-number { font-size: 15px; color: #4a5160; }
.doc-total { text-align: right; }
.doc-total span { display: block; }
.doc-total strong { font-size: 24px; font-weight: 700; color: #0d47a1; }
.doc-total small { font-size: 14px; font-weight: 500; }

.kv-list .kv { padding: 6px 0; }
.kv-list .kv strong { max-width: 65%; }
.party-name { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.party-card .badge-scheme { margin-left: 6px; }

.sig-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 14px; }
.sig-box { border: 1px solid #e2e6ee; border-left-width: 4px; border-radius: 10px; padding: 14px 16px; }
.sig-box.sig-valid { border-left-color: #2e9e4f; background: #f6fbf7; }
.sig-box.sig-invalid { border-left-color: #cf1322; background: #fff7f7; }
.sig-box.sig-none { border-left-color: #faad14; background: #fffdf5; }
.sig-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.sig-valid .sig-head strong { color: #2e9e4f; }
.sig-invalid .sig-head strong { color: #cf1322; }
.sig-none .sig-head strong { color: #d48806; }
.sig-note { margin: 6px 0 8px; font-size: 13.5px; color: #4a5160; }
.tag-warn { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #ffe58f; color: #614700; font-size: 11.5px; }

@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .hero h1 { font-size: 22px; }
    .card { padding: 16px; }
    .file-drop { padding: 24px 12px; }
    .result-summary { padding: 18px; gap: 14px; }
    .doc-total { text-align: left; }
    .kv { flex-direction: column; gap: 2px; }
    .kv strong, .kv-list .kv strong { text-align: left; max-width: none; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .privacy-note { margin: 0; text-align: center; }
}
