/* ============================================================
   PriceLive — ราคาช่าง · Construction price viewer
   ใช้โทนเดียวกับช่างคิด (orange #F58220 / blue #1B4F8C)
   ============================================================ */

:root {
  --orange: #F58220;
  --orange-light: #FFA552;
  --orange-dark: #D96A0E;
  --blue: #1B4F8C;
  --blue-light: #3A7BD5;
  --blue-dark: #0F3666;
  --green: #0F9D58;
  --red: #DC2626;
  --gold: #CA8A04;
  --bg: #F7F9FC;
  --bg-soft: #EEF2F8;
  --ink: #0E1A2E;
  --ink-soft: #4B5C75;
  --ink-mute: #748098;
  --line: #E2E8F0;
  --line-soft: #EEF2F7;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15,54,102,.06), 0 2px 8px rgba(15,54,102,.04);
  --shadow: 0 4px 12px rgba(15,54,102,.08), 0 12px 32px rgba(15,54,102,.08);
  --shadow-lg: 0 12px 24px rgba(15,54,102,.10), 0 32px 64px rgba(15,54,102,.12);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select { font-family: inherit; }

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0; z-index: 30;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(226,232,240,.7);
  display: flex; align-items: center;
  gap: 18px;
  padding: 12px 24px;
}
.topbar .back {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 700; font-size: 14px;
  color: var(--blue);
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  transition: all .18s;
}
.topbar .back:hover { background: var(--bg-soft); border-color: var(--blue-light); }
.title-block { flex: 1; min-width: 0; line-height: 1.2; }
.title-block .title {
  font-size: 18px; font-weight: 800; letter-spacing: -.01em;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-block .title-th { color: var(--orange); font-weight: 700; }
.title-block .subtitle {
  font-size: 12.5px; color: var(--ink-soft); font-weight: 500;
  margin-top: 1px;
}
.updated-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-soft);
  padding: 6px 11px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.updated-tag .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-mute);
}
.updated-tag .dot.live {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(15,157,88,.18);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(15,157,88,.18); }
  50%     { box-shadow: 0 0 0 6px rgba(15,157,88,.10); }
}

