:root {
    --ink: #14233c;
    --muted: #66758a;
    --line: #dce4e8;
    --canvas: #f3f6f5;
    --card: #ffffff;
    --navy: #153958;
    --navy-deep: #0d2b45;
    --teal: #00a58b;
    --teal-soft: #e7f7f3;
    --amber: #f0b429;
    --rose: #df4b5f;
    --shadow: 0 16px 42px rgba(25, 50, 71, .08);
    --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background:
        radial-gradient(circle at 8% 8%, rgba(0, 165, 139, .07), transparent 28rem),
        var(--canvas);
    color: var(--ink);
    font-family: "IBM Plex Sans Thai", Tahoma, sans-serif;
    line-height: 1.5;
}

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.page-shell { min-height: 100vh; }

.hero {
    position: relative;
    min-height: 280px;
    padding: 54px max(5vw, 24px) 76px;
    overflow: hidden;
    color: #fff;
    background:
        linear-gradient(118deg, rgba(13, 43, 69, .98), rgba(18, 68, 91, .95) 58%, rgba(0, 138, 119, .88)),
        var(--navy-deep);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 36px;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 6px;
    background: linear-gradient(90deg, var(--teal), #70d9c6, var(--amber));
}

.hero__content { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 22px; }

.brand-mark {
    width: 66px;
    height: 66px;
    flex: 0 0 66px;
    display: grid;
    place-items: center;
    color: #7ce7d4;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 20px;
    background: rgba(255,255,255,.08);
    box-shadow: inset 0 1px rgba(255,255,255,.18);
}

.brand-mark svg { width: 42px; height: 42px; }

.eyebrow, .section-kicker {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .17em;
}

.eyebrow { color: #aeeadf; display: flex; align-items: center; gap: 9px; }
.eyebrow span { width: 22px; height: 2px; background: #60ddc7; }

.hero h1 { margin: 10px 0 12px; font-size: clamp(2rem, 3.5vw, 3.6rem); font-weight: 500; line-height: 1.13; letter-spacing: -.02em; }
.hero h1 strong { color: #81ecd8; font-weight: 700; }
.hero p { max-width: 650px; margin: 0; color: rgba(255,255,255,.72); font-size: 1.05rem; }

.hero__meta {
    position: relative;
    z-index: 1;
    min-width: 236px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 16px 18px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 17px;
    background: rgba(255,255,255,.08);
    backdrop-filter: blur(10px);
}

.hero__meta small, .hero__meta strong { display: block; }
.hero__meta small { color: rgba(255,255,255,.62); }
.hero__meta strong { margin-top: 2px; font-size: .92rem; }
.live-dot { width: 11px; height: 11px; border-radius: 50%; background: #57ddb5; box-shadow: 0 0 0 6px rgba(87,221,181,.13); }

.hero__glow { position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); }
.hero__glow--one { width: 330px; height: 330px; right: 7%; top: -190px; box-shadow: 0 0 0 60px rgba(255,255,255,.02), 0 0 0 120px rgba(255,255,255,.018); }
.hero__glow--two { width: 180px; height: 180px; right: 36%; bottom: -145px; background: rgba(0,165,139,.12); }

main { width: min(1480px, calc(100% - 40px)); margin: -35px auto 0; position: relative; z-index: 2; }

.filter-card, .chart-card, .interpret-card, .method-note {
    background: var(--card);
    border: 1px solid rgba(20, 57, 88, .09);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-card { padding: 22px 24px 24px; }

.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 48px 0 20px; }
.section-heading--filter { margin: 0 0 18px; align-items: center; }
.section-heading h2 { margin: 3px 0 0; font-size: clamp(1.35rem, 2vw, 1.8rem); line-height: 1.25; }
.section-heading p { margin: 0; color: var(--muted); }
.section-kicker { color: var(--teal); }

.filter-toggle { display: none; border: 0; background: var(--teal-soft); color: #087664; padding: 9px 13px; border-radius: 11px; font-weight: 600; cursor: pointer; }
.filter-toggle span { display: inline-block; transition: transform .2s ease; }
.filter-toggle[aria-expanded="true"] span { transform: rotate(180deg); }

.filter-form { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 14px; align-items: end; }
.filter-form label > span { display: block; margin: 0 0 7px; color: #4d5b6e; font-size: .82rem; font-weight: 600; }
.filter-form input, .filter-form select {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    color: var(--ink);
    border: 1px solid #d7e0e3;
    border-radius: 11px;
    outline: 0;
    background: #fbfcfc;
    transition: border-color .18s, box-shadow .18s;
}
.filter-form input:focus, .filter-form select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,165,139,.12); }
.filter-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 2px; }
.button { min-height: 42px; padding: 0 18px; border: 0; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; font-weight: 600; }
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.button--primary { color: #fff; background: var(--navy); box-shadow: 0 8px 18px rgba(21,57,88,.18); }
.button--primary:hover { background: var(--navy-deep); }
.button--ghost { color: #526174; background: #edf1f2; }

.alert { margin-top: 22px; padding: 15px 18px; border-radius: 14px; background: #fff7df; border: 1px solid #f4d990; color: #755709; display: flex; gap: 9px 18px; flex-wrap: wrap; }
.alert--error { background: #fff0f2; border-color: #f2b9c1; color: #8c2534; }

.overview-grid { display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); gap: 14px; }
.total-card, .metric-card { min-height: 190px; border-radius: 20px; overflow: hidden; }
.total-card { position: relative; padding: 24px; color: #fff; background: linear-gradient(145deg, #123550, #0d6170); display: flex; align-items: center; gap: 18px; box-shadow: 0 16px 36px rgba(13,57,76,.18); }
.total-card::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -70px; bottom: -100px; border: 28px solid rgba(255,255,255,.05); }
.total-card__icon { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.total-card__icon svg { width: 28px; fill: none; stroke: #7fe4d2; stroke-width: 1.7; }
.total-card span, .total-card strong, .total-card small { display: block; }
.total-card span { color: rgba(255,255,255,.72); }
.total-card strong { margin: 3px 0 -1px; font-size: clamp(2.25rem, 4vw, 3.4rem); line-height: 1.05; letter-spacing: -.03em; }
.total-card small { color: #92e5d6; }
.total-card__stamp { position: absolute; top: 17px; right: 18px; font-size: .68rem; font-weight: 700; letter-spacing: .15em; color: rgba(255,255,255,.35); }

.metric-card { padding: 20px; background: #fff; border: 1px solid #e0e7e9; box-shadow: 0 10px 25px rgba(25,50,71,.055); }
.metric-card__top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; }
.metric-card__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.metric-card h3 { min-height: 48px; margin: 15px 0 8px; font-size: 1rem; line-height: 1.4; }
.metric-card__value { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.metric-card__value strong { font-size: 2rem; line-height: 1; letter-spacing: -.03em; }
.metric-card__value span { color: var(--accent); font-weight: 700; }
.mini-progress { height: 5px; margin: 15px 0 9px; border-radius: 99px; background: #edf1f2; overflow: hidden; }
.mini-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.metric-card small { color: var(--muted); font-size: .72rem; }
.metric-card--amber { --accent: #d99b08; }
.metric-card--violet { --accent: #8265d6; }
.metric-card--blue { --accent: #397fb8; }
.metric-card--rose { --accent: #d64a60; }

.legend-summary { color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.legend-dot--safe { background: #2fb27c; }
.legend-dot--risk { background: #df4b5f; }

.interpret-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.interpret-card { padding: 20px; box-shadow: 0 8px 24px rgba(25,50,71,.055); }
.interpret-card__header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.interpret-card h3 { margin: 0; font-size: 1rem; }
.interpret-card p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; }
.interpret-card__header > strong { color: var(--navy); font-size: 1.15rem; }
.stacked-bar { display: flex; height: 9px; margin: 19px 0 18px; border-radius: 99px; overflow: hidden; background: #edf1f2; }
.stacked-bar span { height: 100%; min-width: 0; }
.segment-list { display: grid; gap: 10px; }
.segment-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .77rem; }
.segment-label { min-width: 0; display: flex; align-items: center; gap: 7px; color: #4f5e70; }
.segment-label i { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; }
.segment-value { display: flex; align-items: baseline; gap: 7px; }
.segment-value strong { font-size: .84rem; }
.segment-value small { min-width: 36px; text-align: right; color: var(--muted); }

.analytics-grid { display: grid; grid-template-columns: 1fr 1.7fr; gap: 14px; }
.analytics-grid--geography { grid-template-columns: 1fr 1.15fr 1fr; }
.chart-card { min-width: 0; padding: 22px; box-shadow: 0 8px 24px rgba(25,50,71,.055); }
.chart-card__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.chart-card__header h3 { margin: 0; font-size: 1.05rem; }
.chart-card__header p { margin: 3px 0 0; color: var(--muted); font-size: .77rem; }
.chart-card__header > span { padding: 5px 9px; border-radius: 8px; color: #468679; background: var(--teal-soft); font-size: .67rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.chart-wrap { position: relative; width: 100%; height: 300px; }
.chart-wrap--donut { width: 230px; height: 230px; margin: 0 auto; }
.chart-wrap--compact { height: 245px; }
.chart-wrap--factors { height: 430px; }
.chart-wrap--tall { height: 340px; }
.donut-center { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; }
.donut-center strong, .donut-center span { display: block; }
.donut-center strong { font-size: 1.45rem; line-height: 1.1; }
.donut-center span { color: var(--muted); font-size: .7rem; }
.chart-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 18px; }
.chart-legend__item { display: flex; align-items: center; gap: 6px; font-size: .72rem; color: #536274; }
.chart-legend__item i { width: 8px; height: 8px; border-radius: 50%; }
.chart-legend__item strong { color: var(--ink); }

.rank-list { display: grid; gap: 13px; }
.rank-item { display: flex; align-items: center; gap: 11px; }
.rank-number { width: 27px; height: 27px; flex: 0 0 27px; display: grid; place-items: center; border-radius: 9px; color: #28796b; background: var(--teal-soft); font-size: .75rem; font-weight: 700; }
.rank-content { min-width: 0; flex: 1; }
.rank-content > div:first-child { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; }
.rank-content > div:first-child span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #4c5c6e; }
.rank-bar { height: 5px; margin-top: 6px; border-radius: 99px; background: #edf1f2; overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #00a58b, #63cfbc); }
.empty-state { color: var(--muted); text-align: center; padding: 30px 0; }

.method-note { margin-top: 42px; padding: 19px 22px; display: flex; align-items: center; gap: 15px; box-shadow: none; background: #f8fbfa; }
.method-note__icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); font-family: Georgia, serif; font-weight: 700; }
.method-note strong { display: block; font-size: .9rem; }
.method-note p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.method-note code { padding: 1px 5px; border-radius: 5px; color: #0c6c5e; background: #def2ed; }
.print-button { margin-left: auto; flex: 0 0 auto; border: 1px solid #ccd8da; border-radius: 10px; padding: 8px 12px; color: #47586a; background: #fff; cursor: pointer; }

footer { width: min(1480px, calc(100% - 40px)); margin: 28px auto 0; padding: 22px 0 30px; border-top: 1px solid #dbe3e5; color: #7a8796; display: flex; justify-content: space-between; gap: 20px; font-size: .72rem; }

@media (max-width: 1240px) {
    .filter-form { grid-template-columns: repeat(3, 1fr); }
    .overview-grid { grid-template-columns: repeat(4, 1fr); }
    .total-card { grid-column: span 2; }
    .interpret-grid { grid-template-columns: repeat(3, 1fr); }
    .analytics-grid--geography { grid-template-columns: 1fr 1fr; }
    .analytics-grid--geography .list-card { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
    .hero { align-items: flex-start; flex-direction: column; padding-top: 40px; }
    .hero__meta { margin-left: 88px; }
    main { width: min(100% - 24px, 1480px); }
    .filter-toggle { display: inline-flex; }
    .filter-form { grid-template-columns: repeat(2, 1fr); max-height: 0; overflow: hidden; opacity: 0; transition: max-height .25s ease, opacity .2s ease; }
    .filter-form.is-open { max-height: 900px; opacity: 1; }
    .overview-grid { grid-template-columns: repeat(2, 1fr); }
    .total-card { grid-column: 1 / -1; }
    .interpret-grid { grid-template-columns: repeat(2, 1fr); }
    .analytics-grid, .analytics-grid--geography { grid-template-columns: 1fr; }
    .analytics-grid--geography .list-card { grid-column: auto; }
}

@media (max-width: 540px) {
    .hero { min-height: 330px; padding: 32px 20px 65px; }
    .hero__content { gap: 13px; }
    .brand-mark { width: 50px; height: 50px; flex-basis: 50px; border-radius: 15px; }
    .brand-mark svg { width: 33px; }
    .hero h1 { font-size: 1.72rem; }
    .hero p { font-size: .9rem; }
    .hero__meta { margin-left: 63px; min-width: 0; width: calc(100% - 63px); }
    main { margin-top: -28px; }
    .filter-card { padding: 18px; }
    .filter-form { grid-template-columns: 1fr; }
    .filter-actions { flex-direction: column; }
    .button { width: 100%; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .section-heading--filter { flex-direction: row; align-items: center; }
    .overview-grid, .interpret-grid { grid-template-columns: 1fr; }
    .total-card { min-height: 175px; }
    .metric-card { min-height: 170px; }
    .legend-summary { flex-wrap: wrap; }
    .chart-card { padding: 18px 14px; }
    .chart-wrap { height: 270px; }
    .chart-wrap--donut { width: 210px; height: 210px; }
    .method-note { align-items: flex-start; flex-wrap: wrap; }
    .print-button { margin-left: 49px; }
    footer { width: calc(100% - 24px); flex-direction: column; gap: 5px; }
}

@media print {
    body { background: #fff; }
    .hero { min-height: auto; padding: 30px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    main { width: 100%; margin: 20px 0 0; padding: 0 12px; }
    .filter-card, .print-button { display: none !important; }
    .section-heading { margin-top: 28px; }
    .overview-grid { grid-template-columns: repeat(3, 1fr); }
    .total-card { grid-column: span 1; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .interpret-grid { grid-template-columns: repeat(3, 1fr); }
    .analytics-grid, .analytics-grid--geography { grid-template-columns: 1fr 1fr; }
    .chart-card, .interpret-card { break-inside: avoid; box-shadow: none; }
    footer { width: 100%; padding-inline: 12px; }
}
