/* ตรวจงบนนทบุรี — design tokens + shared chrome + home page
   CI: navy (#0b2a5b) / azure (#1f7ae0) / white, typeface Prompt. */

:root {
  /* น้ำเงินเข้ม — สีหลัก */
  --navy: #0b2a5b;
  --navy-dark: #08214a;
  --navy-deep: #061838;
  --navy-soft: #dbe6f7;

  /* ฟ้า — สีรอง */
  --azure: #1f7ae0;
  /* Text-weight blue: --azure itself is only 4.27:1 on white. */
  --azure-ink: #1668c8;
  --azure-light: #4da3f5;
  --azure-soft: #e3f0fd;
  --azure-pale: #f4f9ff;

  /* ขาว */
  --white: #ffffff;
  --paper: #ffffff;

  --ink: #0f1b2d;
  --muted: #52627a;
  --line: rgba(11, 42, 91, 0.16);
  --line-strong: rgba(11, 42, 91, 0.28);
  --danger: #c0392b;
  --success: #177044;

  --shadow-sm: 0 3px 0 rgba(11, 42, 91, 0.08);
  --shadow-md: 0 10px 28px rgba(11, 42, 91, 0.1);
  --shadow-lg: 0 22px 60px rgba(11, 42, 91, 0.16);

  --radius-lg: 32px;
  --radius-md: 22px;
  --radius-sm: 14px;
  --header-height: 72px;

  --font: "Prompt", "Noto Sans Thai", "IBM Plex Sans Thai", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
}

body {
  margin: 0;
  font-family: var(--font);
  /* rem, not px: the accessibility panel scales the root font size, and a px
     body would keep its own size while everything around it grew. */
  font-size: 1.0625rem;
  line-height: 1.55;
  font-weight: 400;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
}

p {
  margin: 0;
}

a {
  color: var(--azure-ink);
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--azure-light);
  outline-offset: 3px;
  border-radius: 6px;
}

.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 200;
  padding: 12px 20px;
  background: var(--navy-deep);
  color: var(--white);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  transition: top 0.18s ease;
}

.skip-link:focus-visible {
  top: 0;
}

.shell {
  width: min(1200px, 100% - 40px);
  margin-inline: auto;
}

/* ------------------------------------------------------------------ header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.site-header .shell {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  /* Without this the brand refuses to shrink and pushes the nav — and the Aa
     button with it — past the right edge of a narrow screen. */
  min-width: 0;
  overflow: hidden;
  text-decoration: none;
  color: var(--navy);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: var(--radius-sm);
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex: 0 0 auto;
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 0 1 auto;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
}

.site-nav a:hover {
  background: var(--azure-soft);
}

.site-nav a[aria-current="page"] {
  background: var(--navy);
  color: var(--white);
}

.accessibility-button {
  width: 52px;
  height: 52px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--navy);
  font-weight: 600;
  cursor: pointer;
}

.accessibility-button:hover {
  background: var(--azure-soft);
  border-color: var(--azure);
}

/* -------------------------------------------------------------------- hero */

.hero {
  position: relative;
  background: var(--navy);
  color: var(--white);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto auto;
  width: 620px;
  height: 620px;
  background: radial-gradient(circle, rgba(77, 163, 245, 0.35), transparent 62%);
  pointer-events: none;
}

.hero .shell {
  position: relative;
  min-height: min(620px, calc(100svh - var(--header-height)));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 56px 0 64px;
  text-align: center;
}

.hero .eyebrow {
  display: block;
  align-self: center;
  padding: 0;
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 4.5vw, 4rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  width: 100%;
  max-width: none;
  text-align: center;
}

#rotating-title {
  color: var(--azure-light);
  display: inline-block;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

#rotating-title.is-swapping {
  opacity: 0;
  transform: translateY(-6px);
}

.hero-lede {
  max-width: 70ch;
  margin-inline: auto;
  font-size: 1.05rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.hero-jump-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.jump-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.jump-link:hover {
  background: var(--white);
  color: var(--navy);
  border-color: var(--white);
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(960px, 100%);
  margin-inline: auto;
  text-align: left;
  background: var(--white);
  padding: 8px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  text-align: left;
}

.search-form input[type="search"]::placeholder {
  color: var(--muted);
}

.search-form button {
  width: 52px;
  height: 52px;
  min-height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease;
}

.search-form button svg {
  width: 24px;
  height: 24px;
}

.search-form button:hover {
  background: var(--azure);
}

.search-starters {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  width: min(1024px, 100%);
  margin-inline: auto;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.search-starters button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-size: 0.92rem;
  cursor: pointer;
  white-space: nowrap;
}

.search-starters button:hover {
  background: var(--white);
  color: var(--navy);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  width: min(800px, 100%);
  margin: 6px auto 0;
  text-align: center;
}

@media (min-width: 1024px) {
  .hero .search-starters {
    justify-content: center;
  }
}

.hero-stats div {
  padding: 0;
}

.hero-stats dt,
.hero-stats .stat-label {
  font-size: 0.82rem;
  color: var(--white);
}

.hero-stats .stat-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.hero-stats .stat-value strong {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 700;
  color: var(--white);
}

.hero-stats .stat-value small {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--white);
}

/* --------------------------------------------------- search results overlay */

.search-results {
  width: min(960px, 100%);
  margin-inline: auto;
  background: var(--white);
  color: var(--ink);
  text-align: left;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  max-height: 46vh;
  overflow-y: auto;
}

.search-results[hidden] {
  display: none;
}

.search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
}

.search-results a:hover,
.search-results a:focus-visible {
  background: var(--azure-soft);
}

.search-results .result-name {
  font-weight: 500;
}

.search-results .result-meta {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
}

.search-results mark {
  background: #fff2a8;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.search-results .result-amount {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--navy);
}

