html[data-theme="light"], :root {
  --bg: #F2F6FC;
  --bg2: #EFF4FB;
  --header: rgba(244,246,242,0.86);
  --surface: #ffffff;
  --bd: #E4E9E3;
  --bd2: #DCE3DC;
  --hover: #F5F9F6;
  --ink: #16233D;
  --text: #54655F;
  --muted: #8A9993;
  --on-brand: #ffffff;
  --brand: #1B5FD1;
  --brand-d: #164FB0;
  --accent: #2E90E8;
  --tint: #E8F0FC;
  --tint-bd: #C9DEFA;
  --dark: #14213D;
  --chart: #6FB4FF;
  --brand-blue: #2E90E8;
}
html[data-theme="dark"] {
  --bg: #0C0C0D;
  --bg2: #141416;
  --header: rgba(12,12,13,0.86);
  --surface: #161619;
  --bd: #28282C;
  --bd2: #33333A;
  --hover: #202024;
  --ink: #F4F4F5;
  --text: #B7B7BE;
  --muted: #8B8B93;
  --on-brand: #0C0C0D;
  --brand: #F4F4F5;
  --brand-d: #D4D4D8;
  --accent: #E4E4E7;
  --tint: #202024;
  --tint-bd: #33333A;
  --dark: #050506;
  --chart: #E4E4E7;
  --brand-blue: #2E90E8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-d); }
.mono { font-family: 'IBM Plex Mono', monospace; }

/* Top loading bar (shown while navigating to a page that needs to hit the SEC API) — no dimming,
   page stays fully visible underneath. */
.loading-bar-top {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999;
  background: transparent; display: none; pointer-events: none;
}
.loading-bar-top.show { display: block; }
.loading-bar-top-fill {
  height: 100%; width: 0%; background: var(--brand); transition: width 0.2s ease-out;
  box-shadow: 0 0 8px rgba(27,95,209,0.55);
}
.loading-retry-toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 9999;
  border: 1px solid var(--bd2); background: var(--surface); color: var(--ink);
  font-family: 'Sarabun', sans-serif; font-size: 13.5px; font-weight: 600; padding: 9px 20px; border-radius: 999px;
  cursor: pointer; box-shadow: 0 12px 30px -10px rgba(20,35,31,0.35);
}
.loading-retry-toast:hover { border-color: var(--brand); color: var(--brand); }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--header); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bd);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.brand-dot { color: var(--brand-blue); }
.topnav { display: flex; align-items: center; gap: 20px; }
.topnav a { font-size: 15px; font-weight: 500; color: var(--text); }
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--bd2);
  background: var(--surface); cursor: pointer; color: var(--ink);
}
.theme-toggle:hover { border-color: var(--brand); }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }

.container { max-width: 1180px; margin: 0 auto; padding: 36px 28px 64px; }

/* Hero / search */
.hero { text-align: center; padding: 40px 0 8px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; background: var(--tint); border: 1px solid var(--tint-bd);
  color: var(--brand); font-size: 13.5px; font-weight: 600; padding: 7px 14px; border-radius: 999px; margin-bottom: 22px;
}
.hero-badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(46,144,232,0.18); }
.hero h1 { font-size: 34px; line-height: 1.3; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 14px; color: var(--ink); }
.hero-sub { font-size: 16px; line-height: 1.6; color: var(--text); margin: 0 auto 32px; max-width: 560px; }

.search-box-wrap { position: relative; max-width: 620px; margin: 0 auto; }
.search-box {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--bd2);
  border-radius: 16px; padding: 6px 6px 6px 18px; box-shadow: 0 12px 40px -18px rgba(27,95,209,0.25);
}
.search-box.focused { border-color: var(--brand); }
.search-icon { flex-shrink: 0; color: var(--brand); }
.search-box input {
  flex: 1; border: none; outline: none; font-family: 'Sarabun', sans-serif; font-size: 17px;
  color: var(--ink); background: transparent; padding: 12px 0;
}
.search-btn {
  border: none; cursor: pointer; font-family: 'Sarabun', sans-serif; font-size: 15px; font-weight: 700;
  color: var(--on-brand); background: var(--brand); padding: 12px 24px; border-radius: 11px;
}

