:root {
  --bg: #07090f;
  --surface: rgba(20, 25, 40, 0.72);
  --surface-solid: #121726;
  --surface-2: #181e30;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e7eaf3;
  --text-2: #a3abc0;
  --muted: #6b7390;
  --accent: #7c8cff;
  --accent-2: #a78bfa;
  --up: #2ebd85;
  --down: #f6465d;
  --warn: #f5c451;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --sans: 'Noto Sans Thai', 'Leelawadee UI', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(124, 140, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(46, 189, 133, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.25); outline: none; min-height: 38px;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.18); }
select option { background: var(--surface-solid); }
code { font-family: var(--mono); font-size: 12px; background: rgba(255,255,255,.05); padding: 1px 5px; border-radius: 5px; word-break: break-word; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: var(--radius-sm); font-weight: 600; transition: transform .08s, filter .15s, background .15s; text-decoration: none; min-height: 38px; }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; font-weight: 500; min-height: 32px; }
.btn.block { width: 100%; }
.btn.primary { background: linear-gradient(135deg, #7c8cff, #a78bfa); color: #fff; box-shadow: 0 8px 24px -10px rgba(124, 140, 255, 0.8); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); color: var(--text-2); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.btn.danger { background: rgba(246, 70, 93, 0.15); color: #ff8a9a; border: 1px solid rgba(246, 70, 93, 0.3); }
.btn:disabled { opacity: .5; pointer-events: none; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: rgba(7, 9, 15, 0.85);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .01em; font-size: 16px; color: var(--text); text-decoration: none; }
.brand i { font-style: normal; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #7c8cff, #a78bfa); }
.sp, .top .sp { flex: 1; }
.who { color: var(--text-2); font-size: 13px; }
.who b { color: var(--text); }
.role { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: rgba(124,140,255,.16); color: #b9c1ff; margin-left: 4px; vertical-align: 1px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 18px 20px 40px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid .wide { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 20px 50px -30px rgba(0,0,0,.8); }
.card h2 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h2 .sp { flex: 1; }
.card.on { border-color: rgba(245,196,81,.45); }
.sub { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.f-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
label.f { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mt { margin-top: 12px; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
.err { color: #ff8a9a; }
.ok-chip, .no-chip { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.ok-chip { background: rgba(46,189,133,.15); color: #57d6a2; }
.no-chip { background: rgba(255,255,255,.06); color: var(--muted); }

/* switch */
.sw { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw .tr { width: 40px; height: 22px; border-radius: 99px; background: rgba(255,255,255,.12); position: relative; transition: background .15s; flex: none; }
.sw .tr::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw input:checked + .tr { background: #f5c451; }
.sw input:checked + .tr::after { transform: translateX(18px); }
.sw input:focus-visible + .tr { box-shadow: 0 0 0 3px rgba(124,140,255,.35); }
.sw em { font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sw input:checked ~ em { color: #f5c451; font-weight: 700; }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--mono); }
tr.pass td { background: rgba(245,196,81,.06); }
tr.pass td:first-child { box-shadow: inset 3px 0 0 #f5c451; }
.cols2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 20px; align-items: start; margin-top: 8px; }
.kind h3 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kind h3 .sp { flex: 1; }
.kind .cols2 { margin-top: 6px; }
.wrap.full { max-width: none; }
.live-h { margin: 4px 0 10px; font-size: 16px; }
.live { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1699px) { .live .cols2 { grid-template-columns: minmax(0, 1fr); } }   /* BUY | SELL side by side only when each card is wide enough */
.col h4 { margin: 4px 0 2px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.col h4.up { color: var(--up); } .col h4.down { color: var(--down); } .col h4 .sp { flex: 1; }
table.compact { font-size: 12.5px; } table.compact th, table.compact td { padding: 6px 6px; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { padding: 6px 12px; border-radius: 99px; color: var(--text-2); background: rgba(255,255,255,.04); border: 1px solid var(--border); font-size: 13px; }
.tabs button.on { background: rgba(124,140,255,.18); color: #fff; border-color: rgba(124,140,255,.5); font-weight: 700; }

/* history */
.hist { display: grid; gap: 8px; }
.hist .it { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: rgba(0,0,0,.18); }
.hist .it pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--sans); color: var(--text-2); }
.hist .it .t { font-size: 12px; color: var(--muted); }

/* login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; margin-bottom: 16px; font-size: 20px; }
.login form { display: grid; gap: 12px; }
.msg { min-height: 20px; font-size: 13px; }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: 0 10px 30px -8px rgba(0,0,0,.7); font-size: 13px; }
.toast.ok { border-color: rgba(46,189,133,.5); } .toast.err { border-color: rgba(246,70,93,.55); }
.secret-box { margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px dashed rgba(245,196,81,.6); background: rgba(245,196,81,.07); }
.secret-box code { font-size: 15px; font-weight: 700; color: #f5c451; user-select: all; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* (no inline styles anywhere: the CSP is style-src 'self') */
.m0 { margin: 0; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.narrow { max-width: 480px; margin: 0 auto 16px; }
.f-grid.one, .f-grid.one { grid-template-columns: minmax(0, 1fr) !important; }
.sel-sm { min-height: 30px; padding: 3px 6px; width: auto; }
.no-chip.bad { color: #ff8a9a; }
.row.nowrap { flex-wrap: nowrap; }
.w-name { max-width: 260px; } .w-role { max-width: 150px; } .w-grow { flex: 1; min-width: 220px; width: auto; }

@media (max-width: 900px) {
  .grid, .cols2, .live { grid-template-columns: minmax(0, 1fr); }
  .wrap { padding: 12px 12px 30px; }
  .top { padding: 8px 12px; }
  .who .nm, .top .btn .nm { display: none; }
  .card { padding: 14px; }
  .f-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) { .f-grid { grid-template-columns: minmax(0, 1fr); } }
