:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans Thai", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --green-950: #0d1277;
  --green-800: #151a98;
  --green-650: #1182f2;
  --mint-100: #eaf3ff;
  --cream: #ffffff;
  --ink: #171c37;
  --muted: #68728a;
  --line: #dfe5f0;
  --white: #ffffff;
  --red: #a43a32;
  --amber: #9a5c06;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #ffffff; color: var(--ink); }
button, input { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.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; }
.eyebrow { margin: 0 0 8px; color: var(--green-650); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.subtle { color: var(--muted); line-height: 1.65; }

.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1120px) / 2)); background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { display: block; width: 190px; height: 58px; object-fit: contain; object-position: left center; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .03em; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 1px; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; color: white; background: var(--green-800); font-size: 25px; font-weight: 800; box-shadow: 0 12px 30px rgba(21, 26, 152, .22); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; box-shadow: none; }
.text-button { padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.text-button:hover { color: var(--green-650); }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.topbar-actions form { margin: 0; }
.topbar-link { color: var(--green-800); font-size: 14px; font-weight: 750; text-decoration: none; }
.topbar-link:hover { color: var(--green-650); }

.page-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 72px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.hero h1 { margin: 0 0 10px; font-size: clamp(32px, 5vw, 54px); line-height: 1.12; letter-spacing: -.035em; }
.hero > div > p:last-child { margin: 0; color: var(--muted); font-size: 17px; }
.live-chip { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid #bdd9fb; border-radius: 99px; background: #edf6ff; color: var(--green-800); font-size: 13px; font-weight: 700; white-space: nowrap; }
.live-chip span { width: 8px; height: 8px; border-radius: 50%; background: #1182f2; box-shadow: 0 0 0 4px #d9ebff; }

.search-panel, .result-panel, .report-panel { background: var(--white); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 15px 40px rgba(21, 26, 152, .07); }
.search-panel { padding: 28px; }
.search-panel h2 { margin: 0 0 16px; font-size: 19px; }
.search-form { display: grid; grid-template-columns: 184px 1fr auto; gap: 12px; }
.search-form input, .search-form select, .login-form input { width: 100%; height: 54px; border: 1px solid #cbd6e8; border-radius: 12px; padding: 0 16px; background: #fbfcff; color: var(--ink); outline: none; }
.search-form input:focus, .search-form select:focus, .login-form input:focus { border-color: var(--green-650); box-shadow: 0 0 0 4px rgba(17, 130, 242, .14); }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 24px; border-radius: 12px; font-weight: 750; text-decoration: none; cursor: pointer; }
.primary-button { border: 0; background: var(--green-800); color: white; box-shadow: 0 8px 20px rgba(21, 26, 152, .18); }
.primary-button:hover { background: var(--green-950); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.secondary-button { border: 1px solid #c9d5e8; background: white; color: var(--green-800); }
.input-help, .privacy-note { margin: 10px 2px 0; color: var(--muted); font-size: 13px; }
.alert { margin-top: 16px; padding: 12px 14px; border: 1px solid #eac2bd; border-radius: 10px; background: #fff1ef; color: #8c2f28; font-size: 14px; }

.result-panel { margin-top: 24px; padding: 28px; scroll-margin-top: 20px; }
.result-heading { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.result-heading h2 { margin: 0; font-size: 25px; letter-spacing: .01em; overflow-wrap: anywhere; }
.status-pill { padding: 9px 13px; border-radius: 99px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.status-pill.delivered { color: #151a98; background: #e8f2ff; }
.status-pill.pending { color: #a44300; background: #fff0e6; }
.status-pill.rejected { color: #b62d08; background: #ffe8e0; }
.status-pill.missing { color: #5e6965; background: #edf0ef; }
.details-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0; }
.details-grid div { min-height: 96px; padding: 22px 20px 18px 0; border-bottom: 1px solid var(--line); }
.details-grid dt { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.details-grid dd { margin: 0; font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.empty-result { display: flex; flex-direction: column; gap: 6px; padding: 28px 0 6px; }
.empty-result span { color: var(--muted); }
.result-age { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.result-age.stale { color: var(--red); font-weight: 700; }
.result-actions { display: flex; flex-wrap: wrap; gap: 9px; padding-top: 22px; }
.result-actions .secondary-button { min-height: 42px; padding: 0 14px; font-size: 13px; }
.result-note { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.group-heading { align-items: flex-start; }
.group-summary { margin: 7px 0 0; color: var(--muted); font-size: 14px; font-weight: 650; }
.group-track-list { display: grid; gap: 12px; padding-top: 20px; }
.group-track-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcff; }
.group-track-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.group-track-header > div { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; min-width: 0; }
.group-track-header code { color: var(--ink); font-family: inherit; font-size: 16px; font-weight: 800; letter-spacing: .015em; overflow-wrap: anywhere; }
.carrier-label { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 99px; background: #eaf3ff; color: var(--green-800); font-size: 12px; font-weight: 800; }
.group-track-details { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 16px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.group-track-details > span:first-child { color: var(--ink); font-weight: 700; }
.group-proof-section { margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.group-proof-section h3 { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 800; }
.group-proof-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.group-proof-image { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #edf2f8; }
.group-proof-image img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.group-proof-image:hover { border-color: var(--green-650); box-shadow: 0 5px 16px rgba(21, 26, 152, .14); }
.proof-section { padding-top: 24px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.section-title h3 { margin: 0; font-size: 17px; }
.section-title > span { color: var(--muted); font-size: 13px; }
.proof-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 15px; }
.proof-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #f8faff; text-decoration: none; }
.proof-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #edf2f8; }
.proof-card span { display: block; padding: 10px 12px; color: var(--green-800); font-size: 13px; font-weight: 700; }

.shopee-health-card { margin-top: 24px; padding: 24px 26px; border: 1px solid var(--line); border-top: 5px solid #8590a4; border-radius: 22px; background: var(--white); box-shadow: 0 15px 40px rgba(21, 26, 152, .07); }
.shopee-health-card.ok { border-top-color: #16834c; }
.shopee-health-card.warning { border-top-color: #c57b09; }
.shopee-health-card.error { border-top-color: #c13e34; }
.shopee-health-top, .shopee-health-content, .shopee-health-meta { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.shopee-health-name { display: flex; align-items: center; gap: 12px; }
.shopee-health-name p { margin: 0; color: var(--muted); font-size: 15px; font-weight: 800; }
.shopee-health-dot { width: 13px; height: 13px; border-radius: 50%; background: #8590a4; box-shadow: 0 0 0 6px #edf0f5; }
.shopee-health-card.ok .shopee-health-dot { background: #16834c; box-shadow: 0 0 0 6px #dff1e6; }
.shopee-health-card.warning .shopee-health-dot { background: #c57b09; box-shadow: 0 0 0 6px #fae9c4; }
.shopee-health-card.error .shopee-health-dot { background: #c13e34; box-shadow: 0 0 0 6px #f7dcd8; }
.shopee-health-badge { padding: 7px 12px; border-radius: 99px; background: #edf0f5; color: #586277; font-size: 12px; font-weight: 800; white-space: nowrap; }
.shopee-health-card.ok .shopee-health-badge { background: #e5f4eb; color: #116d3e; }
.shopee-health-card.warning .shopee-health-badge { background: #fff0d1; color: #945a03; }
.shopee-health-card.error .shopee-health-badge { background: #fde6e3; color: #9c2e27; }
.shopee-health-content { margin-top: 18px; }
.shopee-health-content h2 { margin: 0 0 7px; font-size: 24px; }
.shopee-health-content p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.shopee-health-content .shopee-login-timeline { margin-top: 9px; color: var(--ink); font-size: 13px; font-weight: 700; }
.shopee-health-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; }
.shopee-health-actions .primary-button, .shopee-health-actions .secondary-button { min-height: 44px; padding: 0 18px; font-size: 13px; white-space: nowrap; }
.shopee-login-note { margin: 16px 0 0; padding: 11px 13px; border-radius: 10px; background: #edf6ff; color: var(--green-800); font-size: 13px; font-weight: 700; }
.shopee-health-meta { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.shopee-health-meta a { color: var(--green-800); font-weight: 750; text-decoration: none; }
.shopee-health-meta a:hover { color: var(--green-650); }

.report-panel { margin-top: 24px; padding: 28px; }
.report-title h2 { margin: 0; font-size: 22px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.summary-grid > div { padding: 18px; border-radius: 14px; background: #f4f7fc; }
.summary-grid span { display: block; color: var(--muted); font-size: 12px; }
.summary-grid strong { display: block; margin-top: 6px; font-size: 28px; }
.summary-grid .success { background: #e8f2ff; color: #151a98; }
.summary-grid .waiting { background: #fff0e6; color: #a44300; }
.summary-grid .muted-card { color: #5d6965; }
.report-actions { display: flex; align-items: center; gap: 20px; }
.download-link { color: var(--green-800); font-weight: 700; font-size: 14px; }
footer { padding: 0 20px 30px; text-align: center; color: var(--muted); font-size: 12px; }

.login-page { display: grid; place-items: center; padding: 24px; background: #ffffff; }
.login-shell { width: min(440px, 100%); }
.login-card { padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: #ffffff; box-shadow: 0 25px 70px rgba(21, 26, 152, .12); }
.login-logo { display: block; width: min(300px, 100%); height: auto; margin: 0 0 28px; }
.login-card h1 { margin: 0; font-size: 31px; line-height: 1.25; letter-spacing: -.025em; }
.login-form { margin-top: 24px; }
.login-form label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.login-form .primary-button { width: 100%; margin-top: 12px; }
.privacy-note { text-align: center; margin-top: 20px; }

.admin-shell { padding-top: 40px; }
.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.admin-heading h1 { margin: 0 0 8px; font-size: clamp(32px, 5vw, 48px); letter-spacing: -.035em; }
.admin-heading > div > p:last-child { max-width: 720px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.health-overview { display: flex; align-items: center; gap: 14px; margin-top: 28px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: #f8faff; }
.health-overview-dot { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; background: #8590a4; box-shadow: 0 0 0 6px #edf0f5; }
.health-overview strong, .health-overview span { display: block; }
.health-overview strong { font-size: 17px; }
.health-overview div > span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.health-overview.ok { border-color: #b9d8c7; background: #eef9f3; }
.health-overview.ok .health-overview-dot { background: #16834c; box-shadow: 0 0 0 6px #d9f0e3; }
.health-overview.warning { border-color: #ecd09b; background: #fff8e9; }
.health-overview.warning .health-overview-dot { background: #c57b09; box-shadow: 0 0 0 6px #fae9c4; }
.health-overview.error { border-color: #e8b6b0; background: #fff2f0; }
.health-overview.error .health-overview-dot { background: #c13e34; box-shadow: 0 0 0 6px #f7dcd8; }
.health-section { margin-top: 30px; }
.health-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.health-section-heading h2 { margin: 0; font-size: 23px; }
.health-section-heading > span { color: var(--muted); font-size: 13px; }
.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.automation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.health-card { min-height: 235px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 12px 30px rgba(21, 26, 152, .06); }
.health-card.ok { border-top: 4px solid #16834c; }
.health-card.warning { border-top: 4px solid #c57b09; }
.health-card.error { border-top: 4px solid #c13e34; }
.health-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.health-icon { width: 13px; height: 13px; border-radius: 50%; background: #8590a4; }
.health-card.ok .health-icon { background: #16834c; box-shadow: 0 0 0 5px #e1f2e8; }
.health-card.warning .health-icon { background: #c57b09; box-shadow: 0 0 0 5px #fbeed4; }
.health-card.error .health-icon { background: #c13e34; box-shadow: 0 0 0 5px #f8e1de; }
.health-badge { padding: 5px 9px; border-radius: 99px; background: #edf0f5; color: #586277; font-size: 11px; font-weight: 800; }
.health-card.ok .health-badge { background: #e5f4eb; color: #116d3e; }
.health-card.warning .health-badge { background: #fff0d1; color: #945a03; }
.health-card.error .health-badge { background: #fde6e3; color: #9c2e27; }
.health-card h3 { margin: 22px 0 6px; color: var(--muted); font-size: 14px; }
.health-card > strong { display: block; font-size: 20px; }
.health-card > p { min-height: 48px; margin: 10px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.health-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.health-skeleton { height: 235px; border-radius: 18px; background: linear-gradient(90deg, #f2f4f8 25%, #fafbfc 45%, #f2f4f8 65%); background-size: 220% 100%; animation: health-loading 1.3s ease infinite; }
.admin-footnote { margin: 24px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
@keyframes health-loading { to { background-position: -220% 0; } }

@media (max-width: 760px) {
  .topbar { height: 66px; padding: 0 18px; }
  .page-shell { width: min(100% - 28px, 1120px); padding: 34px 0 54px; }
  .hero { display: block; }
  .hero h1 { font-size: 36px; }
  .live-chip { width: fit-content; margin-top: 20px; }
  .search-panel, .result-panel, .report-panel, .shopee-health-card { border-radius: 18px; padding: 20px; }
  .search-form { grid-template-columns: 1fr; }
  .search-form .primary-button { width: 100%; }
  .result-heading { align-items: flex-start; flex-direction: column; }
  .group-track-header { align-items: flex-start; flex-direction: column; }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .proof-grid, .summary-grid { grid-template-columns: 1fr 1fr; }
  .group-proof-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-title { align-items: flex-start; flex-direction: column; }
  .shopee-health-content { align-items: flex-start; flex-direction: column; }
  .shopee-health-actions { width: 100%; }
  .shopee-health-actions .primary-button, .shopee-health-actions .secondary-button { flex: 1 1 auto; }
  .admin-heading, .health-section-heading { align-items: flex-start; flex-direction: column; }
  .health-grid, .automation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .login-page { padding: 14px; }
  .login-card { padding: 28px 22px; }
  .details-grid { grid-template-columns: 1fr; }
  .details-grid div { min-height: 0; padding: 17px 0; }
  .proof-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid > div { padding: 14px; }
  .report-actions { align-items: stretch; flex-direction: column; gap: 13px; }
  .result-actions { flex-direction: column; }
  .topbar-actions { gap: 12px; }
  .topbar-link, .text-button { font-size: 12px; }
  .shopee-health-actions { align-items: stretch; flex-direction: column; }
  .shopee-health-actions .primary-button, .shopee-health-actions .secondary-button { width: 100%; }
  .shopee-health-meta { align-items: flex-start; flex-direction: column; gap: 8px; }
  .admin-heading .secondary-button { width: 100%; }
  .health-card-meta { align-items: flex-start; flex-direction: column; gap: 5px; }
}