.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 10px); z-index: 20;
  background: var(--surface); border: 1px solid var(--bd); border-radius: 16px;
  box-shadow: 0 24px 60px -24px rgba(20,35,31,0.35); overflow: hidden; text-align: left;
}
.result-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; border-bottom: 1px solid var(--bd); color: var(--ink); text-decoration: none;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover, .result-item.kb-active { background: var(--hover); }
.result-avatar {
  width: 38px; height: 38px; border-radius: 10px; background: var(--tint); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: var(--brand);
}
.result-text { min-width: 0; }
.result-abbr { font-size: 15px; font-weight: 700; color: var(--ink); }
.result-name { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.no-results, .search-error { padding: 22px 18px; text-align: center; color: var(--muted); font-size: 14.5px; }

.chips { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.chips-label { font-size: 13.5px; color: var(--muted); }
.chip {
  border: 1px solid var(--bd2); background: var(--surface); cursor: pointer; font-family: 'Sarabun', sans-serif;
  font-size: 13px; font-weight: 600; color: var(--text); padding: 6px 14px; border-radius: 999px;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* Popular funds (index) */
.popular-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.popular-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.popular-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0; color: var(--ink); }
.popular-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.popular-card {
  display: block; background: var(--surface); border: 1px solid var(--bd); border-radius: 18px; padding: 20px;
  text-decoration: none; color: inherit;
}
.popular-card:hover { border-color: var(--brand); }
.popular-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.popular-card-titles { min-width: 0; }
.popular-card-abbr { font-size: 15.5px; font-weight: 800; color: var(--ink); }
.popular-card-amc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popular-card-name { font-size: 13px; color: var(--text); margin: 12px 0 14px; }
.popular-card-foot { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--bd); }
.popular-card-nav { font-size: 16.5px; font-weight: 700; color: var(--ink); }
.popular-card-pct { font-size: 14.5px; font-weight: 700; }
.popular-card-pct.up { color: #16A34A; }
.popular-card-pct.down { color: #E5484D; }

/* Marketing sections (index) */
.section { padding: 64px 0 8px; }
.section-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; text-align: center; }
.section-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0 auto 40px; text-align: center; color: var(--ink); max-width: 560px; }

.feature-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--bd); border-radius: 20px; padding: 26px;
}
.feature-card.feature-dark {
  grid-row: span 2; background: var(--dark); border: none; color: #EAF1EE; display: flex; flex-direction: column; justify-content: space-between;
}
.feature-icon {
  width: 42px; height: 42px; border-radius: 12px; background: var(--tint); display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.feature-dark .feature-icon { background: rgba(46,144,232,0.18); }
.feature-card h3 { font-size: 18px; font-weight: 800; margin: 0 0 6px; color: var(--ink); }
.feature-dark h3 { color: #fff; }
.feature-card p { font-size: 14px; line-height: 1.6; color: var(--text); margin: 0; }
.feature-dark p { color: #9FB4AD; }
.feature-wide { grid-column: span 2; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.feature-wide .feature-item { display: flex; gap: 12px; }

.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step-card { background: var(--surface); border: 1px solid var(--bd); border-radius: 18px; padding: 26px; }
.step-num { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 600; color: var(--accent); margin-bottom: 14px; }
.step-card h3 { font-size: 18px; font-weight: 800; margin: 0 0 6px; color: var(--ink); }
.step-card p { font-size: 14px; line-height: 1.6; color: var(--text); margin: 0; }

/* Fund detail head */
.fund-head { padding: 8px 0 24px; }
.fund-head-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 20px; }
.fund-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; color: var(--ink); }
.fund-fullname { font-size: 16px; font-weight: 600; color: var(--ink); }
.fund-fullname-en { font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.fund-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tag {
  font-size: 12.5px; font-weight: 600; color: var(--brand); background: var(--tint); border: 1px solid var(--tint-bd);
  padding: 5px 12px; border-radius: 999px;
}
.tag-amc { color: var(--text); background: var(--surface); border-color: var(--bd2); }
.tag-new { color: #16A34A; background: rgba(22,163,74,0.1); border-color: rgba(22,163,74,0.3); white-space: nowrap; }
.feeder-note { font-size: 13.5px; color: var(--text); margin-top: 14px; }
.master-fund-link { color: var(--brand); font-weight: 700; }
.master-fund-link:hover { text-decoration: underline; }

.price-box { background: var(--surface); border: 1px solid var(--bd); border-radius: 16px; padding: 16px 22px; text-align: right; flex-shrink: 0; }
.price-value { font-family: 'IBM Plex Mono', monospace; font-size: 27px; font-weight: 600; color: var(--ink); line-height: 1; }
.price-ccy { font-family: 'Sarabun', sans-serif; font-size: 14px; font-weight: 500; color: var(--muted); }
.price-date { font-size: 12px; color: var(--muted); margin-top: 8px; }

.card { background: var(--surface); border: 1px solid var(--bd); border-radius: 18px; padding: 22px 24px; margin-bottom: 16px; }
.card h3 { margin: 0 0 4px; font-size: 17px; font-weight: 800; color: var(--ink); }

.link-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.link-card {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid var(--bd2); border-radius: 12px;
  text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600;
}
.link-card:hover { border-color: var(--brand); background: var(--tint); }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--bd); }
.tbl thead th { border-top: none; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; }

.bar-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--bd); }
.bar-row:first-child { border-top: none; }
.bar-seq { width: 24px; font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.bar-name { flex: 1; font-size: 14.5px; font-weight: 600; color: var(--ink); min-width: 0; }
.bar-track { width: 120px; height: 8px; border-radius: 99px; background: var(--tint); overflow: hidden; flex-shrink: 0; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.bar-ratio { width: 60px; text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 600; color: var(--ink); flex-shrink: 0; }

.party-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--bd); }
.party-row:first-child { border-top: none; }
.party-role { font-size: 13.5px; color: var(--muted); }
.party-name { font-size: 14.5px; font-weight: 600; color: var(--ink); text-align: right; }

.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.fund-note { color: var(--text); font-size: 14px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--bd);
  border: 1px solid var(--bd); border-radius: 12px; overflow: hidden; margin-top: 4px;
}
.stat-grid > div { background: var(--surface); padding: 16px; }
.stat-grid .muted { font-size: 12.5px; display: block; margin-bottom: 4px; }
.stat-grid .mono { font-size: 17px; font-weight: 600; color: var(--ink); }

.mini-tab-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--bd); padding-bottom: 0; }
.mini-tab {
  border: none; border-bottom: 2px solid transparent; background: transparent; cursor: pointer;
  font-family: 'Sarabun', sans-serif; font-size: 14.5px; font-weight: 500; color: var(--muted);
  padding: 8px 12px; margin-bottom: -1px;
}
.mini-tab.active { border-bottom-color: var(--brand); color: var(--ink); font-weight: 700; }
.plain-list { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.9; color: var(--ink); }

