:root {
  --navy: #1f4e8c;
  --ink: #1a2b3c;
  --muted: #6b7a89;
  --bg: #eef4f8;
  --card: #ffffff;
  --line: #d9e3ec;
  --ok: #1b7f3b;
  --bad: #b3261e;
  --fs: 1; /* ตัวคูณขนาดตัวอักษร ปรับด้วยแถบเลื่อนข้างช่องปี (main.js setupFontSize) */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans Thai", Tahoma, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: calc(16px * var(--fs));
}

.layout { display: flex; min-height: 100vh; }

/* ---------- เมนูซ้าย ---------- */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: #e3eff7;
  padding: clamp(8px, 1.6vh, 16px) 12px;
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1.2vh, 12px);
  /* เมนูซ้ายอยู่กับที่ เลื่อนเฉพาะฝั่งข้อมูล
     ขนาดตัวอักษรและระยะห่างย่อตามความสูงจอ (vh) เพื่อให้เมนูพอดีจอโน้ตบุ๊กโดยไม่ต้องเลื่อน */
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.logo { text-align: center; padding: clamp(2px, 0.8vh, 8px) 0 clamp(2px, 1vh, 12px); }
/* ไฟล์โลโก้มีพื้นที่ว่างรอบรูปมาก จึงตัดให้เห็นเฉพาะตัวโลโก้ (ถ้าเปลี่ยนไฟล์ที่ตัดขอบแล้ว ใช้ img ธรรมดาได้) */
.logo-crop {
  display: block; position: relative; overflow: hidden;
  width: 100%; max-width: clamp(150px, 24vh, 230px); margin: 0 auto; aspect-ratio: 900 / 460;
}
.logo-crop img { position: absolute; width: 222%; max-width: none; left: -60.6%; top: -66.3%; }
.logo-text { font-weight: 700; font-size: calc(22px * var(--fs)); color: var(--navy); }

