/* ===================================================================
   US Screener - ciemny dashboard w stylu "datapine"
   =================================================================== */
:root {
  --bg:        #0c0c17;
  --bg-2:      #10101f;
  --panel:     #16162b;
  --panel-2:   #1b1b36;
  --panel-hi:  #20204020;
  --border:    rgba(255,255,255,0.07);
  --border-hi: rgba(255,255,255,0.14);
  --text:      #e7e7f4;
  --muted:     #8a8ab4;
  --muted-2:   #616185;
  --label:     #b4b4da;
  --blue:      #4f9dff;

  --teal:      #35e6c3;
  --teal-dim:  #23a88f;
  --purple:    #7b6bf2;
  --magenta:   #d24dbe;
  --salmon:    #f4a06a;
  --yellow:    #f2d36b;
  --green:     #35e6a0;
  --red:       #ff5c7c;
  --blue:      #4aa8ff;

  --radius:    12px;
  --shadow:    0 8px 24px rgba(0,0,0,0.35);
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:      "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(123,107,242,0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(53,230,195,0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 22px;
  height: 58px;
  background: rgba(10,10,20,0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-mark {
  width: 16px; height: 16px; border-radius: 4px;
  background: linear-gradient(135deg, var(--teal), var(--purple));
  box-shadow: 0 0 14px rgba(53,230,195,0.5);
}
.brand-name .accent { color: var(--teal); }

.topnav { display: flex; gap: 22px; align-items: center; height: 100%; }
.topnav a {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1px;
  height: 100%;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--teal); border-bottom-color: var(--teal); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.lang-toggle {
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700;
  letter-spacing: .5px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; transition: .15s;
}
.lang-toggle:hover { color: var(--teal); border-color: var(--teal); }
.user-chip {
  color: var(--muted);
  font-size: 12.5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.user-chip::before { content: "●"; color: var(--green); margin-right: 6px; font-size: 9px; vertical-align: middle; }
.logout-form { margin: 0; }
.btn-logout {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  transition: .15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); }

/* ---------------- Layout ---------------- */
.content { padding: 20px 22px 40px; max-width: 1600px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}
.span-4 { grid-column: span 4; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }
.span-3 { grid-column: span 3; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }

@media (max-width: 1150px) {
  .span-4, .span-8, .span-5, .span-6, .span-7 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
}
@media (max-width: 640px) {
  .span-3 { grid-column: span 12; }
}

/* ---------------- Cards ---------------- */
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 14px;
  text-transform: uppercase;
}
.muted-count { color: var(--teal); font-weight: 600; letter-spacing: 0; margin-left: 6px; }

/* ---------------- Toolbar ---------------- */
.toolbar { margin-bottom: 18px; }
.toolbar-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.toolbar-row + .toolbar-row { margin-top: 14px; }
.filters { border-top: 1px solid var(--border); padding-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 340px; }
.field label {
  font-size: 11px; letter-spacing: .6px; color: var(--muted-2); text-transform: uppercase;
}

.input {
  background: #0d0d1c;
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(53,230,195,0.15); }
.input-wide { width: 100%; }
select.input { cursor: pointer; }

.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-dim));
  color: #06231d; border: none; border-radius: 8px;
  padding: 10px 20px; font-weight: 700; font-size: 13.5px; cursor: pointer;
  letter-spacing: .3px; transition: transform .1s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(53,230,195,0.25);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(53,230,195,0.4); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 8px;
  padding: 10px 18px; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: .15s;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }

/* progress + status */
.progress-wrap { flex: 1 1 260px; display: flex; flex-direction: column; gap: 7px; justify-content: flex-end; min-width: 220px; }
.progress { height: 7px; background: #0d0d1c; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--teal), var(--purple));
  transition: width .3s ease;
}
.status { font-size: 12px; color: var(--muted); min-height: 15px; }
.status.err { color: var(--red); }

