/* Trade Dojo — grafikon preko celog ekrana (trade-dojo.com/chart/). Boje kao na sajtu i u aplikaciji. */

:root {
  --bg: #0b0c0f;
  --panel: #111217;
  --panel-2: #171920;
  --line: #22252b;
  --text: #e8e8ea;
  --muted: #8a8f98;
  --gold: #f0b90b;
  --up: #2ebd85;
  --down: #f6465d;
  --hover: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.grow { flex: 1; }

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* bez minmax(0, …) široka tabela pozicija razvuče celu stranicu preko ekrana telefona */
  grid-template-columns: minmax(0, 1fr);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* ── zaglavlje ── */
.top {
  display: flex; align-items: center; gap: 6px;
  height: 48px; padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 800; margin-right: 6px; flex: none; }
.brand img { border-radius: 7px; }
.sym-btn {
  display: flex; align-items: baseline; gap: 8px; flex: none;
  background: transparent; border: 0; border-radius: 8px; padding: 6px 8px;
}
.sym-btn:hover { background: var(--hover); }
.sym-name { font-weight: 800; font-size: 15px; }
.sym-px { font-variant-numeric: tabular-nums; color: var(--muted); }
.sym-px.up { color: var(--up); }
.sym-px.down { color: var(--down); }
.caret { color: var(--muted); font-size: 11px; }
.tfs { display: flex; gap: 2px; flex: none; }
.tf-sel { display: none; }
.tfs::-webkit-scrollbar { display: none; }
.tfs button {
  flex: none; background: transparent; border: 0; border-radius: 6px;
  padding: 5px 8px; color: var(--muted); font-weight: 600;
}
.tfs button:hover { background: var(--hover); color: var(--text); }
.tfs button.on { color: var(--gold); background: rgba(240, 185, 11, 0.1); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.live-dot.live { background: var(--up); box-shadow: 0 0 0 3px rgba(46, 189, 133, 0.15); }
.live-dot.reconnecting { background: var(--gold); }
.type-sel select, .tf-sel select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; color: var(--text);
}
.tf-sel select { color: var(--gold); font-weight: 700; }
.hbtn {
  display: flex; align-items: center; gap: 6px; flex: none;
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 5px 9px; color: var(--text);
}
.hbtn:hover { background: var(--hover); }
.hbtn[aria-pressed="true"] { border-color: rgba(240, 185, 11, 0.35); color: var(--gold); }
.hbtn.icon { padding: 5px 7px; }
.hbtn svg { width: 18px; height: 18px; }
.fx { font-style: italic; font-weight: 800; font-family: Georgia, serif; font-size: 15px; }
.ico { display: flex; }
.signin {
  flex: none; border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 700;
  background: var(--gold); color: #111;
}
.signin:disabled { opacity: 0.45; cursor: not-allowed; }
.signin { display: flex; align-items: center; gap: 6px; }
.si-ico { width: 16px; height: 16px; display: none; }
/* prijavljen: slika iz backupa + nadimak umesto zlatnog dugmeta */
.signin.signed { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 3px 12px 3px 3px; max-width: 180px; }
.signin.signed .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signin.signed .si-ico { display: block; margin-left: 6px; }
.signin .av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; }

