/* KnoxTrade (PZ Computer) colours and sizes, taken from the mod's Lua:
   PZComputer_Apps_Trade.lua and PZComputerFast_Trade*.lua */
:root {
  --ink: #1a1c21;       /* INK   0.10 0.11 0.13 */
  --panel: #212630;     /* PANEL 0.13 0.15 0.19 */
  --panel2: #2b303d;    /* PANEL2 0.17 0.19 0.24 */
  --line: #424a59;      /* LINE  0.26 0.29 0.35 */
  --text: #e0e6ed;      /* TEXT  0.88 0.90 0.93 */
  --muted: #8c94a6;     /* MUTED 0.55 0.58 0.65 */
  --up: #38c766;        /* UP    0.22 0.78 0.40 */
  --down: #eb524d;      /* DOWN  0.92 0.32 0.30 */
  --gold: #f2c74d;      /* GOLD / SEL 0.95 0.78 0.30 */
  --tvup: #26a899;      /* TV_UP 0.15 0.66 0.60 */
  --tvdown: #f0544f;    /* TV_DOWN 0.94 0.33 0.31 */
  --ma: #6b9efa;        /* TV_MA / BLUE 0.42 0.62 0.98 */
  --grid: #333b4a;      /* TV_GRID 0.20 0.23 0.29 */
  --liq: #ff7333;       /* LIQ 1.00 0.45 0.20 */
  --darkup: #1f4d2e;    /* DARKUP */
  --darkdown: #572424;  /* DARKDOWN */
  --darkblue: #293b66;  /* DARKBLUE */
  --font: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ink); color: var(--text); font: 12px/1.25 var(--font); -webkit-text-size-adjust: 100%; overflow: hidden; }
[hidden] { display: none !important; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); } .gold { color: var(--gold); } .liq { color: var(--liq); }
.num { font-variant-numeric: tabular-nums; }

/* KnoxTrade buttons: flat PANEL2, selected = gold with dark text */
.kb {
  background: var(--panel2); color: var(--text); border: 0; border-radius: 0; font: 12px var(--font);
  height: 20px; padding: 0 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb:hover { filter: brightness(1.18); }
.kb.on, .kb.gold { background: var(--gold); color: var(--ink); }
.kb.bup { background: var(--up); color: var(--ink); }
.kb.bdown { background: var(--down); color: var(--text); }
.kb.big { height: 30px; font-size: 15px; font-weight: 600; }
.kb:disabled { opacity: .4; cursor: default; filter: none; }
.kb:focus-visible { outline: 1px solid var(--gold); outline-offset: 1px; }

/* login / dialogs (dark KnoxOS look) */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.dlg-box { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 0; width: min(92vw, 360px); }
dialog.dlg-box::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-title { background: var(--panel2); color: var(--gold); padding: 5px 8px; border-bottom: 1px solid var(--line); font-weight: 600; }
.dlg-body { padding: 10px 10px 4px; display: flex; flex-direction: column; gap: 8px; }
.dlg-body label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); }
.dlg-body input { background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 0; height: 30px; padding: 0 8px; font: 16px var(--font); width: 100%; }
.dlg-body input:focus { outline: 1px solid var(--gold); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 10px 10px; }
.dlg-btns .kb { height: 26px; min-width: 84px; }
.dlg-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.dlg-rows span { color: var(--muted); } .dlg-rows b { text-align: right; font-weight: normal; }
.dlg-text { margin: 0; color: var(--muted); }
.dlg-text.warn { color: var(--gold); }
.msg { color: var(--down); margin: 0; min-height: 1.2em; }
.hint { color: var(--muted); margin: 0; font-size: 11px; }

