:root {
  --bg: #f8fbfd;
  --surface: #ffffff;
  --surface-soft: #f6fafc;
  --text: #173044;
  --muted: #63798a;
  --border: #d9e8ef;
  --blue: #1976d2;
  --blue-soft: #e3f2fd;
  --teal: #00a6a6;
  --teal-soft: #dcf7f4;
  --green: #21a67a;
  --green-soft: #e4f8ee;
  --yellow: #f5b82e;
  --yellow-soft: #fff4d8;
  --amber: #f2a81d;
  --amber-soft: #fff3d6;
  --red: #d94d45;
  --red-soft: #fde9e7;
  --purple: #7367d5;
  --shadow: 0 12px 32px rgba(23, 48, 68, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 58%, #ffffff 100%);
  color: var(--text);
  font-family: "IBM Plex Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-loading {
  cursor: progress;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 34px;
  padding: 58px 0 34px;
}

.brand-title {
  min-width: 0;
  flex: 1 1 auto;
}

.brand-title .subtitle {
  max-width: none;
  margin-top: 6px;
  color: #111;
  font-size: clamp(1.18rem, 1.45vw, 1.56rem);
  line-height: 1.45;
  font-weight: 700;
  white-space: nowrap;
}

.brand-title h1 {
  max-width: none;
  color: #000;
  font-size: clamp(2.47rem, 2.6vw, 2.93rem);
  line-height: 1.18;
  font-weight: 700;
  white-space: nowrap;
}

.header-logo {
  width: auto;
  height: clamp(150px, 12vw, 220px);
  object-fit: contain;
  flex: 0 0 auto;
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 920px;
  font-size: clamp(2rem, 3.8vw, 4rem);
  line-height: 1.18;
  font-weight: 700;
}

h2 {
  font-size: clamp(1.35rem, 1.9vw, 1.8rem);
  line-height: 1.35;
  font-weight: 700;
}

.subtitle {
  max-width: 860px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.kpi-card,
.panel,
.filter-band {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.data-status {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 220px;
  padding: 14px 16px;
  border-radius: 18px;
}

.data-status strong,
.data-status span {
  display: block;
}

.data-status span {
  color: var(--muted);
  font-size: 0.84rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(33, 166, 122, 0.12);
}

.status-dot.is-live {
  background: #10b981;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.16);
}

.filter-band {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px;
  border-radius: 8px;
  backdrop-filter: blur(14px);
}

.mobile-filter-summary-bar,
.mobile-filter-backdrop {
  display: none;
}

.filter-panel-content {
  display: block;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus,
button:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.12);
}

.search-field {
  position: relative;
  min-width: 220px;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  display: none;
  max-height: 310px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 46, 72, 0.16);
}

.search-suggestions.is-open {
  display: grid;
  gap: 6px;
}

.search-suggestion {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.search-suggestion:hover,
.search-suggestion:focus {
  background: var(--teal-soft);
  box-shadow: none;
  transform: none;
}

.search-suggestion strong,
.search-suggestion span {
  display: block;
}

.search-suggestion strong {
  font-size: 0.98rem;
  line-height: 1.35;
}

.search-suggestion span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.search-suggestion-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, minmax(154px, 154px));
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.quick-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-filter {
  background: rgba(255, 255, 255, 0.78);
}

.quick-filter.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--blue-soft);
  color: #0d4f96;
  cursor: pointer;
  font-weight: 700;
}

.reset-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: #0d4f96;
  border-color: #0d4f96;
  color: #ffffff;
}

.reset-button:hover {
  background: #0b437f;
}

.export-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.export-button:hover {
  transform: translateY(-1px);
}

#exportExcel {
  background: #0b6f95;
  border-color: #0b6f95;
}

#exportExcel:hover {
  background: #075d7f;
  border-color: #075d7f;
}

#exportImagePreviewToggle {
  background: #b77905;
  border-color: #b77905;
  color: #ffffff;
}

#exportImagePreviewToggle:hover,
#exportImagePreviewToggle.is-active {
  background: #925f03;
  border-color: #925f03;
  color: #ffffff;
}

.export-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

#exportExcel,
#exportImagePreviewToggle,
#resetFilters {
  width: 100%;
  justify-content: center;
  gap: 6px;
  padding-inline: 10px;
  white-space: nowrap;
}