/* ===== HERO BAND ===== */
.hero-band {
  background:
    radial-gradient(700px 360px at 80% -10%, rgba(245,130,32,.10), transparent 60%),
    radial-gradient(640px 320px at 5% 110%, rgba(58,123,213,.10), transparent 60%),
    linear-gradient(180deg, white 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: 24px 0 18px;
}

/* ===== Lock state สำหรับ chip "ประเภทงาน" (workRow) + "หมวดงาน" (disciplineRow) + "หมวด" (chipsRow) ===== */
/* ⚠️ ยกเว้น chip "ทั้งหมด"/"ทุกหมวด" (data-*=all) — user ยังต้องใช้ปลดล็อก filter ได้ */
body.category-locked :is(#chipsRow, #disciplineRow, #workRow) .chip:not(.chip-more):not([data-cat="all"]):not([data-disc="all"]):not([data-work="all"]) {
  opacity: 0.55;
  cursor: not-allowed;
  position: relative;
}
body.category-locked :is(#chipsRow, #disciplineRow, #workRow) .chip:not(.chip-more):not([data-cat="all"]):not([data-disc="all"]):not([data-work="all"])::after {
  content: '🔒';
  position: absolute;
  top: -6px; right: -4px;
  font-size: 10px;
  background: #FEF3C7;
  border: 1px solid rgba(245,130,32,.4);
  border-radius: 50%;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
body.category-locked :is(#chipsRow, #disciplineRow, #workRow) .filter-label::after {
  content: ' · 🔒 ใช้ครบโควต้า';
  color: var(--orange);
  font-weight: 700;
  font-size: 12px;
}

/* ===== Floating mini search bar — ลอยด้านบน ตอน user scroll ผ่าน hero ===== */
.search-floating {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(255,255,255,.97);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(15,23,42,.08);
  padding: 8px 0;
  transform: translateY(-100%);
  transition: transform .22s ease-out, opacity .15s;
  opacity: 0;
  pointer-events: none;
}
.search-floating.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.search-floating .container {
  display: flex; align-items: center; gap: 10px;
}
.search-floating .brand-mini {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800;
  color: var(--orange);
  white-space: nowrap;
}
.search-floating .brand-mini::before { content: '🔎'; font-size: 14px; }
.search-floating .float-search {
  flex: 1;
  position: relative;
  display: flex; align-items: center;
  background: linear-gradient(135deg, #FFF7ED 0%, #FEF3C7 50%, #FFFBEB 100%);
  border: 1.5px solid var(--orange);
  border-radius: 11px;
  padding: 0 12px;
  box-shadow: 0 2px 6px rgba(245,130,32,.18);
  animation: searchPulse 2.2s ease-out infinite;
}
.search-floating .float-search svg { color: var(--orange); flex-shrink: 0; }
.search-floating .float-search input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-size: 14px;
  padding: 9px 8px;
  color: var(--ink);
  font-weight: 500;
}
.search-floating .float-search input::placeholder {
  color: #B45309;
  font-weight: 600;
}
.search-floating .float-hint {
  font-size: 11.5px; font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
  padding: 4px 9px;
  background: #FFF7ED;
  border: 1px solid rgba(245,130,32,.35);
  border-radius: 999px;
  animation: searchHintBounce 1.6s ease-in-out infinite;
}
@media (max-width: 720px) {
  .search-floating .brand-mini, .search-floating .float-hint { display: none; }
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: stretch;
}
.search-input {
  position: relative;
  display: flex; align-items: center;
  background: linear-gradient(135deg, #FFF7ED 0%, #FEF3C7 50%, #FFFBEB 100%);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(245,130,32,.14);
  animation: none !important; /* หยุด pulse เมื่อ user focus */
}

/* ===== Attention pulse — จูงใจ user ที่ยังไม่เคยค้นหาให้ลองใช้ ===== */
/* class นี้ถูก toggle โดย JS · หยุดทันทีเมื่อ user มี interaction (focus/click chip) */
@keyframes searchPulse {
  0%   { box-shadow: 0 0 0 0 rgba(245,130,32,.45), var(--shadow-sm); border-color: var(--orange); }
  50%  { box-shadow: 0 0 0 10px rgba(245,130,32,0),  var(--shadow-sm); border-color: var(--orange); }
  100% { box-shadow: 0 0 0 0 rgba(245,130,32,0),    var(--shadow-sm); border-color: var(--line); }
}
.search-input.attention-pulse {
  animation: searchPulse 2.2s ease-out infinite;
}
.search-input.attention-pulse::after {
  content: '👆 พิมพ์เพื่อค้นหา';
  position: absolute;
  right: 90px;          /* วางทางขวาเหนือ counter chip · ไม่ทับหมวดงานด้านล่าง */
  top: -28px;           /* ย้ายขึ้นไปบนกล่อง search */
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  background: #FFF7ED;
  border: 1px solid rgba(245,130,32,.35);
  padding: 3px 10px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  animation: searchHintBounce 1.6s ease-in-out infinite;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(245,130,32,.18);
}
/* ลูกศรเล็กชี้ลงไปที่กล่อง search */
.search-input.attention-pulse::before {
  content: '';
  position: absolute;
  right: 110px;
  top: -8px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #FFF7ED;
  filter: drop-shadow(0 1px 0 rgba(245,130,32,.35));
  z-index: 3;
  pointer-events: none;
  animation: searchHintBounce 1.6s ease-in-out infinite;
}
@keyframes searchHintBounce {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50%      { transform: translateY(-3px); opacity: 1; }
}
/* ตอน hero-band ย่อ (is-stuck) → ซ่อน hint (กันเกะกะ) */
.hero-band.is-stuck .search-input.attention-pulse::before,
.hero-band.is-stuck .search-input.attention-pulse::after { display: none; }
/* Mobile: ลด offset */
@media (max-width: 720px) {
  .search-input.attention-pulse::after { right: 14px; top: -26px; }
  .search-input.attention-pulse::before { right: 60px; }
}
/* หยุด pulse ทันทีเมื่อช่องมี value */
.search-input.has-value.attention-pulse,
.search-input.has-value.attention-pulse::after {
  animation: none !important;
}
.search-input.has-value.attention-pulse::after { display: none; }
.search-input svg { color: var(--ink-mute); flex-shrink: 0; }
.search-input input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-size: 15.5px;
  padding: 14px 8px;
  color: var(--ink);
}
.search-input input::placeholder {
  color: #B45309;
  font-weight: 600;
  letter-spacing: 0.2px;
  opacity: 0.75;
}
.search-input input:focus::placeholder { opacity: 0.45; }

/* ===== Search counter chip ===== */
.search-counter {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(22,163,74,.12);
  color: #15803D;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-right: 8px;
  flex-shrink: 0;
  cursor: help;
  transition: all .15s;
}
.search-counter.is-low {
  background: rgba(245,158,11,.15);
  color: #B45309;
}
.search-counter.is-empty {
  background: rgba(220,38,38,.15);
  color: #B91C1C;
  animation: counter-pulse 1.2s ease-in-out infinite;
}
.search-counter.is-pro {
  background: linear-gradient(135deg, rgba(124,58,237,.15), rgba(245,130,32,.15));
  color: #7C3AED;
}
@keyframes counter-pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.06); }
}

