/* Panel — wspólny arkusz stylów. Tokeny na :root, tryb ciemny wg ustawień systemu. */
:root {
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --ink: #15202B;
  --muted: #5B6B7A;
  --line: #D5DCE3;
  --rail: #13263A;
  --rail-ink: #C9D6E3;
  --rail-hi: #FFFFFF;
  --focus: #2F6FB0;
  --up: #1E7B4F;
  --up-soft: #E3F2EA;
  --down: #B23A3A;
  --down-soft: #F8E6E6;
  --watch: #946200;
  --watch-soft: #F7EDD8;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1620; --surface: #15202B; --surface-2: #1B2835; --ink: #E4EAF0; --muted: #93A3B3;
    --line: #2A3A4A; --rail: #0A111A; --rail-ink: #8FA3B8; --focus: #6AA6E0;
    --up: #4CC38A; --up-soft: #133224; --down: #F07A7A; --down-soft: #3A1A1C; --watch: #E0B252; --watch-soft: #33290F;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font);
  font-variant-numeric: tabular-nums; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- układ ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 20px 12px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.rail .brand { color: var(--rail-hi); font-weight: 800; font-size: 20px; text-decoration: none; padding: 4px 10px 20px; }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail a, .rail button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s);
  color: inherit; text-decoration: none; font: inherit; background: none; border: 0; width: 100%; cursor: pointer; text-align: left; }
.rail a:hover, .rail button:hover { color: var(--rail-hi); background: rgba(255,255,255,.06); }
.rail a.is-active { color: var(--rail-hi); background: rgba(255,255,255,.1); box-shadow: inset 3px 0 0 #6AA6E0; }
.rail-foot { margin-top: auto; display: grid; gap: 2px; font-size: 13px; }
.content { padding: 28px 32px 64px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; }
.section { margin-top: 36px; }
.section > h2 { margin-bottom: 12px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .rail .brand { padding: 4px 8px; }
  .rail ul { display: flex; gap: 2px; flex-wrap: wrap; }
  .rail-foot { margin: 0 0 0 auto; display: flex; }
  .rail-foot span { display: none; }
  .content { padding: 20px 16px 48px; }
}

/* ---------- elementy wspólne ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel-pad { padding: 16px 18px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: 600 14px/1 var(--font); padding: 10px 14px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--rail); border-color: var(--rail); color: #fff; }
.btn-primary:hover { background: #1D3854; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.flash p { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-s); background: var(--surface); border-left: 3px solid var(--focus); }
.flash .flash-error { border-left-color: var(--down); }
.flash .flash-success { border-left-color: var(--up); }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius-m); }
.pos { color: var(--up); } .neg { color: var(--down); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { font-weight: 600; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-size: 13px; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; white-space: nowrap; }
table.data .nowrap { white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { white-space: nowrap; padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

/* ---------- pulpit ---------- */
.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; }
.widget > h2 { margin-bottom: 12px; }
.widget > h2 a { text-decoration: none; }
.widget > h2 a:hover { text-decoration: underline; }

