:root { --bg: #0b0e11; --panel: #161a1e; --line: #2b3139; --text: #eaecef; --muted: #848e9c; --up: #0ecb81; --down: #f6465d; --yellow: #f0b90b; --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; font-size: 15px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); } .error { color: var(--down); }
button, input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
input[type=date] { color-scheme: dark; }
button { cursor: pointer; }
button.primary { background: var(--yellow); color: #111; border-color: var(--yellow); font-weight: 700; }
button.ghost:hover { border-color: var(--muted); }
button.danger { border-color: var(--down); color: var(--down); background: none; }
.small-btn { padding: 4px 10px; font-size: 13px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; flex-wrap: wrap; }
.top h1 { font-size: 20px; margin: 0; }
.right { display: flex; align-items: center; gap: 8px; }
main { max-width: 1280px; margin: 0 auto; padding: 0 14px 30px; }

/* การ์ดพอร์ต */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 4px 0 14px; }
.card { min-width: 0; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; cursor: pointer; text-align: left; }
.card.on { border-color: var(--yellow); }
.card .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .big { font-size: 32px; font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 13px; }
.card .chip { display: inline-block; margin-top: 8px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.card .chip.pos { background: rgba(240, 185, 11, .15); color: var(--yellow); }
.card .chip.bad { background: rgba(246, 70, 93, .15); color: var(--down); }

.box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.box-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.box-head b { font-size: 15px; }
.box-head button { margin-left: auto; }
.chart { height: 58vh; min-height: 340px; }
.tfbar { display: flex; gap: 4px; flex-wrap: wrap; }
.tfbar button { padding: 4px 11px; font-size: 13px; border-radius: 8px; }
.tfbar button.on { background: var(--yellow); color: #111; border-color: var(--yellow); font-weight: 700; }
.tfbar button.none { color: var(--muted); border-style: dashed; }
.card .tfs { margin-top: 8px; font-size: 12px; color: var(--muted); }
.cmp-chart { height: 280px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }

/* แท็บ */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { border-radius: 999px; padding: 7px 16px; }
.tabs button.on { background: var(--text); color: #111; border-color: var(--text); font-weight: 700; }
.sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.sum div { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.sum span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.sum b { font-size: 22px; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.holding { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(240, 185, 11, .08); border: 1px solid rgba(240, 185, 11, .3); }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1e2329; }
.trades { max-height: 460px; overflow: auto; }

.cfg { list-style: none; margin: 0; padding: 0; }
.cfg li { display: flex; justify-content: space-between; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.cfg li span { color: var(--muted); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(720px, 95vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 2px; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; margin-top: 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.more { margin-top: 12px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; margin-top: 4px; }
.check input { width: 16px; height: 16px; padding: 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── ฝั่ง Long / Short ── */
.side { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.side.long { background: rgba(14, 203, 129, .15); color: var(--up); }
.side.short { background: rgba(246, 70, 93, .15); color: var(--down); }
.card .top-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .strat { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── ฟอร์มเพิ่มพอร์ต ── */
.step { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 18px 0 8px; }
.step span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--yellow); color: #111; font-size: 12px; font-weight: 800; }
.strats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.strat-opt { text-align: left; background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.strat-opt:hover { border-color: var(--muted); }
.strat-opt.on { border-color: var(--yellow); background: rgba(240, 185, 11, .06); }
.strat-opt b { display: block; margin: 6px 0 2px; font-size: 14px; }
.strat-opt small { color: var(--muted); font-size: 12px; line-height: 1.4; display: block; }
.more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 16px; }

@media (max-width: 600px) { .cards { display: flex; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #2b3139 transparent; } .card { flex: 0 0 190px; } }

/* ── ปุ่มลบบนการ์ด ── */
.card { position: relative; }
.card:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.card .trash { position: absolute; right: 10px; bottom: 10px; width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--muted); opacity: 0; transition: opacity .15s; }
.card:hover .trash, .card:focus-within .trash { opacity: 1; }
.card .trash:hover { color: var(--down); border-color: var(--down); background: rgba(246, 70, 93, .08); }
@media (hover: none) { .card .trash { opacity: .8; } }
.del-dlg { width: min(460px, 92vw); }
.del-opts { display: grid; gap: 8px; margin: 14px 0 6px; }
.del-opts button { padding: 11px 14px; text-align: left; }
button.danger-fill { background: var(--down); border-color: var(--down); color: #fff; font-weight: 700; }
.del-opts button[hidden] { display: none; }

/* ── หน้าเข้าสู่ระบบ ── */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login .logo { width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 18px; background: var(--yellow); color: #111; font-weight: 800; font-size: 24px; display: grid; place-items: center; }
.login h2 { margin: 4px 0 18px; }
.login form { display: grid; gap: 10px; }
.login input, .login button { padding: 14px; font-size: 16px; }