/* ===== Search lock overlay (เมื่อค้นครบ 10 ครั้ง) ===== */
.search-lock-overlay {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center; justify-content: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(15,30,51,.94), rgba(28,52,89,.92));
  border-radius: 14px;
  z-index: 5;
  padding: 0 18px;
  color: #fff;
  font-weight: 600;
}
.search-lock-overlay.is-active { display: flex; }
.search-lock-overlay .lock-icon { font-size: 22px; }
.search-lock-overlay .lock-text {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  flex: 0 1 auto;
}
.search-lock-overlay .lock-cta {
  background: linear-gradient(135deg, #F58220, #FFA552);
  color: #fff;
  border: 0;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245,130,32,.4);
  transition: transform .15s, box-shadow .15s;
}
.search-lock-overlay .lock-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(245,130,32,.55);
}

/* ===== Paywall modal (PriceLive) ===== */
.pl-paywall {
  position: fixed; inset: 0;
  display: none;
  align-items: flex-start; justify-content: center;
  background: rgba(15,30,51,.6);
  padding: 30px 18px;
  z-index: 99999;
  overflow: auto;
}
.pl-paywall.open { display: flex; }
.pl-paywall .pl-card {
  background: #fff;
  border-radius: 18px;
  max-width: 460px; width: 100%;
  padding: 28px 26px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  position: relative;
}
.pl-paywall .pl-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: 0;
  font-size: 26px; line-height: 1;
  color: #64748b; cursor: pointer;
  padding: 4px 10px;
}
.pl-paywall .pl-title {
  font-size: 20px; font-weight: 800;
  color: #1B4F8C;
  margin: 0 24px 6px 0;
}
.pl-paywall .pl-sub {
  font-size: 13.5px;
  color: #64748b;
  margin: 0 0 18px;
  line-height: 1.55;
}
.pl-paywall .pl-plans {
  display: flex; flex-direction: column;
  gap: 10px;
  margin: 8px 0 12px;
}
.pl-paywall .pl-plan {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border: 1.5px solid #E2E8F0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font: inherit;
  text-align: left;
  width: 100%;
  transition: all .15s;
}
.pl-paywall .pl-plan:hover {
  border-color: #F58220;
  box-shadow: 0 4px 12px rgba(245,130,32,.18);
  transform: translateY(-1px);
}
.pl-paywall .pl-plan.is-recommended {
  border-color: #F58220;
  background: linear-gradient(135deg, #FFFBEB 0%, #FFF7ED 100%);
}
.pl-paywall .pl-plan-name {
  font-weight: 800; font-size: 15.5px;
  color: #0E1A2E;
  display: block;
}
.pl-paywall .pl-plan-meta {
  font-size: 12.5px;
  color: #64748b;
  display: block; margin-top: 2px;
}
.pl-paywall .pl-plan-price {
  font-weight: 800; font-size: 20px;
  color: #F58220;
}
.pl-paywall .pl-tag {
  display: inline-block;
  background: #F58220;
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.pl-paywall .pl-note {
  font-size: 12px;
  color: #64748b;
  margin: 12px 0 0;
  text-align: center;
  line-height: 1.5;
}
.pl-paywall .pl-btn-ghost {
  display: block; width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  border-radius: 11px;
  border: 1.5px solid #E2E8F0;
  background: #fff;
  color: #64748b;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.clear-btn {
  display: none;
  background: var(--bg-soft);
  border: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 18px; line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}
.clear-btn:hover { background: var(--line); color: var(--ink); }
.search-input.has-value .clear-btn { display: inline-flex; align-items: center; justify-content: center; }

.select-group {
  display: flex; gap: 10px;
}
.select-wrap {
  display: flex; flex-direction: column;
  background: white;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
  min-width: 140px;
}
.select-wrap .select-label {
  font-size: 11px;
  color: var(--ink-mute);
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.select-wrap select {
  border: 0; outline: 0; background: transparent;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 0;
  cursor: pointer;
}

.filter-block {
  display: flex; align-items: flex-start; gap: 12px;
  margin-top: 12px;
}
.filter-label {
  flex: 0 0 auto;
  min-width: 80px;
  padding: 9px 10px 8px;
  border-radius: 8px;
  transition: all .18s ease;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-mute);
  letter-spacing: .5px;
  text-transform: uppercase;
}
@media (max-width: 760px) {
  .filter-block { flex-direction: column; gap: 6px; margin-top: 10px; }
  .filter-label { padding: 2px 8px; min-width: 0; align-self: flex-start; }
}

/* ===== Filter label states ===== */
/* PENDING — ผู้ใช้ยังไม่กดในแถวนั้นเลย → แดง ⚠️ บังคับให้กด */
.filter-block.is-pending .filter-label {
  background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
  color: #B91C1C;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(220,38,38,.18);
  animation: filter-pending-pulse 2s ease-in-out infinite;
}
.filter-block.is-pending .filter-label::before {
  content: '⚠️ ';
  display: inline-block;
  margin-right: 2px;
  font-size: 12px;
}
@keyframes filter-pending-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.0); }
  50%     { box-shadow: 0 0 0 5px rgba(220,38,38,.15); }
}

