@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/noto-sans-thai-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/noto-sans-thai-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --ink: #29292d;
  --muted: #62626a;
  --paper: #f5f5f6;
  --surface: #ffffff;
  --line: #dedee1;
  --red: #c1202f;
  --red-dark: #971724;
  --red-soft: #fbeaec;
  --green: #18724c;
  --amber: #a76512;
  --shadow: 0 4px 14px rgba(26, 26, 30, .06);
  font-family: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.65; }
img { max-width: 100%; }
button, input, select, fieldset, .hero > *, .status-panel > *, .filter-grid > *, .catalog-tools > * { min-width: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button, select, summary, input { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 12px; z-index: 999; padding: 10px 14px; color: white; background: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 2px solid var(--red); background: #fff; }
.header-shell { width: min(1240px, calc(100% - 40px)); min-height: 76px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 16px; }
.brand img { width: 140px; height: auto; object-fit: contain; }
.brand span { display: flex; flex-direction: column; }
.brand strong { font-size: 1.05rem; letter-spacing: .12em; }
.brand small { color: var(--muted); font-size: .8125rem; }
.refresh-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; flex-shrink: 0; border: 1px solid var(--red); border-radius: 999px; padding: 9px 16px; color: var(--red); background: #fff; font-size: .875rem; transition: color .15s ease, background-color .15s ease; }
.refresh-button:hover { color: #fff; background: var(--red); }
.refresh-button.loading span { display: inline-block; animation: spin .8s linear infinite; }
.refresh-button:disabled { opacity: .6; cursor: wait; }
@keyframes spin { to { transform: rotate(360deg); } }

main, footer { width: min(1240px, calc(100% - 40px)); margin-inline: auto; }
.hero { padding: 40px 36px; display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: center; gap: 32px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 24px 24px; }
.eyebrow { margin: 0 0 8px; color: var(--red); font-size: .8125rem; font-weight: 600; letter-spacing: .1em; }
.hero .eyebrow { color: var(--red); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 16px; color: var(--red); font-size: clamp(1.875rem, 3.6vw, 3.25rem); font-weight: 600; line-height: 1.4; letter-spacing: normal; }
h1 span { color: var(--ink); font-weight: 500; }
.hero-copy { max-width: 660px; margin-bottom: 0; color: var(--muted); font-size: 1rem; }
.rate-card { padding: 22px; border: 1px solid #efb8be; border-radius: 16px; background: var(--red-soft); }
.rate-card span { color: var(--red-dark); font-size: .875rem; }
.rate-card strong { display: block; margin: 8px 0 10px; color: var(--red); font-size: 3rem; font-weight: 600; line-height: 1.2; }
.rate-card p { margin: 0; color: var(--muted); font-size: .8125rem; }

.status-panel { margin: 20px 0 28px; min-height: 78px; padding: 16px 20px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.status-panel strong { font-size: 1rem; font-weight: 600; }
.status-panel p { margin: 3px 0 0; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.status-panel time { color: var(--muted); font-size: .8125rem; overflow-wrap: anywhere; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: #9a9692; box-shadow: 0 0 0 5px #ece8e3; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 5px #dcefe6; }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 0 5px #f7ead8; }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }

.filters, .catalog, .explainers { margin-bottom: 26px; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.section-heading { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.section-heading.compact { margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 1.5rem; font-weight: 600; line-height: 1.5; }
.fixed-note { max-width: 100%; margin: 0; padding: 7px 12px; border-radius: 12px; color: var(--muted); background: #f5f5f6; font-size: .8125rem; font-weight: 400; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)) 1.6fr; gap: 16px; }
.filter-grid > label, .catalog-tools > label:not(.search-control) { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: .875rem; font-weight: 500; }
select, input[type="search"] { width: 100%; min-height: 48px; font-size: 1rem; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
select { padding: 8px 34px 8px 12px; }
select:focus, input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.insurance-toggle { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.insurance-toggle legend { margin-bottom: 7px; color: var(--muted); font-size: .875rem; font-weight: 500; }
.insurance-toggle label { position: relative; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: .9375rem; font-weight: 500; text-align: center; cursor: pointer; }
.insurance-toggle label:has(input:checked) { color: white; border-color: var(--red); background: var(--red); }
.insurance-toggle label:has(input:focus-visible) { outline: 3px solid var(--red); outline-offset: 3px; }
.insurance-toggle input { position: absolute; opacity: 0; }

.catalog-tools { margin: 0 0 18px; padding: 14px 18px; display: grid; grid-template-columns: 1fr 180px 180px auto; gap: 12px; align-items: end; border: 1px solid var(--line); border-radius: 16px; background: #f0f0f2; }
.search-control { min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.search-control:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.search-control input { width: 100%; border: 0; box-shadow: none; }
.search-control input:focus { box-shadow: none; }
.result-count { align-self: center; padding: 8px 12px; border-radius: 999px; color: white; background: var(--red); font-size: .875rem; font-weight: 600; white-space: nowrap; }
.warning-banner { margin-bottom: 16px; padding: 12px 15px; color: #71430e; border: 1px solid #eccb9f; border-radius: 10px; background: #fff5e7; }

.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { padding: 14px; color: #fff; background: var(--red); font-size: .875rem; font-weight: 500; text-align: right; white-space: nowrap; }
th:first-child { text-align: left; }
td { padding: 16px 14px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fdf5f6; }
.product-cell { min-width: 220px; text-align: left; }
.product-identity { display: flex; flex-direction: column; }
.product-identity strong { font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.product-identity span { margin-top: 3px; color: var(--muted); font-size: .8125rem; }
.money { white-space: nowrap; font-size: 1rem; font-weight: 500; }
.price { color: var(--red-dark); }
.installment { color: var(--green); font-size: 1.125rem; font-weight: 700; }
.muted { color: #a5a09c; }
.suspended, .ineligible { color: var(--red); font-size: .875rem; font-weight: 600; }
.quote-details { min-width: 112px; text-align: left; }
.quote-details summary { min-height: 44px; display: flex; align-items: center; gap: 6px; color: var(--red); font-size: .875rem; font-weight: 500; cursor: pointer; }
.quote-details summary::before { content: "+"; font-size: 1.1rem; }
.quote-details[open] summary::before { content: "−"; }
.quote-breakdown { margin: 12px 0 5px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; font-size: .875rem; }
.quote-breakdown dt { color: var(--muted); }
.quote-breakdown dd { margin: 0; font-weight: 700; text-align: right; }
.breakdown-note { max-width: 300px; margin: 10px 0 0; color: var(--muted); font-size: .8125rem; }
.empty-state { height: 160px; color: var(--muted); text-align: center; }

.explainers details { padding: 17px 0; border-top: 1px solid var(--line); }
.explainers details:last-child { border-bottom: 1px solid var(--line); }
.explainers summary { min-height: 44px; padding-block: 8px; font-weight: 500; cursor: pointer; }
.explainers details p { max-width: 850px; margin: 12px 0 0; color: var(--muted); }
footer { padding: 20px 10px 46px; color: var(--muted); font-size: .875rem; text-align: center; }
footer p { margin-bottom: 7px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (max-width: 1000px) {
  .hero { padding: 30px 24px; grid-template-columns: minmax(0, 1fr) 230px; gap: 24px; }
  .brand small { display: none; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .catalog-tools { grid-template-columns: 1fr 1fr; }
  .search-control { grid-column: 1 / -1; }
  .result-count { grid-column: 1 / -1; justify-self: end; }
}

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 22px; }
  .rate-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; padding: 16px 18px; }
  .rate-card strong { grid-column: 1; grid-row: 1 / span 2; align-self: center; margin: 0; font-size: 2.5rem; }
  .rate-card span, .rate-card p { grid-column: 2; }
  .rate-card span { grid-row: 1; }
  .rate-card p { grid-row: 2; }
  .status-panel { grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; }
  .status-panel time { grid-column: 2; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .table-shell { border: 0; overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tbody tr { min-width: 0; padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; }
  tbody tr:hover { background: white; }
  td { min-width: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; border: 0; text-align: left; }
  td::before { content: attr(data-label); margin-bottom: 4px; color: var(--muted); font-size: .8125rem; font-weight: 400; }
  td.product-cell { grid-column: 1 / -1; min-width: 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  td.product-cell::before, td.empty-state::before { display: none; }
  td:last-child { grid-column: 1 / -1; }
  td:last-child::before { display: none; }
  .installment { font-size: 1.25rem; }
  .quote-details { width: 100%; }
  .quote-details summary { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; justify-content: center; background: #fafafa; }
  .quote-details[open] summary { color: var(--red-dark); background: var(--red-soft); }
  .quote-breakdown { width: 100%; }
  .breakdown-note { max-width: none; }
  .empty-state { display: flex; grid-column: 1 / -1; height: 120px; justify-content: center; align-items: center; }
}

@media (max-width: 560px) {
  .header-shell, main, footer { width: calc(100% - 24px); }
  .header-shell { min-height: 68px; gap: 8px; }
  .brand img { width: 104px; }
  .brand span { display: none; }
  .refresh-button { padding: 8px 12px; font-size: .8125rem; }
  .hero { padding: 26px 18px; border-radius: 0 0 18px 18px; }
  h1 { font-size: clamp(1.5rem, 6.1vw, 2rem); line-height: 1.5; }
  .hero-copy { font-size: .9375rem; }
  .rate-card { padding: 14px; gap: 4px 12px; }
  .rate-card strong { font-size: 2rem; }
  .status-panel { margin-block: 16px 20px; padding: 16px; }
  .status-panel p { font-size: .8125rem; }
  .status-panel time { font-size: .8125rem; }
  .filters, .catalog, .explainers { margin-bottom: 16px; padding: 18px 14px; border-radius: 16px; }
  .section-heading { margin-bottom: 18px; }
  .section-heading h2 { font-size: 1.25rem; }
  .filter-grid { gap: 16px 12px; }
  #occupationLabel, .insurance-toggle { grid-column: 1 / -1; }
  .insurance-toggle { gap: 8px; }
  .insurance-toggle label { padding-inline: 8px; font-size: .875rem; }
  .catalog-tools { padding: 14px; gap: 12px; }
  .search-control { padding-inline: 10px; }
  .product-identity strong { line-height: 1.6; }
  tbody tr { padding: 16px 14px; gap: 14px 12px; }
  footer { padding-inline: 4px; text-align: left; }
}