button:hover {
  background: #d6ebff;
}

#filterCaption {
  display: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.definition-strip {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(180px, 1fr);
  gap: 12px;
  margin-top: -6px;
}

.definition-strip > div {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.definition-strip strong,
.definition-strip span {
  display: block;
}

.definition-strip strong {
  color: var(--text);
  font-size: 0.94rem;
}

.definition-strip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.definition-action {
  display: grid;
  align-content: center;
  gap: 10px;
}

.definition-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #bfe1ec;
  border-radius: 8px;
  background: #f7fcfd;
  color: #095e8f;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.definition-link:hover {
  border-color: #78bfd4;
  background: #edf9fc;
  color: #064f77;
}

.definition-link-icon {
  position: relative;
  width: 15px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.definition-link-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 4px;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-35deg);
}

main {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

main > * {
  min-width: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  min-width: 0;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  min-height: 160px;
  padding: 20px 20px 18px 24px;
  border-radius: 8px;
  border-left-width: 5px;
}

.kpi-total {
  border-left-color: var(--teal);
}

.kpi-44 {
  border-left-color: var(--blue);
}

.kpi-45 {
  border-left-color: var(--yellow);
}

.kpi-watch {
  border-left-color: var(--red);
}

.kpi-label,
.kpi-card small {
  position: relative;
  z-index: 1;
  display: block;
}

.kpi-label {
  color: var(--muted);
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.45;
}

#kpi45Label {
  white-space: nowrap;
  font-size: clamp(0.88rem, 1vw, 1rem);
}

.kpi-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 14px;
  font-size: clamp(2.25rem, 4vw, 3.35rem);
  line-height: 1;
}

.kpi-card small {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.kpi-delta,
.kpi-note {
  display: block;
  margin-top: 6px;
  font-size: 0.86rem;
  font-weight: 700;
}

.kpi-delta.is-up {
  color: #177355;
}

.kpi-delta.is-down {
  color: #b13a31;
}

.kpi-delta.is-flat,
.kpi-note {
  color: var(--muted);
}

.year-context-note {
  margin: 14px 0 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--yellow);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.55;
}

.year-context-note[hidden] {
  display: none;
}

.top-visual-grid,
.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  min-width: 0;
}

.top-visual-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  min-width: 0;
}

.region-panel {
  grid-column: 1 / -1;
}

.line-panel {
  grid-column: 1 / -1;
}

.map-panel {
  grid-column: auto;
}

.status-panel {
  grid-column: auto;
  display: flex;
  flex-direction: column;
}

.status-panel .status-chart {
  flex: 1;
  align-content: center;
}

.panel {
  padding: 20px;
  border-radius: 8px;
}

.section-heading {
  display: flex;
  gap: 14px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.top-visual-grid .section-heading h2,
.analysis-grid .section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.35rem, 1.55vw, 1.7rem);
  font-weight: 700;
  line-height: 1.28;
}

.map-panel .section-heading h2 {
  white-space: nowrap;
}

.metric-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #087b78;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.map-placeholder {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 280px;
  padding: 24px;
  border: 1px dashed #9ccddb;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(227, 242, 253, 0.88), rgba(220, 247, 244, 0.82)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255, 255, 255, 0.55) 12px 24px);
}

.map-placeholder strong {
  display: block;
  font-size: 1.12rem;
}

.map-placeholder p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.thai-map-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(280px, 430px);
  gap: 28px;
  align-items: center;
  justify-content: center;
  max-width: 900px;
  margin: 0 auto;
  min-height: 0;
}

.map-panel .thai-map-layout {
  display: block;
  max-width: none;
  margin: 0;
}

.map-panel .map-insight {
  display: none;
}

.thai-map-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  justify-items: center;
  min-width: 0;
  min-height: 0;
}

.thai-map-svg {
  width: min(100%, 380px);
  height: auto;
  aspect-ratio: 480 / 700;
  min-height: 0;
  border-radius: 8px;
  background: #ffffff;
}

.map-panel .thai-map-svg {
  width: min(100%, 360px);
}

.map-panel .thai-map-svg.is-region-view {
  width: min(100%, 440px);
}