/* ---------- logowanie ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; background: var(--rail); }
.login-card { background: var(--surface); padding: 32px; border-radius: var(--radius-m); width: min(360px, 92vw); display: grid; gap: 8px; }
.login-card h1 { margin-bottom: 12px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface-2); color: var(--ink); }
.login-card button { margin-top: 14px; justify-content: center; }
.form-error { color: var(--down); margin: 0; font-size: 14px; }

/* ---------- giełda: stempel rekomendacji ---------- */
.rec { display: grid; grid-template-columns: 170px 1fr 220px; gap: 4px 24px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec-id .ticker { font-size: 22px; font-weight: 800; text-decoration: none; letter-spacing: .01em; }
.rec-id .ticker:hover { text-decoration: underline; }
.rec-id .name { display: block; color: var(--muted); font-size: 13px; }
.rec-id .price { display: block; margin-top: 6px; font-size: 14px; }
.rec-body p { margin: 0 0 8px; max-width: 72ch; }
.rec-body .change { font-size: 13px; color: var(--muted); }
.rec-levels { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; align-content: start; }
.rec-levels dt { color: var(--muted); }
.rec-levels dd { margin: 0; text-align: right; }

.stamp { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.stamp-action { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -0.015em; }
.act-buy  { color: var(--up); }
.act-sell { color: var(--down); }
.act-hold { color: var(--watch); }
.meter { display: inline-grid; grid-template-columns: repeat(10, 7px); gap: 2px; vertical-align: middle; }
.meter i { height: 12px; background: var(--line); border-radius: 1px; }
.meter i.on { background: currentColor; }
.meter-label { font-size: 13px; color: var(--muted); }

.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip-up { background: var(--up-soft); color: var(--up); border-color: transparent; }
.chip-down { background: var(--down-soft); color: var(--down); border-color: transparent; }
.events { display: flex; flex-wrap: wrap; gap: 4px; }

.score { display: inline-block; min-width: 44px; text-align: right; font-weight: 600; }
.scorebar { display: inline-block; width: 60px; height: 6px; background: var(--surface-2); border-radius: 3px; position: relative;
  vertical-align: middle; margin-left: 6px; overflow: hidden; }
.scorebar b { position: absolute; top: 0; bottom: 0; }
.scorebar b.up { left: 50%; background: var(--up); }
.scorebar b.down { right: 50%; background: var(--down); }

.statusbar { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: center; padding: 14px 18px; }
.statusbar .stat strong { display: block; font-size: 18px; }
.statusbar .stat span { font-size: 13px; color: var(--muted); }
.statusbar form { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.running-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--watch); margin-right: 6px;
  animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .running-dot { animation: none; } }

details.more { margin-top: 6px; }
details.more summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details.more summary:hover { color: var(--ink); }
.more-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; margin-top: 10px; font-size: 14px; }
.more-grid h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.more-grid ul { margin: 0; padding-left: 18px; }
.more-grid p { margin: 0; }

.chart { height: 380px; width: 100%; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split > * { min-width: 0; }
.chart { position: relative; overflow: hidden; }
.panel-pad h3 { margin-top: 16px; margin-bottom: 4px; }
.big-score { font-size: 22px; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }
.toggle-form { display: inline; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); }
.disclaimer { margin-top: 40px; font-size: 12px; color: var(--muted); max-width: 80ch; }

@media (max-width: 900px) {
  .rec { grid-template-columns: 1fr; }
  .rec-levels { max-width: 280px; }
  .split { grid-template-columns: minmax(0, 1fr); }
}

.widget-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.widget-list li { display: grid; grid-template-columns: minmax(80px, auto) 90px 1fr; gap: 10px; align-items: baseline; }
.widget-list li > * { white-space: nowrap; }
.chart-readout { height: 22px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart canvas { display: block; }
.btn[aria-pressed="true"] { background: var(--surface-2); border-color: var(--muted); }
table.data tr.group-row th { background: var(--surface-2); color: var(--ink); font-size: 14px; padding: 10px; text-align: left;
  border-bottom: 1px solid var(--line); }
table.data tbody + tbody tr.group-row th { border-top: 2px solid var(--line); }
table.data tbody tr.group-row:hover { background: none; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.summary-card h2 { margin-bottom: 14px; }
.summary-total { background: var(--surface-2); }
.summary-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; align-items: baseline; }
.summary-kv dt { color: var(--muted); font-size: 14px; }
.summary-kv dd { margin: 0; text-align: right; font-size: 18px; font-weight: 600; }
.summary-kv dd.summary-big { font-size: 24px; font-weight: 800; }
.summary-kv dd.muted { font-size: 14px; font-weight: 400; }
.chip-held { background: var(--watch-soft); color: var(--watch); border-color: transparent; margin-left: 4px; }
table.data.agent-table tr.detail-row td { padding-top: 0; }
table.data.agent-table tr:has(+ tr.detail-row) td { border-bottom: 0; }
table.data.agent-table tr.detail-row details.more { margin-top: 0; }
table.data.agent-table tr.detail-row summary { max-width: 100ch; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