.search-results footer {
  padding: 10px 14px 4px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------ browse */

.browse-section { padding: 64px 0; background: var(--white); }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 700; color: var(--navy); }
.section-head p { color: var(--muted); max-width: 60ch; }
.browse-section, .highest-section {
  --category-purple: #6039a5;
  --category-purple-hover: #4e2c8c;
}
.browse-section .section-head, .highest-section .section-head { justify-content: center; text-align: center; }
.browse-section .section-head p, .highest-section .section-head p { max-width: none; }
.quick-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.quick-menu button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 12px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--white); color: var(--navy); font-weight: 500; cursor: pointer; }
.quick-menu button:hover { background: var(--azure-pale); border-color: var(--azure); }
.quick-menu button[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: var(--white); }
.quick-menu svg { width: 22px; height: 22px; flex: 0 0 auto; }
.quick-menu button[aria-selected="true"] svg { color: var(--azure-light); }
.category-area { padding-bottom: 8px; }
.category-head { text-align: center; margin-bottom: 20px; }
.category-head h3 { font-size: 1.25rem; color: var(--navy); }
.category-head .kicker { color: var(--muted); font-size: 0.95rem; }
.category-controls { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.category-controls button { width: 44px; height: 44px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--white); color: var(--navy); cursor: pointer; }
.category-controls button:hover:not(:disabled) { background: var(--azure-soft); }
.category-controls button:disabled { opacity: 0.4; cursor: default; }
.category-grid { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 32px) / 3); gap: 16px; padding: 4px 4px 16px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 4px; scrollbar-width: thin; }
.category-card {
  scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; min-width: 0; aspect-ratio: 1; text-align: center;
  border-radius: 20px; border: 1px solid transparent;
  background: var(--category-purple); color: var(--white); text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease;
}
.category-card:hover, .category-card:focus-visible { transform: translateY(-2px); background: var(--category-purple-hover); }
.category-icon { font-size: 2.6rem; line-height: 1.25; }
.category-card h4 { font-size: clamp(1.15rem, 1.6vw, 1.4rem); font-weight: 600; line-height: 1.45; color: var(--white); overflow-wrap: anywhere; }
.category-card .card-amount { margin-top: 8px; font-size: clamp(1.05rem, 1.5vw, 1.3rem); font-weight: 600; color: var(--white); }
.category-card .card-share { font-size: 0.84rem; }
.category-card .card-meta { font-size: 0.8rem; color: var(--white); margin-top: 4px; }
.category-card .card-bar { width: 100%; height: 6px; flex-shrink: 0; border-radius: 999px; background: rgba(255,255,255,0.24); overflow: hidden; }
.category-card .card-bar i { display: block; height: 100%; border-radius: inherit; background: var(--white); }
.highest-section { padding: 56px 0; background: #f5f1fa; }
.highest-section #highest-title { font-size: clamp(2.4rem, 4.5vw, 3.5rem); line-height: 1.25; margin-bottom: 16px; }
.highest-summary { text-align: center; color: var(--muted); margin: 0 auto; text-wrap: pretty; }
.highest-section .section-head .highest-summary { max-width: 72ch; }
.highest-grid { list-style: none; padding: 8px 4px 20px; margin: 0; display: grid; grid-auto-flow: column; grid-auto-columns: min(360px, 90%); gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 4px; scrollbar-width: thin; }
.highest-grid li { min-width: 0; scroll-snap-align: start; }
.highest-card { display: flex; flex-direction: column; gap: 12px; height: 100%; aspect-ratio: 1; padding: 24px; border: 1px solid transparent; border-radius: 20px; background: var(--category-purple); color: var(--white); text-decoration: none; transition: transform 0.18s ease, background 0.18s ease; }
.highest-card:hover, .highest-card:focus-visible { background: var(--category-purple-hover); transform: translateY(-4px); }
.highest-card-head { display: flex; align-items: center; justify-content: space-between; }
.highest-rank { color: var(--category-purple); -webkit-text-stroke: 2px var(--white); font-size: 5rem; line-height: 1; font-weight: 700; letter-spacing: -0.06em; }
.highest-icon { font-size: 2.6rem; }
.highest-detail { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.highest-plan { font-size: 0.8rem; color: var(--white); }
.highest-detail h3 { font-size: 1.15rem; line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.highest-detail p { font-size: 0.8rem; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.highest-detail strong { font-size: 1.3rem; color: var(--white); margin-top: auto; padding-top: 8px; }
.highest-share { font-size: 0.78rem; color: var(--white); }
.highest-all { display: block; width: fit-content; margin: 28px auto 0; padding: 12px 20px; border-radius: 12px; background: var(--navy); color: var(--white); text-align: center; text-decoration: none; }
.highest-retry { display: block; margin: 16px auto; padding: 12px 20px; border-radius: 12px; cursor: pointer; }
.highest-retry[hidden] { display: none; }
@media (max-width: 1000px) {
  .category-grid { grid-auto-columns: calc((100% - 16px) / 2); }
}
@media (max-width: 600px) {
  .category-grid { grid-auto-columns: 92%; }
  .highest-grid { grid-auto-columns: min(340px, 96%); gap: 16px; }
  .category-card { max-width: 400px; width: 100%; justify-self: center; padding: 20px; gap: 6px; }
  .category-card h4 { font-size: 1.15rem; }
  .highest-card { padding: 16px; gap: 8px; }
  .highest-rank { font-size: 3.5rem; }
  .highest-detail { gap: 6px; }
  .highest-detail h3 { font-size: 1rem; }
  .highest-detail strong { font-size: 1.1rem; }
  .quick-menu button { padding: 12px 8px; }
}

.empty-state {
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
}

/* ---------------------------------------------------- ภาพรวมงบประมาณ 7 ขั้น */

.overview {
  padding: 56px 0 64px;
  background: var(--azure-pale);
  border-block: 1px solid var(--line);
  margin-top: 40px;
}

/* ไล่เฉดเดียวกันทั้งส่วน เข้ม = ก้อนใหญ่ อ่อน = ก้อนเล็ก */
.ov-c1 { --ov-bg: var(--navy); --ov-bg-light: #164377; --ov-fg: #ffffff; }
.ov-c2 { --ov-bg: #17509c; --ov-bg-light: #2067c2; --ov-fg: #ffffff; }
.ov-c3 { --ov-bg: var(--azure); --ov-bg-light: #3586ea; --ov-fg: #ffffff; }
/* จากเฉดนี้ลงไปพื้นสว่างเกินกว่าจะใช้ตัวอักษรสีขาว จึงสลับเป็นน้ำเงินเข้ม */
.ov-c4 { --ov-bg: #63aaf2; --ov-bg-light: #89c0f7; --ov-fg: var(--navy-deep); }
.ov-c5 { --ov-bg: #a8cffa; --ov-bg-light: #cde4fc; --ov-fg: var(--navy-deep); }
.ov-c6 { --ov-bg: #d7e9fd; --ov-bg-light: #edf5fe; --ov-fg: var(--navy-deep); }

.ov-stroke1 circle { stroke: var(--navy); }
.ov-stroke2 circle { stroke: #17509c; }
.ov-stroke3 circle { stroke: var(--azure); }
.ov-stroke4 circle { stroke: #63aaf2; }
.ov-stroke5 circle { stroke: #a8cffa; }

.panel-note {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ------------------------------------------------------------ intro strip */

.ov-intro {
  margin-bottom: 28px;
  text-align: center;
}

.ov-intro h2 {
  font-size: clamp(1.5rem, 3vw, 2.15rem);
  color: var(--navy);
  margin-bottom: 10px;
}

.ov-lede {
  max-width: 72ch;
  color: var(--muted);
  margin-inline: auto;
}

.ov-headline {
  width: min(100%, 1120px);
  margin: 22px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 14px;
}

.ov-headline-figure {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: grid;
  justify-items: center;
  align-content: start;
  text-align: center;
}

.ov-figure-value {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.ov-figure-unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--azure-ink);
}

.ov-figure-label {
  margin-top: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.ov-nav {
  width: min(100%, 1200px);
  margin: 28px auto 0;
  padding: 10px 0 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-padding-inline: 16px;
}

.ov-route {
  width: 100%;
  min-width: 900px;
  margin: 0;
  padding: 0 8px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  list-style: none;
}

.ov-route-stop {
  position: relative;
  min-width: 0;
}

.ov-route-stop:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 25px;
  left: calc(50% + 27px);
  right: calc(-50% + 27px);
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--azure), var(--navy-soft));
}

.ov-route-icon-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ov-route-link {
  position: relative;
  z-index: 1;
  min-height: 106px;
  padding: 0 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  color: var(--navy);
  text-decoration: none;
}

.ov-route-marker {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  display: grid;
  place-items: center;
  border: 4px solid var(--azure-pale);
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--azure), 0 5px 12px rgba(11, 42, 91, 0.18);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ov-route-icon {
  width: 1.55rem;
  height: 1.55rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ov-route-label {
  display: grid;
  gap: 1px;
  max-width: 150px;
  color: var(--navy);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

.ov-route-step {
  color: var(--azure-ink);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ov-route-link:hover .ov-route-marker,
.ov-route-link:focus-visible .ov-route-marker {
  background: var(--azure);
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 0 0 3px var(--azure-pale), 0 7px 16px rgba(11, 42, 91, 0.22);
}

.ov-route-link:hover .ov-route-label,
.ov-route-link:focus-visible .ov-route-label {
  color: var(--azure-ink);
}

/* ------------------------------------------------------------------ steps */

.ov-steps {
  display: grid;
  gap: 20px;
}

.ov-step {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.ov-step-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.ov-step-no {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
}

.ov-step-head h3 {
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  color: var(--navy);
}

.ov-step-note {
  margin-top: 4px;
  font-size: 0.87rem;
  color: var(--muted);
}

.ov-canvas[data-ov-loading] {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
}

.ov-error {
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--azure-pale);
  display: grid;
  gap: 12px;
  justify-items: start;
}

.ov-punch {
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 18px;
  margin-inline: auto;
  max-width: 84ch;
  text-align: center;
}

.ov-punch b {
  color: var(--navy);
  font-weight: 600;
}

.ov-punch-sm {
  font-size: 0.92rem;
  margin: 14px 0 0;
  color: var(--muted);
}

.ov-hint {
  margin-top: 12px;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ------------------------------------------------------- 1. แถบต้นทางของเงิน */

.ov-flow {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.ov-flow-seg {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  padding: 18px 16px;
  border-radius: var(--radius-sm);
  background: var(--ov-bg);
  color: var(--ov-fg);
  display: grid;
  align-content: end;
  gap: 2px;
  min-height: 140px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ov-flow-seg:hover,
.ov-flow-seg.is-active {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.ov-flow-seg.is-active {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
}

.ov-flow-share {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.1;
}

.ov-flow-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.ov-flow-amount {
  font-size: 0.84rem;
  opacity: 0.9;
}

.ov-detail {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-sm);
  background: var(--azure-pale);
  border: 1px solid var(--line);
}

.ov-detail-lead {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  color: var(--navy);
  font-weight: 600;
}

.ov-detail-share,
.ov-detail-note {
  font-weight: 400;
  font-size: 0.86rem;
  color: var(--muted);
}

.ov-detail-note {
  margin: 4px 0 14px;
}

.ov-mini-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.ov-mini-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.ov-mini-head b {
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.ov-mini-track {
  display: block;
  height: 9px;
  border-radius: 999px;
  background: var(--azure-soft);
  overflow: hidden;
}

.ov-mini-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy), var(--azure));
}

/* --------------------------------------------------------------- 2. โดนัท */

.ov-donut-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.ov-donut {
  position: relative;
}

.ov-donut svg {
  display: block;
  width: 100%;
  height: auto;
}

.ov-arc circle {
  fill: none;
  stroke-width: 26;
  transition: stroke-width 0.18s ease;
}

.ov-arc.is-active circle {
  stroke-width: 32;
}

.ov-donut-center {
  position: absolute;
  inset: 22%;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 2px;
  pointer-events: none;
}

.ov-donut-center b {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  color: var(--navy);
  line-height: 1.15;
}

.ov-donut-center span {
  font-size: 0.82rem;
  color: var(--muted);
}

.ov-donut-center small {
  font-size: 0.78rem;
  color: var(--azure-ink);
}

.ov-legend,
.ov-range-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 4px 12px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.ov-legend > li { flex: 1 1 0; min-width: 136px; scroll-snap-align: start; }

.ov-per100 {
  margin: 0 auto 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--azure-pale);
}

.ov-per100-heading {
  display: grid;
  gap: 2px;
  text-align: center;
}

.ov-per100-kicker {
  color: var(--azure-ink);
  font-size: 0.78rem;
  font-weight: 600;
}

.ov-per100-heading strong {
  color: var(--navy);
  font-size: 1.05rem;
}

.ov-per100-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.ov-per100-item {
  min-width: 132px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 9px 1fr;
  align-items: center;
  column-gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  text-align: center;
}

.ov-per100-swatch {
  width: 9px;
  height: 9px;
  grid-row: 1 / span 2;
  border-radius: 50%;
  background: var(--ov-bg);
}

.ov-per100-name {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.ov-per100-value {
  color: var(--navy);
  font-size: 1.05rem;
  line-height: 1.25;
}

.ov-legend-row,
.ov-range-legend a {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  min-height: 166px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
}

.ov-legend-row { align-items: center; text-align: center; }

.ov-legend-row:hover,
.ov-legend-row.is-active,
.ov-legend-row:focus-visible,
.ov-range-legend a:hover,
.ov-range-legend a:focus-visible {
  background: var(--azure-pale);
  border-color: var(--line);
}

.ov-swatch {
  width: 100%;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ov-bg);
}

.ov-legend-name {
  font-weight: 500;
  line-height: 1.35;
  min-height: 2.7em;
  width: 100%;
  text-align: center;
}

.ov-legend-share {
  width: 100%;
  align-self: center;
  margin-top: auto;
  display: grid;
  gap: 2px;
  justify-items: center;
  color: var(--navy);
  white-space: nowrap;
}

.ov-legend-share b {
  color: var(--azure-ink);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.ov-legend-share small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.ov-legend-amount,
.ov-legend-count {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.ov-legend-amount {
  color: var(--azure-ink);
  font-weight: 600;
}

/* ------------------------------------------------------------- 3. treemap */

.ov-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ov-switch button {
  font: inherit;
  cursor: pointer;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--navy);
  font-weight: 500;
}

.ov-switch button.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.ov-bubble-cluster {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 600;
  min-height: 0;
  background: radial-gradient(circle at 45% 48%, rgba(34, 112, 212, 0.05) 0%, rgba(243, 248, 255, 0.65) 68%, transparent 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(10, 37, 64, 0.04);
}

.ov-bubble {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--d);
  height: auto;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--ov-bg-light, var(--ov-bg)), var(--ov-bg));
  color: var(--ov-fg);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(10, 37, 64, 0.16), inset 0 2px 4px rgba(255, 255, 255, 0.25);
  transition: left 0.55s cubic-bezier(0.34, 1.25, 0.64, 1),
              top 0.55s cubic-bezier(0.34, 1.25, 0.64, 1),
              width 0.4s ease,
              height 0.4s ease,
              transform 0.22s cubic-bezier(0.2, 0, 0, 1),
              box-shadow 0.22s ease,
              filter 0.22s ease;
  z-index: 2;
  cursor: pointer;
  animation: ov-bubble-float 4.5s ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * 0.32s);
}

@keyframes ov-bubble-float {
  0% {
    margin-top: 0px;
  }
  100% {
    margin-top: -6px;
  }
}

.ov-bubble:hover,
.ov-bubble:focus-visible {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 14px 34px rgba(10, 37, 64, 0.28), 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 2px 5px rgba(255, 255, 255, 0.35);
  filter: brightness(1.1);
  z-index: 10;
  outline: none;
}

/* min-width: 0 คือหัวใจ — ถ้าไม่ใส่ flex item จะยืดตามความยาวข้อความ
   ชื่อแผนงานยาว ๆ ในวงเล็ก ๆ จึงเคยล้นออกไปลอยอยู่นอกวงกลม */
.ov-bubble-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  padding: 8% 10%;
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  pointer-events: none;
  user-select: none;
}

.ov-bubble-content > * {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ov-bubble-icon {
  display: block;
  line-height: 1;
  margin-bottom: 2px;
}

.ov-bubble-name {
  font-weight: 600;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ov-bubble-share {
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.ov-bubble-amount {
  opacity: 0.9;
  line-height: 1.15;
}

/* Typography scale based on bubble diameter */
.ov-bubble.is-huge .ov-bubble-icon { font-size: 2.2rem; margin-bottom: 4px; }
.ov-bubble.is-huge .ov-bubble-name { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; max-width: 85%; }
.ov-bubble.is-huge .ov-bubble-share { font-size: 1.65rem; margin-bottom: 3px; }
.ov-bubble.is-huge .ov-bubble-amount { font-size: 0.95rem; font-weight: 500; }

.ov-bubble.is-medium .ov-bubble-icon { font-size: 1.5rem; margin-bottom: 3px; }
.ov-bubble.is-medium .ov-bubble-name { font-size: 0.9rem; margin-bottom: 3px; max-width: 90%; }
.ov-bubble.is-medium .ov-bubble-share { font-size: 1.15rem; margin-bottom: 2px; }
.ov-bubble.is-medium .ov-bubble-amount { font-size: 0.78rem; }

.ov-bubble.is-small .ov-bubble-icon { font-size: 1.15rem; }
.ov-bubble.is-small .ov-bubble-name { font-size: 0.75rem; margin-bottom: 2px; max-width: 92%; }
.ov-bubble.is-small .ov-bubble-share { font-size: 0.88rem; }
.ov-bubble.is-small .ov-bubble-amount { font-size: 0.7rem; }

.ov-bubble.is-tiny .ov-bubble-icon { font-size: 1.05rem; }
.ov-bubble.is-tiny .ov-bubble-name { font-size: 0.68rem; margin-bottom: 1px; }
.ov-bubble.is-tiny .ov-bubble-share { font-size: 0.76rem; }
.ov-bubble.is-tiny .ov-bubble-amount { display: none; }

/* Context message shown while hovering, focusing, or inspecting a bubble on touch */
.ov-bubble-message {
  position: absolute;
  z-index: 20;
  width: min(340px, calc(100% - 24px));
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.98);
  color: var(--navy-deep);
  box-shadow: 0 14px 32px rgba(10, 37, 64, 0.2);
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.ov-bubble-message.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ov-bubble-message.is-below {
  transform: translate(-50%, 0);
}

.ov-bubble-message.is-below.is-visible {
  transform: translate(-50%, 8px);
}

.ov-message-kicker {
  color: var(--azure-ink);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ov-bubble-message strong {
  color: var(--navy);
  font-size: 1rem;
  line-height: 1.35;
}

.ov-bubble-message > span:not(.ov-message-kicker) {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.ov-bubble-message b {
  color: var(--navy);
}

/* Interactive Hover / Focus Inspection HUD */
.ov-bubble-inspect {
  margin-top: 10px;
  padding: 10px 18px;
  background: var(--azure-pale);
  border: 1px solid var(--azure-subtle);
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  color: var(--navy-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 44px;
  text-align: center;
  transition: all 0.2s ease;
}

.ov-inspect-badge {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ov-inspect-stat {
  font-weight: 700;
  color: var(--navy);
}

.ov-inspect-share {
  font-weight: 700;
  color: var(--azure);
}

.ov-inspect-count {
  color: var(--muted);
  font-size: 0.82rem;
}

.ov-inspect-go {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--azure);
  margin-left: 4px;
}

/* Mobile Responsiveness */
@media (max-width: 720px) {
  .ov-bubble-cluster {
    aspect-ratio: 420 / 580;
    min-height: 0;
    padding: 8px;
  }

  .ov-bubble.is-huge .ov-bubble-icon { font-size: 1.8rem; }
  .ov-bubble.is-huge .ov-bubble-name { font-size: 0.95rem; }
  .ov-bubble.is-huge .ov-bubble-share { font-size: 1.3rem; }
  .ov-bubble.is-huge .ov-bubble-amount { font-size: 0.72rem; }

  .ov-bubble.is-medium .ov-bubble-icon { font-size: 1.25rem; }
  .ov-bubble.is-medium .ov-bubble-name { font-size: 0.78rem; }
  .ov-bubble.is-medium .ov-bubble-share { font-size: 0.95rem; }
  .ov-bubble.is-medium .ov-bubble-amount { font-size: 0.7rem; }

  .ov-bubble.is-small .ov-bubble-name { font-size: 0.68rem; }
  .ov-bubble.is-small .ov-bubble-share { font-size: 0.78rem; }
  .ov-bubble.is-small .ov-bubble-amount { display: none; }

  /* วงจิ๋วบนจอมือถือเหลือที่ว่างข้างในราว 20 px ชื่อแผนงานอ่านไม่ออกอยู่แล้ว
     และเคยล้นออกไปลอยอยู่นอกวง — ตัดออก ชื่อยังอยู่ใน aria-label ของลิงก์ */
  .ov-bubble.is-tiny .ov-bubble-name { display: none; }
  .ov-bubble.is-tiny .ov-bubble-share { font-size: 0.7rem; }

  .ov-bubble-inspect {
    font-size: 0.82rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
  }

  .ov-bubble-message {
    width: min(280px, calc(100% - 20px));
    padding: 12px;
  }

  .ov-bubble-message strong {
    font-size: 0.92rem;
  }

  .ov-bubble-message > span:not(.ov-message-kicker) {
    font-size: 0.78rem;
  }
}

/* -------------------------------------------------------------- 4. เมทริกซ์ */

.ov-matrix-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.ov-matrix {
  border-collapse: collapse;
  width: 100%;
  min-width: 620px;
  font-size: 0.88rem;
}

.ov-matrix th,
.ov-matrix td {
  border-bottom: 1px solid var(--line);
  padding: 0;
  text-align: center;
}

.ov-matrix thead th {
  padding: 10px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  background: var(--azure-pale);
}

.ov-matrix thead th:first-child,
.ov-matrix tbody th {
  text-align: left;
}

.ov-matrix tbody th button {
  font: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--navy);
  font-weight: 500;
}

.ov-matrix tbody th button:hover,
.ov-matrix tbody th button.is-active {
  background: var(--navy);
  color: var(--white);
}

/* หยุดการไล่เฉดไว้ที่ 48% ของน้ำเงิน ช่องที่เข้มที่สุดจึงยังอ่านตัวอักษร
   น้ำเงินเข้มได้เกิน 4.5:1 ทั้งตาราง โดยไม่ต้องสลับเป็นตัวอักษรสีขาวกลางคัน */
.ov-cell {
  background: var(--azure-soft);
  background: color-mix(in srgb, var(--navy) calc(var(--i) * 48%), var(--azure-pale));
}

.ov-cell a {
  display: block;
  padding: 10px 8px;
  text-decoration: none;
  color: var(--navy-deep);
  font-weight: 500;
}

.ov-cell a:hover,
.ov-cell a:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: -2px;
}

.ov-matrix td.is-empty {
  color: var(--line-strong);
  padding: 10px 8px;
}

.ov-cell-total {
  padding: 10px 12px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.ov-detail-head h4 {
  font-size: 1.05rem;
  color: var(--navy);
}

.ov-detail-head p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.ov-detail-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 20px;
}

.ov-detail-cols h5 {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 10px;
}

.ov-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: ov-rank;
  display: grid;
  gap: 10px;
}

.ov-rank li {
  counter-increment: ov-rank;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding-left: 26px;
  position: relative;
  font-size: 0.88rem;
}

.ov-rank li::before {
  content: counter(ov-rank);
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--azure-soft);
  color: var(--navy);
  font-size: 0.72rem;
  display: grid;
  place-items: center;
}

.ov-rank b {
  color: var(--navy);
  white-space: nowrap;
}

.ov-rank small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
}

.ov-detail-link {
  display: inline-block;
  margin-top: 16px;
  font-weight: 600;
  color: var(--azure-ink);
}

/* --------------------------------------------------------------- 5. วาฟเฟิล */
#ov-inside-detail { padding: 24px; background: linear-gradient(145deg, var(--azure-pale), #fff); }
#ov-inside-detail .ov-detail-head { text-align: center; margin-bottom: 24px; }
#ov-inside-detail .ov-detail-head h4 { font-size: 1.5rem; margin-bottom: 12px; }
#ov-inside-detail .ov-plan-summary { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 20px; margin: 0; }
#ov-inside-detail .ov-plan-summary b { color: var(--navy); font-weight: 700; }
#ov-inside-detail .ov-detail-cols { align-items: start; gap: 16px; }
#ov-inside-detail .ov-detail-cols > div { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 4px 16px #11335905; }
#ov-inside-detail .ov-detail-cols h5 { text-align: center; color: var(--navy); font-size: 1rem; font-weight: 600; padding: 10px 12px; margin: -4px -4px 18px; border-radius: 10px; background: var(--azure-soft); }
#ov-inside-detail .ov-detail-cols > div:last-child h5 { background: var(--navy); color: var(--white); }
#ov-inside-detail .ov-mini-bars { gap: 16px; }
#ov-inside-detail .ov-mini-head { flex-wrap: wrap; gap: 4px 12px; }
#ov-inside-detail .ov-mini-head b { margin-left: auto; color: var(--azure-ink); }
#ov-inside-detail .ov-mini-track { height: 10px; }
#ov-inside-detail .ov-mini-track i { background: linear-gradient(90deg, #2358a8, #398df0); }
#ov-inside-detail .ov-rank { gap: 8px; }
#ov-inside-detail .ov-rank li { padding: 12px 12px 12px 48px; border-radius: 10px; background: var(--azure-pale); }
#ov-inside-detail .ov-rank li::before { left: 12px; top: 12px; width: 25px; height: 25px; border-radius: 8px; font-weight: 700; }
#ov-inside-detail .ov-rank li:first-child { background: var(--azure-soft); }
#ov-inside-detail .ov-rank li:first-child::before { background: var(--navy); color: var(--white); }
#ov-inside-detail .ov-detail-link { display: table; margin: 20px auto 0; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); text-align: center; text-decoration: none; }
#ov-inside-detail .ov-detail-link:hover { background: var(--azure-soft); }
@media (max-width: 640px) {
  #ov-inside-detail { padding: 16px; }
  #ov-inside-detail .ov-detail-cols { grid-template-columns: minmax(0, 1fr); }
  #ov-inside-detail .ov-detail-cols > div { padding: 14px; }
  #ov-inside-detail .ov-rank li { grid-template-columns: minmax(0, 1fr); }
}

.ov-waffle {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11px, 1fr));
  gap: 3px;
  margin-bottom: 18px;
}

/* สีของจุด = ขนาดของรายการ ส่วนวงรอบจุด = อยู่ในช่วงที่แถบเลื่อนเลือกไว้
   เป็นคนละความหมายกัน จุดที่ไม่ได้เลือกจึงยังเก็บสีไว้ให้เทียบขนาดได้ */
.ov-dot {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--ov-bg);
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.ov-dot.is-half {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--navy);
}

.ov-dot:hover {
  transform: scale(1.6);
  opacity: 1;
}

.ov-slider label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.ov-slider input[type="range"] {
  width: 100%;
  accent-color: var(--azure);
}

/* แถบเลื่อนของเบราว์เซอร์สูงราว 16 px กดยากมากบนจอสัมผัส
   ขยายพื้นที่กดให้ถึง 44 px โดยแถบยังอยู่กึ่งกลางเหมือนเดิม */
@media (pointer: coarse) {
  .ov-slider input[type="range"] {
    height: 44px;
  }
}

.ov-readout {
  margin-top: 10px;
  font-size: 0.95rem;
}

.ov-readout b {
  color: var(--navy);
}

.ov-pick {
  margin: 16px 0 20px;
}

.ov-pick-card {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--azure-pale);
  text-decoration: none;
  color: var(--ink);
}

.ov-pick-card:hover,
.ov-pick-card:focus-visible {
  border-color: var(--azure);
  box-shadow: var(--shadow-sm);
}

.ov-pick-rank {
  font-size: 0.78rem;
  color: var(--azure-ink);
  font-weight: 600;
}

.ov-pick-card strong {
  color: var(--navy);
  font-weight: 600;
  line-height: 1.35;
}

.ov-pick-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.ov-pick-amount {
  font-weight: 600;
  color: var(--navy);
}

.ov-pick-go {
  font-size: 0.82rem;
  color: var(--azure-ink);
  font-weight: 600;
}

.ov-range-heading { margin: 24px 0 14px; }
.ov-range-heading h3 { color: var(--navy); font-size: 1.05rem; margin-bottom: 4px; }
.ov-range-heading p { color: var(--muted); font-size: .82rem; }
.ov-range-legend { display: grid; gap: 10px; overflow: visible; padding: 0; }
.ov-range-legend a { display: grid; grid-template-columns: minmax(190px, 1.4fr) minmax(100px, .7fr) minmax(125px, .9fr) minmax(150px, 1fr) auto; align-items: center; gap: 20px; min-height: 0; padding: 18px 20px; border-radius: 14px; }
.ov-range-legend a:hover { border-color: var(--azure); }
.ov-range-legend a:focus-visible { outline: 3px solid var(--azure); outline-offset: 3px; }
.ov-range-title { display: flex; align-items: center; gap: 12px; }
.ov-range-title > span:last-child, .ov-range-metric { display: grid; gap: 4px; }
.ov-range-legend small { font-size: .75rem; font-weight: 400; color: var(--muted); }
.ov-range-legend strong { color: var(--navy); font-size: .95rem; }
.ov-range-dot { width: 10px; height: 32px; flex-shrink: 0; border-radius: 6px; background: var(--ov-bg); }
.ov-range-proportion { display: grid; gap: 8px; }
.ov-range-proportion > span:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ov-range-proportion strong { font-size: 1.15rem; }
.ov-range-track { display: block; height: 7px; background: var(--azure-pale); border-radius: 9px; overflow: hidden; }
.ov-range-track > span { display: block; height: 100%; min-width: 2px; background: var(--ov-bg); border-radius: inherit; }
.ov-range-go { color: var(--azure-ink); font-size: .8rem; font-weight: 600; white-space: nowrap; }
@media (min-width: 1001px) {
  .ov-range-legend { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
  .ov-range-legend > li { min-width: 0; }
  .ov-range-legend a { height: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr auto; align-items: start; gap: 10px; padding: 14px 16px; box-shadow: 0 4px 14px #11335906; }
  .ov-range-title { flex-direction: column; align-items: stretch; gap: 8px; }
  .ov-range-dot { width: 100%; height: 5px; }
  .ov-range-title > span:last-child { min-height: 44px; align-content: start; }
  .ov-range-metric { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 6px; }
  .ov-range-metric strong { font-size: .95rem; overflow-wrap: anywhere; }
  .ov-range-proportion { align-self: end; padding-top: 10px; border-top: 1px solid var(--line); }
  .ov-range-proportion > span:first-child { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .ov-range-proportion strong { font-size: 1.4rem; line-height: 1.2; }
  .ov-range-go { padding-top: 2px; }
}
@media (max-width: 1000px) {
  .ov-range-legend a { grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; }
  .ov-range-proportion { grid-column: 1 / 3; }
  .ov-range-go { justify-self: end; }
}
@media (max-width: 540px) {
  .ov-range-legend a { grid-template-columns: 1fr 1fr; padding: 16px; gap: 14px; }
  .ov-range-title { grid-column: 1 / -1; }
  .ov-range-proportion { grid-column: 1 / -1; }
  .ov-range-go { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------- 6. ต่อหัวคุณ */

.ov-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 20px;
}

.ov-card {
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--azure-pale);
}

.ov-card h4 {
  font-size: 1.05rem;
  color: var(--navy);
}

.ov-card-note {
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.ov-bighead {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.ov-bighead small {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.ov-people {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 18px;
  font-size: 0.88rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.ov-people input {
  font: inherit;
  width: 84px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
}

.ov-perhead-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.ov-perhead-list a,
.ov-perhead-rest {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
}

.ov-perhead-list a:hover,
.ov-perhead-list a:focus-visible {
  background: var(--paper);
}

.ov-perhead-list b {
  color: var(--navy);
  white-space: nowrap;
}

.ov-perhead-rest {
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.ov-bar-compare {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.ov-bar-compare li.is-accent .ov-mini-track i {
  background: linear-gradient(90deg, #b8541f, #e08a2f);
}

/* ------------------------------------------------------------- 7. ตรวจเลย */

.ov-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 14px;
}

.ov-check-card {
  --check-accent: #17665d;
  --check-tint: #e9f6f0;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 12px;
  padding: 22px 20px 16px;
  border-radius: 20px;
  border: 1px solid #dfe6ed;
  border-top: 4px solid var(--check-accent);
  background: linear-gradient(155deg, var(--check-tint), #fff 65%);
  box-shadow: 0 4px 12px #18375b06;
  text-decoration: none;
  color: var(--ink);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.ov-check-theme-1 { --check-accent: #955415; --check-tint: #fff3db; }
.ov-check-theme-2 { --check-accent: #5c47a2; --check-tint: #f1edff; }
.ov-check-theme-3 { --check-accent: #216695; --check-tint: #e9f4ff; }
.ov-check-top { display: flex; align-items: center; gap: 10px; }
.ov-check-tag { font-size: 0.7rem; color: var(--check-accent); font-weight: 600; }

.ov-check-card:hover,
.ov-check-card:focus-visible {
  border-color: var(--check-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.ov-check-card:focus-visible { outline: 3px solid var(--check-accent); outline-offset: 4px; }

.ov-check-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  background: #ffffffcf;
  border: 1px solid #ffffff;
  border-radius: 14px;
  font-size: 1.5rem;
}

.ov-check-card strong {
  color: var(--navy);
  font-weight: 600;
}

.ov-check-note {
  font-size: 0.84rem;
  color: var(--muted);
}

.ov-check-stat {
  display: grid;
  gap: 2px;
  font-weight: 600;
  color: var(--check-accent);
}
.ov-check-stat b { font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: -0.035em; line-height: 1.4; }
.ov-check-stat small { font-size: 0.78rem; color: var(--muted); font-weight: 400; }

.ov-check-go {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #16385b13;
  font-size: 0.82rem;
  color: var(--navy);
  font-weight: 600;
}
.ov-check-go > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--check-tint); color: var(--check-accent); font-size: 1.1rem; }

.ov-random {
  margin-top: 20px;
  padding: 24px;
  border-radius: 20px;
  background: linear-gradient(115deg, #102b55, #214c76);
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
}
.ov-random-intro { display: flex; align-items: center; gap: 16px; }
.ov-random-intro strong { font-size: 1.05rem; }
.ov-random-icon { display: grid; place-items: center; min-width: 52px; height: 52px; background: #ffffff16; border: 1px solid #ffffff25; border-radius: 16px; font-size: 1.75rem; }
#ov-random { display: flex; align-items: center; justify-content: center; gap: 20px; min-height: 48px; padding: 12px 20px; border: 0; border-radius: 100px; background: #ffdf8b; color: #26354b; font: inherit; font-weight: 600; cursor: pointer; }
#ov-random:hover { background: #ffe9ac; }
#ov-random:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

.ov-random p {
  color: #ccdced;
  margin: 4px 0 0;
  font-size: 0.83rem;
}

.ov-random-out:empty {
  display: none;
}

.ov-random-out {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
  overflow-wrap: anywhere;
}
.ov-random-out .ov-pick-card { background: #fff; color: var(--ink); }
@media (max-width: 600px) {
  .ov-random { grid-template-columns: 1fr; padding: 20px; }
  #ov-random { width: 100%; }
  .ov-check-card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .ov-flow-seg,
  .ov-tile,
  .ov-bubble,
  .ov-dot,
  .ov-check-card,
  .ov-arc circle {
    transition: none;
    animation: none;
  }
}

/* --------------------------------------------------------------------- SEO */

.seo-content {
  padding: 56px 0 64px;
}

.seo-content h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  color: var(--navy);
  margin-bottom: 12px;
}

.seo-content > .shell > p {
  max-width: 78ch;
  color: var(--muted);
  margin-bottom: 12px;
}

.seo-faq {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.seo-faq details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 4px 18px;
}

.seo-faq details[open] {
  border-color: var(--azure);
  background: var(--azure-pale);
}

.seo-faq summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 500;
  color: var(--navy);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.seo-faq p {
  padding-bottom: 16px;
  color: var(--muted);
  max-width: 80ch;
}

/* ------------------------------------------------------------------ footer */

.site-footer { background: var(--navy-deep); color: #c6d4e9; padding: 40px 0 0; font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 88px); align-items: center; padding-bottom: 32px; }
.footer-logos { display: flex; align-items: center; gap: 24px; margin-bottom: 18px; }
.footer-logos a { display: inline-flex; }
.footer-nont-logo { width: 116px; height: 116px; object-fit: contain; }
.footer-flashthink-logo { width: 140px; height: 116px; object-fit: contain; }
.footer-logo-divider { width: 1px; height: 48px; background: #ffffff26; }
.site-footer .footer-tagline { color: var(--white); font-size: clamp(1rem, 1.6vw, 1.2rem); font-weight: 600; margin-bottom: 12px; }
.footer-description { line-height: 1.85; max-width: 66ch; }
.footer-contact { margin-top: 14px; line-height: 1.8; }
.site-footer a { color: #90c8ff; text-underline-offset: 4px; overflow-wrap: anywhere; }
.site-footer a:hover { color: var(--white); }
.site-footer a:focus-visible { outline: 3px solid var(--azure-light); outline-offset: 5px; }
.footer-thanks { border-left: 2px solid var(--azure); padding: 8px 0 8px 28px; line-height: 1.8; }
.footer-thanks-label { color: #90c8ff; font-size: .85rem; margin-bottom: 10px; }
.footer-supporter { color: var(--white); font-size: clamp(1.15rem, 2vw, 1.45rem); margin-bottom: 4px; }
.footer-thanks-note { margin-top: 10px; color: #aabdd8; }
.footer-copyright { border-top: 1px solid #ffffff20; padding: 14px 0; text-align: center; color: #aabdd8; font-size: .72rem; font-weight: 300; }
@media (max-width: 700px) {
  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .footer-thanks { padding-left: 20px; }
  .footer-logos { gap: 18px; }
}

/* ------------------------------------------------------------- breakpoints */

@media (max-width: 900px) {
  .shell {
    width: min(1200px, 100% - 32px);
  }

  /* ต่ำกว่านี้แถบที่แคบที่สุด (10.3%) เหลือราว 90 px ชื่อกับตัวเลขถูกบีบจนอ่านยาก
     จึงเรียงลงมาเป็นแนวตั้งแทน */
  .ov-flow {
    flex-direction: column;
  }

  /* เมื่อวางเรียงเป็นแนวตั้ง flex-basis: 0 ทำให้ปุ่มสูงแค่ padding
     ตัวหนังสือจึงล้นออกไปทับปุ่มถัดไป — ให้ความสูงมาจากเนื้อหาแทน */
  .ov-flow-seg {
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
    align-content: start;
    padding: 14px 16px;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
  }

  .hero .shell {
    padding: 40px 0 48px;
    min-height: 0;
  }

  .search-form {
    flex-wrap: nowrap;
    border-radius: var(--radius-md);
  }

  .search-form input[type="search"] {
    width: auto;
  }

  .site-nav {
    gap: 2px;
  }

  .site-nav a {
    padding: 0 9px;
    font-size: 0.86rem;
  }

  .hero .search-starters {
    justify-content: flex-start;
  }

  .browse-section,
  .overview,
  .seo-content {
    padding: 40px 0;
  }

  .ov-step {
    padding: 18px 16px;
  }

  .ov-nav {
    margin-top: 24px;
    padding-bottom: 12px;
  }

  .ov-route {
    width: 840px;
    min-width: 840px;
    padding-inline: 6px;
  }

  .ov-route-stop:not(:last-child)::after {
    top: 23px;
    left: calc(50% + 24px);
    right: calc(-50% + 24px);
  }

  .ov-route-link {
    min-height: 96px;
    gap: 8px;
  }

  .ov-route-marker {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .ov-route-icon {
    width: 1.35rem;
    height: 1.35rem;
  }

  .ov-route-label {
    max-width: 112px;
    font-size: 0.78rem;
  }

  .ov-route-step {
    font-size: 0.65rem;
  }

  .ov-donut-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .ov-donut {
    max-width: 280px;
    margin-inline: auto;
  }

  /* ตารางกว้าง 620 px ต้องเลื่อนแนวนอนบนมือถือ ตรึงคอลัมน์ชื่อแผนงานไว้
     ไม่งั้นเลื่อนไปแล้วไม่รู้ว่าตัวเลขเป็นของแผนงานไหน */
  .ov-matrix thead th:first-child,
  .ov-matrix tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--white);
    box-shadow: 1px 0 0 var(--line);
  }

  .ov-matrix thead th:first-child {
    z-index: 2;
    background: var(--azure-pale);
  }

  .site-footer li a,
  .site-footer .footer-brand + p a {
    display: inline-block;
    padding-block: 7px;
  }
}

@media (max-width: 480px) {
  .site-header .shell {
    gap: 8px;
  }

  .site-nav a {
    padding: 0 7px;
    font-size: 0.8rem;
  }

}

@media (max-width: 420px) {
  .hero .hero-stats {
    grid-template-columns: 1fr;
    width: min(240px, 100%);
    gap: 12px;
  }

  .quick-menu button {
    flex: 1 1 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