.map-panel .thai-map-card {
  justify-items: center;
}

.map-panel .map-legend {
  width: min(100%, 300px);
}

.thai-map-svg path {
  cursor: pointer;
  stroke: #ffffff;
  stroke-width: 0.7;
  transition: fill 0.18s ease, opacity 0.18s ease, stroke 0.18s ease;
  vector-effect: non-scaling-stroke;
}

.thai-map-svg path:hover {
  opacity: 0.76;
}

.thai-map-svg path.is-muted {
  opacity: 0.2;
}

.thai-map-svg path.is-selected {
  stroke: #122420;
  stroke-width: 2.1;
}

.thai-map-svg text.map-label {
  fill: #173044;
  font-weight: 700;
  pointer-events: none;
  text-anchor: middle;
}

.thai-map-svg text.map-label-value {
  font-weight: 800;
}

.map-legend {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.map-legend-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--legend-from, #e7f4f2), var(--legend-to, var(--teal)));
}

.map-insight {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #ffffff;
}

.map-insight span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.map-insight strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.25;
}

.map-insight p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.7;
}

.map-reset {
  align-self: flex-start;
  background: var(--teal-soft);
  border-color: #b8e8e3;
  color: #087b78;
}

.map-reset-icon {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #c9e6e3;
  color: #087b78;
  box-shadow: 0 10px 28px rgba(15, 46, 72, 0.12);
  font-size: 1.18rem;
  font-weight: 900;
}

.map-reset-icon:hover:not(:disabled) {
  background: var(--teal-soft);
  border-color: #9bdad4;
  transform: translateY(-1px);
}

.map-reset-icon:disabled {
  opacity: 0;
  pointer-events: none;
}

.map-shape {
  position: relative;
  width: 120px;
  height: 230px;
  margin: 0 auto;
}

.map-shape span {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(33, 166, 122, 0.95), rgba(25, 118, 210, 0.82));
  box-shadow: 0 16px 32px rgba(25, 118, 210, 0.20);
}

.map-shape span:nth-child(1) { left: 38px; top: 0; width: 48px; height: 74px; }
.map-shape span:nth-child(2) { left: 18px; top: 48px; width: 70px; height: 88px; transform: rotate(-16deg); }
.map-shape span:nth-child(3) { left: 52px; top: 112px; width: 46px; height: 68px; transform: rotate(14deg); }
.map-shape span:nth-child(4) { left: 62px; top: 168px; width: 32px; height: 56px; transform: rotate(-10deg); }
.map-shape span:nth-child(5) { left: 82px; top: 208px; width: 20px; height: 20px; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 26px;
  height: 9px;
  border-radius: 999px;
}

