:root {
  --ground: #F6F5F1; --surface: #FFFFFF; --ink: #15171C; --muted: #5B6070; --soft: #4A4F5C;
  --line: #E3E1DA; --line2: #EFEDE7; --field: #CFCCC3;
  --buy: #1F4FD1; --buy-ink: #163A9E; --buy-bg: #E6ECFB;
  --sell: #F0A27A; --sell-ink: #8F3709; --sell-bg: #FBE9DF;
  --gold-bg: #F5EDD6; --gold-ink: #6B5310;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; font-size: 15px; }
a { color: var(--buy); } a:hover { color: var(--buy-ink); }
h1, h2, h3 { margin: 0; }
h1 { font-size: 30px; } h2 { font-size: 18px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--ink); color: #fff; }
.top-in { max-width: 1840px; margin: 0 auto; padding: 14px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.nav a { color: #D9DCE4; text-decoration: none; padding: 8px 14px; border-radius: 8px; }
.nav a[aria-current="page"] { color: #fff; background: #2B2F38; font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #D9DCE4; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #3A4BA8; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.linkbtn { background: none; border: 0; color: #D9DCE4; font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; padding: 8px 4px; }

/* layout */
main { max-width: 1840px; margin: 0 auto; padding: 32px 24px 48px; display: flex; flex-direction: column; gap: 24px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head p { margin: 6px 0 0; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.grow { flex: 999 1 640px; min-width: 0; }
.side { flex: 1 1 340px; max-width: 440px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card.flush { padding: 0; gap: 0; overflow-x: auto; }
.card-h { padding: 18px 20px 6px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi span:first-child { font-size: 14px; color: var(--muted); }
.kpi b { font-family: var(--mono); font-size: 28px; font-weight: 600; }
.kpi small { font-size: 15px; color: var(--muted); font-weight: 500; }
.note { font-size: 13px; color: var(--muted); margin: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 500; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line2); }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
.num { text-align: right; font-family: var(--mono); }
th.num { font-family: inherit; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover, tbody tr.sel { background: #F4F7FE; }
.sym { font-family: var(--mono); font-weight: 600; }
.sub { display: block; font-size: 13px; color: var(--muted); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }

/* badges */
.badge { font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 8px; white-space: nowrap; display: inline-block; }
.b-buy { background: var(--buy-bg); color: var(--buy-ink); }
.b-sell { background: var(--sell-bg); color: var(--sell-ink); }
.b-hold { background: var(--line2); color: #3F4350; font-weight: 500; }
.b-wait { color: var(--muted); font-weight: 400; padding-left: 0; }
.b-gold { background: var(--gold-bg); color: var(--gold-ink); }
.up { color: var(--buy-ink); font-weight: 600; }
.down { color: var(--sell-ink); font-weight: 600; }

/* controls */
.btn { font: inherit; font-weight: 600; font-size: 15px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--buy); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { background: var(--buy-ink); color: #fff; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--field); font-weight: 500; }
.btn.ghost:hover { background: var(--ground); }
.btn.danger { background: var(--surface); color: var(--sell-ink); border: 1px solid var(--field); font-weight: 500; min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font: inherit; font-size: 15px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); cursor: pointer; }
.pill[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 600; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--field); border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { font: inherit; font-size: 14px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 600; }
form.stack, .stack { display: flex; flex-direction: column; gap: 14px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; padding: 11px 12px; border: 1px solid var(--field); border-radius: 10px; background: #fff; color: var(--ink); min-width: 0; min-height: 44px; }
input:focus, select:focus, .btn:focus-visible, .pill:focus-visible { outline: 2px solid var(--buy); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--field); border-radius: 10px; padding: 0 14px; min-width: 260px; }
.search input { border: 0; padding: 0; min-height: 42px; flex: 1; }
.search input:focus { outline: none; }
.msg { font-size: 14px; padding: 10px 12px; border-radius: 10px; }
.msg.err { background: var(--sell-bg); color: var(--sell-ink); }
.msg.ok { background: var(--buy-bg); color: var(--buy-ink); }

/* stats bars */
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line2); }
.bar .w { background: var(--buy); } .bar .l { background: var(--sell); }
.brk { display: grid; grid-template-columns: 120px minmax(0, 1fr) 120px; gap: 14px; align-items: center; }
.legend { display: flex; gap: 20px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hero-stat { flex: 1 1 300px; background: var(--ink); color: #fff; border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.hero-stat .big { font-family: var(--mono); font-size: 64px; font-weight: 600; line-height: 1; }
.hero-stat .bar { height: 12px; background: #3A3E48; } .hero-stat .bar .w { background: #8FB0FF; } .hero-stat .bar .l { background: #E8875A; }
.chart-wrap { position: relative; }
.chart-wrap.full { position: fixed; inset: 0; z-index: 100; background: #fff; padding: 12px; }
.chart-wrap.full .chart { height: 100%; }
.chart-fs { position: absolute; top: 8px; left: 8px; z-index: 3; font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line2); background: rgba(255,255,255,.92); color: var(--ink); cursor: pointer; }
.chart-wrap.full .chart-fs { top: 20px; left: 20px; }
body.noscroll { overflow: hidden; }
.chart { height: clamp(380px, 52vh, 560px); border-radius: 10px; overflow: hidden; border: 1px solid var(--line2); }
.lvl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lvl div { display: flex; flex-direction: column; gap: 2px; background: var(--ground); border-radius: 10px; padding: 10px 12px; }
.lvl span { font-size: 12px; color: var(--muted); } .lvl b { font-family: var(--mono); }

@media (max-width: 640px) {
  main { padding: 24px 16px 40px; }
  .top-in { padding: 12px 16px; }
  .side { max-width: none; }
  .brk { grid-template-columns: 90px minmax(0, 1fr) 90px; }
  .search { min-width: 0; width: 100%; }
  .brand { flex: 1; }
  .nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; } .kpi b { font-size: 22px; }
  h1 { font-size: 26px; }
}