.gauge-panel { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.gauge-svg-wrap { width: 220px; flex-shrink: 0; text-align: center; }
.gauge-caption { font-size: 15px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.gauge-caption .mono { color: var(--brand); font-size: 22px; }
.gauge-desc { flex: 1; min-width: 240px; font-size: 15px; line-height: 1.65; color: var(--text); margin: 0; }

.tf-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 14px; }
.tf-btn {
  border: 1px solid var(--bd2); background: transparent; cursor: pointer; font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px; font-weight: 600; color: var(--text); padding: 6px 13px; border-radius: 8px;
}
.tf-btn:hover { border-color: var(--brand); color: var(--brand); }
.tf-btn.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.eq-chart { display: block; width: 100%; height: 220px; cursor: crosshair; }
.eq-line { fill: none; stroke: var(--chart); stroke-width: 2.5; }
.eq-area { fill: var(--chart); opacity: 0.22; }
.eq-grid { stroke: var(--bd); stroke-width: 1; stroke-dasharray: 3 3; }
.eq-frame { fill: none; stroke: var(--bd2); stroke-width: 1; }
.eq-axis-label { font-size: 9px; fill: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.eq-crosshair-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
.eq-crosshair-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 1.5; pointer-events: none; }
.eq-crosshair-tip-bg { fill: var(--surface); stroke: var(--bd); stroke-width: 1; pointer-events: none; }
.eq-crosshair-tip-text { font-size: 9px; fill: var(--ink); font-family: 'IBM Plex Mono', monospace; pointer-events: none; }

/* ── Sector Rotation (RRG) page ─────────────────────────────────────── */
/* semantic quadrant colors — readable ทั้ง light & dark (medium saturation) */
:root {
  --q-leading: #1f9d5f; --q-weakening: #cf9b2e; --q-lagging: #d33f33; --q-improving: #3a7fc0;
  --rrg-chart-max: 720px;
}
.rrg-hero { padding-bottom: 0; }
.rrg-section { padding-top: 28px; }

.rrg-controls { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.rrg-controls label {
  display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600;
}
.rrg-controls select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--bd2);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: 'Sarabun', sans-serif;
}
.rrg-controls input[type=range] { accent-color: var(--brand); }
#tail-val { min-width: 24px; text-align: center; color: var(--brand); font-weight: 600; }
.rrg-btn {
  background: var(--brand); color: var(--on-brand); border: 0; border-radius: 8px; padding: 8px 15px;
  font-weight: 600; font-size: 13px; cursor: pointer; font-family: 'Sarabun', sans-serif;
}
.rrg-btn:hover { filter: brightness(1.1); }
.rrg-btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--bd2); }
.rrg-pills { display: flex; gap: 10px; margin-left: auto; }
.rrg-pill {
  display: inline-flex; flex-direction: column; padding: 7px 13px; background: var(--surface);
  border: 1px solid var(--bd); border-radius: 10px; line-height: 1.3;
}
.rrg-pill-k { font-size: 9px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }
.rrg-pill-v { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 600; color: var(--ink); }