#nav { display: flex; flex-direction: column; gap: clamp(0px, 0.4vh, 4px); }
.nav-title { font-size: calc(13px * var(--fs)); color: var(--muted); margin: clamp(2px, 1vh, 10px) 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: clamp(2px, 0.8vh, 8px) 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: calc(clamp(13px, 1.9vh, 15px) * var(--fs)); line-height: 1.3;
}
.nav-item:hover { background: #d3e6f2; }
.nav-item.active { background: #93bfd9; font-weight: 600; }
.nav-icon {
  width: clamp(28px, 4.6vh, 36px); height: clamp(28px, 4.6vh, 36px); border-radius: 50%;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #fff;
}
.nav-icon img { width: 72%; height: 72%; object-fit: contain; }
.nav-icon.home { background: var(--navy); color: #fff; font-size: calc(18px * var(--fs)); }

.side-links { margin-top: auto; font-size: calc(13px * var(--fs)); line-height: 1.35; display: flex; flex-direction: column; gap: 4px; }
.side-links a { color: var(--navy); }

/* ---------- ส่วนหลัก ---------- */
.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  position: relative; background: #f7fafc;
}
/* ภาพเมืองจางๆ ท้ายหน้า */
.main::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 520px;
  background: url("../images/bannerdown.png") center bottom / 100% auto no-repeat;
  opacity: .35; pointer-events: none; z-index: 0;
}
.main > * { position: relative; z-index: 1; }

.topbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 22px 28px 14px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.85) 0%, rgba(255,255,255,.55) 55%, rgba(255,255,255,0) 100%),
    url("../images/bannerup.png") center / cover no-repeat;
}
.titles h1 { margin: 0; font-size: calc(34px * var(--fs)); line-height: 1.25; color: var(--navy); font-weight: 700; }
.titles .subtitle { margin: 2px 0 0; font-size: calc(20px * var(--fs)); color: var(--ink); }
.titles .tagline { margin: 2px 0 0; font-size: calc(15px * var(--fs)); color: #3d4f61; }
.crumb { margin-top: 10px; font-size: calc(14px * var(--fs)); color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb .sep { margin: 0 4px; }

.year-box {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  background: #fff; border: 2px solid var(--navy); border-radius: 999px; padding: 6px 16px;
  font-size: calc(18px * var(--fs)); color: var(--navy);
}
.year-box label { font-weight: 600; }
.year-box input {
  width: 4.6em; border: 0; border-bottom: 2px dashed transparent; background: transparent;
  font: inherit; font-weight: 700; color: var(--navy); outline: none; padding: 0;
}
.year-box input:focus { border-bottom-color: #93bfd9; }
.year-box input::placeholder { color: #9fb3c8; }
.year-box input.invalid { color: var(--bad); border-bottom-color: var(--bad); }
/* ช่องปี + แถบปรับขนาดตัวอักษร (แถบนี้ใช้ขนาดคงที่ ไม่ขยายตาม --fs จะได้ไม่ขยับขณะลาก) */
.top-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.font-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 2px solid var(--navy); border-radius: 999px; padding: 6px 14px;
  color: var(--navy);
}
.font-a {
  border: 0; background: none; padding: 0 2px; cursor: pointer;
  font-family: inherit; font-weight: 700; color: var(--navy); line-height: 1;
}
.font-a.sm { font-size: 14px; }
.font-a.lg { font-size: 24px; }
.font-a:hover { color: #93bfd9; }
.font-box input[type="range"] { width: 110px; accent-color: var(--navy); cursor: pointer; margin: 0; }
.cal-icon { width: 30px; height: 30px; fill: #fff; stroke: var(--navy); stroke-width: 1.6; }
.cal-icon .cal-top, .cal-icon rect[height="5"] { fill: var(--navy); }
.cal-icon .cal-dots rect { fill: var(--navy); stroke: none; }

.updated-badge { padding: 4px 28px 0; font-size: calc(12px * var(--fs)); color: var(--muted); }
.updated-badge b { color: var(--navy); font-weight: 600; }

.content { padding: 12px 24px 28px; flex: 1; }
.footer { text-align: center; padding: 28px 14px 22px; color: #5d6f80; font-weight: 600; font-size: calc(17px * var(--fs)); line-height: 1.6; }
.footer span { display: inline-block; } /* ตัดบรรทัดระหว่างสองท่อน ไม่ตัดกลางคำ */

/* ---------- การ์ดและตารางพื้นฐาน ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 10px; font-size: calc(20px * var(--fs)); color: var(--navy); }
.card h3 { margin: 0 0 8px; font-size: calc(16px * var(--fs)); }
.muted { color: var(--muted); }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

.alert {
  background: #fdecea; border: 1px solid #f3b9b4; color: #7a1c15;
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
}
.alert ul { margin: 6px 0 0 18px; padding: 0; }

table.simple { border-collapse: collapse; width: 100%; font-size: calc(14px * var(--fs)); }
table.simple th, table.simple td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 600; }
table.simple td.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 2px 12px; border-radius: 999px;
  font-size: calc(13px * var(--fs)); font-weight: 600; color: #fff; white-space: nowrap;
}
.pill.light { color: var(--ink); }
.pill.none { background: #c4ccd4; }

/* ---------- ไอคอนด้าน (ถ้ารูปหาย จะเป็นวงกลมสีประจำด้าน) ---------- */
.dim-icon {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px;
}
.dim-icon img { width: 100%; height: 100%; object-fit: contain; }
.dim-icon:empty { background: var(--dot); border-radius: 50%; }
.dim-icon.sm { width: 44px; height: 44px; }
.dim-icon.lg { width: 64px; height: 64px; }

/* ---------- หน้าแรก ---------- */
.content .card { border-color: #cfe0ee; border-radius: 16px; }

.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.card-head h2 { margin: 0; font-size: calc(22px * var(--fs)); line-height: 1.3; }
.card-head .sub { color: #3d4f61; font-size: calc(17px * var(--fs)); }
.head-icon { width: 38px; height: 38px; fill: var(--navy); flex-shrink: 0; }

.home-top {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.65fr); gap: 16px;
}
.home-top > .card { margin-bottom: 16px; display: flex; flex-direction: column; }

/* เกจ */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; }
.gauge { width: 100%; max-width: 290px; display: block; }
/* ตัวเลขในเกจอยู่ในภาพขนาดคงที่ จึงไม่ขยายตามแถบปรับขนาด (ใหญ่พออยู่แล้ว) */
.gauge-label { font-size: 17px; font-weight: 700; fill: var(--ink); }
.gauge-score { font-size: 34px; font-weight: 700; fill: var(--ink); }
.gauge-wrap .pill-block { width: auto; min-width: 200px; margin-top: 4px; font-size: calc(22px * var(--fs)); padding: 4px 28px; }

/* ป้ายระดับเต็มกว้าง */
.pill-block {
  display: block; width: 100%; text-align: center;
  padding: 3px 10px; border-radius: 999px;
  font-weight: 700; font-size: calc(18px * var(--fs)); color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.pill-block.none { background: #c4ccd4; }

/* เทียบปีก่อน */
.change { text-align: center; margin-top: 8px; line-height: 1.3; }
.change b { font-size: calc(20px * var(--fs)); }
.change small { display: block; font-size: calc(13px * var(--fs)); color: var(--muted); }
.change.up { color: #2f7d3a; }
.change.down { color: #c62828; }
.change.flat { color: var(--muted); }
.change .arrow { font-size: calc(20px * var(--fs)); }

/* แถบ 5 ระดับ */
.lvl-scale {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  margin: 18px 4px 4px;
}
.lvl-line {
  position: absolute; top: 14px; height: 6px; border-radius: 3px;
  left: calc(50% / var(--n)); right: calc(50% / var(--n));
}
.lvl-step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
.lvl-step .dot {
  width: 26px; height: 26px; margin-top: 4px; border-radius: 50%;
  background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.06);
}
.lvl-step .lbl { margin-top: 6px; font-size: calc(14px * var(--fs)); font-weight: 700; color: var(--c); line-height: 1.2; }
.lvl-step.active .dot { width: 34px; height: 34px; margin-top: 0; box-shadow: 0 0 0 3px var(--c); }
.lvl-step.active .lbl { color: var(--ink); text-decoration: underline 2px var(--c); text-underline-offset: 4px; }

/* กล่องกราฟ */
.chart-box { position: relative; width: 100%; }
.chart-box.lg { height: 340px; flex: 1; min-height: 300px; }
.chart-box.sm { height: 220px; background: #fff; border-radius: 8px; padding: 6px 6px 2px; }

/* หัวข้อส่วน */
.sec-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: calc(24px * var(--fs)); }
.year-chip {
  display: inline-block; padding: 0 20px; border: 2px solid var(--navy);
  border-radius: 999px; background: #eef5fb; font-size: calc(24px * var(--fs));
}

/* การ์ด 6 ด้าน */
.dim-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.dim-cards.has-watch { row-gap: 46px; padding-bottom: 36px; }
.dim-cell { position: relative; display: flex; flex-direction: column; }
.dim-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 14px 14px; border-radius: 18px; background: var(--bg);
  color: var(--ink); text-decoration: none; text-align: center;
  transition: transform .15s, box-shadow .15s;
}
.dim-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(31,78,140,.15); }
/* ด้านที่เข้ากฎ "ควรติดตาม": ขอบแดง ไอคอนเตือนมุมขวาบน ตัวเลขคะแนนสีแดง */
.dim-card { position: relative; }
.dim-card.is-watch { box-shadow: inset 0 0 0 3px #f05a5a; }
.dim-card.is-watch:hover { box-shadow: inset 0 0 0 3px #f05a5a, 0 6px 16px rgba(240,90,90,.3); }
.dim-card.is-watch .val { color: #d63c3c; }
.card-warn { position: absolute; top: 10px; right: 10px; animation: warn-pulse 1.6s ease-in-out infinite; }
.card-warn .warn-icon { width: 30px; height: 30px; display: block; }
@keyframes warn-pulse { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .card-warn { animation: none; } }
.dim-card-name { font-size: calc(18px * var(--fs)); line-height: 1.3; min-height: 2.6em; display: flex; align-items: center; }
.dim-card-score {
  width: 100%; margin-top: auto; background: #fff; border-radius: 14px; padding: 6px 8px 8px;
}
.dim-card-score .lbl { font-weight: 700; font-size: calc(17px * var(--fs)); }
.dim-card-score .val { font-weight: 700; font-size: calc(28px * var(--fs)); line-height: 1.3; margin-bottom: 4px; }
.watch {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px;
  text-align: center; color: #e05252; font-weight: 700; font-size: calc(18px * var(--fs));
}
.warn-icon { width: 28px; height: 28px; }

/* แนวโน้มรายด้าน */
.dim-trends { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.trend-box {
  display: block; padding: 10px 14px 14px; border-radius: 18px; background: var(--bg);
  color: var(--ink); text-decoration: none;
}
.trend-head { display: flex; align-items: center; gap: 8px; font-size: calc(18px * var(--fs)); margin-bottom: 6px; }

/* ---------- หน้ารายด้าน ---------- */
.dim-top .card-head { align-items: center; }
.dim-top .card-head h2 { font-size: calc(24px * var(--fs)); }
/* ไอคอนในวงกลมสีอ่อนประจำด้าน (ไอคอนบางอันมีส่วนสีขาว เช่น หัวใจ จะได้มองเห็นบนการ์ดขาว) */
.dim-icon.circle { width: 58px; height: 58px; padding: 9px; border-radius: 50%; background: var(--soft, #eef4f8); }
.dim-icon.circle:empty { background: var(--dot); }
.dim-gauge-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex: 1; }
.dim-gauge-row .gauge-wrap { flex: 0 1 300px; }
.dim-gauge-row .gauge-wrap .pill-block { min-width: 170px; }
.dim-gauge-row .change { margin-top: 0; flex-shrink: 0; }
.dim-gauge-row .change small { white-space: nowrap; }

.watch-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  background: #fff; border: 1px solid #f3c4c4; border-left: 10px solid #f05a5a; border-radius: 14px;
  padding: 10px 18px; margin-bottom: 16px; font-size: calc(18px * var(--fs));
}
.watch-bar .warn { color: #e05252; font-size: calc(20px * var(--fs)); }
.watch-bar .warn-icon { width: 32px; height: 32px; }

.comps-card { background: color-mix(in srgb, var(--bg) 45%, #fff); }
.sec-title .sub { font-weight: 400; color: var(--ink); font-size: calc(20px * var(--fs)); }
.comp-panel {
  display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2.4fr); gap: 24px;
  background: #fff; border-radius: 18px; padding: 16px 20px; margin-top: 14px;
}
.comp-title { display: flex; align-items: center; gap: 14px; font-size: calc(21px * var(--fs)); line-height: 1.3; color: var(--navy); }
.comp-badge {
  flex-shrink: 0; background: #183c66; color: #fff; font-weight: 700; font-size: calc(26px * var(--fs));
  padding: 0 16px; border-radius: 12px;
}
.comp-score { display: flex; align-items: center; gap: 16px; margin: 12px 0 2px; }
.comp-score .big { font-size: calc(44px * var(--fs)); font-weight: 700; color: #183c66; line-height: 1.1; }
.comp-score .pill-block { width: auto; min-width: 120px; padding: 2px 20px; }
.change-inline { font-size: calc(18px * var(--fs)); }
.change-inline small { font-size: calc(14px * var(--fs)); color: var(--muted); margin-left: 4px; }
.change-inline.up { color: #2f7d3a; }
.change-inline.down { color: #e04848; }
.change-inline.flat { color: var(--muted); }
.chart-box.comp { height: 190px; margin-top: 8px; }

.comp-right { min-width: 0; overflow-x: auto; }
.ind-table { width: 100%; border-collapse: collapse; }
.ind-table th {
  text-align: left; font-weight: 400; font-size: calc(19px * var(--fs)); color: var(--navy);
  padding: 4px 8px; border-bottom: 3px solid #7fb6cf;
}
.ind-table td { padding: 8px; border-bottom: 1px solid #dde3e8; vertical-align: middle; }
.ind-table .ind-name { font-size: calc(15px * var(--fs)); line-height: 1.4; }
.ind-table .ind-spark { width: 130px; padding: 4px; }
.spark-box { position: relative; width: 122px; height: 40px; }
.ind-table .ind-num { width: 76px; text-align: center; font-weight: 700; color: #183c66; font-variant-numeric: tabular-nums; }
.ind-table .ind-lvl { width: 118px; text-align: center; }
.ind-table .ind-chg { width: 96px; }
.ind-table th.ind-chg, .ind-table th.ind-num, .ind-table th.ind-lvl { white-space: nowrap; }
.ind-table td.ind-num, .ind-table td.ind-lvl, .ind-table td.ind-chg { border-left: 1px solid #dde3e8; }
.ind-table .pill-block { font-size: calc(15px * var(--fs)); padding: 3px 8px; }

/* แถวตัวชี้วัดที่คลิกได้ → เปิดกราฟใหญ่ใต้แถว */
.ind-table tr.ind-row { cursor: pointer; }
.ind-table tr.ind-row:hover > td { background: #f3f7fb; }
.ind-table tr.ind-row:focus-visible { outline: 2px solid var(--main, var(--navy)); outline-offset: -2px; }
.ind-table tr.ind-row.open > td { background: #eef4f9; border-bottom-color: transparent; }
.ind-caret {
  display: inline-block; width: 1em; margin-right: 4px; color: var(--main, var(--navy));
  transition: transform .15s;
}
.ind-row.open .ind-caret { transform: rotate(90deg); }
.ind-table tr.ind-detail > td { padding: 0 0 12px; background: #eef4f9; }
.ind-detail-box {
  background: #fff; border: 1px solid #d5e1ec; border-top: 3px solid var(--main, var(--navy));
  border-radius: 10px; margin: 0 8px; padding: 10px 14px 6px;
  /* width 0 + min-width 100%: กว้างเท่าแถว แต่ไม่ดันให้ตารางกว้างขึ้น (กราฟจะได้ไม่ล้นจอมือถือ) */
  width: 0; min-width: calc(100% - 16px);
}
.ind-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ind-detail-head h4 { margin: 0; font-size: calc(16px * var(--fs)); line-height: 1.4; color: var(--navy); }
.ind-detail-head h4 .sub { font-weight: 400; color: var(--muted); }
.ind-close {
  flex-shrink: 0; border: 0; background: #eef2f6; color: var(--muted); border-radius: 50%;
  width: 30px; height: 30px; cursor: pointer; font-size: 15px; line-height: 1;
}
.ind-close:hover { background: #dde5ee; color: var(--ink); }
.chart-box.ind-big { height: 260px; margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .ind-caret { transition: none; } }
.chg { font-weight: 700; white-space: nowrap; }
.chg.up { color: #2f7d3a; }
.chg.down { color: #e04848; }
.chg.flat { color: var(--muted); font-weight: 400; }

/* ---------- หน้าเกี่ยวกับดัชนี (คำนิยาม) ---------- */
.def-quote { margin: 0; white-space: pre-line; color: #3d4f61; line-height: 1.6; }
.def-quote::before { content: "\201C"; }
.def-quote::after { content: "\201D"; }
.def-quote.empty { color: var(--muted); font-style: italic; }
.def-quote.empty::before, .def-quote.empty::after { content: none; }

.def-overall { margin-bottom: 16px; }
.def-tab {
  display: inline-block; background: var(--navy); color: #fff; font-weight: 700; font-size: calc(22px * var(--fs));
  padding: 4px 18px; border-radius: 6px 6px 0 0; position: relative; z-index: 1;
}
.def-overall-card { margin: -4px 0 0; border-top-left-radius: 0; }
.def-overall-card .def-quote { padding-left: 48px; font-size: calc(16px * var(--fs)); }

.dim-defs { display: flex; flex-direction: column; gap: 18px; }
.dim-def {
  border-radius: 18px; overflow: hidden;
  background: color-mix(in srgb, var(--bg) 45%, #fff);
}
.dim-def-head {
  display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: var(--bg); color: var(--navy); text-decoration: none;
}
.dim-def-head:hover h3 { text-decoration: underline; }
.dim-def-head h3 { margin: 0; font-size: calc(26px * var(--fs)); }
.dim-def-body { padding: 12px 20px 20px; }
.dim-def-body > .def-quote { padding: 0 0 0 64px; font-size: calc(16px * var(--fs)); }
.comp-count { margin: 12px 0 8px; font-size: calc(18px * var(--fs)); color: var(--ink); }

.comp-defs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.comp-def {
  background: #fff; border: 1.5px solid var(--main); border-radius: 6px; padding: 12px 18px 18px;
}
.comp-def h4 {
  display: flex; gap: 10px; align-items: baseline; margin: 0 0 10px;
  font-size: calc(20px * var(--fs)); line-height: 1.35; color: var(--navy);
}
.comp-def h4 .num { color: var(--main); font-size: calc(24px * var(--fs)); flex-shrink: 0; }
.comp-def .def-quote { font-size: calc(16px * var(--fs)); }

/* ---------- จอเล็ก ---------- */
@media (max-width: 1200px) {
  .home-top { grid-template-columns: minmax(0, 1fr); }
  .dim-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dim-trends { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comp-defs { grid-template-columns: minmax(0, 1fr); }
  .comp-panel { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

/* ---------- 14. หน้า Infographic และรายงานดัชนี (js/pdfview.js) ---------- */
.nav-icon.home svg { width: 58%; height: 58%; }
.doc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-head { margin-bottom: 0; align-items: center; }
.doc-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.doc-icon svg { width: 60%; height: 60%; }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 999px;
  background: var(--navy); color: #fff; border: 2px solid var(--navy); text-decoration: none; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: calc(15px * var(--fs)); line-height: 1.2;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: #163b6b; border-color: #163b6b; }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.ghost:hover { background: #eef4f9; }
.btn.sm { padding: 5px 14px; font-size: calc(14px * var(--fs)); }
.btn:disabled { opacity: .4; cursor: default; }
.doc-status { margin: 0; padding: 40px 12px; text-align: center; color: var(--muted); }
.doc-status.bad { color: var(--bad); }
.doc-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; background: #eef2f6; border-radius: 12px; padding: 16px; }
.doc-page { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(20,40,70,.18); }
.flip { position: relative; display: flex; align-items: center; gap: 8px; }
.flip-stage {
  flex: 1; min-width: 0; min-height: 360px; display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: #eef2f6; border-radius: 12px; padding: 8px; touch-action: pan-y;
}
.flip-stage canvas { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(20,40,70,.18); }
.flip-side {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--navy);
  background: #fff; color: var(--navy); font-size: 28px; line-height: 1; cursor: pointer; padding: 0 0 4px;
}
.flip-side:hover:not(:disabled) { background: var(--navy); color: #fff; }
.flip-side:disabled { opacity: .3; cursor: default; }
.flip-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: calc(15px * var(--fs)); }
.flip-bar input { width: 4.2em; padding: 4px 6px; border: 1px solid #c5d3e0; border-radius: 6px; font: inherit; text-align: center; }
.flip-hint { text-align: center; margin: 6px 0 0; font-size: calc(13px * var(--fs)); }
.doc-empty { text-align: center; padding: 56px 16px; background: #f4f7fa; border: 2px dashed #c9d6e3; border-radius: 12px; }
.doc-empty p { margin: 4px 0; font-size: calc(17px * var(--fs)); }
.doc-empty-icon { display: inline-flex; width: 64px; height: 64px; color: #9fb3c8; margin-bottom: 8px; }
.doc-empty-icon svg { width: 100%; height: 100%; }

@media (max-width: 800px) {
  .flip-side { display: none; }
  .flip-stage { padding: 4px; min-height: 240px; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; height: auto; overflow: visible; }
  .topbar { flex-direction: column; padding: 16px; }
  .titles, .top-controls { align-self: stretch; min-width: 0; }
  .titles h1 { font-size: calc(22px * var(--fs)); }
  .titles .subtitle { font-size: calc(16px * var(--fs)); }
  .titles .tagline { font-size: calc(13px * var(--fs)); }
  .updated-badge { padding: 4px 16px 0; }
  .content { padding: 12px 16px 24px; }
  .dim-trends { grid-template-columns: minmax(0, 1fr); }
  .chart-box.lg { height: 260px; min-height: 0; }
  .sec-title, .year-chip { font-size: calc(20px * var(--fs)); }
  .footer { font-size: calc(14px * var(--fs)); }
  .def-overall-card .def-quote, .dim-def-body > .def-quote { padding-left: 0; }
  .dim-def-head h3 { font-size: calc(20px * var(--fs)); }
}

@media (max-width: 600px) {
  .dim-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dim-card-name { font-size: calc(15px * var(--fs)); }
  .dim-card-score .val { font-size: calc(22px * var(--fs)); }
  .pill-block { font-size: calc(15px * var(--fs)); }
  .lvl-step .lbl { font-size: calc(12px * var(--fs)); }
  .ind-table .ind-spark { display: none; }
  .ind-table .ind-num, .ind-table .ind-lvl, .ind-table .ind-chg { width: auto; }
  .ind-table th { font-size: calc(14px * var(--fs)); padding: 4px; }
  .ind-table th.ind-chg { white-space: normal; }
  .ind-table td { padding: 6px 4px; }
  .ind-table .ind-name { font-size: calc(13px * var(--fs)); }
  .ind-table .pill-block { font-size: calc(12px * var(--fs)); padding: 2px 6px; }
  .chg { font-size: calc(13px * var(--fs)); }
  .comp-panel { padding: 12px; }
  .dim-gauge-row { flex-direction: column; }
}