:root {
  --canvas: #f4f1ea;
  --surface: #fffcf6;
  --ink: #172538;
  --muted: #68727d;
  --line: #d9d3c7;
  --accent: #a35d12;
  --success: #287a57;
  --warning: #9b6817;
  --danger: #a33a32;
  --font: Tahoma, "Noto Sans Thai", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }

.report-masthead, main, footer { width: min(1380px, calc(100% - 40px)); margin-inline: auto; }
.report-masthead { display: flex; justify-content: space-between; gap: 36px; align-items: end; padding: 34px 0 24px; border-bottom: 1px solid var(--ink); }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--accent); font-size: 13px; font-weight: 700; }
.section-nav { display: flex; flex-wrap: wrap; gap: 16px; }
.section-nav .back-link { color: var(--muted); text-decoration: none; }
.section-nav .back-link.current, .section-nav .back-link:hover { color: var(--accent); }
.eyebrow, .section-kicker { margin: 0 0 5px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(32px, 4vw, 48px); line-height: 1.05; letter-spacing: -.025em; }
h2 { margin-bottom: 0; font-size: 23px; line-height: 1.2; }
.lede { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 16px; }
.truth-note { flex: 0 0 285px; padding-left: 18px; border-left: 3px solid var(--success); font-weight: 700; }
.truth-note small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }

main { padding: 26px 0 48px; }
.filter-section, .registry { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.filter-section { padding: 22px 26px 24px; }
.filter-heading, .registry-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; }
.result-count { margin-bottom: 0; color: var(--muted); }
.result-count strong { color: var(--ink); font-size: 24px; font-variant-numeric: tabular-nums; }
.filter-grid { display: grid; grid-template-columns: minmax(280px, 2.2fr) repeat(3, minmax(120px, .7fr)) auto; gap: 12px; align-items: end; margin-top: 20px; }
.filter-grid label { color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-grid input, .filter-grid select { width: 100%; min-height: 44px; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; }
.filter-button, .pagination button, .table-action, .insight-link, .close-button { min-height: 44px; padding: 8px 14px; border: 1px solid var(--ink); border-radius: 7px; color: #fff; background: var(--ink); font-weight: 700; }
.filter-button { min-width: 110px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .table-scroll:focus-visible { outline: 3px solid #e6aa5c; outline-offset: 2px; }

.registry { margin-top: 24px; overflow: hidden; }
.registry-heading { padding: 22px 26px 18px; }
#report-state { color: var(--muted); font-size: 12px; }
#report-state.error { color: var(--danger); }
.table-scroll { max-width: 100%; overflow: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
table { width: 100%; min-width: 1160px; border-collapse: collapse; background: var(--surface); }
th, td { padding: 13px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; z-index: 2; color: #fff; background: var(--ink); font-size: 12px; white-space: nowrap; }
td { font-size: 13px; }
tbody tr:hover { background: #f8f4ec; }
td:first-child { width: 54px; color: var(--muted); font-variant-numeric: tabular-nums; }
td:nth-child(2) { width: 260px; }
td:nth-child(3), td:nth-child(7) { width: 80px; font-variant-numeric: tabular-nums; }
td:nth-child(4), td:nth-child(5) { width: 190px; }
td:nth-child(6) { width: 120px; }
td:nth-child(8) { width: 115px; }
td:nth-child(9) { width: 145px; }
.judgment-title { display: block; margin-bottom: 3px; font-size: 14px; line-height: 1.4; }
.doc-id, .cell-muted { color: var(--muted); font-size: 11px; }
.cell-lines { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.status { display: inline-block; padding: 3px 7px; border: 1px solid currentColor; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status[data-status="verified"] { color: var(--success); }
.status[data-status="pending"], .status[data-status="rendered"] { color: var(--muted); }
.status[data-status="stale"] { color: var(--warning); }
.status[data-status="failed"] { color: var(--danger); }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table-action, .insight-link { min-height: 36px; padding: 6px 9px; font-size: 11px; text-decoration: none; }
.insight-link { color: var(--accent); border-color: var(--accent); background: transparent; }
.empty-row { padding: 42px 20px; color: var(--muted); text-align: center; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 18px 24px; font-variant-numeric: tabular-nums; }
.pagination button { color: var(--ink); border-color: var(--line); background: transparent; }

dialog { width: min(920px, calc(100% - 32px)); max-height: 90vh; padding: 0; overflow: hidden; color: var(--ink); background: var(--surface); border: 1px solid var(--ink); border-radius: 12px; }
dialog::backdrop { background: rgba(23, 37, 56, .58); }
.dialog-heading { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 20px 24px; color: #fff; background: var(--ink); }
.dialog-heading .section-kicker { color: #e6aa5c; }
.close-button { color: var(--ink); background: #fff; }
.detail-content { max-height: calc(90vh - 88px); padding: 24px; overflow: auto; }
.detail-title { margin-bottom: 18px; font-size: 22px; line-height: 1.35; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 24px; border-top: 1px solid var(--ink); }
.detail-grid div { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); }
.detail-grid div:not(:nth-child(3n + 1)) { padding-left: 12px; border-left: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: 11px; }
.detail-grid dd { margin: 3px 0 0; white-space: pre-line; }
.detail-section { padding-top: 18px; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 10px; font-size: 17px; }
.detail-section p { white-space: pre-line; }
.detail-insight { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 20px; padding: 8px 13px; color: #fff; background: var(--accent); border-radius: 7px; font-weight: 700; text-decoration: none; }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 20px 0 32px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }

@media (max-width: 980px) {
  .filter-grid { grid-template-columns: 2fr 1fr 1fr; }
  .filter-grid label:nth-child(4), .filter-button { grid-row: 2; }
  .filter-button { align-self: end; }
}

@media (max-width: 620px) {
  .report-masthead, main, footer { width: min(100% - 24px, 1380px); }
  .report-masthead { display: block; padding-top: 24px; }
  .truth-note { margin-top: 20px; }
  .filter-section { padding: 18px; }
  .filter-heading { align-items: start; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .search-field, .filter-button { grid-column: 1 / -1; }
  .filter-grid label:nth-child(4), .filter-button { grid-row: auto; }
  .registry-heading { align-items: start; padding: 18px; }
  table { min-width: 1080px; }
  .pagination { gap: 8px; padding-inline: 12px; }
  .pagination button { padding-inline: 10px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid div:not(:nth-child(3n + 1)) { padding-left: 0; border-left: 0; }
  .detail-content { padding: 18px; }
  footer { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

@media print {
  .back-link, .filter-section, .pagination, .table-actions, dialog, footer { display: none !important; }
  .report-masthead, main { width: 100%; }
  .report-masthead { padding-top: 0; }
  .registry { border: 0; }
  .table-scroll { overflow: visible; }
  table { min-width: 0; font-size: 9px; }
  th { position: static; color: #000; background: #fff; border-bottom: 1px solid #000; }
}