/* ── nalog ── */
.acct-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.acct-lead { margin: 0; color: var(--text); line-height: 1.5; }
.gbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; border-radius: 10px;
  border: 1px solid #dadce0; background: #fff; color: #1f1f1f; font: 600 15px/1 inherit; cursor: pointer;
}
.gbtn:disabled { opacity: 0.6; cursor: progress; }
.gbtn.busy span::after, .btn.busy::after { content: '…'; }
.filebtn {
  display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 10px;
  border: 1px dashed var(--line); color: var(--muted); font-weight: 600; cursor: pointer;
}
.filebtn:hover { color: var(--text); border-color: var(--muted); }
.filebtn input { display: none; }
.acct-facts { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; display: grid; gap: 4px; }
.acct-small { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.acct-who { display: flex; align-items: center; gap: 12px; }
.acct-who b { display: block; font-size: 16px; }
.acct-who small { color: var(--muted); }
.acct-av { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; flex: none; }
.acct-av img { width: 100%; height: 100%; object-fit: cover; }
.acct-av .si-ico { display: block; width: 24px; height: 24px; color: var(--muted); }
.acct-stats { margin: 0; color: var(--muted); }
.acct-actions { display: flex; gap: 8px; }
.acct-err { margin: 0 16px 16px; padding: 10px 12px; border-radius: 10px; background: rgba(246, 70, 93, 0.12); color: var(--down); font-size: 13px; line-height: 1.45; }
.sym-sec { padding: 10px 14px 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* ── telo: alati + grafikon ── */
.body { display: grid; grid-template-columns: 44px 1fr; min-height: 0; }
.tools {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-right: 1px solid var(--line); background: var(--panel);
  overflow-y: auto; scrollbar-width: none;
}
.tools::-webkit-scrollbar { display: none; }
.tools .sep { width: 24px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
.tool {
  flex: none; width: 36px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--muted);
}
.tool:hover { background: var(--hover); color: var(--text); }
.tool.on { color: var(--gold); background: rgba(240, 185, 11, 0.12); }
.tool svg { width: 20px; height: 20px; }

.stage { position: relative; min-width: 0; min-height: 0; }
.cv { position: absolute; inset: 0; touch-action: none; }
.cv-chart { position: absolute; inset: 0; }
.cv-legend {
  position: absolute; top: 6px; left: 8px; right: 70px; z-index: 3; pointer-events: none;
  font-size: 12px; line-height: 1.5;
}
.cv-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; text-shadow: 0 0 4px var(--bg); }
.cv-title .sym { font-weight: 800; font-size: 13px; }
.cv-title .tf, .cv-title .src { color: var(--muted); }
.ohlc { font-variant-numeric: tabular-nums; }
.ohlc i { font-style: normal; color: var(--muted); margin: 0 2px 0 6px; }
.ohlc.up { color: var(--up); }
.ohlc.down { color: var(--down); }
.ohlc b { margin-left: 6px; font-weight: 600; }
.cv-pane-legends { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.cv-pane-legend { position: absolute; left: 8px; right: 70px; font-size: 12px; }
.lg-row { display: flex; align-items: center; gap: 8px; min-height: 22px; text-shadow: 0 0 4px var(--bg); }
.lg-name { color: var(--text); white-space: nowrap; }
.lg-vals { display: flex; gap: 6px; font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap; }
.lg-btn {
  pointer-events: auto; border: 0; background: rgba(23, 25, 32, 0.85); color: var(--muted);
  width: 22px; height: 22px; border-radius: 6px; font-size: 12px; line-height: 1; padding: 0;
  opacity: 0; transition: opacity 0.15s;
}
.lg-row:hover .lg-btn, .lg-btn:focus-visible { opacity: 1; }
.lg-btn:hover { color: var(--text); }
@media (hover: none) { .lg-btn { opacity: 1; } }
.cv-status {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 4;
  color: var(--muted); font-size: 14px; padding: 20px; text-align: center; pointer-events: none;
}

/* traka za izabrani crtež */
.draw-bar {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 6px; padding: 5px 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.db-colors { display: flex; gap: 4px; }
.db-colors button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.db-colors button.on { border-color: var(--text); }
.db-text { width: 150px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.db-del { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--down); }
.db-del:hover { background: rgba(246, 70, 93, 0.12); }
.db-del svg { width: 18px; height: 18px; }
.draw-hint {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: rgba(23, 25, 32, 0.92); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; color: var(--muted); font-size: 12px; white-space: nowrap; pointer-events: none;
}

/* ── pozicije ── */
.pos { border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); }
.pos-head { display: flex; align-items: center; gap: 10px; padding: 0 8px; height: 38px; }
.pos-tabs { display: flex; gap: 2px; }
.pos-tabs button { background: transparent; border: 0; border-radius: 6px; padding: 6px 10px; color: var(--muted); font-weight: 600; }
.pos-tabs button[aria-selected="true"] { color: var(--text); background: var(--hover); }
#posCount { color: var(--gold); }
.pos-note { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.pos-note b { font-weight: 700; }
.pos-note .muted { color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--gold); font: inherit; font-weight: 600; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.why { color: var(--muted); font-size: 11px; margin-left: 4px; }
.pos-toggle { margin-left: auto; background: transparent; border: 0; color: var(--muted); padding: 6px 8px; border-radius: 6px; transition: transform 0.15s; }
.pos.collapsed .pos-toggle { transform: rotate(180deg); }
.pos.collapsed .pos-body { display: none; }
.pos-body { max-height: 28vh; overflow: auto; }
table.pt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pt th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; text-align: right; padding: 5px 10px; font-size: 12px; }
.pt td { text-align: right; padding: 7px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
.pt th:first-child, .pt td:first-child { text-align: left; }
.pt tr.row { cursor: pointer; }
.pt tr.row:hover td { background: var(--hover); }
.side { font-weight: 700; }
.side.LONG, .pnl.up { color: var(--up); }
.side.SHORT, .pnl.down { color: var(--down); }
.empty { color: var(--muted); padding: 14px 10px; }

/* ── dijalozi ── */
.dlg {
  width: min(440px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 40px));
  padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.dlg.wide { width: min(640px, calc(100vw - 24px)); }
.dlg.small { width: min(360px, calc(100vw - 32px)); }
.confirm-text { margin: 0; padding: 18px 16px 6px; font-size: 14px; }
.dlg[open] { display: flex; flex-direction: column; }
.dlg form { display: flex; flex-direction: column; min-height: 0; }
.dlg::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.dlg-head h2 { margin: 0; font-size: 16px; }
.x { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.x:hover { background: var(--hover); color: var(--text); }
.sym-list { overflow: auto; padding: 0 6px 8px; }
.sym-row {
  display: grid; grid-template-columns: 1fr auto 70px; gap: 10px; align-items: center; width: 100%;
  background: transparent; border: 0; border-radius: 8px; padding: 9px 10px; text-align: left;
}
.sym-row:hover, .sym-row.on { background: var(--hover); }
.sym-row b { font-weight: 700; }
.sym-row small { color: var(--muted); margin-left: 6px; }
.sym-row .p { font-variant-numeric: tabular-nums; text-align: right; }
.sym-row .c { font-variant-numeric: tabular-nums; text-align: right; }
.ind-search { margin: 0 14px 8px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.ind-cats { display: flex; gap: 4px; overflow-x: auto; padding: 0 14px 8px; scrollbar-width: none; flex: none; }
.ind-cats button { flex: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; color: var(--muted); font-size: 12px; }
.ind-cats button.on { color: var(--gold); border-color: rgba(240, 185, 11, 0.45); }
.ind-list { overflow: auto; padding: 0 6px; min-height: 0; flex: 1; }
.ind-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 8px; padding: 8px 10px;
}
.ind-row:hover { background: var(--hover); }
.ind-row .n { font-weight: 600; }
.ind-row .d { color: var(--muted); font-size: 12px; display: block; }
.ind-row .added { margin-left: auto; color: var(--gold); font-size: 12px; flex: none; }
.credits { color: var(--muted); font-size: 11px; padding: 8px 14px 12px; margin: 0; border-top: 1px solid var(--line); }
.set-fields { display: grid; gap: 10px; padding: 4px 14px 12px; overflow: auto; }
.set-fields label { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 10px; }
.set-fields input, .set-fields select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; }
.set-fields input[type="color"] { padding: 2px; height: 32px; }
.dlg-actions { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.btn { border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; background: var(--panel-2); font-weight: 600; }
.btn.gold { background: var(--gold); color: var(--on-gold, #111); border-color: var(--gold); }
.btn.ghost { background: transparent; }

/* ── uži ekrani: zaglavlje se sažima korak po korak ── */
@media (max-width: 1080px) {
  .brand span { display: none; }
  .brand { margin-right: 0; }
}
@media (max-width: 900px) {
  .hbtn .lbl { display: none; }
}

/* ── telefon ── */
@media (max-width: 760px) {
  .live-dot, #posBtn { display: none; }
  .tfs { display: none; }
  .tf-sel { display: block; }
  .sym-px { display: none; }
  .sym-btn { padding: 6px 4px; }
  .top { gap: 4px; padding: 0 4px; overflow-x: auto; scrollbar-width: none; }
  .top::-webkit-scrollbar { display: none; }
  .type-sel select { max-width: 96px; }
  .signin { padding: 6px 10px; }
  .body { grid-template-columns: 40px 1fr; }
  .tool { width: 34px; }
  /* zbir ide u drugi red ispod tabova */
  .pos-head { flex-wrap: wrap; height: auto; min-height: 38px; row-gap: 0; }
  .pos-note { order: 3; flex-basis: 100%; padding: 0 4px 6px; }
  .pos-note:empty { display: none; }
  .signin.signed { padding: 3px; }
  .signin.signed .lbl { display: none; }
  .pos-body { max-height: 24vh; }
  .pt-open th:nth-child(5), .pt-open td:nth-child(5) { display: none; } /* TP / SL */
  .cv-legend { right: 56px; font-size: 11px; }
  .cv-title .src { display: none; }
  .dlg { max-height: calc(100dvh - 24px); }
}
@media (max-width: 480px) {
  .brand { display: none; }
  .type-sel select { max-width: 84px; }
  .caret { display: none; }
  .signin { padding: 7px; }
  .signin .lbl { display: none; }
  .si-ico { display: block; }
  /* uzan telefon: ostaje ono bez čega tabela nema smisla, P&L uvek */
  .pt-open :is(th, td):is(:nth-child(3), :nth-child(6)),
  .pt-hist :is(th, td):is(:nth-child(3), :nth-child(4)),
  .pt-orders :is(th, td):nth-child(5) { display: none; }
  .pt td, .pt th { padding-left: 6px; padding-right: 6px; }
}