/* CONFIRMED — กดแล้วอย่างน้อย 1 ครั้ง (รวม "ทั้งหมด") → เขียว ✓ */
.filter-block.is-confirmed .filter-label {
  background: linear-gradient(135deg, #DCFCE7 0%, #BBF7D0 100%);
  color: #15803D;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(22,163,74,.18);
}
.filter-block.is-confirmed .filter-label::before {
  content: '✓ ';
  display: inline-block;
  margin-right: 2px;
  color: #16A34A;
  font-weight: 900;
  font-size: 12px;
  transform: scale(1.1);
}

/* ACTIVE FILTER — confirmed + ไม่ใช่ "ทั้งหมด" → เขียวเข้มขึ้น */
.filter-block.is-confirmed.is-active-filter .filter-label {
  background: linear-gradient(135deg, #BBF7D0 0%, #86EFAC 100%);
  box-shadow: 0 2px 6px rgba(22,163,74,.25);
}

.filter-block .filter-label::before {
  content: '';
}

/* Hint banner เมื่อผลลัพธ์ = 0 ทั้งที่มี filter เปิดอยู่ */
.filter-hint {
  display: none;
  margin: 12px 0 8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FEF3C7 0%, #FFFBEB 100%);
  border: 1px dashed #F59E0B;
  color: #92400E;
  font-size: 13.5px;
  line-height: 1.55;
}
.filter-hint.is-show { display: block; }
.filter-hint b { color: #15803D; }
.filter-hint .hint-reset {
  background: #fff;
  color: #1B4F8C;
  border: 1.5px solid #1B4F8C;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  margin-left: 8px;
}
.filter-hint .hint-reset:hover { background: #EEF2F8; }

.chips-row {
  flex: 1;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: white;
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.chip:hover { border-color: var(--blue-light); color: var(--blue); }
.chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  box-shadow: 0 6px 14px rgba(27,79,140,.25);
}
.chip .count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-weight: 700;
}
.chip.active .count { background: rgba(255,255,255,.22); color: white; }

.result-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
  font-weight: 500;
}
.result-meta #resultCount strong { color: var(--ink); font-weight: 700; }
.result-meta .rc-type {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  margin: 0 1px;
}
.result-meta .rc-type.t-material { background: rgba(27,79,140,.08);  color: var(--blue); }
.result-meta .rc-type.t-labor    { background: rgba(15,118,110,.10); color: #0F766E; }
.result-meta .rc-type.t-work     { background: rgba(202,138,4,.12);  color: #CA8A04; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: white;
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.ghost-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}
.ghost-btn svg { flex-shrink: 0; }

/* ===== Transport Calculator button (เด่นชัดขึ้น) ===== */
.transport-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
  border: 1.5px solid #3B82F6;
  color: #1E40AF;
  padding: 9px 14px;
  border-radius: 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 2px 6px rgba(59,130,246,.15);
}
.transport-btn:hover {
  background: linear-gradient(135deg, #BFDBFE 0%, #93C5FD 100%);
  border-color: #2563EB;
  color: #1E3A8A;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(59,130,246,.28);
}
.transport-btn svg { flex-shrink: 0; }

/* ===== Premium buttons (Export CSV / Plot PDF) — locked ===== */
.premium-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1.5px solid #F59E0B;
  color: #92400E;
  padding: 9px 14px;
  border-radius: 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  box-shadow: 0 2px 6px rgba(245,158,11,.12);
}
.premium-btn:hover {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  border-color: #F58220;
  color: #7C2D12;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(245,130,32,.22);
}
.premium-btn svg { flex-shrink: 0; }
.premium-btn .premium-lock { font-size: 12px; line-height: 1; }
.premium-btn.is-unlocked {
  background: linear-gradient(135deg, #DCFCE7 0%, #BBF7D0 100%);
  border-color: #16A34A;
  color: #15803D;
}
.premium-btn.is-unlocked:hover {
  background: linear-gradient(135deg, #BBF7D0 0%, #86EFAC 100%);
}

/* ===== CARDS ===== */
.main-grid { flex: 1; padding: 28px 24px 60px; }
.cards-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ⭐ Favorite button on card */
.fav-btn {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 3;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-mute);
  transition: all .15s;
  padding: 0;
}
.fav-btn:hover {
  color: #CA8A04;
  border-color: #CA8A04;
  transform: scale(1.08);
}
.fav-btn.on {
  color: #CA8A04;
  background: #FFF9E5;
  border-color: #CA8A04;
}

/* ⭐ Favorite chip in type row */
.chip.fav-chip {
  border-color: #FCD34D;
  color: #B45309;
}
.chip.fav-chip svg { margin-right: 1px; }
.chip.fav-chip.active {
  background: linear-gradient(135deg, #F59E0B 0%, #CA8A04 100%);
  border-color: #CA8A04;
  color: white;
  box-shadow: 0 6px 14px rgba(202,138,4,.28);
}

/* ⭐ Favorite button in modal detail head */
.fav-btn-detail {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink-soft);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.fav-btn-detail:hover {
  border-color: #CA8A04;
  color: #CA8A04;
}
.fav-btn-detail.on {
  background: #FFF9E5;
  border-color: #CA8A04;
  color: #CA8A04;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--orange-light);
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-color, var(--blue));
}
.card .row1 {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
  padding-right: 36px; /* เว้นที่ให้ปุ่ม ⭐ มุมขวาบน */
}
.cat-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .3px;
  background: var(--card-tint, rgba(27,79,140,.10));
  color: var(--card-color, var(--blue));
}
.obec-code {
  display: inline-flex; align-items: center;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px; font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  letter-spacing: .5px;
}

/* ===== Type badge on cards ===== */
.type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .3px;
  padding: 3px 8px;
  border-radius: 999px;
}
.type-badge.t-material { background: rgba(27,79,140,.10);  color: var(--blue); }
.type-badge.t-labor    { background: rgba(15,118,110,.12); color: #0F766E; }
.type-badge.t-work     { background: rgba(202,138,4,.14);  color: #CA8A04; }

/* ===== Verification badge (provenance) ===== */
.verify-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .2px;
  padding: 3px 7px;
  border-radius: 999px;
  cursor: help;
}
.verify-badge.v-doc      { background: rgba(15,157,88,.12);  color: #0F9D58; }
.verify-badge.v-mfg      { background: rgba(124,45,18,.12);  color: #7C2D12; }
.verify-badge.v-url      { background: rgba(37,99,235,.12);  color: #2563EB; }
.verify-badge.v-agg      { background: rgba(168,85,247,.12); color: #7C3AED; }
.verify-badge.v-sample   { background: rgba(202,138,4,.18);  color: #92400E; border: 1px dashed rgba(146,64,14,.4); }

.chip.chip-more {
  background: rgba(107,114,128,.10);
  color: var(--ink-soft, #6B7280);
  border: 1px dashed rgba(107,114,128,.4);
  font-style: italic;
}
.chip.chip-more:hover {
  background: rgba(107,114,128,.18);
  border-style: solid;
}

.live-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(22,163,74,.12);
  color: #16A34A;
  font-size: 11.5px;
  font-weight: 700;
  animation: pulse-live 2s ease-in-out infinite;
}

/* ===== TPSO Loading Banner (full-width · เด่นชัด) ===== */
.tpso-loading-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 999;
  background: linear-gradient(135deg, #F58220 0%, #FFA552 40%, #F58220 100%);
  background-size: 200% 100%;
  color: #fff;
  padding: 14px 22px 0;
  box-shadow: 0 6px 20px rgba(245,130,32,.45);
  animation: tpso-loading-slide-down .35s ease-out, tpso-loading-bg-shimmer 2.5s linear infinite;
}
.tpso-loading-banner.is-show { display: block; }
.tpso-loading-inner {
  display: flex; align-items: center; gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}
.tpso-loading-icon {
  font-size: 32px;
  animation: tpso-loading-icon-pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.25));
}
.tpso-loading-text { flex: 1; line-height: 1.4; }
.tpso-loading-main {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.tpso-loading-main span {
  font-weight: 900;
  background: rgba(255,255,255,.25);
  padding: 1px 10px;
  border-radius: 6px;
  margin-left: 4px;
}
.tpso-loading-sub {
  font-size: 13px;
  font-weight: 500;
  margin-top: 3px;
  opacity: .95;
}
.tpso-loading-sub b { font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.tpso-loading-sub em { font-style: normal; opacity: 0.85; }

.tpso-loading-bar {
  height: 4px;
  background: rgba(0,0,0,.18);
  margin-top: 12px;
  border-radius: 0 0 4px 4px;
  overflow: hidden;
  position: relative;
}
.tpso-loading-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 35%;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: tpso-loading-bar-move 1.3s ease-in-out infinite;
}

@keyframes tpso-loading-slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes tpso-loading-bg-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
@keyframes tpso-loading-icon-pulse {
  0%, 100% { transform: scale(1) rotate(-5deg); }
  50%      { transform: scale(1.15) rotate(5deg); }
}
@keyframes tpso-loading-bar-move {
  0%   { left: -35%; }
  100% { left: 100%; }
}

@media (max-width: 760px) {
  .tpso-loading-banner { padding: 11px 14px 0; }
  .tpso-loading-icon { font-size: 26px; }
  .tpso-loading-main { font-size: 15px; }
  .tpso-loading-sub { font-size: 12px; }
}

.admin-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7C3AED 0%, #A855F7 100%);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(124,58,237,.35);
}

.preview-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1B4F8C 0%, #3A7BD5 100%);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(27,79,140,.35);
  transition: transform .15s, box-shadow .15s;
}
.preview-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(27,79,140,.5);
}
@keyframes pulse-live {
  0%,100% { opacity: 1; }
  50%     { opacity: .6; }
}

/* Card outline tint when sample (warn the user) */
.card.is-sample {
  background: linear-gradient(180deg, rgba(252,211,77,.06), transparent 30%);
}
.card.is-sample::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: repeating-linear-gradient(90deg, #F59E0B 0 8px, transparent 8px 14px);
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

/* ===== Verify URL link in modal ===== */
.verify-link {
  display: inline-block;
  margin-left: 4px;
  text-decoration: none;
  opacity: .7;
  font-size: 12px;
}
.verify-link:hover { opacity: 1; transform: scale(1.15); }
.agg-note {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: #7C3AED;
  background: rgba(124,58,237,.08);
  padding: 2px 6px;
  border-radius: 4px;
}
.prod-code {
  display: inline-block;
  margin-left: 6px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 10.5px;
  background: var(--bg-soft, #f5f5f5);
  color: var(--ink-soft, #555);
  padding: 1px 5px;
  border-radius: 3px;
}

.src-agency {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-mute, #64748b);
  line-height: 1.45;
  padding-left: 18px;
  border-left: 2px solid rgba(100,116,139,.15);
  margin-left: 6px;
}

/* ===== Section headers when grouped ===== */
.cards-section {
  grid-column: 1 / -1;
  margin: 14px 0 6px;
  display: flex; align-items: baseline; gap: 12px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}
.cards-section:first-child { margin-top: 0; }
.cards-section h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -.005em;
}
.cards-section .sec-count {
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 600;
}

.price-split {
  font-size: 12.5px;
  color: var(--ink-mute);
  margin-bottom: 10px;
  display: flex; flex-wrap: wrap; gap: 6px 12px;
}
.price-split .ps-mat { color: var(--blue); font-weight: 600; }
.price-split .ps-lab { color: var(--green); font-weight: 600; }

.obec-code-detail {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-mute);
}
.obec-code-detail strong {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  background: var(--bg-soft);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--ink);
}

.trend-badge {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.trend-badge.up   { background: rgba(220,38,38,.08);  color: var(--red); }
.trend-badge.down { background: rgba(15,157,88,.10);  color: var(--green); }
.trend-badge.flat { background: var(--bg-soft); color: var(--ink-mute); }
.trend-badge.flat-annual { background: rgba(202,138,4,.10); color: #92400E; }

/* "อัปเดต X วันก่อน" badge — ทดแทน trend % ที่เป็น synthetic */
.updated-badge {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.updated-badge svg { width: 11px; height: 11px; }
.updated-badge.fresh { background: rgba(15,157,88,.10);  color: var(--green); }
.updated-badge.aged  { background: var(--bg-soft); color: var(--ink-mute); }
.updated-badge.up    { background: rgba(220,38,38,.08); color: var(--red); }
.updated-badge.down  { background: rgba(15,157,88,.10); color: var(--green); }
.updated-badge.flat  { background: var(--bg-soft); color: var(--ink-mute); }

.stat-box.flat-annual .stat-value { color: var(--ink); font-size: 18px; }

/* Notice ใต้ chart — บอกชัดว่าใช้ข้อมูลจริงเท่านั้น */
.data-notice {
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 22px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.data-notice strong { color: #92400E; }

/* ===== Scope chips (รวม/ไม่รวม VAT/ขนส่ง/กำไร/Factor F) ===== */
.scope-note-row td { padding: 6px 12px 12px; background: var(--bg-soft); }
.scope-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.scope-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.scope-chip.inc { background: rgba(15,157,88,.12); color: var(--green); }
.scope-chip.exc { background: rgba(220,38,38,.10); color: var(--red); }
.scope-note { color: var(--ink-soft); font-size: 12px; line-height: 1.55; }

/* ===== Meta actions (header buttons) ===== */
.meta-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== Transport calculator modal ===== */
.tc-title { margin: 0 0 4px; font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.tc-sub   { margin: 0 0 22px; font-size: 13px; color: var(--ink-soft); }

.tc-section { margin-bottom: 18px; }
.tc-section-title { font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 8px; }
.tc-label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-mute); letter-spacing: .3px; text-transform: uppercase; margin-bottom: 6px; }
.tc-hint  { font-size: 11.5px; color: var(--ink-mute); margin-top: 4px; }

.tc-select, .tc-num {
  width: 100%; padding: 9px 12px;
  font-family: inherit; font-size: 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  box-sizing: border-box;
}
.tc-select:focus, .tc-num:focus { outline: 0; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,130,32,.12); }
.tc-select-sm { width: auto; }

.tc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tc-table th { background: var(--bg-soft); color: var(--ink-mute); font-weight: 700; font-size: 11.5px; letter-spacing: .3px; text-transform: uppercase; padding: 8px; text-align: center; border-bottom: 1px solid var(--line); }
.tc-table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tc-table td:first-child { font-weight: 600; }
.tc-table input.tc-num { padding: 6px 8px; font-size: 13px; }

.tc-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tc-qty { display: flex; gap: 6px; }
.tc-qty .tc-num { flex: 1; }

.tc-calc-btn {
  width: 100%; padding: 13px 20px; margin: 6px 0 18px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
  color: white; border: 0; border-radius: 12px;
  font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(245,130,32,.3);
  transition: all .15s;
}
.tc-calc-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(245,130,32,.4); }

.tc-result { margin-top: 10px; }
.tc-result-section { background: var(--bg-soft); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.tc-result-section h4 { margin: 0 0 10px; font-size: 14px; color: var(--ink); font-weight: 700; }
.tc-result-table { width: 100%; font-size: 12.5px; margin-bottom: 12px; }
.tc-result-table th { font-weight: 700; color: var(--ink-mute); font-size: 11px; padding: 6px; text-align: left; }
.tc-result-table td { padding: 4px 6px; color: var(--ink-soft); }

.tc-calc-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: var(--ink-soft); border-top: 1px dashed var(--line); }
.tc-calc-row:first-of-type { border-top: 0; }
.tc-calc-row strong { color: var(--ink); font-weight: 700; }

.tc-final { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tc-final-box { background: white; border: 2px solid var(--orange); border-radius: 14px; padding: 14px; text-align: center; }
.tc-final-box.tc-final-total { grid-column: 1 / -1; border-color: var(--green); background: rgba(15,157,88,.05); }
.tc-final-label { font-size: 11.5px; font-weight: 600; color: var(--ink-mute); letter-spacing: .3px; text-transform: uppercase; }
.tc-final-val { font-size: 24px; font-weight: 800; color: var(--orange); letter-spacing: -.02em; margin: 4px 0; }
.tc-final-box.tc-final-total .tc-final-val { color: var(--green); }
.tc-final-unit { font-size: 12px; color: var(--ink-soft); }

.tc-disclaimer {
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.tc-disclaimer strong { color: #92400E; }
.tc-warn { color: var(--red); font-weight: 700; padding: 10px; background: rgba(220,38,38,.06); border-radius: 10px; }

@media (max-width: 760px) {
  .tc-row-2 { grid-template-columns: 1fr; }
  .tc-final { grid-template-columns: 1fr; }
}
.trend-badge svg { width: 11px; height: 11px; }

.card h3 {
  font-size: 16px; font-weight: 700;
  margin: 4px 0 4px;
  letter-spacing: -.005em;
  color: var(--ink);
  line-height: 1.3;
}
.card .spec {
  font-size: 12.5px;
  color: var(--ink-mute);
  margin: 0 0 14px;
  min-height: 32px;
}

.price-block {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 6px;
}
.price-big {
  font-size: 26px; font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
  line-height: 1;
}

/* ===== Paywall blur — ราคาเบลอตอนใช้ครบโควต้า ===== */
/* รายการที่ถูก lock: blur เฉพาะตัวเลขราคา/ช่วงราคา/range bar */
/* ชื่อสินค้า/code/source ยังคงเห็น (Ctrl+F หาได้ตามปกติ) */
/* คลิกที่ใดของ card ก็เปิด paywall (ยกเว้น fav button) */
.card.price-locked {
  position: relative;
  cursor: pointer;
}
.card.price-locked:hover {
  border-color: rgba(245,130,32,.45);
  box-shadow: 0 6px 18px rgba(245,130,32,.18);
}
.card.price-locked .price-big,
.card.price-locked .price-range,
.card.price-locked .range-bar,
.card.price-locked .price-row {
  filter: blur(5px);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  transition: filter .2s;
}
.card.price-locked::after {
  content: '🔒 สนับสนุนเพื่อดูราคา';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, 30%);
  background: linear-gradient(135deg, #F58220, #ff9d4d);
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(245,130,32,.35);
  z-index: 2;
  pointer-events: auto;
}
.card.price-locked:hover::after {
  transform: translate(-50%, 30%) scale(1.05);
}

/* ===== Anonymous lock — user ยังไม่ login + รายการเกิน 100 ===== */
.card.anon-locked {
  position: relative;
  cursor: pointer;
}
.card.anon-locked:hover {
  border-color: rgba(27,79,140,.45);
  box-shadow: 0 6px 18px rgba(27,79,140,.18);
}
.card.anon-locked .price-big,
.card.anon-locked .price-range,
.card.anon-locked .range-bar,
.card.anon-locked .price-row {
  filter: blur(5px);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  transition: filter .2s;
}
.card.anon-locked::after {
  content: '🔓 เข้าสู่ระบบเพื่อดูราคา';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, 30%);
  background: linear-gradient(135deg, #1B4F8C, #3A7BD5);
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(27,79,140,.35);
  z-index: 2;
  pointer-events: auto;
}
.card.anon-locked:hover::after {
  transform: translate(-50%, 30%) scale(1.05);
}
.price-unit {
  font-size: 13px; color: var(--ink-soft); font-weight: 500;
}
.price-range {
  font-size: 12.5px; color: var(--ink-mute);
  margin-bottom: 10px;
}
.price-range .min { color: var(--green); font-weight: 600; }
.price-range .max { color: var(--red); font-weight: 600; }

.range-bar {
  width: 100%; height: 28px;
  margin: 6px 0 10px;
  cursor: pointer;
}

.src-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: auto;
}
.src-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  color: white;
  letter-spacing: .2px;
}

/* ===== EMPTY / ERROR ===== */
.loading-state, .empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.loading-state .spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--bg-soft);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state h4 { font-size: 18px; font-weight: 700; color: var(--ink); margin: 8px 0; }
.empty-state .icon-big {
  font-size: 48px; margin-bottom: 10px;
}

/* ===== FOOTER ===== */
.page-foot {
  border-top: 1px solid var(--line);
  background: white;
  padding: 22px 0 28px;
}
.foot-grid {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.foot-meta {
  font-size: 12.5px;
  color: var(--ink-soft);
  max-width: 640px;
  line-height: 1.55;
}
.foot-sources {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.foot-src {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}
.foot-src .swatch {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* ===== MODAL ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(14,26,46,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  width: 100%; max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 30px 26px;
  animation: pop .22s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 0; cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-soft);
  z-index: 3;
}
.modal-close:hover { background: var(--line); color: var(--ink); }

.detail-head {
  border-left: 4px solid var(--card-color, var(--blue));
  padding-left: 14px;
  margin-bottom: 22px;
}
.detail-head .cat-pill { margin-bottom: 8px; }
.detail-head h2 {
  font-size: 22px; font-weight: 800;
  margin: 0 0 4px;
  color: var(--ink);
  letter-spacing: -.01em;
}
.detail-head .spec { color: var(--ink-soft); font-size: 14px; margin: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.stat-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--bg-soft);
}
.stat-box .stat-label {
  font-size: 11.5px;
  color: var(--ink-mute);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.stat-box .stat-value {
  font-size: 22px; font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
  margin: 4px 0 2px;
}
.stat-box .stat-sub {
  font-size: 12px;
  color: var(--ink-soft);
}
.stat-box.up   .stat-value { color: var(--red); }
.stat-box.down .stat-value { color: var(--green); }

.chart-wrap {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 22px;
}
.chart-wrap canvas { width: 100% !important; height: 240px !important; }
.chart-title {
  font-size: 14px; font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
}

.source-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.source-table th, .source-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.source-table th {
  font-weight: 700;
  color: var(--ink-mute);
  font-size: 11.5px;
  letter-spacing: .4px;
  text-transform: uppercase;
  background: var(--bg-soft);
}
.source-table td:last-child {
  text-align: right;
  font-weight: 700;
  color: var(--ink);
}
.source-table .src-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 10px 14px; }
  .topbar .back span { display: none; }
  .title-block .title { font-size: 16px; }
  .title-block .title-th { display: none; }
  .updated-tag { padding: 5px 9px; font-size: 11.5px; }
  .container { padding: 0 14px; }
  .search-row { grid-template-columns: 1fr; }
  .select-group { width: 100%; }
  .select-wrap { flex: 1; min-width: 0; }
  .main-grid { padding: 18px 14px 40px; }
  .cards-wrap { grid-template-columns: 1fr; gap: 12px; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 22px 18px; }
}
