/* Trading Bot webapp 5.03.6 — กลางคืน / กลางวัน (ตามเครื่อง หรือกดสลับ) */
:root, :root[data-theme="night"] {
  --bg:#0E1116; --card:#171B22; --line:#262C36; --line2:#222832; --nav:#12161C; --text:#E7EAF0; --muted:#9AA3B2;
  --text2:#B8C0CC; --link:#8FB8FF; --accent:#6EA8FE; --up:#34D3A6; --down:#FFA674; --okText:#7FE6C6; --okBg:#10261F;
  --okLine:#1F5A47; --badBg:#2E1A12; --badLine:#6B3A22; --badText:#FFB48A; --tagBg:#2A1E16; --btnLine:#2E3B52;
  --seg:#2A3550; --axis:#3A4352; --ref:#C9D1DE; --off:#323946; --primary:#3E7BEA; --input:#2E3646;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="night"]) {
    --bg:#F4F5F7; --card:#FFFFFF; --line:#DCE0E6; --line2:#ECEEF2; --nav:#FFFFFF; --text:#14171C; --muted:#5A6371;
    --text2:#3E4652; --link:#1D5BD8; --accent:#2F6FE4; --up:#0B7F60; --down:#B84E16; --okText:#0B6F53; --okBg:#E3F4ED;
    --okLine:#A6D9C5; --badBg:#FBEADF; --badLine:#E7B798; --badText:#9A3F10; --tagBg:#FBE6D8; --btnLine:#C3D1EA;
    --seg:#E1E8F6; --axis:#B5BDC9; --ref:#38414E; --off:#C7CDD6; --primary:#2F6FE4; --input:#C9D0DA;
    color-scheme: light;
  }
}
:root[data-theme="day"] {
  --bg:#F4F5F7; --card:#FFFFFF; --line:#DCE0E6; --line2:#ECEEF2; --nav:#FFFFFF; --text:#14171C; --muted:#5A6371;
  --text2:#3E4652; --link:#1D5BD8; --accent:#2F6FE4; --up:#0B7F60; --down:#B84E16; --okText:#0B6F53; --okBg:#E3F4ED;
  --okLine:#A6D9C5; --badBg:#FBEADF; --badLine:#E7B798; --badText:#9A3F10; --tagBg:#FBE6D8; --btnLine:#C3D1EA;
  --seg:#E1E8F6; --axis:#B5BDC9; --ref:#38414E; --off:#C7CDD6; --primary:#2F6FE4; --input:#C9D0DA;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "IBM Plex Sans Thai", "Leelawadee UI", "Noto Sans Thai", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
.mono, .num { font-family: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.row { display: flex; align-items: center; } .gap8 { gap: 8px; } .between { justify-content: space-between; }
.up { color: var(--up); } .down { color: var(--down); }

/* login */
.login { min-height: 100vh; padding: 24px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.login .logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; background: var(--card); border: 1px solid var(--line); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.login h1, .login > p { text-align: center; }
.loginform { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.loginform label { font-size: 13px; color: var(--text2); }
.loginform input[type=password] { min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--input); background: var(--card); color: var(--text); font-size: 16px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.primary { min-height: 50px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
.err { color: var(--down); min-height: 1.2em; margin: 0; font-size: 13px; }

/* main */
#main { display: flex; flex-direction: column; min-height: 100vh; }
.top { display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top)) 16px 6px; }
.iconbtn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--card); border: 1px solid var(--line); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok { background: var(--okBg); border-color: var(--okLine); color: var(--okText); } .pill.ok::before { background: var(--up); }
.pill.bad { background: var(--badBg); border-color: var(--badLine); color: var(--badText); } .pill.bad::before { background: var(--down); }
.stale { margin: 0 16px 6px; padding: 8px 12px; border-radius: 10px; background: var(--badBg); border: 1px solid var(--badLine); color: var(--badText); font-size: 12px; }
.view { flex: 1 1 auto; padding: 6px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.flush { padding: 0; gap: 0; }
.big { font-size: 34px; font-weight: 600; letter-spacing: -0.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv .k { font-size: 11px; color: var(--muted); } .kv .v { font-size: 14px; }
.stat .v { font-size: 20px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; } .bar > i { display: block; height: 6px; border-radius: 3px; background: var(--accent); }
.bar.hot > i { background: var(--down); }
.ok-box { background: var(--okBg); border: 1px solid var(--okLine); color: var(--okText); border-radius: 12px; padding: 10px 12px; font-size: 12px; }
.bad-box { background: var(--badBg); border: 1px solid var(--badLine); color: var(--badText); border-radius: 12px; padding: 10px 12px; font-size: 12px; }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line2); }
.list .item:last-child { border-bottom: 0; }
.item .t { font-size: 14px; font-weight: 600; } .item .s { font-size: 12px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--tagBg); color: var(--down); }
.tag.long { background: var(--okBg); color: var(--okText); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--seg); color: var(--text); font-weight: 600; }
.ghost { min-height: 44px; padding: 0 14px; border: 1px solid var(--btnLine); border-radius: 10px; background: transparent; color: var(--link); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.switch { flex: 0 0 auto; width: 52px; height: 32px; border-radius: 16px; border: 0; padding: 3px; display: flex; cursor: pointer; background: var(--off); justify-content: flex-start; }
.switch[aria-pressed="true"] { background: var(--primary); justify-content: flex-end; }
.switch span { width: 26px; height: 26px; border-radius: 50%; background: #F4F6FA; }
.note { display: flex; gap: 10px; padding: 10px 12px; }
.note i { flex: 0 0 4px; border-radius: 2px; background: var(--accent); }
.note.k-guard i, .note.k-dead i { background: var(--down); } .note.k-trade i { background: var(--up); }
.chart { position: relative; height: 150px; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; }
.chart .zero { position: absolute; left: 0; right: 0; height: 1px; background: var(--axis); }
.chart .col { position: relative; }
.chart .b { position: absolute; left: 1px; right: 1px; border-radius: 3px; background: var(--accent); }
.chart .b.neg { background: var(--down); } .chart .b.cur { opacity: .6; }
.chart .r { position: absolute; left: -1px; right: -1px; height: 2px; background: var(--ref); }
.xlab { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; font-size: 9px; color: var(--muted); text-align: center; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); } .legend .ln { width: 10px; height: 2px; background: var(--ref); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 560px; margin: 0 auto; border-top: 1px solid var(--line); background: var(--nav); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; min-height: 44px; }
.tabs button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--link); }
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.th { font-family: "IBM Plex Sans Thai", "Leelawadee UI", "Noto Sans Thai", system-ui, sans-serif; }
.card.note { flex-direction: row; }