/* app frame: ticker 20, tab bar 22, body, status bar */
#appView { height: 100%; display: flex; flex-direction: column; }
.clockbar { height: 34px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; background: var(--ink); border-bottom: 1px solid var(--line); }
.clockbar .appname { color: var(--gold); font-weight: 600; font-size: 13px; }
.clockbar .clock { color: #00fbf8; font-size: 22px; font-weight: 700; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.ticker { height: 21px; background: var(--panel); border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; flex: none; }
.ticker-track { display: inline-block; padding-top: 3px; animation: tick 30s linear infinite; }
.ticker-track span { margin-right: 22px; }
.ticker-track i { font-style: normal; margin-left: 5px; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tabbar { height: 23px; background: var(--panel2); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; padding: 0 2px 0 4px; flex: none; }
.tabs { display: flex; gap: 4px; }
.tabs .kb { width: 92px; }
.tabinfo { margin-left: auto; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct { width: 126px; }
.body { flex: 1; min-height: 0; position: relative; }
.statusbar { height: 18px; background: var(--panel); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--muted); font-size: 11px; flex: none; }
.statusbar .grow { flex: 1; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--up); } .dot.off { background: var(--down); }

/* trade tab */
.pane { position: absolute; inset: 0; }
.pane.trade { display: flex; }
.left { width: 150px; flex: none; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.srow { position: relative; height: 40px; border-bottom: 1px solid var(--line); cursor: pointer; }
.srow.on { background: var(--panel2); }
.srow.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.srow .sym { position: absolute; left: 8px; top: 4px; }
.srow.on .sym { color: var(--gold); }
.srow .pr { position: absolute; right: 6px; top: 4px; }
.srow .ch { position: absolute; right: 6px; top: 21px; }
.srow canvas { position: absolute; left: 8px; top: 22px; }
.leftsum { padding: 8px 6px 8px 8px; display: grid; grid-template-columns: 1fr auto; row-gap: 2px; }
.leftsum .k { color: var(--muted); } .leftsum .v { text-align: right; }
.leftsum .gap { grid-column: 1 / -1; height: 8px; }
.right { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.upper { flex: 1; min-height: 0; display: flex; position: relative; }
.chartcol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tfrow { height: 20px; display: flex; gap: 2px; flex: none; }
.tfrow .kb.info { margin-left: auto; width: 62px; }

/* side panel (PZComputerFast_TradeInfo look) */
.panel { width: var(--pw, 300px); flex: none; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.right.overlay .panel { position: absolute; left: 0; right: 0; top: 20px; bottom: 0; width: auto; z-index: 3; border-left: 0; }
.ptabs { display: flex; gap: 4px; padding: 2px 4px; height: 23px; border-bottom: 1px solid var(--line); flex: none; }
.ptabs .kb { flex: 1; height: 18px; padding: 0 2px; }
.pbody { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 6px; }
.pfoot { flex: none; display: flex; gap: 4px; padding: 4px 6px; border-top: 1px solid var(--line); }
.pfoot:empty { display: none; }
.pfoot .kb { height: 20px; }
.prow { display: flex; justify-content: space-between; gap: 8px; min-height: 15px; line-height: 15px; }
.prow > span:first-child { color: var(--muted); white-space: nowrap; }
.prow > span:last-child { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psep { height: 1px; background: var(--line); margin: 4px 0; }
.pname { color: var(--gold); margin-bottom: 3px; }
.pline { line-height: 15px; min-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbtns { display: flex; gap: 4px; margin: 4px 0; }
.pbtns .kb { flex: 1; }
.phead { display: flex; justify-content: space-between; color: var(--gold); border-bottom: 1px solid var(--line); padding: 3px 0 2px; margin-bottom: 2px; }
.phead span:last-child { color: var(--muted); }
.post { padding: 2px 4px 4px; margin-bottom: 4px; cursor: default; }
.post.player { background: var(--panel2); }
.post.crowd { border-bottom: 1px solid var(--line); }
.post.sel { box-shadow: inset 0 0 0 1px var(--gold); }
.post.mine { cursor: pointer; }
.post .ph { display: flex; align-items: center; gap: 5px; }
.post .ph .when { margin-left: auto; color: var(--muted); }
.post .pt { padding-left: 4px; line-height: 15px; word-break: break-word; }
.post.crowd .pt { color: #ccd4e0; }
.post.crowd .nm { color: #b3bdcc; }
.calrow { display: flex; align-items: center; gap: 6px; height: 20px; padding: 0 2px; }
.calrow.cur { background: var(--panel2); }
.calrow .badge { width: 40px; text-align: center; height: 14px; line-height: 14px; font-size: 11px; }
.calrow .r { margin-left: auto; }
.taperow { display: flex; align-items: center; gap: 6px; height: 19px; position: relative; padding-left: 6px; }
.taperow.mine::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 2px; background: var(--ma); }
.taperow .r { margin-left: auto; }
.firm { border-bottom: 1px solid var(--line); padding: 3px 0; }
.firm .fl1, .firm .fl2 { display: flex; justify-content: space-between; gap: 6px; line-height: 16px; align-items: center; }
.firm .fl2 .kb { height: 16px; width: 94px; flex: none; font-size: 11px; }
.ebadge { display: inline-block; height: 14px; line-height: 14px; padding: 0 3px; font-size: 11px; color: var(--ink); margin-left: 5px; vertical-align: 1px; }
.tfrow .kb { width: 34px; height: 18px; padding: 0; }
.tfrow .kb.mode { width: 70px; margin-left: 6px; }
.chartwrap { flex: 1; min-height: 200px; position: relative; background: var(--panel2); }
.chartwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.slip { flex: none; background: var(--panel); border-top: 1px solid var(--line); padding: 2px 0 8px; display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.srow2 { display: flex; gap: 3px; align-items: center; min-height: 20px; }
.srow2 .kb { min-width: 54px; }
.srow2 .kb.w90 { width: 90px; } .srow2 .kb.w84 { width: 84px; } .srow2 .kb.w70 { width: 70px; } .srow2 .kb.w100 { width: 100px; }
.srow2 .push { margin-left: auto; }
.strip { background: var(--panel); min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; }
.strip.dark { background: var(--panel2); }
.info { display: flex; justify-content: space-between; gap: 8px; padding: 2px 8px; min-height: 20px; }
.acts { display: flex; gap: 6px; }
.acts .kb { flex: 1; }

/* positions / depot / history (PZComputerFast_TradeTabs look) */
.pane.cards { display: flex; flex-direction: column; padding: 4px 8px 0; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); height: 38px; flex: none; margin: 0 -2px; }
.summary .cell { padding: 3px 8px; border-left: 1px solid var(--line); min-width: 0; }
.summary .cell:first-child { border-left: 0; }
.summary .cell span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary .cell b { display: block; font-weight: normal; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spread { height: 6px; background: var(--ink); margin: 6px 0 0; display: flex; flex: none; }
.rows { flex: 1; min-height: 0; overflow-y: auto; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.card { position: relative; background: var(--panel); padding: 3px 8px 4px 10px; flex: none; cursor: pointer; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--stripe, var(--line)); }
.card.sel { box-shadow: inset 0 0 0 1px var(--gold); }
.card.sel.row::before, .card.row.sel::before { background: var(--gold); }
.card.row.sel { background: var(--panel2); box-shadow: none; }
.card .l1, .card .l2, .card .l3 { display: flex; align-items: center; gap: 6px; min-height: 16px; }
.card .r { margin-left: auto; text-align: right; white-space: nowrap; }
.card .big { font-size: 15px; }
.card .sym { color: var(--gold); }
.card .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chip { display: inline-block; height: 14px; line-height: 14px; padding: 0 4px; font-size: 11px; white-space: nowrap; }
.bar { flex: 1; height: 4px; background: var(--ink); position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; }
.swatch { width: 6px; height: 6px; display: inline-block; }
.empty { color: var(--muted); text-align: center; padding-top: 40px; }
.bottom { height: 34px; flex: none; display: flex; gap: 4px; align-items: center; }
.bottom .kb { height: 24px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 8px 12px; max-width: calc(100% - 32px); z-index: 20; }
.toast.ok { border-color: var(--up); } .toast.err { border-color: var(--down); }

/* phone: stock list on top, scrolls sideways; page scrolls */
@media (max-width: 720px) {
  body { overflow: auto; }
  #appView { height: auto; min-height: 100%; }
  .body { position: static; }
  .pane { position: static; }
  .pane.trade { flex-direction: column; }
  .left { width: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; overflow: visible; }
  #stockRows { display: flex; overflow-x: auto; }
  .srow { width: 150px; flex: none; border-right: 1px solid var(--line); }
  .leftsum { grid-template-columns: auto 1fr auto 1fr; column-gap: 10px; }
  .leftsum .gap { display: none; }
  .chartwrap { height: 300px; flex: none; }
  /* timeframe row: buttons share the width */
  .tfrow { height: auto; min-height: 26px; }
  .tfrow .kb { flex: 1; width: auto; height: 26px; }
  .tfrow .kb.mode { flex: 1.6; width: auto; margin-left: 4px; }
  /* chart, then the order slip, then the side panel (always open) */
  .right.stack .upper { display: contents; }
  .right.stack .chartcol { order: 1; }
  .right.stack .slip { order: 2; }
  .right.stack .panel { order: 3; width: auto; border-left: 0; border-top: 1px solid var(--line); margin-top: 6px; }
  .right.stack .ptabs { height: 32px; padding: 3px 4px; }
  .right.stack .ptabs .kb { height: 26px; font-size: 13px; }
  .right.stack .pbody { overflow: visible; padding: 8px 10px; }
  .right.stack .pbody:has(.post) { max-height: 60vh; overflow-y: auto; }
  .prow, .pline { line-height: 19px; min-height: 19px; }
  .pfoot .kb { height: 28px; }
  .srow2 { flex-wrap: wrap; padding: 0 2px; }
  .srow2 .kb { flex: 1 1 auto; }
  .srow2 .kb.w90, .srow2 .kb.w84, .srow2 .kb.w70, .srow2 .kb.w100 { width: auto; }
  .srow2 .push { margin-left: 0; }
  .strip { flex-wrap: wrap; padding: 4px 8px; }
  .strip .srow2 { width: 100%; padding: 0; }
  .acts { padding: 0 2px; }
  .tabs .kb { width: auto; flex: 1; }
  .tabs { flex: 1; }
  .tabinfo { display: none; }
  .acct { width: 70px; }
  .pane.cards { min-height: calc(100vh - 96px); }
  .clockbar .clock { font-size: 20px; }
  .summary { grid-template-columns: repeat(2, 1fr); height: auto; }
  .summary .cell:nth-child(3) { border-left: 0; }
  .bottom { flex-wrap: wrap; height: auto; padding: 6px 0; }
}
