:root {
  --bg: #0b0e11; --panel: #161a1e; --line: #2b3139; --text: #eaecef; --muted: #848e9c;
  --up: #0ecb81; --down: #f6465d; --yellow: #f0b90b; --blue: #4c7dff; --cyan: #22d3ee;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.up { color: var(--up); } .down { color: var(--down); }
.error { color: var(--down); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.logo { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 18px; background: var(--yellow); color: #111; font-weight: 800; font-size: 24px; display: grid; place-items: center; }
.login h1 { margin: 4px 0; }
.login form { display: grid; gap: 10px; margin-top: 20px; }
input { padding: 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; }
button { padding: 14px; border: 0; border-radius: 10px; background: var(--yellow); color: #111; font-weight: 700; font-size: 16px; cursor: pointer; }
button.secondary { background: var(--line); color: var(--text); width: 100%; }
button.link { background: none; color: var(--muted); font-weight: 400; font-size: 13px; width: 100%; }
button:disabled { opacity: .5; }

main { max-width: 820px; margin: 0 auto; padding: 10px 12px 28px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; padding: 6px 2px 10px; }
.sym { font-weight: 700; }
.tf { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.price { font-size: 26px; font-weight: 700; }
.right { text-align: right; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; background: var(--line); }
.pill.ok { background: rgba(14, 203, 129, .15); color: var(--up); }
.pill.bad { background: rgba(246, 70, 93, .15); color: var(--down); }
.pill.trade { background: rgba(240, 185, 11, .15); color: var(--yellow); }

.chart { width: 100%; height: 56vh; min-height: 300px; max-height: 520px; border-radius: 12px; overflow: hidden; background: var(--panel); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot.blue { background: var(--blue); } .dot.green { background: var(--up); } .dot.cyan { background: var(--cyan); } .dot.red { background: var(--down); }

.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.cards .card { margin-bottom: 0; }
.card h2 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.row.head h2 { margin: 0; }
.steps { display: flex; gap: 6px; margin-top: 8px; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--yellow); }

.events { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.events li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; display: flex; gap: 10px; }
.events li:first-child { border-top: 0; }
.events .t { color: var(--muted); font-size: 12px; min-width: 76px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tab.on { background: var(--yellow); color: #111; border-color: var(--yellow); }
.dot.ok { background: var(--up); } .dot.trade { background: var(--yellow); } .dot.bad { background: var(--down); }
.tab.on .dot.trade { background: #111; }

/* ── กราฟเต็มจอ ── */
.chart-wrap { position: relative; }
.fs-btn { position: absolute; top: 8px; left: 8px; z-index: 5; width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  background: rgba(22, 26, 30, .85); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.fs-bar { display: none; }
.chart-wrap.full { position: fixed; inset: 0; z-index: 100; background: var(--panel); display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.chart-wrap.full .fs-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 15px; }
.chart-wrap.full .chart { flex: 1; height: auto; min-height: 0; max-height: none; border-radius: 0; }
.chart-wrap.full .fs-btn { display: none; }
#fs-close { margin-left: auto; padding: 6px 12px; background: var(--line); color: var(--text); font-size: 14px; font-weight: 600; }
body.noscroll { overflow: hidden; }

/* ── จุดแดงบนป้ายเหรียญ: มีการเปิด/ปิดออเดอร์ที่ยังไม่ได้ดู ── */
.tab { position: relative; }
.badge { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--down); border: 2px solid var(--bg); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