.swatch-44 {
  background: linear-gradient(90deg, var(--blue), #4aa3ff);
}

.swatch-45 {
  background: linear-gradient(90deg, var(--yellow), #ffd966);
}

.swatch-watch {
  background: linear-gradient(90deg, var(--red), #f07b72);
}

.vertical-chart {
  display: block;
  min-height: 430px;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  position: relative;
}

.region-svg {
  display: block;
  width: 100%;
  min-width: 980px;
  height: 430px;
}

.axis-line,
.grid-line {
  stroke: #d9e8ef;
  stroke-width: 1;
}

.axis-text {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.axis-category-label {
  fill: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.axis-title-label {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.bar-value-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.bar-value-label.is-muted,
.region-bar-44.is-muted,
.region-bar-45.is-muted {
  opacity: 0.28;
}

.axis-text.is-selected {
  fill: var(--text);
  font-weight: 800;
}

.region-highlight {
  fill: rgba(0, 166, 166, 0.08);
}

.region-bar-44 {
  fill: var(--blue);
}

.region-bar-45 {
  fill: var(--yellow);
}

.region-bar-watch {
  fill: var(--red);
}

.trend-placeholder {
  min-height: 430px;
}

.trend-svg {
  display: block;
  width: 100%;
  height: 430px;
}

.trend-load-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.trend-axis,
.trend-grid {
  stroke: #d9e8ef;
  stroke-width: 1;
}

.trend-line-44 {
  fill: none;
  stroke: var(--blue);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-line-45 {
  fill: none;
  stroke: var(--yellow);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-line-watch {
  fill: none;
  stroke: var(--red);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-dot-44 {
  fill: var(--blue);
}

.trend-dot-45 {
  fill: var(--yellow);
}

.trend-dot-watch {
  fill: var(--red);
}

.trend-label {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.trend-value {
  fill: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.trend-value-school {
  fill: #8a6400;
}

.trend-value-lpa {
  fill: #0d4f96;
}

.trend-value-44 {
  fill: #0d4f96;
}

.trend-value-45 {
  fill: #8a6400;
}

.trend-value-watch {
  fill: #a63832;
}

.trend-marker {
  stroke: #9fb3c0;
  stroke-width: 1.4;
  stroke-dasharray: 6 6;
}

.trend-marker-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.ranking-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.ranking-pagination button,
.page-controls button {
  min-width: 42px;
  padding-inline: 12px;
  font-size: 1.05rem;
}

#rankPageInfo {
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-note {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.rank-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  width: min(100%, 560px);
}

.province-ranking-panel .section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  justify-content: start;
}

.province-ranking-panel .section-heading h2 {
  max-width: 920px;
  font-size: clamp(1.35rem, 1.55vw, 1.7rem);
  line-height: 1.28;
}

.province-ranking-panel .rank-controls {
  width: min(100%, 640px);
}

.rank-item {
  display: grid;
  grid-template-columns: 40px minmax(160px, 1fr) minmax(260px, 48%);
  gap: 18px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #edf3f6;
}

.rank-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--blue-soft);
  color: #0d4f96;
  font-weight: 800;
}

.rank-title strong,
.rank-title span {
  display: block;
}

.rank-title span {
  color: var(--muted);
  font-size: 0.84rem;
}

.mini-track {
  height: 10px;
  border-radius: 999px;
  background: #edf5f8;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.rank-positive .mini-fill {
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.rank-positive .rank-no {
  background: var(--green-soft);
  color: #177355;
}

.rank-value {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.status-chart {
  display: grid;
  gap: 14px;
}

.donut-wrap {
  display: grid;
  gap: 24px;
  justify-items: center;
}

.donut {
  width: min(320px, 82%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 1deg, var(--amber) 1deg 2deg, var(--red) 2deg 3deg);
  display: grid;
  place-items: center;
}

.donut::before {
  content: "";
  width: 58%;
  height: 58%;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--border);
}

.legend-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: min(520px, 100%);
}

.legend-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.legend-item strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.legend-percent {
  min-width: 64px;
  text-align: right;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.district-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.district-empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 230px;
  padding: 28px;
  border: 1px dashed #b9dbe8;
  border-radius: 8px;
  background: #fbfdfe;
  color: var(--muted);
  text-align: center;
}

.district-empty-icon {
  position: relative;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border: 3px solid #78bfd4;
  border-radius: 50%;
}

.district-empty-icon::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 1px;
  width: 16px;
  height: 3px;
  border-radius: 999px;
  background: #78bfd4;
  transform: rotate(45deg);
  transform-origin: left center;
}

.district-empty strong {
  color: var(--text);
  font-size: 1.18rem;
}

.district-empty p {
  max-width: 420px;
  margin: 8px auto 0;
  line-height: 1.7;
}

.district-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(247, 251, 255, 0.76);
}

.district-item strong,
.district-item span {
  display: block;
}

.district-item span {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 4px;
}

.table-panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #edf3f6;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

td {
  line-height: 1.55;
}

.area-cell strong,
.area-cell span,
.name-cell strong,
.name-cell span {
  display: block;
}

.area-cell span,
.name-cell span,
.score-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.status-badge.pass {
  background: var(--green-soft);
  color: #177355;
}

.status-badge.fail,
.status-badge.follow {
  background: var(--amber-soft);
  color: #9b6500;
}

.status-badge.both {
  background: var(--red-soft);
  color: #a63832;
}

.status-badge.missing,
.status-badge.issue {
  background: var(--red-soft);
  color: #a63832;
}

.status-badge.cut {
  background: var(--blue-soft);
  color: #0d4f96;
}

.status-badge.ok {
  background: var(--teal-soft);
  color: #087b78;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  justify-content: space-between;
  padding-top: 16px;
}

.pagination-bar label {
  width: 150px;
}

.page-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#pageInfo {
  color: var(--muted);
  font-size: 0.9rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.export-preview-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.export-preview-panel[hidden] {
  display: none;
}

.export-preview-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(13, 33, 48, 0.42);
  backdrop-filter: blur(5px);
  cursor: default;
}

.export-preview-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 1380px);
  max-height: min(92vh, 900px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 28px 72px rgba(15, 46, 72, 0.25);
}

body.export-modal-open {
  overflow: hidden;
}

.export-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.export-preview-toolbar div {
  display: grid;
  gap: 2px;
}

.export-preview-toolbar strong {
  font-size: 1rem;
}

.export-preview-toolbar span {
  color: var(--muted);
  font-size: 0.86rem;
}

.export-preview-toolbar button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #0d4f99;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.export-close-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.export-modal-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.export-format-group {
  display: inline-flex;
  width: fit-content;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7fbfd;
}

.export-format-option {
  min-width: 70px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #0d4f99;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

.export-format-option.is-active {
  background: var(--teal);
  color: #ffffff;
}

.export-download-button {
  min-width: 132px;
  justify-content: center;
  background: #0d4f99;
  color: #ffffff;
}

.export-slide-frame {
  overflow: auto;
  padding: 18px;
  border-radius: 10px;
  background: #edf4f7;
  max-height: min(74vh, 760px);
}

.export-preview-image {
  display: block;
  width: 1280px;
  height: 720px;
  background: #ffffff;
  border: 1px solid #d7e7ee;
  box-shadow: 0 18px 42px rgba(23, 48, 68, 0.12);
}

.export-slide {
  width: 1280px;
  aspect-ratio: 16 / 9;
  display: grid;
  grid-template-rows: auto 90px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 26px 28px 24px;
  background: #fff;
  color: var(--text);
  font-family: "IBM Plex Sans Thai", Tahoma, sans-serif;
  border: 1px solid #d7e7ee;
  box-shadow: 0 18px 42px rgba(23, 48, 68, 0.12);
}

.export-slide-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

.export-slide-header h2 {
  margin: 0;
  color: #000;
  font-size: 1.72rem;
  line-height: 1.18;
  font-weight: 700;
}

.export-slide-header p {
  margin: 6px 0 0;
  color: #111;
  font-size: 0.98rem;
  font-weight: 700;
}

.export-slide-header aside {
  display: grid;
  align-content: center;
  min-height: 76px;
  padding: 12px 14px;
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #f8fcfd;
}

.export-slide-header aside span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.45;
}

.export-slide-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.export-slide-kpi {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #fff;
}

.export-kpi-blue { border-left-color: var(--blue); }
.export-kpi-yellow { border-left-color: var(--yellow); }
.export-kpi-red { border-left-color: var(--red); }

.export-slide-kpi span,
.export-slide-kpi small {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.26;
}

.export-slide-kpi strong {
  font-size: 1.72rem;
  line-height: 1;
}

.export-slide-main {
  min-height: 0;
  display: grid;
  gap: 12px;
}

.export-slide-country .export-slide-main {
  grid-template-columns: 36% minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.export-slide-area .export-slide-main {
  grid-template-columns: 30% minmax(0, 1.2fr) 27%;
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.export-slide-card {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.export-slide-card h3 {
  margin: 0;
  min-width: 0;
  font-size: 0.96rem;
  line-height: 1.18;
  overflow-wrap: break-word;
}

.export-slide-card-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.export-slide-card-heading span {
  flex: 0 0 auto;
  justify-self: end;
  max-width: 90px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: #007b7b;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.12;
  text-align: center;
  white-space: normal;
}

.export-slide-map-card {
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.export-slide-trend-card,
.export-slide-bar-card {
  display: grid;
  grid-template-rows: 28px minmax(0, 1fr);
  gap: 4px;
}

.export-slide-area .export-slide-trend-card {
  grid-column: 2;
  grid-row: 1;
}

.export-slide-area .export-slide-bar-card {
  grid-column: 2;
  grid-row: 2;
}

.export-slide-detail {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.export-slide-map,
.export-slide-chart {
  min-height: 0;
  display: grid;
  align-items: stretch;
  justify-items: stretch;
}

.export-slide-chart {
  width: 100%;
  height: 100%;
}

.export-slide .export-cloned-svg {
  width: 104%;
  height: 100%;
  max-height: 100%;
}

.export-slide .export-map-svg {
  width: 92%;
  height: 100%;
  max-height: 370px;
}

.export-slide-country .export-map-svg {
  max-height: 430px;
}

.export-slide .export-region-svg,
.export-slide .export-trend-svg {
  width: 112%;
  max-width: none;
}

.export-compact-bar-svg,
.export-compact-trend-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.export-chart-grid {
  stroke: #dcebf2;
  stroke-width: 1;
}

.export-chart-axis-line {
  stroke: #c9dde7;
  stroke-width: 1.2;
}

.export-chart-axis,
.export-chart-value {
  fill: var(--text);
  font-family: "IBM Plex Sans Thai", sans-serif;
}

.export-chart-axis {
  font-size: 12px;
  font-weight: 700;
}

.export-chart-category {
  font-size: 13px;
}

.export-chart-y-title {
  fill: var(--muted);
}

.export-chart-value {
  font-size: 12px;
  font-weight: 800;
}

.export-bar-lpa {
  fill: var(--blue);
}

.export-bar-school {
  fill: var(--yellow);
}

.export-bar-watch {
  fill: var(--red);
}

.export-trend-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-trend-dot {
  stroke: #fff;
  stroke-width: 2;
}

.export-trend-lpa {
  stroke: var(--blue);
  fill: var(--blue);
}

.export-trend-school {
  stroke: var(--yellow);
  fill: var(--yellow);
}

.export-trend-watch {
  stroke: var(--red);
  fill: var(--red);
}

.export-trend-value {
  font-size: 12px;
}

.export-trend-marker {
  stroke: #b9cfda;
  stroke-dasharray: 5 5;
}

.export-trend-marker-label {
  fill: var(--muted);
  font-family: "IBM Plex Sans Thai", sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.export-chart-highlight {
  fill: var(--teal-soft);
}

.export-slide .trend-load-note {
  display: none;
}

.export-slide-map-note {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.export-detail-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: hidden;
}

.export-detail-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 82px 44px;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf3f6;
}

.export-detail-rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #007b7b;
  font-size: 0.78rem;
  font-weight: 700;
}

.export-detail-row strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.2;
}

.export-detail-row small {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}

.export-detail-bar {
  height: 8px;
  border-radius: 999px;
  background: #e7f3f3;
  overflow: hidden;
}

.export-detail-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.export-detail-row > span:last-child {
  text-align: right;
  font-size: 0.78rem;
  font-weight: 700;
}

.export-slide-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.export-slide-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.72rem;
}

@media (max-width: 1100px) {
  .brand-title h1 {
    white-space: normal;
  }

  .brand-title .subtitle {
    white-space: normal;
  }

  .map-panel .section-heading h2 {
    white-space: normal;
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-grid,
  .top-visual-grid,
  .analysis-grid,
  .definition-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .region-panel {
    grid-column: 1 / -1;
  }

  .thai-map-layout {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    max-width: 540px;
    min-height: 0;
  }

  .thai-map-svg {
    width: min(100%, 340px);
    min-height: 0;
  }

  .vertical-chart {
    overflow-x: auto;
    padding-inline: 0;
  }

  .export-preview-panel {
    padding: 14px;
  }

  .export-preview-dialog {
    max-height: 94vh;
  }

  .export-modal-actions {
    grid-template-columns: 1fr;
  }

  .export-format-group,
  .export-modal-actions button {
    width: 100%;
  }

  .export-format-option {
    flex: 1;
  }
}

@media (max-width: 1400px) and (min-width: 761px) {
  .app-shell {
    width: min(100% - 40px, 1480px);
  }

  .page-header {
    gap: 22px;
    padding: 42px 0 28px;
  }

  .brand-title h1 {
    font-size: clamp(2rem, 3vw, 2.35rem);
    line-height: 1.2;
    white-space: normal;
  }

  .brand-title .subtitle {
    font-size: clamp(0.98rem, 1.55vw, 1.16rem);
    line-height: 1.42;
    white-space: normal;
  }

  .header-logo {
    height: clamp(104px, 10vw, 150px);
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search-field {
    min-width: 0;
  }

  .filter-actions {
    grid-template-columns: minmax(0, 1fr) repeat(3, minmax(142px, 142px));
  }

  .quick-filter-group {
    gap: 8px;
  }

  .quick-filter,
    #resetFilters,
    #exportExcel,
    #exportImagePreviewToggle {
    padding-inline: 12px;
    font-size: 0.86rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-card {
    min-height: 144px;
  }

  .top-visual-grid,
  .analysis-grid {
    gap: 16px;
  }

  .top-visual-grid .section-heading h2,
  .analysis-grid .section-heading h2 {
    font-size: clamp(1.25rem, 1.85vw, 1.55rem);
  }

  .map-panel .section-heading {
    align-items: start;
  }

  .map-panel .section-heading h2 {
    white-space: normal;
  }

  .metric-pill {
    flex: 0 0 auto;
  }

  .map-panel .thai-map-svg {
    width: min(100%, 330px);
  }

  .map-panel .thai-map-svg.is-region-view {
    width: min(100%, 390px);
  }

  .status-panel .status-chart {
    align-content: start;
  }

  .donut-wrap {
    gap: 28px;
    padding-bottom: 12px;
  }

  .donut {
    width: min(300px, 76%);
  }

  .legend-list {
    width: min(460px, 100%);
  }

  .version-badge {
    right: 18px;
    bottom: 18px;
  }
}

@media (max-width: 1024px) and (orientation: portrait) {
  .app-shell {
    width: min(100% - 28px, 1480px);
    padding: 14px 0;
  }

  .page-header {
    gap: 18px;
    padding: 22px 0 16px;
  }

  .brand-title h1 {
    font-size: clamp(1.45rem, 3.9vw, 2.05rem);
  }

  .subtitle {
    margin-top: 4px;
    font-size: clamp(0.78rem, 1.95vw, 1.02rem);
    line-height: 1.45;
  }

  .header-logo {
    width: auto;
    height: clamp(92px, 13vw, 132px);
    margin-top: 0;
  }

  .data-status {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .filter-band {
    padding: 10px;
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 10px;
  }

  label span {
    margin-bottom: 3px;
    font-size: 0.72rem;
  }

  select,
  input {
    min-height: 34px;
    padding: 6px 9px;
    border-radius: 10px;
    font-size: 0.86rem;
  }

  .search-field {
    min-width: 0;
  }

  .filter-actions {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
  }

  .quick-filter-group {
    gap: 6px;
  }

  .quick-filter,
  #resetFilters {
    min-height: 32px;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 0.8rem;
  }

  #filterCaption {
    margin-left: auto;
    font-size: 0.78rem;
  }

  .definition-strip {
    gap: 8px;
    margin-top: -8px;
  }

  .definition-strip > div {
    padding: 10px 12px;
  }

  .definition-strip span {
    font-size: 0.78rem;
    line-height: 1.45;
  }

  .kpi-card {
    min-height: 124px;
    padding: 16px;
  }

  .kpi-card strong {
    margin-top: 10px;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1480px);
    padding: 12px 0;
  }

  .page-header {
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0 10px;
  }

  .brand-title h1 {
    font-size: clamp(1.18rem, 5.8vw, 1.55rem);
    line-height: 1.22;
  }

  .subtitle {
    margin-top: 5px;
    font-size: clamp(0.62rem, 2.9vw, 0.78rem);
    line-height: 1.42;
  }

  .header-logo {
    width: auto;
    height: 72px;
    margin-top: 2px;
  }

  .data-status {
    min-width: 0;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .page-header,
  .kpi-grid,
  .top-visual-grid,
  .analysis-grid,
  .map-placeholder,
  .thai-map-layout,
  .donut-wrap,
  .definition-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-band {
    position: sticky;
    top: 0;
    padding: 8px;
    overflow: visible;
    box-shadow: 0 8px 22px rgba(23, 48, 68, 0.08);
  }

  .mobile-filter-summary-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-filter-summary-bar span,
  .mobile-filter-summary-bar strong {
    display: block;
  }

  .mobile-filter-summary-bar span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .mobile-filter-summary-bar strong {
    margin-top: 2px;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .mobile-filter-toggle {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 6px 12px;
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
  }

  .filter-panel-content {
    display: none;
  }

  .filter-band.is-mobile-open {
    position: fixed;
    inset: auto 12px 12px;
    z-index: 80;
    max-height: min(82vh, 680px);
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
    background: #ffffff;
  }

  .filter-band.is-mobile-open .filter-panel-content {
    display: block;
    margin-top: 12px;
  }

  .mobile-filter-backdrop.is-visible {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    border: 0;
    border-radius: 0;
    background: rgba(23, 48, 68, 0.28);
    cursor: pointer;
  }

  body.has-mobile-filter-open {
    overflow: hidden;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  label span {
    margin-bottom: 3px;
    font-size: 0.72rem;
  }

  select,
  input {
    min-height: 32px;
    padding: 5px 8px;
    border-radius: 10px;
    font-size: 0.86rem;
  }

  .search-field {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .filter-actions {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 6px;
  }

  .quick-filter-group {
    display: grid;
    flex: 1 1 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .quick-filter {
    width: 100%;
    min-height: 30px;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #resetFilters,
  #exportExcel,
  #exportImagePreviewToggle {
    justify-self: stretch;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
  }

  #filterCaption {
    font-size: 0.76rem;
  }

  .definition-strip {
    gap: 8px;
    margin-top: -6px;
  }

  .definition-strip > div {
    padding: 10px 12px;
  }

  .definition-strip strong {
    font-size: 0.86rem;
  }

  .definition-strip span {
    font-size: 0.76rem;
    line-height: 1.45;
  }

  .thai-map-layout {
    gap: 10px;
  }

  .thai-map-svg {
    width: min(100%, 300px);
    min-height: 0;
  }

  .map-insight {
    padding: 12px;
  }

  .map-insight strong {
    font-size: 1.22rem;
  }

  .map-insight p {
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .map-reset {
    width: 100%;
  }

  .vertical-chart {
    min-height: 310px;
    overflow-x: auto;
  }

  .region-svg {
    height: 310px;
    min-width: 900px;
  }

  .trend-placeholder {
    min-height: 340px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .trend-svg {
    height: 340px;
    min-width: 680px;
  }

  .section-heading {
    flex-direction: column;
  }

  .rank-controls {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .rank-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .rank-visual {
    grid-column: 2;
  }
}

.page-footer {
  margin-top: 34px;
  padding: 28px 12px 34px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.8;
}

.page-footer p {
  margin: 4px 0;
}

.footer-live {
  display: none;
  margin-top: 12px;
  color: #9aa9b4;
  font-size: 0.84rem;
}

.version-badge {
  position: fixed;
  right: 12px;
  bottom: 10px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(196, 218, 229, 0.9);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.84);
  color: #7b8e9c;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(23, 48, 68, 0.08);
}

.version-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #8fb6c7;
  box-shadow: 0 0 0 4px rgba(143, 182, 199, 0.18);
}

.version-status-dot.is-static,
.version-status-dot.is-live {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.16);
}

.version-status-dot.is-cache {
  background: #f5b82e;
  box-shadow: 0 0 0 4px rgba(245, 184, 46, 0.18);
}

.version-status-dot.is-checking {
  background: #1976d2;
  box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.14);
}

.version-status-dot.is-updating {
  background: #8b5cf6;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.16);
}

.version-status-dot.is-fallback,
.version-status-dot.is-error {
  background: #d94d45;
  box-shadow: 0 0 0 4px rgba(217, 77, 69, 0.16);
}

.version-status-dot.is-loading {
  background: #1976d2;
  box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.14);
}

.inline-control {
  min-width: 0;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(248, 251, 253, 0.72);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(360px, 100%);
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 50px rgba(23, 48, 68, 0.12);
  text-align: center;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #d9e8ef;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-card strong {
  color: var(--text);
  font-size: 1.05rem;
}

#loadingText {
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-retry {
  margin-top: 4px;
  border-color: #b8d7ea;
  background: #e9f5fc;
  color: var(--blue-deep);
  font-size: 0.9rem;
}

.loading-retry[hidden] {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
