/* คอมโพเนนต์: ปุ่ม แผง ตาราง สถิติ กราฟ */

/* ---------- ปุ่ม ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--step-sm);
  font-weight: 500;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #5c97ff, #3d7ded);
  color: #06101f;
  font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(180deg, #6ba1ff, #4a88f5); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: #2f4257; color: var(--text); }

.btn-danger {
  background: var(--down-soft);
  border-color: rgba(255, 92, 108, 0.4);
  color: var(--down);
}
.btn-danger:hover { background: rgba(255, 92, 108, 0.2); }

.btn-block { width: 100%; padding: 0.65rem; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: var(--step-sm); }

.link { color: var(--accent); font-size: var(--step-sm); }

/* ---------- แผง ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.panel-foot {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.empty-inline {
  padding: 2.5rem 1.1rem;
  text-align: center;
  color: var(--text-dim);
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

.empty {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  padding: 4rem 1rem;
  text-align: center;
}

/* ---------- แถบสรุปด้านบน ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) 2fr;
  gap: var(--gap-lg);
  padding: 1.4rem 1.5rem;
  background:
    linear-gradient(135deg, rgba(76, 141, 255, 0.10), transparent 55%),
    var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-main { display: grid; gap: 0.2rem; align-content: center; }
.hero-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.hero-value small { font-size: 0.4em; color: var(--text-mute); font-weight: 500; }
.hero-sub { color: var(--text-dim); font-size: var(--step-sm); }

.hero-stats, .stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat {
  display: grid;
  gap: 0.15rem;
  align-content: center;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
}
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.2;
}
.stat-sub { color: var(--text-mute); font-size: var(--step-sm); }

/* ---------- ตาราง ---------- */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-sm);
}
.table th, .table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-mute);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
}
.table thead th.num { text-align: right; }
.table tbody tr:hover { background: rgba(76, 141, 255, 0.05); }
.table tfoot td {
  background: var(--surface-2);
  font-weight: 600;
  border-bottom: none;
}
.table .note {
  white-space: normal;
  max-width: 22ch;
  color: var(--text-dim);
}

.sym { font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.02em; }

/* ---------- บล็อกรายไม้ในหน้ารายหุ้น ---------- */

.lot-block { border-bottom: 1px solid var(--line-soft); }
.lot-block:last-child { border-bottom: none; }

.lot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  padding: 0.8rem 1.1rem;
  background: var(--surface-2);
}
.lot-head strong { font-family: var(--font-mono); }
.lot-head .muted { font-size: var(--step-sm); }
.lot-nums {
  display: flex;
  align-items: baseline;
  gap: var(--gap);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-sm);
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag-buy  { background: var(--up-soft);   color: var(--up); }
.tag-sell { background: var(--down-soft); color: var(--down); }

/* ---------- กราฟแท่งรายเดือน ---------- */

.bars { list-style: none; margin: 0; padding: 0.5rem 1.1rem 1rem; display: grid; gap: 0.55rem; }
.bars li {
  display: grid;
  grid-template-columns: 4.5rem 1fr 6.5rem;
  grid-template-areas: 'label track value' 'label meta meta';
  align-items: center;
  gap: 0.15rem 0.75rem;
}
.bar-label { grid-area: label; font-family: var(--font-mono); font-size: var(--step-sm); color: var(--text-dim); }
.bar-track { grid-area: track; height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar-fill  { display: block; height: 100%; border-radius: 999px; }
.bar-fill.up   { background: linear-gradient(90deg, rgba(34,201,147,.5), var(--up)); }
.bar-fill.down { background: linear-gradient(90deg, rgba(255,92,108,.5), var(--down)); }
.bar-fill.flat { background: var(--text-mute); }
.bar-value { grid-area: value; font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.bar-meta  { grid-area: meta; font-size: 0.75rem; color: var(--text-mute); }

/* ---------- ฟีดรายการล่าสุด ---------- */

.feed { list-style: none; margin: 0; padding: 0.35rem 1.1rem 1rem; display: grid; gap: 0.1rem; }
.feed li {
  display: grid;
  grid-template-columns: 3.2rem 5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.feed li:last-child { border-bottom: none; }
.feed-detail { font-family: var(--font-mono); font-size: var(--step-sm); color: var(--text-dim); }
.feed-date { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-mute); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
}

/* ---------- ตารางสถิติ ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--line-soft);
}
.metric {
  display: grid;
  gap: 0.15rem;
  align-content: start;
  padding: 0.85rem 1rem;
  background: var(--surface);
}
.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.2;
}
.metric-value small { font-size: 0.6em; color: var(--text-mute); font-weight: 500; }

/* ---------- กราฟการเติบโตของพอร์ต ---------- */

.growth { padding: 0.5rem 0.6rem 0.9rem; }
.growth-svg { width: 100%; height: auto; display: block; overflow: visible; }

.growth-zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.growth-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.growth-line.up   { stroke: var(--up); }
.growth-line.down { stroke: var(--down); }
.growth-area { stroke: none; opacity: 0.16; }
.growth-area.up   { fill: var(--up); }
.growth-area.down { fill: var(--down); }
.growth-dot { fill: var(--surface); stroke: var(--text-mute); stroke-width: 1.5; }
.growth-dot.last.up   { fill: var(--up);   stroke: var(--up); }
.growth-dot.last.down { fill: var(--down); stroke: var(--down); }
.growth-tick { fill: var(--text-mute); font-size: 11px; font-family: var(--font-mono); }
.growth-tick.end { text-anchor: end; }

.growth-legend {
  display: flex;
  align-items: baseline;
  gap: var(--gap-lg);
  flex-wrap: wrap;
  padding: 0.6rem 0.5rem 0;
}
.growth-legend span { display: grid; gap: 0.1rem; }
.growth-legend strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-1);
}
.growth-legend .hint { align-self: center; margin-left: auto; }

/* ---------- การ์ดสมาชิกในหน้ารวม ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}

.user-card {
  display: grid;
  gap: 0.7rem;
  padding: 1rem 1.1rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease;
}
.user-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: #2f4257;
}

.user-card-head { display: flex; align-items: center; gap: 0.6rem; }
.user-card-head strong { display: block; line-height: 1.25; }
.user-card-head .muted { font-family: var(--font-mono); font-size: var(--step-sm); }
.user-rank {
  font-family: var(--font-mono);
  font-size: var(--step-sm);
  color: var(--text-mute);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

.user-card-main { display: grid; gap: 0.1rem; }
.user-pct {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.1;
}
.user-pct small { font-size: 0.5em; color: var(--text-mute); }

.spark { width: 100%; height: 44px; display: block; }
.spark-empty {
  height: 44px;
  display: grid;
  place-items: center;
  font-size: var(--step-sm);
  border-top: 1px dashed var(--line-soft);
  border-bottom: 1px dashed var(--line-soft);
}
.spark-line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-line.up   { stroke: var(--up); }
.spark-line.down { stroke: var(--down); }

.user-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
}
.user-card-stats dt { font-size: 0.7rem; color: var(--text-mute); }
.user-card-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-sm);
  font-weight: 600;
}

.user-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-mute);
}

/* ---------- เนื้อหาแบบบทความ (หน้านโยบาย) ---------- */
.prose { padding: 0.9rem 1.1rem 1.1rem; color: var(--text-dim); }
.prose p { margin: 0 0 0.8rem; }
.prose p:last-child, .prose ul:last-child { margin-bottom: 0; }
.prose ul { margin: 0 0 0.8rem; padding-left: 1.2rem; display: grid; gap: 0.4rem; }
.prose strong { color: var(--text); }