.rrg-health {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; border: 1px solid;
  font-size: 12.5px; line-height: 1.7;
}
.rrg-health.hl-ok, .rrg-health.hl-info { color: #16A34A; background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.28); }
.rrg-health.hl-warn { color: #B45309; background: rgba(217,119,6,0.1); border-color: rgba(217,119,6,0.32); }
.rrg-health.hl-stale { color: #E5484D; background: rgba(229,72,77,0.1); border-color: rgba(229,72,77,0.35); }
html[data-theme="dark"] .rrg-health.hl-warn { color: #F59E0B; }

.rrg-stage { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: flex-start; }
.rrg-chart-wrap {
  position: relative; width: min(var(--rrg-chart-max), 92vw); flex: 0 0 auto;
  background: var(--surface); border: 1px solid var(--bd); border-radius: 14px; padding: 10px;
}
.rrg-legend { width: 250px; flex: 1 1 220px; max-width: 320px; }
@media (max-width: 860px) { .rrg-legend { max-width: none; width: min(var(--rrg-chart-max), 92vw); } }
#rrg { width: 100%; height: auto; display: block; }
.rrg-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}
.rrg-loading[hidden] { display: none; }

.rrg-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface);
  border: 1px solid var(--bd); border-radius: 10px; padding: 10px 12px; font-size: 12px;
  max-width: 266px; box-shadow: 0 12px 30px -10px rgba(20, 35, 31, 0.4); color: var(--ink);
}
.rrg-tip .tip-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.rrg-tip .tip-sym { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; }
.rrg-tip .tip-nm { color: var(--ink); font-weight: 600; }
.rrg-tip .tip-info { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin: 2px 0 0; }
.rrg-tip .tip-when {
  background: var(--tint); border: 1px solid var(--tint-bd); border-radius: 7px;
  padding: 5px 8px; margin: 8px 0; font-family: 'IBM Plex Mono', monospace;
}
.rrg-tip .tip-when .wk { color: var(--brand); font-weight: 600; }
.rrg-tip .tip-when .ago { color: var(--muted); font-size: 11px; }
.rrg-tip .tip-q { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 2px 0 4px; }
.rrg-tip .row { display: flex; justify-content: space-between; gap: 14px; padding: 1px 0; font-family: 'IBM Plex Mono', monospace; }
.rrg-tip .row > span:first-child { color: var(--muted); font-family: 'Sarabun', sans-serif; }

.rrg-legend h3 {
  font-size: 10px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase;
  font-weight: 600; margin: 10px 0 8px;
}
.quad-legend, .sym-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.quad-legend li { font-size: 12px; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.quad-legend em { color: var(--muted); font-style: normal; font-size: 11px; margin-left: auto; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.q-leading { background: var(--q-leading); } .q-weakening { background: var(--q-weakening); }
.q-lagging { background: var(--q-lagging); } .q-improving { background: var(--q-improving); }
.sym-legend li {
  font-size: 12px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 3px 6px; border-radius: 6px; color: var(--ink);
}
.sym-legend li:hover { background: var(--hover); }
.sym-legend li.dim { opacity: 0.34; }
.sym-legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.sym-legend .sym { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }
.sym-legend .nm { color: var(--muted); margin-left: auto; font-size: 11px; }
.rrg-hint {
  margin: 14px 0 0; font-size: 11px; line-height: 1.55; color: var(--muted);
  background: var(--hover); border: 1px solid var(--bd2); border-radius: 8px; padding: 8px 10px;
}
.rrg-hint b { color: var(--brand); }
.rotation-disclaimer { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 14px 4px 0; }

/* SVG bits */
.q-rect-leading   { fill: var(--q-leading);   opacity: 0.07; }
.q-rect-weakening { fill: var(--q-weakening); opacity: 0.07; }
.q-rect-lagging   { fill: var(--q-lagging);   opacity: 0.07; }
.q-rect-improving { fill: var(--q-improving); opacity: 0.07; }
.q-label { font-family: 'Sarabun', sans-serif; font-size: 12px; font-weight: 600; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }
.axis-line { stroke: var(--bd2); stroke-width: 1; }
.center-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.6; }
.grid-line { stroke: var(--bd); stroke-width: 1; opacity: 0.55; }
.axis-text { font-family: 'IBM Plex Mono', monospace; font-size: 10px; fill: var(--muted); }
.tail-line { fill: none; stroke-width: 2.2; opacity: 0.6; stroke-linecap: round; }
.tail-dot { cursor: pointer; }
.head-dot { stroke: var(--surface); stroke-width: 1.6; cursor: pointer; }
.head-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 600; fill: var(--ink);
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; cursor: pointer;
}
.rrg-series { transition: opacity 0.15s ease; }
.faded { opacity: 0.13 !important; }

/* Footer */
.site-footer { border-top: 1px solid var(--bd); background: var(--bg2); margin-top: 24px; }
.footer-inner {
  max-width: 1180px; margin: 0 auto; padding: 32px 28px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.footer-brand { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 19px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.footer-tagline { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; color: var(--muted); }
.footer-tagline .accent { color: var(--brand-blue); }
.foot-meta { display: flex; align-items: center; gap: 22px; font-size: 13.5px; color: var(--text); flex-wrap: wrap; }
.foot-meta a { color: var(--brand); font-weight: 700; }
.foot-meta a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .popular-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .feature-grid, .feature-wide, .steps-grid, .link-grid, .popular-grid { grid-template-columns: 1fr; }
  .feature-card.feature-dark { grid-row: auto; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Tighter gutters so narrow screens keep more usable content width */
  .container { padding: 24px 16px 48px; }
  .topbar-inner, .footer-inner { padding: 14px 16px; }

  /* Headings scale down for small viewports */
  .hero { padding: 28px 0 8px; }
  .hero h1 { font-size: 26px; }
  .hero-sub { font-size: 15px; }
  .section { padding: 44px 0 4px; }
  .section-title { font-size: 24px; }

  /* Fund head: stack the title above the price box, price left-aligned full width */
  .fund-head-top { flex-direction: column; gap: 14px; }
  .fund-head h1 { font-size: 27px; }
  .price-box { text-align: left; width: 100%; }

  .card { padding: 18px 16px; }
  .card h3 { font-size: 16px; }
  .popular-title { font-size: 23px; }
}

@media (max-width: 460px) {
  .hero h1 { font-size: 23px; }
  .section-title { font-size: 21px; }
  .fund-head h1 { font-size: 24px; }
  .price-value { font-size: 24px; }
  .search-box { padding: 5px 5px 5px 14px; border-radius: 13px; }
  .search-box input { font-size: 16px; }
  .search-btn { padding: 11px 16px; font-size: 14px; }
  .topnav { gap: 12px; }
  .topnav a { font-size: 14px; }
  .gauge-panel { gap: 18px; }
}

/* == Ported from Flask dev build: data health + asset rotation + portfolio page == */
/* Data health banner (ความสด + ความครบของข้อมูล) */
.data-health {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; border: 1px solid;
  font-size: 12.5px; line-height: 1.7;
}
.data-health.hl-ok { color: #16A34A; background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.28); }
.data-health.hl-warn { color: #B45309; background: rgba(217,119,6,0.1); border-color: rgba(217,119,6,0.32); }
.data-health.hl-stale { color: #E5484D; background: rgba(229,72,77,0.1); border-color: rgba(229,72,77,0.35); }
html[data-theme="dark"] .data-health.hl-warn { color: #F59E0B; }

/* Asset rotation (index) */
.rotation-sub { font-size: 14px; line-height: 1.6; color: var(--text); margin: 10px 0 0; max-width: 640px; }
.rotation-asof { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.rotation-list { border: 1px solid var(--bd); border-radius: 18px; background: var(--surface); overflow: hidden; }
.rotation-row, .rotation-head-row {
  display: grid; grid-template-columns: 44px minmax(150px, 1.2fr) 120px 64px 64px 64px 118px 96px;
  gap: 12px; align-items: center; padding: 13px 20px; border-top: 1px solid var(--bd);
}
.rotation-head-row {
  border-top: none; padding-top: 14px; padding-bottom: 10px; background: var(--hover);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.rotation-rank { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 600; color: var(--muted); }
.rotation-row.top3 .rotation-rank { color: var(--brand); }
.rotation-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.rotation-ticker { font-size: 12px; color: var(--muted); margin-top: 1px; }
.rotation-spark { width: 120px; height: 34px; display: block; }
.rotation-ret { font-family: 'IBM Plex Mono', monospace; font-size: 13.5px; font-weight: 600; text-align: right; }
.rotation-ret.up { color: #16A34A; }
.rotation-ret.down { color: #E5484D; }
.rotation-ret .ret-label { display: none; }
.rotation-status {
  justify-self: start; font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px; border: 1px solid;
}
.rs-strong { color: #16A34A; background: rgba(22,163,74,0.1); border-color: rgba(22,163,74,0.3); }
.rs-improving { color: #2E90E8; background: rgba(46,144,232,0.1); border-color: rgba(46,144,232,0.3); }
.rs-weakening { color: #D97706; background: rgba(217,119,6,0.1); border-color: rgba(217,119,6,0.3); }
.rs-weak { color: #E5484D; background: rgba(229,72,77,0.1); border-color: rgba(229,72,77,0.3); }
.rotation-find {
  justify-self: end; border: 1px solid var(--bd2); background: transparent; cursor: pointer;
  font-family: 'Sarabun', sans-serif; font-size: 12.5px; font-weight: 600; color: var(--text);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.rotation-find:hover { border-color: var(--brand); color: var(--brand); }
.rotation-disclaimer { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 14px 4px 0; }
/* wrappers exist for the mobile layout — on desktop their children join the row grid directly */
.rotation-rets-wrap, .rotation-foot-wrap { display: contents; }

@media (max-width: 920px) {
  .rotation-head-row { display: none; }
  .rotation-row { grid-template-columns: 30px 1fr 110px; grid-template-areas: "rank name spark" "rank rets rets" "rank foot foot"; row-gap: 8px; }
  .rotation-row .rotation-rank { grid-area: rank; align-self: start; }
  .rotation-row .rotation-titles { grid-area: name; }
  .rotation-row .rotation-spark { grid-area: spark; justify-self: end; }
  .rotation-rets-wrap { grid-area: rets; display: flex; gap: 16px; }
  .rotation-ret { text-align: left; }
  .rotation-ret .ret-label { display: inline; color: var(--muted); font-weight: 400; margin-right: 4px; }
  .rotation-foot-wrap { grid-area: foot; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
}


/* Portfolio page */
.pf-hero { padding-bottom: 0; }
.pf-section { padding-top: 32px; }
.tier-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.tier-card {
  text-align: left; cursor: pointer; font-family: 'Sarabun', sans-serif;
  background: var(--surface); border: 1.5px solid var(--bd); border-radius: 18px; padding: 18px 20px;
}
.tier-card:hover { border-color: var(--brand); }
.tier-card.active { border-color: var(--brand); box-shadow: 0 12px 32px -18px rgba(27,95,209,0.45); }
.tier-code { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 600; color: var(--brand); }
.tier-card.active .tier-code { color: var(--brand); }
.tier-label { font-size: 14.5px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.tier-desc { font-size: 12.5px; line-height: 1.55; color: var(--text); margin-top: 8px; }

.pf-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.pf-donut-wrap { position: relative; width: 200px; margin: 14px auto 6px; }
.pf-donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 26px; color: var(--ink); pointer-events: none;
}
.pf-donut-center .sub { font-family: 'Sarabun', sans-serif; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.pf-legend { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.pf-legend-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink); }
.pf-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.pf-legend-row .w { margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-weight: 600; }

.pf-table-note { font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; }
.pf-row {
  display: grid; grid-template-columns: minmax(120px, 1.3fr) 64px 74px 64px 112px 96px;
  gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--bd);
}
.pf-row.head { border-top: none; padding-top: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.pf-name { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.pf-sub { font-size: 12px; color: var(--muted); }
.pf-w { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 600; text-align: right; color: var(--ink); }
.pf-w.base { color: var(--muted); font-weight: 500; }
.pf-delta { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; font-weight: 600; text-align: right; }
.pf-delta.up { color: #16A34A; }
.pf-delta.down { color: #E5484D; }
.pf-delta.flat { color: var(--muted); }
.pf-status-cell { justify-self: start; }
.pf-find-cell { justify-self: end; }

.pf-funds-card { margin-top: 16px; }
.pf-funds-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 8px; }
.pf-fund-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pf-fund-head { font-size: 13px; font-weight: 700; color: var(--ink); padding-bottom: 6px; border-bottom: 1px solid var(--bd); }
.pf-fund-row {
  display: block; padding: 9px 11px; border: 1px solid var(--bd); border-radius: 10px;
  text-decoration: none; color: inherit; min-width: 0;
}
.pf-fund-row:hover { border-color: var(--brand); background: var(--hover); }
.pf-fund-main { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pf-fund-abbr { font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-fund-pct { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.pf-fund-pct.up { color: #16A34A; }
.pf-fund-pct.down { color: #E5484D; }
.pf-fund-sub { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-fund-empty { font-size: 12.5px; color: var(--muted); padding: 8px 2px; }
.pf-fund-more { align-self: flex-start; margin-top: 2px; }

/* กองทุนตัวแทนรายสินทรัพย์ (หน้าแผนที่สินทรัพย์) */
.am-funds-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.pf-fund-proxy { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.pf-fund-ui {
  display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; vertical-align: 1px;
  color: #B45309; background: rgba(245, 158, 11, 0.14); border: 1px solid rgba(245, 158, 11, 0.35);
}
.pf-fund-note { font-size: 11px; color: #B45309; }

/* the best ของกลุ่ม (composite: return 50% + Sharpe 30% + MaxDD 20%) */
.pf-fund-row.best { border-color: rgba(180, 138, 62, 0.55); background: rgba(180, 138, 62, 0.05); }
.pf-fund-best {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em; vertical-align: 1px; white-space: nowrap;
  color: var(--gold, #B48A3E); background: rgba(180, 138, 62, 0.12); border: 1px solid rgba(180, 138, 62, 0.4);
}
.pf-fund-hold {
  font-size: 10.5px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* สรุปตัวจุดชนวนของรอบ rebalance (กลุ่มที่ย้ายสถานะบนแผนที่) */
.rebal-trigger {
  flex-basis: 100%; font-size: 11.5px; color: var(--ink); opacity: 0.85;
  padding: 2px 0 4px; font-weight: 600;
}

.pf-stats-card { margin-top: 16px; }
.pf-stats-scroll { overflow-x: auto; }
.pf-stats-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; min-width: 640px; }
.pf-stats-table th {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bd);
  color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.04em;
}
.pf-stats-table td { padding: 9px 10px; border-bottom: 1px solid var(--bd); color: var(--ink); }
.pf-stats-table tr:last-child td { border-bottom: none; }
.pf-stats-table tr.active td { background: var(--tint); }
.pf-stats-table .tier-cell { font-weight: 600; color: var(--brand); }
.pf-stats-table .up { color: #16A34A; }
.pf-stats-table .down { color: #E5484D; }

.pf-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.pf-note h3 { font-size: 15px; }
.pf-note p { font-size: 13px; line-height: 1.65; color: var(--text); margin: 6px 0 0; }
.pf-disclaimer {
  margin-top: 16px; padding: 14px 18px; border: 1px solid var(--tint-bd); background: var(--tint);
  border-radius: 12px; font-size: 12.5px; line-height: 1.7; color: var(--text);
}

@media (max-width: 1020px) {
  .pf-grid { grid-template-columns: 1fr; }
  .pf-donut-card { max-width: 480px; }
}

@media (max-width: 860px) {
  .tier-cards, .pf-notes { grid-template-columns: 1fr; }
  .pf-row { grid-template-columns: minmax(100px, 1.3fr) 52px 60px 52px; }
  .pf-row .pf-status-cell, .pf-row .pf-find-cell { grid-column: span 2; }
  .pf-row.head .pf-status-cell, .pf-row.head .pf-find-cell { display: none; }
}


.pf-growth-toggle {
  margin-top: 14px; border: 1px solid var(--bd2); background: transparent; cursor: pointer;
  font-family: 'Sarabun', sans-serif; font-size: 13px; font-weight: 600; color: var(--brand);
  padding: 8px 16px; border-radius: 999px;
}
.pf-growth-toggle:hover { border-color: var(--brand); }
.pf-growth-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 6px; }
.pf-growth-title { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.pf-growth-final { font-size: 14px; font-weight: 600; color: #16A34A; }

/* nav highlight + growth year select + rebalance timeline */
.topnav a.nav-hl {
  color: var(--on-brand); background: linear-gradient(135deg, var(--brand), var(--accent));
  padding: 7px 16px; border-radius: 999px; font-weight: 700;
  box-shadow: 0 6px 18px -8px rgba(27,95,209,0.55);
}
.topnav a.nav-hl:hover { filter: brightness(1.08); color: var(--on-brand); }
.pf-growth-startlabel { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.pf-growth-startlabel select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--bd2);
  border-radius: 8px; padding: 5px 8px; font-size: 12.5px; font-family: 'Sarabun', sans-serif;
}
.pf-rebal-card { margin-top: 16px; }
.rebal-row { display: flex; gap: 14px; padding: 11px 0; border-top: 1px solid var(--bd); align-items: flex-start; }
.rebal-row:first-child { border-top: none; }
.rebal-date { font-size: 12.5px; color: var(--muted); flex: 0 0 88px; padding-top: 4px; }
.rebal-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.rebal-chip { font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; border: 1px solid; }
.rebal-chip.buy { color: #16A34A; background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.3); }
.rebal-chip.sell { color: #E5484D; background: rgba(229,72,77,0.08); border-color: rgba(229,72,77,0.3); }
.rebal-hold { font-size: 12.5px; color: var(--muted); padding-top: 4px; }

/* Asset class map (/assets) — 4 quadrants เรียงตามวงจร: ฟื้น→แข็งแกร่ง→แผ่ว→อ่อนแอ */
.qmap-hero { padding-bottom: 0; }
.qmap-section { padding-top: 28px; }
.qmap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qmap-cell { border: 1.5px solid; border-radius: 18px; padding: 16px 18px; min-height: 150px; }
.qm-strong    { border-color: rgba(22,163,74,0.4);  background: rgba(22,163,74,0.05); }
.qm-improving { border-color: rgba(46,144,232,0.4); background: rgba(46,144,232,0.05); }
.qm-weakening { border-color: rgba(217,119,6,0.4);  background: rgba(217,119,6,0.05); }
.qm-weak      { border-color: rgba(229,72,77,0.4);  background: rgba(229,72,77,0.05); }
.qmap-head { font-size: 15.5px; font-weight: 800; color: var(--ink); margin-bottom: 12px; }
.qmap-head span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.qmap-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.qmap-card {
  text-align: left; cursor: pointer; font-family: 'Sarabun', sans-serif;
  background: var(--surface); border: 1px solid var(--bd); border-radius: 12px; padding: 10px 12px;
}
.qmap-card:hover { border-color: var(--brand); }
.qmap-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.qmap-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.qmap-r3 { font-size: 12.5px; font-weight: 600; }
.qmap-r3.up { color: #16A34A; }
.qmap-r3.down { color: #E5484D; }
.qmap-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.qmap-moved {
  margin-top: 7px; font-size: 11px; font-weight: 700; color: var(--brand);
  background: var(--tint); border: 1px solid var(--tint-bd); border-radius: 7px; padding: 3px 8px;
}
.qmap-empty { font-size: 12.5px; color: var(--muted); padding: 8px 2px; }
.qmap-section .popular-head { flex-wrap: wrap; gap: 10px; align-items: center; }
.qmap-section .rotation-asof { white-space: normal; }
@media (max-width: 760px) { .qmap-grid { grid-template-columns: 1fr; } }

/* topnav มี 3 เมนู + ปุ่มธีม — จอแคบให้ห่อบรรทัดแทนดันจอ */
@media (max-width: 560px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
  .topnav { gap: 12px; flex-wrap: wrap; }
  .topnav a { font-size: 13.5px; }
  .topnav a.nav-hl { padding: 6px 13px; }
  .brand { font-size: 19px; }
}


.rebal-why { display: block; font-size: 10.5px; font-weight: 500; font-style: normal; opacity: 0.78; margin-top: 2px; }
.rebal-tier-tabs { margin: 2px 0 12px; }

/* การซื้อขาย & การรับเงิน (T+n) + ปันผล */
.trade-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 6px; }
.trade-cell { padding: 11px 13px; border: 1px solid var(--bd); border-radius: 10px; min-width: 0; }
.trade-cell-hl { border-color: var(--brand); background: var(--hover); }
.trade-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.trade-val { font-size: 14px; font-weight: 600; color: var(--ink); }
.div-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.div-tbl th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bd); color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.div-tbl td { padding: 8px 10px; border-bottom: 1px solid var(--bd); color: var(--ink); }
.div-tbl tbody tr:hover { background: var(--hover); }

/* หน้า FAQ */
.faq-section { max-width: 820px; margin: 0 auto; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item { border: 1px solid var(--bd); border-radius: 12px; background: var(--surface); overflow: hidden; }
.faq-item[open] { border-color: var(--brand); }
.faq-q {
  cursor: pointer; padding: 16px 18px; font-size: 15.5px; font-weight: 700; color: var(--ink);
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after { content: '+'; font-size: 22px; font-weight: 400; color: var(--brand); flex-shrink: 0; }
.faq-item[open] .faq-q::after { content: '−'; }
.faq-q:hover { color: var(--brand); }
.faq-a { padding: 0 18px 16px; font-size: 14.5px; line-height: 1.7; color: var(--text); }
.foot-link { font-size: 13px; margin-right: 14px; }

/* เนื้อหาอธิบาย server-rendered (portfolio/หน้าหลัก) — SEO/AEO/GEO */
.pf-intro { max-width: 920px; margin: 0 auto; }
.pf-intro-lead p { font-size: 15px; line-height: 1.75; color: var(--text); margin: 0 0 12px; }
.pf-intro-lead b { color: var(--ink); }
.pf-intro-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0; }
.pf-intro-tier { border: 1px solid var(--bd); border-radius: 12px; padding: 16px 18px; background: var(--surface); }
.pf-intro-tier h2 { font-size: 16px; margin: 0 0 8px; color: var(--ink); }
.pf-intro-tier p { font-size: 13.5px; line-height: 1.65; color: var(--text); margin: 0; }
.pf-intro-how { margin-top: 18px; }
.pf-intro-how h2 { font-size: 18px; margin: 0 0 8px; color: var(--ink); }
.pf-intro-how p { font-size: 14.5px; line-height: 1.75; color: var(--text); margin: 0; }

/* AI narrative (/ai) */
.ai-narrative p { font-size: 15px; line-height: 1.8; color: var(--text); margin: 0 0 14px; }
.ai-narrative p:last-of-type { margin-bottom: 0; }
.ai-meta { font-size: 11.5px; color: var(--muted); margin-top: 14px; border-top: 1px solid var(--bd); padding-top: 10px; }
.ai-spin { display: inline-block; animation: ai-spin 1s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* สภาวะเศรษฐกิจ ณ ตอนนี้ (Investment Clock — การ์ดหัวหน้า /ai) */
.econ-state {
  margin-bottom: 20px; padding: 16px 18px; border-radius: 14px;
  background: var(--hover); border: 1px solid var(--bd);
}
.econ-head { display: flex; align-items: flex-start; gap: 12px; }
.econ-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; margin-top: 4px; }
.econ-dot.recovery { background: #00c853; }
.econ-dot.overheat { background: #ffab00; }
.econ-dot.stagflation { background: #ff5252; }
.econ-dot.reflation { background: #2e90e8; }
.econ-headtext { min-width: 0; }
.econ-title { font-weight: 700; font-size: 16px; color: var(--ink); line-height: 1.4; }
.econ-title .econ-en { font-weight: 500; font-size: 13px; color: var(--muted); }
.econ-metrics { margin-top: 4px; font-size: 11.5px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.econ-explain { margin: 12px 0 0; font-size: 14px; line-height: 1.75; color: var(--text); }
.econ-funds {
  margin-top: 12px; padding: 11px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.7;
  color: var(--text); background: var(--tint); border: 1px solid var(--tint-bd);
}
.econ-funds b { color: var(--ink); }
.arc-link {
  display: inline-block; font-size: 14px; font-weight: 600; color: var(--brand);
  padding: 8px 16px; border: 1px solid var(--bd2); border-radius: 999px; text-decoration: none;
}
.arc-link:hover { background: var(--hover); }

/* คลังบทวิเคราะห์ย้อนหลัง (/archive) */
.arc-layout { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
.arc-dates {
  position: sticky; top: 16px; border: 1px solid var(--bd); border-radius: 12px;
  background: var(--surface); overflow: hidden;
}
.arc-dates-head {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--bd);
}
.arc-dates-list { max-height: 65vh; overflow-y: auto; }
.arc-date-item {
  display: block; padding: 10px 14px; font-size: 13.5px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--bd);
}
.arc-date-item:last-child { border-bottom: 0; }
.arc-date-item:hover { background: var(--hover); }
.arc-date-item.active { background: var(--tint); color: var(--brand); font-weight: 700; }
.arc-content-date { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
@media (max-width: 720px) {
  .arc-layout { grid-template-columns: 1fr; }
  .arc-dates { position: static; }
  .arc-dates-list { max-height: 200px; }
}

/* คุกกี้ / PDPA consent banner (footer.php, ทุกหน้า) */
.cookie-consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200; max-width: 760px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--bd); border-radius: 14px; padding: 16px 20px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18); display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.cookie-consent[hidden] { display: none; }
.cc-text { flex: 1 1 320px; font-size: 13px; line-height: 1.65; color: var(--text); margin: 0; }
.cc-text a { color: var(--brand); }
.cc-actions { display: flex; gap: 10px; flex: 0 0 auto; }
.cc-btn { border-radius: 8px; padding: 8px 15px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: 'Sarabun', sans-serif; }
.cc-btn:hover { filter: brightness(1.1); }
.cc-accept { background: var(--brand); color: var(--on-brand); border: 0; }
.cc-decline { background: transparent; color: var(--text); border: 1px solid var(--bd2); }
@media (max-width: 560px) { .cookie-consent { flex-direction: column; align-items: stretch; } .cc-actions { justify-content: flex-end; } }

/* ── /funds สารบัญกองทุน ───────────────────────────────────────────── */
.fl-alpha { display: flex; flex-wrap: wrap; gap: 6px; }
.fl-letter { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--bd); background: var(--surface); color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 14px; line-height: 1; transition: background .15s, border-color .15s; }
.fl-letter:hover { background: var(--tint); border-color: var(--tint-bd); }
.fl-letter.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.fl-letter.empty { opacity: .32; cursor: default; }
.fl-n { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 600; color: var(--muted); }
.fl-letter.active .fl-n { color: var(--on-brand); opacity: .8; }

.fl-group { padding-top: 8px; }
.fl-head { display: flex; align-items: baseline; gap: 10px; font-size: 21px; margin: 0 0 14px;
  color: var(--ink); border-bottom: 1px solid var(--bd); padding-bottom: 8px; }
.fl-head-n { font-size: 13px; font-weight: 500; color: var(--muted); }

.fl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.fl-item { display: flex; flex-direction: column; gap: 3px; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--bd); background: var(--surface); text-decoration: none;
  transition: border-color .15s, transform .15s; }
.fl-item:hover { border-color: var(--tint-bd); background: var(--hover); transform: translateY(-1px); }
.fl-abbr { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 14.5px; color: var(--brand-blue); }
.fl-name { font-size: 13px; color: var(--ink); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
.fl-tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--tint);
  border: 1px solid var(--tint-bd); color: var(--text); white-space: nowrap; }
.fl-amc { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fl-more { display: inline-block; margin-top: 14px; font-size: 14px; font-weight: 600;
  color: var(--brand-blue); text-decoration: none; }
.fl-more:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .fl-grid { grid-template-columns: 1fr; }
  .fl-letter { padding: 6px 10px; font-size: 13px; }
}

/* ── /guide บทความคู่มือ ───────────────────────────────────────────── */
.gd-article { max-width: 760px; margin: 0 auto; padding: 28px 0 10px; }
.gd-crumb { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.gd-crumb a { color: var(--muted); text-decoration: none; }
.gd-crumb a:hover { color: var(--brand-blue); }
.gd-head h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.3; color: var(--ink); margin: 0 0 10px; }
.gd-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 6px; }
.gd-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--tint); border: 1px solid var(--tint-bd); color: var(--text); }

.gd-body { font-size: 15.5px; line-height: 1.85; color: var(--text); }
.gd-body h2 { font-size: 21px; color: var(--ink); margin: 34px 0 12px; padding-top: 10px; border-top: 1px solid var(--bd); }
.gd-body h3 { font-size: 17px; color: var(--ink); margin: 22px 0 8px; }
.gd-body p { margin: 0 0 14px; }
.gd-body ul, .gd-body ol { margin: 0 0 16px; padding-left: 22px; }
.gd-body li { margin-bottom: 8px; }
.gd-body b { color: var(--ink); }
.gd-body a { color: var(--brand-blue); }

.gd-table { width: 100%; border-collapse: collapse; margin: 14px 0 20px; font-size: 14px; }
.gd-table th, .gd-table td { border: 1px solid var(--bd); padding: 9px 12px; text-align: left; vertical-align: top; }
.gd-table th { background: var(--tint); color: var(--ink); font-weight: 700; }
.gd-table tr:nth-child(even) td { background: var(--hover); }

.gd-formula { font-family: 'IBM Plex Mono', monospace; font-size: 13.5px; line-height: 1.8;
  background: var(--tint); border: 1px solid var(--tint-bd); border-radius: 10px;
  padding: 14px 16px; margin: 14px 0 18px; color: var(--ink); overflow-x: auto; }
.gd-note { background: var(--tint); border: 1px solid var(--tint-bd); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 12px 16px; margin: 14px 0 18px; font-size: 14px; }

.gd-faq { margin-top: 36px; }
.gd-faq h2 { font-size: 21px; color: var(--ink); margin: 0 0 14px; }
.gd-faq-item { border: 1px solid var(--bd); border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
.gd-faq-item summary { padding: 13px 16px; font-weight: 600; color: var(--ink); cursor: pointer; font-size: 14.5px; }
.gd-faq-item summary:hover { color: var(--brand-blue); }
.gd-faq-item p { padding: 0 16px 14px; margin: 0; font-size: 14.5px; line-height: 1.75; color: var(--text); }

.gd-related { margin-top: 36px; }
.gd-related h2 { font-size: 21px; color: var(--ink); margin: 0 0 14px; }
.gd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.gd-grid-index { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.gd-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 12px;
  border: 1px solid var(--bd); background: var(--surface); text-decoration: none;
  transition: border-color .15s, transform .15s; }
.gd-card:hover { border-color: var(--tint-bd); transform: translateY(-2px); }
.gd-card-title { font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.4; }
.gd-card-desc { font-size: 13px; color: var(--muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.gd-card-meta { font-size: 12px; color: var(--muted); margin-top: auto; }

.gd-disclaimer { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--bd);
  font-size: 12.5px; color: var(--muted); }

@media (max-width: 640px) {
  .gd-table { display: block; overflow-x: auto; white-space: nowrap; }
  .gd-table td, .gd-table th { white-space: normal; min-width: 120px; }
}
