/* Giá Chợ — dark theme tokens + components. See docs/UI-DESIGN.md. */
:root {
  --bg: #0b0e13;
  --surface: #141821;
  --surface-2: #1c222e;
  --border: rgba(255, 255, 255, 0.08);
  --text-1: #f4f6fb;
  --text-2: #a7b0c0;
  --muted: #6b7688;
  --accent: #2dd4a7;

  --series-chung: #3987e5;
  --series-bhx: #199e70;
  --series-winmart: #e66767;

  --up: #e5674f;    /* giá tăng — xấu cho người mua */
  --down: #2dd4a7;  /* giá giảm — tốt */

  --radius: 16px;
  --gap: 18px;
  --maxw: 1080px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(45,212,167,0.04), transparent);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 40px; height: 40px; flex: 0 0 auto; }
.brand .name { font-size: 20px; font-weight: 800; letter-spacing: 0.2px; }
.brand .tag { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-top: 1px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: var(--text-2); padding: 7px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 600; border: 1px solid transparent;
}
.nav a:hover { color: var(--text-1); background: var(--surface-2); text-decoration: none; }
.nav a.cta { color: var(--text-1); border-color: var(--border); }
.nav a.cta:hover { border-color: var(--accent); }

/* Section heads */
.page-title { font-size: 26px; font-weight: 800; margin: 26px 0 4px; }
.page-sub { color: var(--text-2); margin: 0 0 20px; font-size: 15px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; letter-spacing: 0.2px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.grid { display: grid; gap: var(--gap); }

/* Stat tiles */
.tiles { grid-template-columns: repeat(3, 1fr); margin: 20px 0; }
@media (max-width: 720px) { .tiles { grid-template-columns: 1fr; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.tile .label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.tile .value { font-size: 46px; font-weight: 800; line-height: 1.1; margin: 6px 0 2px; }
.tile.hero .value { color: var(--text-1); }
.tile .delta { font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }
.tile .base { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* Two-up */
.two-up { grid-template-columns: 1fr 1fr; margin: 20px 0; }
@media (max-width: 720px) { .two-up { grid-template-columns: 1fr; } }

/* Movers list */
.movers { list-style: none; margin: 0; padding: 0; }
.movers li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.movers li:last-child { border-bottom: 0; }
.movers .nm { color: var(--text-1); font-size: 14px; }
.chip { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 999px; }
.chip.up { color: var(--up); background: rgba(229,103,79,0.12); }
.chip.down { color: var(--down); background: rgba(45,212,167,0.12); }

/* Chart */
.chart-card { margin: 20px 0; }
.chart-box { position: relative; width: 100%; height: 360px; }
@media (max-width: 720px) { .chart-box { height: 300px; } }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 2px 0 14px; }
.legend .item { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.legend .swatch { width: 16px; height: 3px; border-radius: 2px; }
.toggle {
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.toggle:hover { color: var(--text-1); }
.tableview { margin-top: 14px; overflow-x: auto; }
.tableview[hidden] { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--text-2); background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }

/* Note + compare */
.note { font-size: 15px; color: var(--text-1); }
.note .date { color: var(--muted); font-size: 13px; margin-top: 10px; }
.compare-line { font-size: 15px; color: var(--text-2); }
.compare-line strong { color: var(--text-1); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 22px 0 40px; color: var(--muted); font-size: 13px; }
.site-footer a { color: var(--text-2); }
.site-footer .row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* Item detail page */
.crumb { color: var(--muted); font-size: 13px; margin: 22px 0 2px; }
.crumb a { color: var(--text-2); }
.item-title { font-size: 26px; font-weight: 800; margin: 2px 0 2px; }
.item-group { color: var(--text-2); font-size: 14px; margin: 0 0 20px; }
.chains { grid-template-columns: 1fr 1fr; margin-bottom: 20px; }
@media (max-width: 720px) { .chains { grid-template-columns: 1fr; } }
.chain-card { display: flex; gap: 16px; }
.chain-card .prod-img {
  width: 84px; height: 84px; flex: 0 0 auto; border-radius: 12px;
  object-fit: cover; background: var(--surface-2); border: 1px solid var(--border);
}
.chain-card .prod-img.ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.chain-body { min-width: 0; flex: 1; }
.chain-name { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.disp-name { font-size: 15px; font-weight: 600; margin: 6px 0 2px; color: var(--text-1); }
.meta-row { color: var(--muted); font-size: 12.5px; margin: 1px 0; }
.price-block { margin-top: 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price-now { font-size: 22px; font-weight: 800; }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 14px; }
.unitprice { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.in { color: var(--down); background: rgba(45,212,167,0.12); }
.badge.out { color: var(--up); background: rgba(229,103,79,0.12); }
.badge.carry { color: var(--muted); background: var(--surface-2); }
.store-line { color: var(--muted); font-size: 12px; margin-top: 10px; }
.store-line a, .meta-row a { color: var(--text-2); }

/* Products grid (dashboard) */
.prod-grid { grid-template-columns: repeat(4, 1fr); margin: 20px 0; }
@media (max-width: 900px) { .prod-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .prod-grid { grid-template-columns: 1fr; } }
.pcard { display: flex; flex-direction: column; gap: 10px; padding: 14px; text-decoration: none; color: inherit; }
.pcard:hover { border-color: var(--accent); text-decoration: none; }
.pcard .thumb { width: 100%; aspect-ratio: 1/1; border-radius: 10px; object-fit: cover; background: #fff; border: 1px solid var(--border); }
.pcard .thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 30px; background: var(--surface-2); }
.pcard .pn { font-size: 13.5px; font-weight: 600; line-height: 1.35; color: var(--text-1);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .pg { font-size: 11.5px; color: var(--muted); }
.pcard .pp { margin-top: auto; }
.pcard .pp .amt { font-size: 17px; font-weight: 800; }
.pcard .pp .unit { font-size: 12px; color: var(--text-2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 4px; }
.section-head h2 { font-size: 18px; font-weight: 800; margin: 0; }
.section-head .cnt { color: var(--muted); font-size: 13px; }
.basewk { color: var(--muted); font-size: 13px; font-weight: 600; }

/* Catalog page (full product list) */
.catalog-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 18px 0; padding: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.catalog-toolbar input[type="search"],
.catalog-toolbar select {
  background: var(--surface-2); color: var(--text-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: var(--font);
}
.catalog-toolbar input[type="search"] { flex: 1 1 220px; min-width: 160px; }
.catalog-toolbar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.catalog-toolbar .spacer { flex: 1 1 auto; }
.catalog-toolbar .result-cnt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.pcard .badge-discount {
  position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 800;
  color: #fff; background: var(--up); padding: 2px 7px; border-radius: 999px;
}
.pcard .thumb-wrap { position: relative; }
.pcard .price-old-sm { color: var(--muted); text-decoration: line-through; font-size: 12px; margin-right: 6px; }
.pcard .stock-out { color: var(--up); font-size: 11px; font-weight: 700; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 24px 0; flex-wrap: wrap; }
.pager button {
  background: var(--surface-2); color: var(--text-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button:disabled { color: var(--muted); cursor: default; }
.pager button.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.pager .pageinfo { color: var(--text-2); font-size: 13px; margin: 0 6px; }
.catalog-loading, .catalog-empty { color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center; }
