/* ===== Design tokens — DARK (dark-luxury fintech, mặc định) ===== */
:root,
:root[data-theme='dark'] {
  --ink: #0a0a0c;
  --surface: #141418;
  --surface2: #1c1c22;
  --line: #2a2a33;
  --gold: #d4af37;
  --goldsoft: #e7c768;
  --up: #34d399;
  --down: #fb7185;
  --text: #ededf0;
  --muted: #9a9aa6;

  --card-bg: rgba(20, 20, 24, 0.8);
  --header-bg: rgba(10, 10, 12, 0.8);
  --on-gold: #1a1407; /* chữ trên nền vàng — luôn tối ở cả 2 theme */
  --page-glow:
    radial-gradient(900px 500px at 85% -10%, rgba(212, 175, 55, 0.08), transparent 60%),
    radial-gradient(700px 400px at -10% 0%, rgba(120, 120, 180, 0.06), transparent 55%);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 0 1px rgba(212, 175, 55, 0.25), 0 8px 30px -8px rgba(212, 175, 55, 0.25);
  --gold-grad: linear-gradient(135deg, #e7c768 0%, #d4af37 45%, #9a7d23 100%);

  color-scheme: dark;
}

/* ===== Design tokens — LIGHT (light-luxury) ===== */
:root[data-theme='light'] {
  --ink: #f6f3ec;
  --surface: #ffffff;
  --surface2: #f0ebe1;
  --line: #e2dccf;
  --gold: #b8860b;
  --goldsoft: #92701a; /* đủ tối để đọc giá trên nền sáng */
  --up: #15803d;
  --down: #be123c;
  --text: #201d17;
  --muted: #6f6a5f;

  --card-bg: rgba(255, 255, 255, 0.92);
  --header-bg: rgba(246, 243, 236, 0.85);
  --on-gold: #2a1f06;
  --page-glow:
    radial-gradient(900px 500px at 85% -10%, rgba(184, 134, 11, 0.12), transparent 60%),
    radial-gradient(700px 400px at -10% 0%, rgba(120, 120, 180, 0.06), transparent 55%);

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 12px 30px -16px rgba(90, 75, 30, 0.35);
  --shadow-glow: 0 0 0 1px rgba(184, 134, 11, 0.3), 0 8px 26px -10px rgba(184, 134, 11, 0.3);

  color-scheme: light;
}

/* ===== Reset & base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background-color: var(--ink);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background-image: var(--page-glow);
  background-attachment: fixed;
  background-repeat: no-repeat;
  transition: background-color 0.25s ease, color 0.25s ease;
}
a {
  color: inherit;
  text-decoration: none;
}
h1 {
  margin: 0;
}
.display {
  font-family: 'Playfair Display', Georgia, serif;
}
.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}
.gold-text {
  color: var(--goldsoft);
}
.muted {
  color: var(--muted);
}

/* ===== Layout ===== */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header / nav ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--gold-grad);
  color: var(--on-gold);
  font-weight: 700;
  font-size: 18px;
  font-family: 'Playfair Display', serif;
  box-shadow: var(--shadow-glow);
}
.brand .title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.1;
}
.brand .sub {
  font-size: 11px;
  color: var(--muted);
}
nav.tabs {
  display: flex;
  gap: 4px;
}
nav.tabs a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
nav.tabs a:hover {
  color: var(--text);
  background: var(--surface2);
}
nav.tabs a.active {
  color: var(--text);
  background: var(--surface2);
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover {
  border-color: var(--gold);
}

/* ===== Chips & cards ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.chip-gold {
  background: var(--gold-grad);
  color: var(--on-gold);
  border-color: transparent;
  font-weight: 700;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.dot.live {
  background: var(--up);
  animation: pulse 1.6s ease-in-out infinite;
}
.dot.dead {
  background: var(--down);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.card {
  border: 1px solid var(--line);
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(4px);
}
.card.glow {
  box-shadow: var(--shadow-glow), var(--shadow-card);
}
.pad {
  padding: 20px;
}

/* ===== Main ===== */
main.wrap {
  padding-top: 24px;
  padding-bottom: 24px;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.page-head h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-head p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* ===== Grids ===== */
.grid {
  display: grid;
  gap: 16px;
}
.grid.fx {
  grid-template-columns: 1fr 1fr;
}
.grid.sources {
  grid-template-columns: 1fr 1fr;
}
.grid.stats {
  grid-template-columns: repeat(4, 1fr);
}
.col-span-2 {
  grid-column: 1 / -1;
}
/* Tablet & nhỏ hơn */
@media (max-width: 760px) {
  .grid.fx,
  .grid.sources {
    grid-template-columns: 1fr;
  }
  .grid.stats {
    grid-template-columns: 1fr 1fr;
  }
  nav.tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  nav.tabs::-webkit-scrollbar {
    display: none;
  }
  .page-head {
    margin-bottom: 16px;
  }
  .controls {
    width: 100%;
  }
}

/* Điện thoại nhỏ */
@media (max-width: 480px) {
  .wrap {
    padding: 0 12px;
  }
  .pad {
    padding: 16px;
  }
  .price-row,
  .price-head {
    grid-template-columns: minmax(0, 1fr) 6rem 6rem;
    padding: 10px 14px;
    gap: 8px;
  }
  .price-row .label .nm {
    font-size: 13px;
  }
  .price-row .buy,
  .price-row .sell {
    font-size: 13px;
  }
  .delta {
    font-size: 11px;
  }
  .brand .sub {
    display: none; /* gọn header trên màn rất nhỏ */
  }
  .tab {
    padding: 8px 14px;
    font-size: 13px;
  }
  select {
    max-width: 100%;
    flex: 1;
  }
  label.picker {
    width: 100%;
  }
}

/* Desktop rộng — nhiều khoảng thở hơn */
@media (min-width: 1280px) {
  .wrap {
    max-width: 1180px;
  }
}

/* ===== FX cards ===== */
.fx-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}
.fx-big {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(24px, 6vw, 30px);
  margin-top: 12px;
}
.fx-pair {
  display: flex;
  gap: 18px;
  margin-top: 12px;
}
.fx-pair .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.fx-pair .v {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 22px;
}
/* Thẻ giá cao nhất / thấp nhất — mỗi dòng: giá bên trái, branch nổi bật bên phải */
.extreme-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
}
.extreme-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
}
.extreme-item + .extreme-item {
  border-top: 1px solid var(--line);
}
.extreme-price .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.extreme-price .v {
  margin-top: 3px;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 22px;
}
.branch {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(18px, 4.5vw, 24px);
  color: var(--goldsoft);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}
