/* หน้าสถิติ */

.stat-main { padding-top: 20px; padding-bottom: 40px; display: grid; gap: 12px; }

.stat-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.range { min-width: 260px; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 820px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: grid; gap: 2px; min-width: 0;
}
.kpi-label { font-size: 14px; color: var(--ink-2); }
.kpi-value { font-size: 30px; font-weight: 600; line-height: 1.2; }
.kpi-sub { font-size: 13px; color: var(--ink-3); min-height: 1.4em; }

.two-col { display: grid; gap: 12px; }
@media (min-width: 820px) { .two-col { grid-template-columns: 1fr 1fr; } }

.chart { position: relative; height: 240px; }
.chart-sm { height: 190px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .bar-est { fill: url(#hatch); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.is-hover { opacity: 0.8; }
.chart-note { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.swatch-hatch {
  width: 14px; height: 14px; border-radius: 3px; flex: none;
  background: repeating-linear-gradient(135deg, var(--accent) 0 2px, transparent 2px 5px);
  border: 1px solid var(--accent);
}
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--ink-3); font-size: 15px; }

.chart-tip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--ink); color: var(--ground);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.4;
  box-shadow: var(--shadow-lift); white-space: nowrap;
}
.chart-tip b { font-variant-numeric: tabular-nums; }

.live-list { display: grid; gap: 8px; }
.live-room {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 12px; background: var(--surface-2);
}
.live-room b { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.live-names { flex-basis: 100%; font-size: 14px; color: var(--ink-2); }
.empty { color: var(--ink-3); padding: 8px 0; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table td.code { font-weight: 500; font-variant-numeric: tabular-nums; }
.table .names { color: var(--ink-2); font-size: 14px; max-width: 34ch; }

/* มือถือ: ตารางกลายเป็นการ์ดรายแถว */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  .table td { border: 0; padding: 0; }
  .table td.code { font-size: 17px; }
  .table td.r::after { content: attr(data-unit); color: var(--ink-3); font-size: 13px; margin-left: 4px; }
  .table td.when { grid-column: 1 / -1; color: var(--ink-3); font-size: 14px; }
  .table td.names { grid-column: 1 / -1; max-width: none; }
  .table td.peak { text-align: right; color: var(--ink-3); font-size: 14px; }
}