/* ---------------- Quick stats ---------------- */
.stat-hero { margin-bottom: 6px; }
.stat-big {
  font-size: 46px; font-weight: 800; line-height: 1;
  color: var(--teal); text-shadow: 0 0 22px rgba(53,230,195,0.35);
}
.stat-label { font-size: 11px; letter-spacing: 1px; color: var(--muted); margin-top: 6px; text-transform: uppercase; }
.sparkline { height: 46px; margin: 10px 0 4px; }
.stat-mini-row { display: flex; gap: 10px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.stat-mini { flex: 1; text-align: center; }
.stat-mini .num { font-size: 24px; font-weight: 700; }
.stat-mini .num.teal { color: var(--teal); }
.stat-mini .lab { font-size: 10px; letter-spacing: .6px; color: var(--muted-2); margin-top: 3px; text-transform: uppercase; }

/* ---------------- Charts ---------------- */
.chart-sm { height: 230px; width: 100%; }
.chart-lg { height: 520px; width: 100%; position: relative; }
.chart-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--muted-2); font-size: 13px; padding: 20px;
}
.map-legend { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 7px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.teal { background: var(--teal); }

/* ---------------- Table ---------------- */
.table-wrap { max-height: 460px; overflow: auto; border-radius: 8px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.rtable thead th {
  position: sticky; top: 0; z-index: 2;
  background: #14142a;
  color: var(--muted);
  text-align: right;
  font-size: 11px; letter-spacing: .5px; text-transform: uppercase; font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--border-hi); white-space: nowrap;
}
.rtable thead th:first-child, .rtable thead th:nth-child(2) { text-align: left; }
.rtable tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.rtable tbody td:first-child { text-align: left; font-weight: 700; }
.rtable tbody td:nth-child(2) { text-align: left; color: var(--muted); max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.rtable tbody tr { cursor: pointer; transition: background .12s; }
.rtable tbody tr:hover { background: rgba(123,107,242,0.10); }
.rtable tbody tr.selected { background: rgba(53,230,195,0.14); }
.rtable tbody tr.cat-strong td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.rtable tbody tr.cat-tech   td:first-child { box-shadow: inset 3px 0 0 var(--purple); }
.rtable tbody tr.cat-fund   td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.empty-row td { text-align: center !important; color: var(--muted-2); padding: 30px !important; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.pill-pass { background: rgba(53,230,160,0.16); color: var(--green); }
.pill-fail { background: rgba(255,92,124,0.16); color: var(--red); }
.pill-muted { background: rgba(255,255,255,0.06); color: var(--muted); }
.pill-yes { background: rgba(53,230,195,0.16); color: var(--teal); }
.pill-no { color: var(--muted-2); }

/* ---------------- Report ---------------- */
.report {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 500px;
  overflow: auto;
}

/* ---------------- Flash ---------------- */
.flash-wrap { padding: 12px 22px 0; max-width: 1600px; margin: 0 auto; }
.flash {
  padding: 11px 16px; border-radius: 8px; margin-bottom: 10px; font-size: 13px;
  border: 1px solid var(--border-hi);
}
.flash-danger  { background: rgba(255,92,124,0.12); border-color: rgba(255,92,124,0.4); color: #ffb3c2; }
.flash-warning { background: rgba(242,211,107,0.12); border-color: rgba(242,211,107,0.4); color: #f2e2a0; }
.flash-success { background: rgba(53,230,160,0.12); border-color: rgba(53,230,160,0.4); color: #a6f2d3; }

/* ---------------- Login / error ---------------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: 16px;
  padding: 34px 30px; box-shadow: var(--shadow);
}
.login-brand { font-size: 28px; font-weight: 800; text-align: center; }
.login-brand .accent { color: var(--teal); }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 24px; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { font-size: 11px; letter-spacing: .5px; color: var(--muted-2); text-transform: uppercase; margin-top: 6px; }
.btn-block { width: 100%; margin-top: 18px; padding: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; text-transform: none !important; letter-spacing: 0 !important; margin-top: 12px !important; }
.check input { accent-color: var(--teal); width: 15px; height: 15px; }

/* ---------------- Users form ---------------- */
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.stack-form label { font-size: 11px; letter-spacing: .5px; color: var(--muted-2); text-transform: uppercase; margin-top: 6px; }
.btn-danger-sm {
  background: transparent; color: var(--red); border: 1px solid rgba(255,92,124,0.4);
  border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.btn-danger-sm:hover:not(:disabled) { background: rgba(255,92,124,0.14); }
.btn-danger-sm:disabled { opacity: .4; cursor: not-allowed; }

/* ===================================================================
   Panel standardowego uzytkownika (widok gotowosci)
   =================================================================== */
.userbar { margin-bottom: 18px; }
.userbar-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.userbar-title { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.userbar-sub { color: var(--muted); font-size: 13px; margin-top: 4px; max-width: 640px; }
.userbar-actions { display: flex; align-items: center; gap: 14px; }
.userbar .progress-wrap { margin-top: 14px; max-width: none; min-width: 0; }

/* karty statystyk */
.stat-card { display: flex; flex-direction: column; gap: 8px; min-height: 118px; justify-content: center; }
.stat-card .stat-ico { font-size: 12px; letter-spacing: 1px; }
.stat-card .stat-num { font-size: 42px; font-weight: 800; line-height: 1; color: var(--text); text-shadow: 0 0 22px rgba(255,255,255,0.08); }
.stat-card .stat-cap { font-size: 11px; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); }
.stat-card.green  .stat-num { color: var(--green);  text-shadow: 0 0 22px rgba(53,230,160,0.32); }
.stat-card.yellow .stat-num { color: var(--yellow); text-shadow: 0 0 22px rgba(242,211,107,0.28); }
.stat-card.gray   .stat-num { color: #9a9ac2; }
.stat-card.teal   .stat-num { color: var(--teal);   text-shadow: 0 0 22px rgba(53,230,195,0.32); }
.stat-card .stat-ico.green  { color: var(--green); }
.stat-card .stat-ico.yellow { color: var(--yellow); }
.stat-card .stat-ico.gray   { color: #6a6a8c; }
.stat-card .stat-ico.teal   { color: var(--teal); }

/* wykres zbiorczy - naglowek ze zmiana */
.mkt-change { font-weight: 700; margin-left: 8px; letter-spacing: 0; font-size: 13px; }
.mkt-change.up { color: var(--green); }
.mkt-change.down { color: var(--red); }
.mkt-periods { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.mkt-chip {
  display: flex; flex-direction: column; gap: 3px; padding: 7px 13px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 9px; min-width: 82px;
}
.mkt-chip-lab { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.mkt-chip-val { font-size: 15px; font-weight: 700; }
.mkt-chip-val.up { color: var(--green); }
.mkt-chip-val.down { color: var(--red); }
.mkt-chip-val.flat { color: var(--muted-2); }
.mkt-foot { font-size: 11px; color: var(--label); margin-top: 8px; }

/* legenda + kropki sygnalizatora */
.ready-legend { display: flex; gap: 18px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.ready-legend span { display: inline-flex; align-items: center; gap: 7px; }
.rdot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; vertical-align: middle; }
.rdot.green  { background: var(--green);  box-shadow: 0 0 10px rgba(53,230,160,0.75); }
.rdot.yellow { background: var(--yellow); box-shadow: 0 0 10px rgba(242,211,107,0.65); }
.rdot.gray   { background: #4a4a66; }

/* tabela uzytkownika: status ze sygnalizatorem */
.utable tbody td:nth-child(2) { color: var(--text); }
.utable tbody td.status-td { text-align: left; }
.status-cell { display: inline-flex; align-items: center; gap: 9px; }
.status-cell .lab { font-size: 12.5px; color: var(--muted); }
.utable tbody tr.rd-green  td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.utable tbody tr.rd-yellow td:first-child { box-shadow: inset 3px 0 0 var(--yellow); }
.utable tbody tr.rd-gray   td:first-child { box-shadow: inset 3px 0 0 #4a4a66; }
.ov-search { max-width: 200px; margin-left: auto; padding: 6px 10px; font-size: 12.5px; }
.pf-sel-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pf-sel { min-width: 190px; padding: 7px 10px; font-size: 12.5px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .card-title { margin-bottom: 0; }
.pf-head-actions { display: flex; align-items: center; gap: 10px; }
.card-title.with-tool { display: flex; align-items: center; gap: 10px; }

/* ---------------- portfolio ---------------- */
.pf-form { display: flex; flex-direction: column; gap: 14px; }
.pf-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.pf-grid .field.grow { grid-column: span 6; }
@media (max-width: 1100px) { .pf-grid { grid-template-columns: repeat(3, 1fr); } .pf-grid .field.grow { grid-column: span 3; } }
@media (max-width: 640px)  { .pf-grid { grid-template-columns: repeat(2, 1fr); } .pf-grid .field.grow { grid-column: span 2; } }
.pf-form-actions { display: flex; align-items: center; gap: 12px; }

.pf-stats { display: flex; flex-wrap: wrap; gap: 12px; }
.pf-stat {
  flex: 1 1 140px; min-width: 130px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.pf-stat .lab { font-size: 10px; letter-spacing: .6px; color: var(--label); text-transform: uppercase; }
.pf-stat .num { font-size: 22px; font-weight: 700; margin-top: 5px; }
.pf-stats-user .num { font-size: 20px; }

/* Widok uzytkownika: dwie kolumny per broker (czytelne porownanie portfeli) */
.pf-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 980px) { .pf-columns { grid-template-columns: 1fr; } }
.pf-col-card { display: flex; flex-direction: column; gap: 12px; }
.pf-col-head { display: flex; align-items: center; gap: 10px; }
.pf-col-name {
  font-size: 15px; font-weight: 700; letter-spacing: .3px; color: var(--text);
  padding: 4px 12px; border: 1px solid var(--border-hi); border-radius: 999px;
  background: var(--panel-2);
}
.pf-col-subtitle { margin-top: 2px; }
.pf-col-card .pf-stat { flex: 1 1 110px; min-width: 104px; padding: 10px 12px; }
.pf-col-card .pf-stat .num { font-size: 18px; }

/* Ticker jako link do TradingView */
.tv-link {
  color: inherit; text-decoration: none; cursor: pointer;
  border-bottom: 1px dashed transparent;
}
.tv-link:hover { color: var(--teal); border-bottom-color: currentColor; }

.pf-actions { display: flex; gap: 6px; white-space: nowrap; }
.btn-mini {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.btn-mini:hover { border-color: var(--teal); color: var(--teal); }

.pf-pos { color: var(--green); }
.pf-neg { color: var(--red); }
.pf-status-tag {
  display: inline-block; margin-right: 8px; font-size: 10px; letter-spacing: .5px;
  text-transform: uppercase; color: var(--label);
}
.pf-status-tag.is-open { color: var(--blue); font-weight: 700; }