.unit {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* ===== Source cards / price table ===== */
.src-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.src-head .name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(16px, 4vw, 18px);
}
.src-head .chip {
  text-transform: uppercase;
}
.price-row,
.price-head {
  display: grid;
  /* Cột Mua/Bán rộng cố định -> mọi hàng + header canh thẳng cột (tabular-nums) */
  grid-template-columns: minmax(0, 1fr) 7.5rem 7.5rem;
  gap: 12px;
  align-items: center;
  padding: 11px 20px;
}
.price-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 8px;
  padding-bottom: 8px;
}
.price-row + .price-row,
.price-head + .price-row {
  border-top: 1px solid var(--line);
}
.price-row .label {
  min-width: 0;
}
.price-row .label .nm {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.price-row .buy {
  text-align: right;
  font-size: 14px;
  color: var(--muted);
}
.price-row .sell {
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--goldsoft);
}
.right {
  text-align: right;
}

/* ===== Delta tag ===== */
.delta {
  font-size: 12px;
  font-weight: 500;
}
.delta.up {
  color: var(--up);
}
.delta.down {
  color: var(--down);
}
.delta.flat {
  color: var(--muted);
}

/* ===== Stat boxes ===== */
.stat .k {
  font-size: 12px;
  color: var(--muted);
}
.stat .v {
  margin-top: 4px;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 20px;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
label.picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
select,
.seg button {
  font: inherit;
}
select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  max-width: 320px;
}
select:focus {
  border-color: var(--gold);
}
.seg {
  display: inline-flex;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.15s;
}
.seg button:hover {
  color: var(--text);
}
.seg button.active {
  background: var(--gold-grad);
  color: var(--on-gold);
  font-weight: 600;
}

/* ===== Tab trượt ngang theo nguồn (trang Giá hiện tại) ===== */
.tabs-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs-bar::-webkit-scrollbar {
  display: none;
}
.tab {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  background: var(--gold-grad);
  color: var(--on-gold);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}
.slider {
  overflow: hidden;
  margin-top: 14px;
  touch-action: pan-y; /* cho phép cuộn dọc, ta tự xử lý vuốt ngang */
  transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.track {
  display: flex;
  align-items: flex-start; /* panel không bị kéo cao bằng panel cao nhất */
  will-change: transform;
}
.panel {
  flex: 0 0 100%;
  min-width: 100%;
}

/* ===== Chart ===== */
.chart-box {
  position: relative;
  height: clamp(240px, 46vh, 360px);
}
.legend {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
}
.legend i {
  display: inline-block;
  width: 20px;
  height: 0;
  margin-right: 6px;
  vertical-align: middle;
}
.legend i.sell {
  border-top: 2px solid var(--goldsoft);
}
.legend i.buy {
  border-top: 2px dashed #7c7cff;
}

/* ===== Skeleton / states ===== */
.skeleton {
  background: var(--surface2);
  border-radius: var(--radius);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}
.empty {
  display: grid;
  place-items: center;
  height: 320px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ===== Footer ===== */
.site-footer {
  padding: 40px 16px;
  font-size: 12px;
  color: var(--muted);
}
.note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
code {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 12px;
}
