:root {
  color-scheme: light;
  --bg: #faf7f0;
  --surface: #ffffff;
  --surface-2: #f4efe3;
  --text: #1f1b13;
  --muted: #6b6354;
  --border: #e6dfcf;
  --accent: #8f6100;
  --accent-soft: #f6ebcf;
  --on-accent: #ffffff;
  --gold: #c99a24;
  --up: #0b7a43;
  --down: #c0392b;
  --notice-bg: #fff4dd;
  --notice-border: #eec26a;
  --chart-buy: #8c7f68;
  --chart-sell: #c99a24;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(60 45 15 / 6%), 0 6px 20px rgb(60 45 15 / 5%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateY(-200%);
  padding: 8px 12px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus {
  transform: none;
}

.muted,
.meta {
  color: var(--muted);
}

.text-up {
  color: var(--up);
}

.text-down {
  color: var(--down);
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 12px 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: linear-gradient(135deg, #f6d98a, #b07d12);
  transform: rotate(45deg);
}

.header-time {
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: right;
}

.nav-scroll {
  position: relative;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-block: 6px 8px;
  scrollbar-width: none;
}

.nav-scroll::-webkit-scrollbar {
  display: none;
}

.nav-scroll a {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav-scroll a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-scroll a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Nội dung */

main {
  padding-block: 16px 56px;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.125rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h2 {
  margin: 36px 0 10px;
  font-size: 1.25rem;
  line-height: 1.3;
}

.lead {
  max-width: 70ch;
  margin: 0 0 16px;
  font-size: 1.0625rem;
}

.meta {
  margin: -2px 0 10px;
  font-size: 0.875rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.8125rem;
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 4px;
}

.breadcrumbs a {
  color: inherit;
}

.notice {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid var(--notice-border);
  border-radius: var(--radius);
  background: var(--notice-bg);
  font-size: 0.9375rem;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 4px;
}

.prose {
  max-width: 72ch;
}

.prose ul {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: 6px;
}

/* Thẻ tóm tắt */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-block: 16px 8px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

.card-title a:hover {
  text-decoration: underline;
}

.card-label {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.card-value {
  margin: 2px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.card-value .price {
  display: inline;
}

.card-unit {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

.card-change {
  margin: 2px 0 0;
  font-size: 0.875rem;
}

.card-change .chg {
  display: inline;
}

.card-details {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.card-details .price {
  display: inline;
  font-weight: 500;
  color: var(--text);
}

.spark {
  display: block;
  width: 100%;
  height: 56px;
  margin-top: 10px;
}

.spark-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.spark-area {
  fill: var(--accent-soft);
}

.spark-empty {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.chart-mini {
  max-width: 560px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.chart-mini .spark {
  height: 96px;
  margin: 0;
}

/* Bảng giá */

.unit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.875rem;
}

.unit-bar strong {
  color: var(--text);
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.segmented button {
  min-height: 32px;
  padding: 4px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.price-table th,
.price-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.price-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.price-table tbody th {
  font-weight: 500;
}

.price-table tbody:last-child tr:last-child > * {
  border-bottom: 0;
}

.price-table .num {
  text-align: right;
  white-space: nowrap;
}

.price-table .group-row th {
  padding-block: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.row-name,
.row-note {
  display: block;
}

.row-note {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

.price {
  display: block;
  font-weight: 600;
}

.chg {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
}

.chg.up {
  color: var(--up);
}

.chg.down {
  color: var(--down);
}

.chg.flat {
  color: var(--muted);
  font-weight: 400;
}

/* Liên kết */

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-grid a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.link-grid a:hover {
  border-color: var(--accent);
}

.tool-list {
  display: grid;
  gap: 10px;
  max-width: 640px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.tool-list a {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.tool-list a:hover {
  border-color: var(--accent);
}

.tool-list span {
  color: var(--muted);
  font-size: 0.9375rem;
}

.big-link {
  font-size: 1.125rem;
  font-weight: 600;
}

/* Biểu đồ */

.chart-card {
  padding: 14px 16px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chip {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.chart-title {
  margin: 10px 0 4px;
  font-weight: 600;
}

.chart-plot {
  min-height: 320px;
}

.chart-status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.chart-status:empty {
  display: none;
}

.uplot,
.uplot .u-legend {
  font-family: var(--font);
}

.uplot .u-legend {
  color: var(--text);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* Công cụ */

.tool {
  display: grid;
  gap: 14px;
  max-width: 600px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 11rem);
  gap: 10px;
}

.field label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.btn {
  justify-self: start;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.form-error {
  margin: 0;
  color: var(--down);
}

.tool-result {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.result-grid dt {
  color: var(--muted);
}

.result-grid dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.result-grid .result-main {
  font-size: 1.25rem;
}

/* Footer */

.site-footer {
  padding-block: 24px 32px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  max-width: 80ch;
  margin: 8px 0 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.footer-links a {
  color: var(--text);
}

@media (max-width: 520px) {
  .price-table th,
  .price-table td {
    padding: 9px 10px;
  }

  .price-table .price {
    font-size: 0.9375rem;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 8rem);
  }

  .header-time {
    display: none;
  }
}