/* ⭐ 5.03.6 ปฏิทินกำไร */
.row.wrap { flex-wrap: wrap; gap: 6px 12px; }
.seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.iconbtn:disabled { color: var(--line); cursor: default; }
.cal { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) 62px; gap: 4px; }
.cal.mini { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.cal .ch { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal .cd, .cal .wk { min-height: 52px; box-sizing: border-box; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 0; }
.cal .cd { border: 2px solid transparent; background: transparent; cursor: pointer; font: inherit; color: inherit; }
.cal .cd.today { border-color: var(--ref); }
.cal .cd.sel { border-color: var(--accent); }
.cal .cd.fut { border: 1px dashed var(--line); justify-content: flex-start; padding-top: 6px; cursor: default; }
.cal .wk { background: var(--bg); }
.cal .dn { font-size: 10px; color: var(--muted); line-height: 1; }
.cal .pv { font-size: 12px; font-weight: 600; line-height: 1.2; }
.cal .nt { font-size: 9px; color: var(--muted); line-height: 1; }
.cal.mini .cd { min-height: 26px; height: 26px; padding: 0; border-width: 0; border-radius: 5px; font-size: 10px; font-weight: 500; }
.cal.mini .cd.today { border: 2px solid var(--ref); }
.cal.mini .cd.fut { border: 1px dashed var(--line); padding: 0; }
.tbox { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; font-size: 11px; color: var(--muted); padding: 8px 10px; white-space: nowrap; }
.tbl td { padding: 9px 10px; border-top: 1px solid var(--line2); vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { padding-left: 14px; } .tbl th:last-child, .tbl td:last-child { padding-right: 14px; }
.tbl .r, .num.r { text-align: right; }
.item.note { justify-content: flex-start; }
.item.note i { flex: 0 0 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--accent); align-self: flex-start; }
.item.note.k-guard i, .item.note.k-dead i { background: var(--down); } .item.note.k-trade i { background: var(--up); }

/* ⭐ 5.03.6 จอกว้าง ≥ 1100 px */
body.wide #app { max-width: 1440px; }
body.wide .top { padding: 20px 24px 6px; }
body.wide .tabs { position: static; max-width: none; margin: 4px 24px 6px; width: auto; display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: var(--card); }
body.wide .tabs button { flex-direction: row; gap: 8px; padding: 0 16px; font-size: 14px; border-radius: 9px; }
body.wide .tabs button svg { width: 18px; height: 18px; }
body.wide .tabs button.on { background: var(--seg); color: var(--text); font-weight: 600; }
body.wide #main { flex-direction: column; }
body.wide #main > .tabs { order: 1; } body.wide #main > .top { order: 0; } body.wide #stale { order: 2; } body.wide .view { order: 3; padding: 10px 24px 40px; gap: 16px; }
body.wide .view.narrow { max-width: 760px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.wrow { display: flex; flex-wrap: wrap; gap: 16px; }
.wrow .w2 { flex: 2 1 600px; min-width: 0; } .wrow .w1 { flex: 1 1 380px; min-width: 0; }
.cal3 { display: flex; flex-wrap: wrap; gap: 20px; }
.calm { flex: 1 1 380px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
body.wide .cal { grid-template-columns: repeat(5, minmax(0, 1fr)) 70px; }
body.wide .cal .cd, body.wide .cal .wk { min-height: 58px; }
body.wide .cal .pv { font-size: 13px; } body.wide .cal .nt { font-size: 10px; }
.eq { position: relative; height: 220px; }
.eq svg { width: 100%; height: 220px; display: block; }
.eq .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.eq .ln { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.eq .pk { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.eq .pkl { position: absolute; right: 4px; background: var(--card); padding: 0 4px; }
.eqx { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.eqx span { position: absolute; top: 0; white-space: nowrap; }
.pr { display: grid; grid-template-columns: 64px minmax(0, 1fr) 96px; align-items: center; gap: 10px; font-size: 12px; }
.pb { position: relative; height: 14px; }
.pb i { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.pb .ax { left: 50%; top: 0; bottom: 0; width: 1px; border-radius: 0; background: var(--axis); }
.pb .pos { left: 50%; background: var(--up); } .pb .neg { right: 50%; background: var(--down); }
.card.flush > .item, .card.flush > .list > .item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line2); }
.card.flush > .item:last-child { border-bottom: 0; }
.card.flush > .empty { border-bottom: 0; }
.ghost { white-space: nowrap; }
.cal.mini .cd.fut { justify-content: center; }
/* ⭐ 5.03.6 ฝาก/ถอน */
.cal .cb { font-size: 9px; line-height: 1; padding: 2px 4px; border-radius: 4px; background: var(--seg); color: var(--text2); margin-top: 1px; white-space: nowrap; }
.cal.mini .cd.hc { box-shadow: inset 0 -3px 0 var(--text2); }
.cashnote { color: var(--text2); }
.item.cashrow { background: color-mix(in srgb, var(--seg) 45%, transparent); }
.eqseg { width: 220px; }
.eqseg button { min-height: 36px; }
.eq .z { stroke: var(--axis); stroke-width: 1; vector-effect: non-scaling-stroke; }
.eq .cm { stroke: var(--text2); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.eq .cml { position: absolute; bottom: 4px; transform: translateX(-50%); font-size: 10px; color: var(--text2); background: var(--card); padding: 0 3px; white-space: nowrap; }

/* ⭐ 5.03.6 นาฬิกาบนหัวจอทุกหน้า (เวลาไทย · server กำกับ) */
.clock { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.clock svg { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.clock b { color: var(--text); font-weight: 600; }
.clock.ponly { padding: 0 16px 8px; }
.clock.wonly { display: none; }
body.wide .clock.ponly { display: none; }
body.wide .clock.wonly { display: flex; padding: 8px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 13px; }
