/* novascanner - same dark theme as the desktop app */
:root {
  --bg: #17181c; --panel: #202127; --panel-alt: #1b1c21; --panel2: #2a2b33; --header: #262833;
  --grid: #111216; --fg: #e8e8ea; --muted: #9a9ca5; --accent: #4f8cff; --green: #34d399;
  --red: #f87171; --amber: #fbbf24; --border: #34353d; --hover: #3a3b45;
  --ui: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, ui-monospace, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--fg);
  font: 13px/1.35 var(--ui); overflow: hidden; }
h1 { font-size: 18px; font-weight: 600; margin: 0; }
h2 { font-size: 13px; font-weight: 600; margin: 12px 0 2px; }
h2:first-child { margin-top: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.only-narrow { display: none; }
.grow { flex: 1; }
* { scrollbar-color: #3a3b45 var(--panel); scrollbar-width: thin; }

button, select, input, textarea { font: inherit; color: var(--fg); }
button { background: var(--panel2); border: 0; padding: 5px 11px; cursor: pointer; border-radius: 2px; white-space: nowrap; }
button:hover { background: var(--hover); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .ht:focus-visible {
  outline: 1px solid var(--accent); outline-offset: 0; }
button.accent { background: var(--accent); color: #fff; font-weight: 600; }
button.accent:hover { background: #3b78f0; }
button.stop { background: #c2410c; color: #fff; font-weight: 600; }
button.stop:hover { background: #a3360a; }
input[type=text], input[type=number], input[type=password], select, textarea {
  background: var(--panel2); border: 1px solid var(--border); padding: 3px 5px; border-radius: 2px; min-width: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); margin: 0 6px 0 0; }

/* ---- top bar ---- */
#top { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; flex-wrap: wrap; }
#top form { margin: 0; }
#top .tb { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#top #refresh { width: 58px; }
#body { flex: 1; display: flex; min-height: 0; padding: 0 10px; }
#status { color: var(--muted); font-size: 12px; padding: 4px 12px 6px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
#status.err { color: var(--red); }

/* ---- side menu ---- */
#menu { width: 286px; flex: none; overflow-y: auto; background: var(--panel); padding: 12px; margin-right: 8px; }
#menu .hint, dialog .hint, .qhead .hint { color: var(--muted); font-size: 12px; margin: 0 0 4px; }
#menu .row, dialog .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
#menu .check, dialog .check { display: flex; align-items: center; margin: 3px 0; cursor: pointer; }
#menu .num { width: 62px; }
#menu select { max-width: 170px; }
#menu textarea { width: 100%; font: 13px var(--mono); resize: vertical; margin-top: 4px; }
#menu #csvLink { margin-left: 8px; font-size: 12px; }
.fgrid { display: grid; grid-template-columns: 1fr 68px 10px 68px; gap: 4px 4px; align-items: center; margin-bottom: 4px; }
.fgrid .cap { color: var(--muted); font-size: 12px; text-align: center; }
.fgrid .dash { color: var(--muted); text-align: center; }
.fgrid input { width: 100%; }
#strategies .row input { width: 54px; }

/* ---- split panes ---- */
#dash { flex: 1; min-width: 0; }
.split { display: flex; min-width: 0; min-height: 0; }
.split.h { flex-direction: row; }
.split.v { flex-direction: column; }
.pane { min-width: 80px; min-height: 48px; overflow: hidden; flex: 1 1 0; }
.gutter { flex: none; touch-action: none; }
.split.h > .gutter { width: 6px; cursor: col-resize; }
.split.v > .gutter { height: 6px; cursor: row-resize; }
.gutter:hover, .gutter.drag { background: #2f313b; }

/* ---- panels ---- */
.panel { display: flex; flex-direction: column; background: var(--grid); border: 1px solid var(--grid); }
.panel > header { flex: none; height: 26px; background: var(--header); display: flex; align-items: stretch; overflow: hidden; }
.ptitle { font-weight: 700; font-size: 12px; padding: 0 8px; align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbody { flex: 1; min-height: 0; background: var(--panel); display: flex; flex-direction: column; position: relative; }
.ib { background: none; color: var(--muted); padding: 0 6px; font-size: 12px; border-radius: 0; }
.ib:hover { background: none; color: var(--fg); }
.ib.on { color: var(--accent); }
.ib.amber { color: var(--amber); }
.ib.off { color: #6b6f7a; }
.tab { background: var(--header); color: var(--muted); font-weight: 700; font-size: 12px; padding: 0 10px; border-radius: 0; }
.tab:hover { background: var(--header); color: var(--fg); }
.tab.on { background: #31344a; color: var(--fg); }
.tabpage { flex: 1; min-height: 0; display: none; flex-direction: column; }
.tabpage.on { display: flex; }

/* ---- heat tables ---- */
.ht { flex: 1; min-height: 0; overflow: auto; background: var(--grid); position: relative; outline-offset: -1px; }
.ht table { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; }
.ht th { position: sticky; top: 0; z-index: 1; height: 24px; background: var(--panel2); font: 700 12px var(--ui);
  padding: 0 6px 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; user-select: none;
  box-shadow: inset -1px 0 0 #3a3b45; }
.ht.nosort th { cursor: default; }
.ht th .rz { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 2; touch-action: none; }
.ht td { height: 22px; padding: 0 6px 0 5px; font: 13px var(--mono); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); cursor: default; }
.ht tbody tr { background: var(--panel-alt); }
.ht tbody tr:nth-child(odd) { background: var(--panel); }
.ht .a-w { text-align: left; } .ht .a-e { text-align: right; } .ht .a-center { text-align: center; }
.ht tr.sel td { box-shadow: inset 0 2px 0 #9cc0ff, inset 0 -2px 0 #9cc0ff; }
.ht tr.sel td:first-child { box-shadow: inset 2px 0 0 #9cc0ff, inset 0 2px 0 #9cc0ff, inset 0 -2px 0 #9cc0ff; }
.ht tr.sel td:last-child { box-shadow: inset -2px 0 0 #9cc0ff, inset 0 2px 0 #9cc0ff, inset 0 -2px 0 #9cc0ff; }
.ht-empty { position: sticky; left: 0; padding: 20px 10px; text-align: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.ht.nohead thead { display: none; }
.qtable { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.qtable .ht td { height: 21px; }
.qtable .ht td.lbl { font: 12px var(--ui); }

/* ---- log ---- */
.log { flex: 1; overflow: auto; font: 12px var(--mono); padding: 4px 6px; white-space: pre-wrap; word-break: break-word; }
.log .t { color: var(--muted); }
.log .info { color: var(--accent); } .log .warn { color: var(--amber); } .log .error { color: var(--red); }

/* ---- news ---- */
.newsfilter { padding: 6px; }
.newsfilter input { width: 100%; font-size: 12px; padding: 4px 6px; }
.newsfilter input::placeholder { color: #6b6f7a; }
.news { flex: 1; overflow: auto; padding: 0 8px 6px; font-size: 12px; }
.news .item { margin-bottom: 10px; }
.news .meta { color: var(--muted); font-size: 11px; }
.news .fresh { color: #ff9f43; font-weight: 700; }
.news .tag { color: #fff; font-weight: 700; font-size: 11px; padding: 0 4px; }
.news .tag.bad { background: #e5484d; } .news .tag.good { background: #3fb56d; } .news .tag.info { background: #4f7fd9; }
.news .head { font-weight: 700; color: var(--fg); display: block; text-decoration: none; }
.news a.head:hover { text-decoration: underline; }
.news .summary { color: #b9bcc6; font-size: 11px; }
.news .empty { color: var(--muted); }

/* ---- quote ---- */
.qhead { display: flex; align-items: center; gap: 6px; padding: 6px 8px 2px; }
.qhead input { width: 84px; font: 700 14px var(--mono); text-transform: uppercase; }
.qhead .hint { margin: 0; color: #6b6f7a; font-size: 11px; }
.qname { font-weight: 700; font-size: 14px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 19px; }
.qmeta { color: var(--muted); font-size: 11px; padding: 0 8px 2px; min-height: 15px; }
.qactions { padding: 0 2px 4px; }

/* ---- chart ---- */
.chart { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #131419; }
.chart .bar { flex: none; height: 28px; background: var(--header); display: flex; align-items: stretch; overflow: hidden; }
.chart .sym { font-weight: 700; font-size: 13px; padding: 0 8px; align-self: center; }
.chart .info { flex: none; color: var(--muted); font: 12px var(--mono); padding: 1px 8px; white-space: nowrap; overflow: hidden; min-height: 18px; }
.chart .cv { flex: 1; min-height: 0; position: relative; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: crosshair; }

/* ---- context menu, toasts, dialog ---- */
.ctx { position: fixed; z-index: 50; background: var(--panel2); border: 1px solid var(--border); min-width: 200px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); padding: 3px 0; }
.ctx button { display: block; width: 100%; text-align: left; background: none; border-radius: 0; padding: 5px 14px; }
.ctx button:hover { background: var(--accent); color: #fff; }
.ctx hr { border: 0; border-top: 1px solid var(--border); margin: 3px 0; }
#toasts { position: fixed; right: 14px; bottom: 34px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 28px)); }
.toast { background: var(--panel2); border-left: 4px solid var(--accent); padding: 9px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.5); cursor: pointer; }
.toast.error { border-left-color: var(--red); }
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--border); padding: 16px; width: min(460px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin-top: 0; }
dialog .row > label:first-child { flex: none; width: 170px; }
dialog .row > input[type=text], dialog .row > input[type=password], dialog .row > select { flex: 1; }
dialog .num { width: 84px; }
dialog .hint.right { padding-left: 178px; }
dialog .result { min-height: 18px; color: var(--fg); }
dialog .buttons { margin-top: 10px; justify-content: flex-start; }

/* ---- sign-in page ---- */
body.loginpage { align-items: center; justify-content: center; overflow: auto; }
.login { background: var(--panel); border: 1px solid var(--border); padding: 28px 28px 24px; width: min(340px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }
.login img { align-self: center; }
.login label { text-align: left; color: var(--muted); font-size: 12px; margin-bottom: -6px; }
.login input { padding: 8px; font-size: 15px; }
.login button { padding: 9px; font-size: 14px; }
.login .err { color: var(--red); margin: 0; }

/* ---- phones and narrow windows: one column, the page scrolls ---- */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { overflow: auto; display: block; }
  body.loginpage { display: flex; min-height: 100vh; }
  #top { padding: 8px 10px; }
  .only-narrow { display: block; width: 100%; margin-bottom: 10px; }
  #top h1 { font-size: 16px; }
  #top .grow { flex-basis: 100%; height: 0; }
  #body { display: block; padding: 0 8px; }
  #menu { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(310px, 88vw); margin: 0;
    box-shadow: 8px 0 30px rgba(0,0,0,.6); }
  .split, .split.h, .split.v { display: block; }
  .gutter { display: none; }
  .pane { min-height: 0; }
  .panel { margin-bottom: 8px; }
  #p-grid { height: 68vh; } #p-run { height: 42vh; } #p-tabs { height: 42vh; }
  #p-news { height: 52vh; } #p-quote { height: 640px; } #p-chart { height: 62vh; }
  #status { white-space: normal; position: sticky; bottom: 0; background: var(--bg); }
  dialog .row > label:first-child { width: 130px; }
  dialog .hint.right { padding-left: 0; }
}
