:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #69736e;
  --paper: #f4f1e9;
  --surface: #fffefa;
  --line: #ddd9cf;
  --forest: #12261f;
  --forest-2: #23463a;
  --gold: #d9b86c;
  --gold-soft: #f4e8c9;
  --green: #267351;
  --shadow: 0 18px 60px rgba(18, 38, 31, .10);
  --radius: 20px;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); min-height: 100vh; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; }

.topbar {
  height: 74px;
  padding: 0 clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 254, 250, .94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; line-height: 1.05; letter-spacing: -.02em; }
.brand .app-icon { width: 38px; height: 38px; border-radius: 10px; }
.brand .mp-25-logo { width: 126px; height: auto; padding: 4px 7px; background: #fff; border-radius: 7px; }
.brand b { color: var(--green); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.source-badge { color: var(--green); background: #e6f2eb; border: 1px solid #c9e0d2; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.text-button, .icon-button, .avatar-button { border: 0; background: transparent; color: var(--ink); }
.text-button { font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; font-size: 20px; }
.avatar-button { width: 40px; height: 40px; border-radius: 50%; background: var(--forest); color: #fff; font-weight: 700; }

main { width: min(1400px, calc(100% - 36px)); margin: 0 auto 72px; }
.hero { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: end; padding: clamp(48px, 7vw, 92px) clamp(2px, 2vw, 20px) 42px; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.hero h1 { margin: 0; font-family: Georgia, "Noto Serif Thai", serif; font-size: clamp(38px, 5.6vw, 76px); line-height: .98; letter-spacing: -.045em; font-weight: 500; }
.hero h1 span { color: var(--green); }
.hero-copy { max-width: 700px; margin: 22px 0 0; color: var(--muted); font-size: 15px; }
.hero-stat { width: 220px; border-left: 1px solid var(--line); padding-left: 30px; display: grid; }
.hero-stat strong { font-family: Georgia, serif; color: var(--forest); font-size: 46px; line-height: 1; }
.hero-stat span { font-weight: 700; margin-top: 6px; }
.hero-stat small { color: var(--muted); margin-top: 12px; }

.search-panel { background: var(--forest); border-radius: var(--radius); padding: clamp(20px, 3vw, 34px); box-shadow: var(--shadow); }
.search-box { height: 62px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; background: #fff; border-radius: 13px; padding: 0 18px; }
.search-box > span { color: var(--green); font-size: 29px; transform: rotate(-15deg); }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 17px; }
.search-box kbd { color: #8a918d; background: #f0eee8; border: 1px solid #dedbd2; border-radius: 5px; padding: 3px 8px; font-family: inherit; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)) auto; gap: 14px; margin-top: 18px; align-items: end; }
.filters label { display: grid; gap: 6px; color: #c9d5cf; font-size: 11px; font-weight: 700; letter-spacing: .05em; }
.filters select { min-width: 0; width: 100%; height: 43px; padding: 0 34px 0 12px; color: #fff; background: #1d382f; border: 1px solid #38564b; border-radius: 9px; }
.clear-button { height: 43px; padding: 0 18px; color: var(--gold); background: transparent; border: 1px solid #4e625b; border-radius: 9px; }

.results-head { display: flex; align-items: end; justify-content: space-between; padding: 48px 2px 18px; }
.results-head h2 { margin: 0; font-family: Georgia, "Noto Serif Thai", serif; font-size: clamp(27px, 3vw, 38px); font-weight: 500; }
.muted { color: var(--muted); }
.results { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: opacity .15s; }
.results.loading { opacity: .55; }
.result-row { display: grid; grid-template-columns: minmax(290px, 2.3fr) minmax(130px, 1fr) 110px 125px 125px 120px; gap: 16px; align-items: center; min-height: 82px; padding: 14px 22px; border-top: 1px solid #ebe8df; }
.result-row:first-child { border-top: 0; }
.result-header { min-height: 46px; background: #eeece5; color: #69736e; font-size: 11px; font-weight: 800; letter-spacing: .05em; }
.product-cell { min-width: 0; display: grid; gap: 3px; }
.product-cell b { color: var(--green); font-size: 13px; letter-spacing: .02em; overflow-wrap: anywhere; }
.product-cell span { font-weight: 700; overflow-wrap: anywhere; }
.product-cell small { color: var(--muted); }
.result-cell { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.status-pill { width: fit-content; max-width: 100%; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-active { color: #17603e; background: #dff0e7; }
.status-review { color: #7a5a15; background: var(--gold-soft); }
.status-muted { color: #6d5f5c; background: #ebe4e2; }
.row-button { padding: 8px 0; border: 0; background: transparent; color: var(--green); font-weight: 700; font-size: 12px; }
.empty-state { min-height: 260px; display: grid; place-content: center; gap: 6px; text-align: center; color: var(--muted); }
.empty-state b { color: var(--ink); font-size: 18px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; padding-top: 24px; color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; text-decoration: none; font-weight: 800; }
.primary-button { color: #fff; background: var(--forest); border: 1px solid var(--forest); }
.secondary-button { padding: 0 18px; color: var(--forest); background: #fff; border: 1px solid var(--line); }
.secondary-button:disabled { cursor: default; }

.detail-dialog { width: min(720px, calc(100% - 28px)); max-height: 88vh; padding: 34px; color: var(--ink); background: var(--surface); border: 0; border-radius: 20px; box-shadow: var(--shadow); }
.detail-dialog::backdrop { background: rgba(7, 18, 14, .62); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 14px; right: 16px; width: 38px; height: 38px; color: var(--muted); background: transparent; border: 0; font-size: 28px; }
.detail-dialog h2 { margin: 0; padding-right: 28px; font-family: Georgia, "Noto Serif Thai", serif; font-size: 30px; line-height: 1.2; }
.detail-code { color: var(--green); font-weight: 800; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 28px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.detail-grid div { padding: 13px 15px; border-bottom: 1px solid var(--line); }
.detail-grid div:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: 11px; }
.detail-grid dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.source-link { width: 100%; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translate(-50%, 130px); max-width: calc(100% - 32px); padding: 12px 18px; color: #fff; background: var(--forest); border-radius: 10px; box-shadow: var(--shadow); transition: transform .22s; }
.toast.visible { transform: translate(-50%, 0); }

.login-page { background: var(--forest); }
.login-shell { width: 100%; min-height: 100vh; margin: 0; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(390px, 620px); }
.login-brand { min-height: 100vh; padding: clamp(32px, 5vw, 72px); color: #fff; display: flex; flex-direction: column; justify-content: space-between; background: var(--forest); position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 480px; height: 480px; right: -220px; top: 18%; border: 1px solid rgba(217, 184, 108, .22); border-radius: 50%; box-shadow: 0 0 0 80px rgba(217, 184, 108, .04), 0 0 0 160px rgba(217, 184, 108, .025); }
.login-brand .brand { color: #fff; z-index: 1; }
.login-brand .brand b { color: var(--gold); }
.login-copy { position: relative; z-index: 1; max-width: 680px; }
.login-copy .eyebrow { color: var(--gold); }
.login-copy h1 { margin: 0; font-family: Georgia, "Noto Serif Thai", serif; font-size: clamp(44px, 6vw, 86px); line-height: 1; font-weight: 500; letter-spacing: -.04em; }
.login-copy > p:last-child { max-width: 580px; color: #cbd3cf; font-size: 17px; line-height: 1.7; }
.privacy-note { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 12px; max-width: 580px; padding-top: 24px; border-top: 1px solid #385047; color: #abbab4; font-size: 12px; }
.privacy-note > span { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; color: var(--forest); background: var(--gold); border-radius: 50%; font-weight: 900; }
.privacy-note p { margin: 0; line-height: 1.65; }
.privacy-note b { color: #fff; }
.login-card { min-height: 100vh; padding: clamp(32px, 6vw, 90px); display: flex; flex-direction: column; justify-content: center; background: var(--surface); }
.mobile-mark { display: none; }
.login-card h2 { margin: 0; font-family: Georgia, "Noto Serif Thai", serif; font-size: clamp(32px, 4vw, 48px); line-height: 1.08; font-weight: 500; }
.login-card > .muted { line-height: 1.65; }
.support-check { margin: 24px 0 14px; padding: 11px 13px; color: var(--green); background: #e6f2eb; border-radius: 8px; font-size: 12px; font-weight: 700; }
.support-check.warning { color: #745b22; background: var(--gold-soft); }
.biometric-button { width: 100%; min-height: 70px; gap: 14px; text-align: left; }
.biometric-button .fingerprint { font-size: 32px; color: var(--gold); }
.biometric-button span:last-child { display: grid; }
.biometric-button small { color: #b8c5c0; font-weight: 400; }
.setup-panel { display: grid; gap: 14px; }
.setup-panel label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.setup-panel input { width: 100%; height: 46px; padding: 0 12px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; outline: 0; }
.setup-panel input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(38, 115, 81, .12); }
.rule { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; color: var(--muted); font-size: 11px; font-weight: 700; }
.rule::before, .rule::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-message { min-height: 24px; color: #9a3d34; font-size: 13px; }
.login-foot { margin: 20px 0 0; color: #87908c; text-align: center; font-size: 11px; }

@media (max-width: 930px) {
  .result-row { grid-template-columns: minmax(230px, 2fr) 120px 100px 110px 110px; }
  .result-row > :last-child { display: none; }
  .result-row:not(.result-header) { cursor: pointer; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { min-height: 100vh; width: 100%; max-width: 620px; margin: 0 auto; }
  .mobile-mark { display: flex; align-items: center; gap: 9px; margin-bottom: 62px; color: var(--forest); font-weight: 800; }
.mobile-mark .app-icon { width: 36px; }
.mobile-mark .mp-25-logo { width: 120px; height: auto; }
}

@media (max-width: 700px) {
  main { width: min(100% - 24px, 1400px); }
  .topbar { height: 64px; padding: 0 12px; }
  .topbar .brand span { display: none; }
  .topbar .brand .mp-25-logo { width: 102px; }
  .source-badge { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .text-button { display: none; }
  .hero { grid-template-columns: 1fr; padding: 40px 2px 26px; gap: 26px; }
  .hero h1 { font-size: clamp(38px, 12vw, 56px); }
  .hero-stat { width: 100%; grid-template-columns: auto 1fr; column-gap: 12px; align-items: end; border-left: 0; border-top: 1px solid var(--line); padding: 18px 0 0; }
  .hero-stat strong { grid-row: 1 / 3; font-size: 38px; }
  .hero-stat span { margin: 0; }
  .hero-stat small { margin: 0; }
  .search-panel { margin: 0 -4px; padding: 16px; border-radius: 15px; }
  .search-box { height: 56px; padding: 0 12px; }
  .search-box input { font-size: 15px; }
  .search-box kbd { display: none; }
  .filters { grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters label:first-child { grid-column: 1 / -1; }
  .clear-button { grid-column: 1 / -1; }
  .results-head { padding-top: 38px; }
  .result-header { display: none; }
  .results { background: transparent; border: 0; border-radius: 0; overflow: visible; display: grid; gap: 10px; }
  .result-row { min-height: 0; grid-template-columns: 1fr 1fr; gap: 13px 14px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
  .result-row:first-child { border-top: 1px solid var(--line); }
  .product-cell { grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid #ebe8df; }
  .result-cell::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 700; }
  .result-row > .result-cell:nth-of-type(4), .result-row > .result-cell:nth-of-type(5) { display: block; }
  .result-row > :last-child { display: block; grid-column: 1 / -1; text-align: right; }
  .row-button { padding: 2px 0 0; }
  .detail-dialog { padding: 28px 18px 20px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid div:nth-child(odd) { border-right: 0; }
  .login-card { padding: 28px 22px max(28px, env(safe-area-inset-bottom)); }
  .mobile-mark { margin-bottom: auto; padding-bottom: 54px; }
  .mobile-mark span { display: none; }
  .login-card h2 { font-size: 36px; }
  .login-foot { margin-top: auto; padding-top: 38px; }
}

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