/* =========================================================
 FinDash Pro – styles.css (refactored)
 Ulepszenia:
 - naprawa błędów składni (komentarze, reset)
 - spójne breakpoints i stacked tables
 - ultra‑compact (<= 320px, pion): label nad value, pełne szerokości przycisków
 - trades.php: #tradesTable i podtabela Wykonania dopracowane na mobile
========================================================= */

/* -----------------------------
 1) Zmienne (light/dark)
----------------------------- */
:root {
  --bg-primary: linear-gradient(135deg, #f9fafb 0%, #dce2f0 100%);
  --bg-secondary: rgba(255, 255, 255, 0.9);
  --text-primary: #111827;
  --text-secondary: #374151;
  --accent: #2563eb;
  --accent-up: #16a34a;
  --accent-down: #dc2626;
  --accent-cons: #f59e0b;
  --innse-accent: #00b0ff; /* dodatkowy akcent */
  --ergohesta-accent: #7e57c2; /* dodatkowy akcent */
  --glass-bg: rgba(255, 255, 255, 0.25);
  --glass-border: rgba(255, 255, 255, 0.25);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  --blur: blur(12px);
  --chart-bg: #ffffff;
  --chart-text: #111827;
  --chart-candle-up: #16a34a;
  --chart-candle-down: #dc2626;
  --radius: 14px;
  --spacing: 12px;
  --focus-ring: 2px solid rgba(37, 99, 235, 0.65);

  /* Footer mini defaults */
  --footer-h: 40px;
  --footer-fs: 12px;
  --footer-ico: 18px;
  --footer-gap: 6px;
  --footer-pad-x: 8px;
}

[data-theme="dark"] {
  --bg-primary: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
  --bg-secondary: rgba(20, 20, 30, 0.9);
  --text-primary: #f1f5f9;
  --text-secondary: #9ca3af;
  --accent: #2563eb;
  --accent-up: #22c55e;
  --accent-down: #ef4444;
  --accent-cons: #f59e0b;
  --innse-accent: #00b0ff;
  --ergohesta-accent: #7e57c2;
  --glass-bg: rgba(30, 30, 40, 0.4);
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  --chart-bg: #161b22;
  --chart-text: #f1f5f9;
  --chart-candle-up: #22c55e;
  --chart-candle-down: #ef4444;
}

/* -----------------------------
 2) Reset i baza
----------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
  scroll-behavior: smooth;
}

/* Użyteczne klasy kolorystyczne (np. PNL) */
.positive { color: var(--accent-up) !important; }
.negative { color: var(--accent-down) !important; }
.neutral { color: var(--text-secondary) !important; }

/* -----------------------------
 3) Header i nawigacja
----------------------------- */
header {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.75rem 1rem;
  display: flex; justify-content: center; align-items: center;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 100;
  width: 100%; max-width: 100vw;
}

.logo {
  font-size: 1.3rem; font-weight: 700; white-space: nowrap;
  background: linear-gradient(45deg, #ff4ecd, #00dbde, #ff4ecd);
  background-size: 200% 100%;
  background-clip: text; -webkit-background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: 0 0; } }

.theme-toggle, .hamburger {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  color: var(--text-primary); padding: 0.5rem; border-radius: 50%;
  transition: transform 0.2s ease, background 0.3s ease; position: absolute;
}
.theme-toggle { right: 1rem; }
.hamburger { left: 1rem; }
.theme-toggle:hover, .hamburger:hover { transform: scale(1.1); background: var(--glass-bg); }
.theme-toggle:focus-visible, .hamburger:focus-visible { outline: var(--focus-ring); }

/* Mobile nav (hamburger) */
nav {
  position: fixed; top: 0; left: -100%; width: min(80vw, 220px); height: 100vh;
  transition: left 0.3s ease; padding: 1.5rem; z-index: 200;
  background: rgba(10, 10, 15, 0.75); backdrop-filter: var(--blur);
  border-right: 1px solid var(--glass-border); overflow-y: auto;
}
nav.active { left: 0; }
nav ul { list-style: none; }
nav li { margin: 1.2rem 0; }
nav a {
  text-decoration: none; font-size: 1rem; font-weight: 500; color: #ffffff; transition: color 0.3s ease;
}
nav a:hover { color: var(--accent-up); }
[data-theme="dark"] nav { background: rgba(10, 10, 15, 0.95); }
[data-theme="dark"] nav a { color: #f9fafb; }
[data-theme="dark"] nav a:hover { color: #22c55e; }

/* Desktop: poziome menu w headerze */
@media (min-width: 992px) {
  header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "logo nav theme";
    align-items: center;
    padding: 0.55rem 1rem;
  }
  .logo { grid-area: logo; margin: 0 12px 0 0; }
  .hamburger { display: none !important; }
  .theme-toggle { grid-area: theme; position: static; }

  nav#nav {
    grid-area: nav;
    position: static; left: auto; top: auto; width: auto; height: auto;
    padding: 0; background: transparent; border: 0; overflow: visible;
  }
  nav#nav ul {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin: 0; padding: 0; list-style: none;
  }
  nav#nav li { margin: 0; }
  nav#nav a {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-primary);
    font-weight: 600; font-size: 0.95rem;
    padding: 6px 10px; border-radius: 8px;
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
  }
  nav#nav a:hover { background: rgba(148,163,184,0.18); }
  nav#nav a[aria-current="page"] { background: var(--accent); color: #fff; }
  [data-theme="dark"] nav#nav a:hover { background: rgba(255,255,255,0.08); }
}

/* -----------------------------
 4) Siatka dashboardu
----------------------------- */
.dashboard {
  padding: 1rem;
  padding-bottom: calc(4rem + 1rem + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr; gap: 1rem;
  max-width: 100vw; width: 100%; box-sizing: border-box;
  container-type: inline-size; container-name: dashboard;
}
@media (min-width: 480px) { .dashboard { grid-template-columns: repeat(2, 1fr); padding: 1rem 0.5rem; } }
@media (min-width: 768px) { .dashboard { grid-template-columns: repeat(3, 1fr); padding: 1rem; } }

/* -----------------------------
 5) Kafelki
----------------------------- */
.tile {
  background: var(--glass-bg); backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 0.9rem; text-align: center; box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  animation: scrollFade 0.4s ease-out; width: 100%; position: relative;
}
.tile:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 15px 30px rgba(0,0,0,.35); }
.tile.trend-up { border-left: 3px solid var(--accent-up); }
.tile.trend-down { border-left: 3px solid var(--accent-down); }
.tile.trend-flat,
.tile.trend-consolidation { border-left: 3px solid var(--accent-cons); }

@container (min-width: 160px) { .tile { font-size: .9rem; padding: .6rem; } }
@container (min-width: 200px) { .tile { font-size: 1rem; padding: .75rem; } }
.tile.updated { animation: tileFlash 0.8s ease-in-out; }

.symbol { font-size: .9rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .4rem; white-space: nowrap; }
.price { font-size: clamp(1.05rem, 2.8vw, 1.3rem); font-weight: 700; margin-bottom: .2rem; }
.change { font-size: .75rem; font-weight: 600; }
.trend { font-size: 1rem; animation: pulse 1s 2; }

.chart-icon {
  position: absolute; top: .5rem; right: .5rem; font-size: 1rem; cursor: pointer;
  color: var(--text-secondary); transition: color .2s ease, transform .2s ease;
}
.chart-icon:hover { color: var(--accent-up); transform: scale(1.1); }
.chart-icon:focus-visible { outline: var(--focus-ring); border-radius: 6px; }

.open-trade-badge {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 6px; font-size: .85rem; line-height: 1; padding: 2px 6px;
  border-radius: 8px; background: rgba(37,99,235,.12); color: var(--accent);
  border: 1px solid rgba(37,99,235,.25);
}
.volatility, .volume { font-size: .7rem; color: var(--text-secondary); margin-top: .4rem; }

/* Alerty w kafelkach */
.alert {
  font-size: .75rem; color: var(--text-primary);
  background: rgba(239, 68, 68, .12);
  border-radius: 8px; padding: .4rem .5rem; margin-top: .35rem;
  animation: fadeIn .5s ease-in; word-wrap: break-word;
}
.alert.positive { background: rgba(22, 163, 74, .12); }
.alert.neutral { background: rgba(128, 128, 128, .12); }
body.hide-neutral .alert.neutral { display: none !important; }

/* Podsumowanie trendu i ikony */
.trend-summary {
  display: flex; justify-content: center; align-items: center;
  gap: .35rem; font-weight: 600; font-size: .85rem; margin-top: .4rem;
  color: var(--text-primary); white-space: nowrap;
}
.trend-icon { font-size: 1rem; line-height: 1; }
.trend-icon.up { color: var(--accent-up); }
.trend-icon.down { color: var(--accent-down); }
.trend-icon.flat, .trend-icon.cons { color: var(--accent-cons); }
.trend-summary .tf { font-size: .75rem; font-weight: 500; color: var(--text-secondary); }
.clickable-trend, .clickable-cons { cursor: pointer; }
.clickable-trend:hover, .clickable-cons:hover { text-decoration: underline; }

/* Badge zgodności/div/lag */
.sync-badge {
  display: inline-block; padding: 2px 6px; margin-left: 6px;
  border-radius: 6px; font-size: 12px; line-height: 1; border: 1px solid transparent;
}
.sync-badge.ok { background: #e6ffed; color: #0a7a28; border-color: #b5f0c4; }
.sync-badge.div { background: #fff8e6; color: #7a4b0a; border-color: #f0ddb5; }
.sync-badge.lag { background: #eef2ff; color: #22317a; border-color: #cdd5ff; }

/* -----------------------------
 6) Stopka (sticky) – baza
----------------------------- */
footer {
  background: var(--glass-bg); backdrop-filter: var(--blur);
  border-top: 1px solid var(--glass-border); padding: .75rem 1rem;
  padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center;
  position: fixed; bottom: 0; width: 100%; max-width: 100vw; box-shadow: var(--shadow);
}
.footer-items { display: flex; justify-content: space-around; flex-wrap: wrap; width: 100%; max-width: 400px; gap: .5rem; }
.footer-item { text-align: center; color: var(--text-secondary); cursor: pointer; transition: color .2s ease; flex: 1; min-width: 60px; }
.footer-item a { display: inline-block; color: inherit; text-decoration: none; }
.footer-item:hover, .footer-item:focus { color: var(--text-primary); }
.footer-item i { font-size: 1.3rem; display: block; margin-bottom: .2rem; }
.footer-refresh { display: flex; justify-content: center; width: 100%; max-width: 400px; padding: .25rem 0; border-top: 1px solid var(--glass-border); }
.footer-refresh .footer-item { font-size: .85em; color: var(--text-secondary); padding: 0 .5rem; text-transform: lowercase; }
.footer-refresh .footer-item:hover, .footer-refresh .footer-item:focus { color: var(--text-primary); }
.footer-item[title="Odśwież"] { color: var(--accent-up); }

.last-updated {
  font-size: .75rem; font-weight: 500; color: var(--text-secondary);
  text-align: center; margin-top: .35rem; opacity: .85; transition: color .3s ease, opacity .3s ease; white-space: nowrap;
}
.last-updated:hover, .last-updated:focus { color: var(--text-primary); opacity: 1; }

/* Tryb kompaktowy kafli i footer */
body.tiles-compact .tile { padding: .55rem; }
body.tiles-compact .price { font-size: 1.1rem; }
body.tiles-compact .symbol { font-size: .78rem; }
body.tiles-compact .volatility,
body.tiles-compact .volume,
body.tiles-compact .daily-stats { display: none; }

footer { padding: .55rem .75rem; }
.footer-items { max-width: 360px; }
.footer-item i { font-size: 1.15rem; }

/* Ikony bez napisów na mobile */
@media (max-width: 768px) {
  .footer-item span { display: none; }
  .footer-items { gap: .25rem; }
  footer { padding: .5rem .65rem; }
}

/* Wymuś kompakt także na desktop (opcjonalnie, przez body.footer-compact) */
body.footer-compact footer { padding: .45rem .6rem; }
body.footer-compact .footer-item span { display: none; }
body.footer-compact .footer-item i { font-size: 1.05rem; }

/* -----------------------------
 7) Modal + animacje
----------------------------- */
.modal {
  display: none; position: fixed; z-index: 1000; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
}
.modal.show,
.modal.active,
.modal[aria-hidden="false"],
.modal[data-open="1"] {
  display: flex !important; justify-content: center; align-items: center;
}
.modal[style="display: block"] {
  display: flex !important; justify-content: center; align-items: center;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  width: min(96%, 980px);
  max-height: calc(100vh - 120px);
  padding: calc(var(--spacing) * 1.5);
  box-shadow: var(--shadow);
  position: relative;
  transform: scale(.95);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  overflow-y: auto;
  margin: 6vh auto;
}
.modal.show .modal-content { transform: scale(1); opacity: 1; }

/* Zamknięcie modala */
.modal .close {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; line-height: 38px;
  text-align: center; border-radius: 50%;
  font-size: 18px; font-weight: 700; color: #fff;
  background: rgba(17,24,39,.85); border: 1px solid rgba(255,255,255,.2);
  cursor: pointer; z-index: 2; transition: background .2s ease, transform .2s ease;
}
.modal .close:hover { background: var(--accent-down); transform: scale(1.06); }

/* Przełączniki TF i sygnałów */
#chartModal .tf-switcher { display: flex; gap: 10px; justify-content: center; align-items: center; margin-bottom: .6rem; }
.tf-button {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--text-primary);
  transition: all .2s ease;
}
.tf-button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tf-button:disabled { opacity: .6; cursor: not-allowed; }
.tf-button:focus-visible { outline: var(--focus-ring); }

/* -----------------------------
 8) Kontener wykresu
----------------------------- */
#chartCanvas {
  width: 100%;
  min-height: clamp(340px, 70vh, 88vh);
  background: var(--chart-bg);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#chartCanvas .apexcharts-annotation-label {
  white-space: nowrap !important; max-width: none !important; font-size: 12px !important;
  padding: 2px 6px !important; border-radius: 6px !important;
}
#chartCanvas .apexcharts-canvas { overflow: visible !important; }
#chartCanvas .apexcharts-tooltip.apexcharts-theme-light,
#chartCanvas .apexcharts-tooltip.apexcharts-theme-dark { font-size: 12px; white-space: nowrap; }

/* -----------------------------
 10) Tabele – baza
----------------------------- */
.tile > div[style="overflow:auto"], .tile .table-scroll {
  overflow-x: auto !important; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable both-edges;
}

.tile table,
.top10-table,
#tradesTable {
  width: 100%;
  border-collapse: collapse;
  background: var(--chart-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tile table th, .tile table td,
.top10-table th, .top10-table td,
#tradesTable th, #tradesTable td {
  padding: 8px 10px;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid var(--glass-border);
}

.tile table thead th,
.top10-table thead th,
#tradesTable thead th {
  background: var(--glass-bg);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--glass-border);
}

.tile table tbody tr:nth-child(even),
.top10-table tbody tr:nth-child(even),
#tradesTable tbody tr:nth-child(even) {
  background: rgba(148,163,184,0.08);
}

.tile table thead th.sortable,
#tradesTable thead th.sortable { cursor: pointer; user-select: none; }
.tile table thead th.sortable::after,
#tradesTable thead th.sortable::after { content: ' ⇅'; font-size: 11px; color: var(--text-secondary); }
.tile table thead th[data-dir="ASC"]::after,
.tile table thead th[data-dir="asc"]::after,
#tradesTable thead th[data-dir="ASC"]::after,
#tradesTable thead th[data-dir="asc"]::after { content: ' ▲'; }
.tile table thead th[data-dir="DESC"]::after,
.tile table thead th[data-dir="desc"]::after,
#tradesTable thead th[data-dir="DESC"]::after,
#tradesTable thead th[data-dir="desc"]::after { content: ' ▼'; }

/* Wyrównania liczb w tabeli */
.tile table td:nth-child(5),
.tile table td:nth-child(6),
.tile table td:nth-child(7),
.tile table td:nth-child(8),
.tile table td:nth-child(11),
#tradesTable td[data-label="Wejście"],
#tradesTable td[data-label="SL"],
#tradesTable td[data-label="TP1/TP2/TP3"],
#tradesTable td[data-label="Qty otw."],
#tradesTable td[data-label="PNL"] {
  text-align: right;
}

/* -----------------------------
 11) Stacked tables (mobile)
     - ogólny wzorzec <= 600px
----------------------------- */
@media (max-width: 600px) {
  .tile table,
  .tile table thead, .tile table tbody, .tile table th, .tile table td, .tile table tr,
  #tradesTable, #tradesTable thead, #tradesTable tbody, #tradesTable th, #tradesTable td, #tradesTable tr {
    display: block; width: 100%;
  }
  .tile table thead,
  #tradesTable thead { display: none; }

  .tile table tr,
  #tradesTable tr {
    margin-bottom: .5rem; border: 1px solid var(--glass-border); border-radius: var(--radius);
    padding: 8px; box-shadow: var(--shadow); background: var(--chart-bg);
  }

  .tile table td,
  #tradesTable td {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px;
    padding: 8px; border: none; border-bottom: 1px solid var(--glass-border);
    text-align: left; white-space: normal;
  }
  .tile table td:last-child,
  #tradesTable td:last-child { border-bottom: none; }

  .tile table td::before,
  #tradesTable td::before {
    content: attr(data-label) " "; font-weight: 600; color: var(--text-secondary);
    margin-right: 10px; flex-shrink: 0;
  }

  /* Akcje – wiersz przycisków */
  .tile table td[data-label="Akcje"],
  #tradesTable td[data-label="Akcje"] {
    justify-content: center; grid-template-columns: 1fr; gap: 8px; padding: 10px 0;
  }
  .tile table td[data-label="Akcje"] form,
  #tradesTable td[data-label="Akcje"] form { background: transparent; display: inline-flex; margin: 0; padding: 0; }
  .tile table td[data-label="Akcje"] .action-btn,
  #tradesTable td[data-label="Akcje"] .tf-button,
  #tradesTable td[data-label="Akcje"] .action-btn { width: 100%; height: 36px; }
}

/* -----------------------------
 12) trades.php – szczegóły (podtabele)
----------------------------- */
.details-row { background: transparent; }
.details-row > td { padding: 8px !important; }
.details-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 900px) {
  .details-wrap { grid-template-columns: 1fr; }
}

/* Tabela Wykonania – dziedziczy reguły z bazowych, doprecyzowanie stacked */
#tradesTable .details-row table {
  width: 100%; border-collapse: collapse; background: var(--chart-bg);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
#tradesTable .details-row table th,
#tradesTable .details-row table td {
  padding: 8px 10px; white-space: nowrap; vertical-align: middle; border: 1px solid var(--glass-border);
}
#tradesTable .details-row table thead th {
  background: var(--glass-bg); font-weight: 600; color: var(--text-primary);
  position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--glass-border);
}

/* Stackowanie podtabeli Wykonania (<= 480px) */
@media (max-width: 480px) {
  #tradesTable .details-row table,
  #tradesTable .details-row table thead,
  #tradesTable .details-row table tbody,
  #tradesTable .details-row table th,
  #tradesTable .details-row table td,
  #tradesTable .details-row table tr {
    display: block !important; width: 100% !important;
  }
  #tradesTable .details-row table thead { display: none !important; }
  #tradesTable .details-row table tr {
    margin-bottom: .5rem !important; border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow); background: var(--chart-bg);
  }
  #tradesTable .details-row table td {
    display: grid !important; grid-template-columns: 1fr auto;
    align-items: center; gap: 6px; padding: 6px !important;
    border: none !important; border-bottom: 1px solid var(--glass-border) !important;
    text-align: left !important; font-size: .9rem;
  }
  #tradesTable .details-row table td:last-child { border-bottom: none !important; }
  #tradesTable .details-row table td::before {
    content: attr(data-label); font-weight: 600; color: var(--text-secondary);
  }
}

/* Uporządkowanie strefy zrzutów */
.shots {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; margin-bottom: 8px;
}
.shots img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--glass-border); }
.shot-file { max-width: 100%; }
.paste-wrap .shot-dataurl {
  width: 100%; min-height: 80px; border: 1px solid var(--glass-border); border-radius: 8px; background: var(--glass-bg); padding: 6px;
}

/* -----------------------------
 13) Formy i kontrolki
----------------------------- */
form {
  background: var(--bg-secondary); padding: calc(var(--spacing) * 1.5); margin: 0 auto 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--glass-border);
  max-width: 980px; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: calc(var(--spacing) * 1.2); align-items: start;
}
form h2 { text-align: center; grid-column: 1 / -1; font-size: 1.2rem; margin: .5rem 0; color: var(--text-primary); }
form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 500; color: var(--text-secondary); }
.date-fields { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--spacing) * 1.2); }
form .submit-row { grid-column: 1 / -1; display: flex; justify-content: center; gap: 10px; }

input, select, textarea {
  font-size: .9rem; padding: 10px; border-radius: var(--radius);
  border: 1px solid var(--glass-border); width: 100%; background: var(--glass-bg); color: var(--text-primary);
  transition: border-color .3s ease, box-shadow .3s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 8px rgba(37,99,235,.3); }
textarea { min-height: 96px; max-height: 160px; resize: vertical; }
input[name="tracking_number"], input[name="nr_pudelka"] { font-family: monospace; }

button, .export-btn, .action-btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 10px 20px; font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .3s ease;
  box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover, .export-btn:hover, .action-btn:hover { background: var(--innse-accent); transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,176,255,.3); }
button:active, .export-btn:active, .action-btn:active { transform: translateY(0); box-shadow: 0 2px 4px rgba(0,0,0,.2) inset; }
.action-btn.edit { background: var(--accent-up); }
.action-btn.danger { background: var(--accent-down); }
.export-btn { width: fit-content; margin: 0 auto; }

/* Eksport – przyciski */
.export-buttons { display: flex; gap: 10px; align-items: center; justify-content: center; margin: calc(var(--spacing) * 1.5) 0; }
.export-buttons form { margin: 0; padding: 0; }
.export-buttons .export-btn { padding: 10px 24px; font-size: .9rem; }
@media (max-width: 600px) { .export-buttons { flex-direction: column; gap: 8px; } .export-buttons .export-btn { width: 100%; margin: 0; } }

/* -----------------------------
 14) Raporty, mini chart
----------------------------- */
.report-split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
@media (max-width: 900px) { .report-split { grid-template-columns: 1fr; } }
.mini-chart {
  background: var(--chart-bg);
  border-radius: 10px;
  min-height: 320px;
  padding: 6px;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
}

/* TOP 10 transakcji */
.top10-table { width: 100%; border-collapse: collapse; background: var(--chart-bg); border-radius: var(--radius); box-shadow: var(--shadow); }
.top10-table th, .top10-table td { padding: 8px 10px; white-space: nowrap; vertical-align: middle; border: 1px solid var(--glass-border); }
.top10-table thead th { background: var(--glass-bg); font-weight: 600; color: var(--text-primary); position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--glass-border); }
.top10-table tbody tr:nth-child(even) { background: rgba(148,163,184,0.08); }
.top10-table tr.row-win { background: rgba(22,163,74,0.08); }
.top10-table tr.row-loss { background: rgba(239,68,68,0.08); }
.top10-table tr.row-top1 { box-shadow: inset 0 0 0 2px rgba(37,99,235,0.25); }

/* Equity Chart kontener */
#equityChart { background: var(--chart-bg); border-radius: 10px; }

/* -----------------------------
 15) Toast
----------------------------- */
#fd-toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 3000;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  display: none;
}

/* -----------------------------
 16) Mobile 320–480 px
----------------------------- */
@media (max-width: 480px) {
  body { padding-bottom: calc(7rem + env(safe-area-inset-bottom)); }
  header, footer { padding: .5rem .75rem; }
  .dashboard { padding: .5rem; gap: .75rem; }
  .tile { padding: .5rem; }
  .price { font-size: 1.2rem; }
  .symbol { font-size: .8rem; white-space: normal; line-height: 1.2; }
  .footer-items { gap: .3rem; max-width: 100%; }
  .footer-item { min-width: 50px; }
  .footer-refresh { padding: .15rem 0; }
  .footer-refresh .footer-item { font-size: .75em; }
  .last-updated { font-size: .65rem; }
  .modal-content { width: 95%; margin: 5% auto; padding: 1rem; }
  #chartCanvas { min-height: 62vh; }
  .modal .close { top: 8px; right: 8px; width: 34px; height: 34px; font-size: 18px; }
  form { grid-template-columns: 1fr; }
  .date-fields { grid-template-columns: 1fr; }
  /* UWAGA: nie stosuj min-width do raportów i trades – mają własne tryby stacked */
  .tile table:not(.report-table):not(#tradesTable) {
    min-width: 820px;
  }
  .tile table th, .tile table td { padding: 6px; font-size: 12px; }
}

/* -----------------------------
 17) Preferuj mniejszy ruch
----------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .logo { animation: none !important; }
}

/* -----------------------------
 18) Tryb oszczędny (coarse)
----------------------------- */
@media (pointer: coarse) {
  header, footer, .tile { backdrop-filter: none !important; }
  .tile { box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
  .modal { backdrop-filter: none !important; background: rgba(0,0,0,0.6); }
  .modal-content { box-shadow: 0 8px 20px rgba(0,0,0,0.35); transform: none; }
}

/* Gdy modal otwarty – zablokuj scroll tła i overscroll bounce */
body.modal-open { overflow: hidden; overscroll-behavior: contain; }

/* -----------------------------
 19) Ultra‑compact (<= 360px)
----------------------------- */
@media (max-width: 360px) {
  form, .mini-form {
    display: grid !important; grid-template-columns: 1fr !important;
    gap: 8px !important; padding: 10px !important;
  }
  form label, .mini-form label { font-size: 0.9rem; }
  .mini-form input, .mini-form select, .mini-form textarea {
    font-size: 0.9rem; padding: 8px;
  }
  .tile table tr { padding: 6px !important; }
  .tile table td { font-size: 12px !important; padding: 6px !important; }
  .tile table td::before { font-size: 12px; }
  .tile .tile {
    box-shadow: none; backdrop-filter: none; border: 1px solid var(--glass-border);
  }
  main, .dashboard { padding-bottom: calc(8rem + env(safe-area-inset-bottom)) !important; }

  .shots { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)) !important; }
  .tf-button.upload-file-btn, .tf-button.toggle-paste, .tf-button.autosnap-btn, .tf-button.upload-paste-btn {
    font-size: .8rem; padding: 8px 12px;
  }
  .shot-file { font-size: .85rem; padding: 6px; }
  .shot-dataurl { font-size: .85rem; padding: 6px; min-height: 60px; }
}

/* Kolumna ukryta na XS */
@media (max-width: 480px) { .col-hide-xs { display: none !important; } }

/* -----------------------------
 20) trades.php – stack wymuszony (<= 480px)
     (pełny card layout niezależnie od min-width tabeli)
----------------------------- */
@media (max-width: 480px) {
  #tradesTable {
    min-width: 0 !important; width: 100% !important; table-layout: fixed !important;
  }
  #tradesTable thead { display: none !important; }
  #tradesTable, #tradesTable tbody, #tradesTable tr, #tradesTable td, #tradesTable th {
    display: block !important; width: 100% !important;
  }
  #tradesTable tr {
    margin-bottom: .5rem !important; border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); background: var(--chart-bg);
  }
  #tradesTable td {
    display: grid !important; grid-template-columns: 1fr auto; align-items: center; gap: 6px;
    padding: 8px !important; border: 0 !important; border-bottom: 1px solid var(--glass-border) !important;
    text-align: left !important; white-space: normal !important;
  }
  #tradesTable td:last-child { border-bottom: 0 !important; }
  #tradesTable td::before {
    content: attr(data-label) " "; font-weight: 600; color: var(--text-secondary);
  }

  /* Szczegóły – przycisk pełnej szerokości */
  #tradesTable td[data-label="Akcje"] { grid-template-columns: 1fr; }
  #tradesTable td[data-label="Akcje"] .tf-button { width: 100%; min-height: 36px; }
}

/* -----------------------------
 21) Ultra‑compact (<= 320px, pion)
     - label nad value
     - jeszcze ciaśniejsze odstępy
----------------------------- */
@media (max-width: 320px) and (orientation: portrait) {
  :root {
    --footer-h: 38px;
    --footer-fs: 11px;
    --footer-ico: 17px;
    --footer-gap: 6px;
    --footer-pad-x: 6px;
  }

  #tradesTable tr { padding: 6px !important; }
  #tradesTable td {
    grid-template-columns: 1fr !important; /* label nad value */
    align-items: start !important;
    gap: 4px !important;
    padding: 6px !important;
  }
  #tradesTable td::before {
    margin: 0 0 2px 0 !important;
    font-size: 12px !important;
    opacity: .9;
  }
  #tradesTable td[data-label="Akcje"] .tf-button {
    width: 100% !important; min-height: 34px !important; padding: 8px 10px !important; font-size: 13px !important;
  }

  /* Podtabela Wykonania także label nad value */
  #tradesTable .details-row table tr { padding: 6px !important; }
  #tradesTable .details-row table td {
    grid-template-columns: 1fr !important;
    align-items: start !important;
    gap: 4px !important;
    padding: 6px !important;
    font-size: 12.5px !important;
  }
  #tradesTable .details-row table td::before { margin: 0 0 2px 0 !important; font-size: 12px !important; }

  /* Komponenty zrzutów */
  .shots { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)) !important; gap: 6px !important; }
  .tf-button { padding: 7px 10px !important; font-size: 13px !important; }

  /* Zmniejszenie paddingów w formach/chipsach */
  .trade-filters .chip { padding: 4px 8px !important; font-size: 12px !important; }
  .mini-form input, .mini-form select { padding: 6px 8px !important; }
}

/* -----------------------------
 22) Minimalistyczny footer v2
----------------------------- */
@media (max-width: 768px) {
  :root {
    --footer-h: 38px;
    --footer-fs: 11px;
    --footer-ico: 17px;
    --footer-gap: 6px;
    --footer-pad-x: 6px;
  }
}
footer.footer--mini {
  padding: 0 var(--footer-pad-x);
  padding-bottom: calc(0.25rem + env(safe-area-inset-bottom));
  height: var(--footer-h); min-height: var(--footer-h);
  display: flex; flex-direction: row; align-items: center; gap: 10px;
}
footer.footer--mini .footer-items,
footer.footer--mini .footer-refresh,
footer.footer--mini .last-updated {
  display: flex; align-items: center; margin: 0;
}
footer.footer--mini .footer-items {
  width: auto; gap: 8px; flex: 0 1 auto;
}
footer.footer--mini .footer-item {
  min-width: unset; font-size: var(--footer-fs); color: var(--text-secondary);
}
footer.footer--mini .footer-item a {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--footer-gap); text-decoration: none; color: inherit; line-height: 1;
}
footer.footer--mini .footer-item i {
  font-size: var(--footer-ico); line-height: 1; display: inline-grid; place-items: center;
  width: calc(var(--footer-ico) + 2px); height: calc(var(--footer-ico) + 2px);
}
footer.footer--mini .footer-item span { line-height: 1; display: inline-block; transform: translateY(0.5px); }
footer.footer--mini .footer-refresh {
  padding-left: 8px; border-left: 1px solid var(--glass-border); margin-left: 2px;
}
footer.footer--mini .footer-refresh .footer-item { font-size: var(--footer-fs); padding: 0; }
footer.footer--mini .last-updated {
  margin-left: auto; font-size: calc(var(--footer-fs) - 1px); opacity: 0.85; white-space: nowrap; line-height: 1;
}
@media (max-width: 768px) {
  footer.footer--mini { height: var(--footer-h); }
  footer.footer--mini .footer-item span { display: none; }
}
@media (max-width: 360px) {
  footer.footer--mini { gap: 6px; }
  footer.footer--mini .footer-item i { font-size: calc(var(--footer-ico) - 1px); }
}
/* Docięcie dolnego paddingu pod sticky footer */
main.dashboard {
  padding-bottom: calc(var(--footer-h) + 12px + env(safe-area-inset-bottom)) !important;
}
footer.footer--mini .last-updated {
  display: flex; align-items: center; line-height: 1;
}

/* -----------------------------
 23) Responsywny tradesTable (ponownie – szczegóły)
----------------------------- */
@media (max-width: 480px) {
  #tradesTable td[data-label="Szczegóły"] {
    justify-content: center; grid-template-columns: 1fr; /* przyciski w kolumnie */
  }
  #tradesTable .details-row table {
    min-width: 0 !important; width: 100% !important; table-layout: fixed !important;
  }
}

/* -----------------------------
 24) CHART – Mobile toolbar
----------------------------- */
@media (pointer: coarse) {
  #chartCanvas { min-height: 80vh !important; }
  #chartCanvas .apexcharts-toolbar {
    top: 8px !important; right: 8px !important; transform: scale(1.22); transform-origin: top right;
  }
  #chartCanvas .apexcharts-toolbar > * { margin-left: 6px; }
  #chartCanvas .apexcharts-annotation-label {
    font-size: 13px !important; line-height: 1.25 !important; padding: 4px 8px !important;
    white-space: normal !important; max-width: 76vw !important; border-radius: 8px !important;
  }
  #chartModal .tf-switcher { gap: 12px !important; margin-bottom: .8rem !important; }
  #chartModal .tf-button { padding: 8px 12px !important; font-size: 14px !important; }
}
@media (max-width: 360px) {
  #chartCanvas { min-height: 74vh !important; }
  #chartCanvas .apexcharts-toolbar { transform: scale(1.12); }
  #chartModal .tf-button { padding: 7px 10px !important; font-size: 13px !important; }
}

/* -----------------------------
 25) CHART_SCRUBBER (mobile)
----------------------------- */
@media (pointer: coarse) {
  .chart-scrubber {
    margin-top: 8px; width: 100%; display: flex; align-items: center;
  }
  .chart-scrubber .scrubber-row { flex: 1; padding: 4px 2px; }
  .chart-scrubber .scrubber-input {
    width: 100%; -webkit-appearance: none; appearance: none; height: 22px; background: transparent;
  }
  .chart-scrubber .scrubber-input:focus { outline: none; }
  .chart-scrubber .scrubber-input::-webkit-slider-runnable-track {
    height: 6px; background: rgba(148,163,184,0.45); border-radius: 4px;
  }
  .chart-scrubber .scrubber-input::-moz-range-track {
    height: 6px; background: rgba(148,163,184,0.45); border-radius: 4px;
  }
  .chart-scrubber .scrubber-input::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    margin-top: -7px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); border: 2px solid rgba(255,255,255,.9);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
  }
  .chart-scrubber .scrubber-input::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); border: 2px solid rgba(255,255,255,.9);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
  }
}

/* =======================
Footer tools (extended)
======================= */
footer.footer--mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Grupy: narzędzia, skróty, refresh, status */
footer.footer--mini .footer-tools,
footer.footer--mini .footer-nav,
footer.footer--mini .footer-refresh,
footer.footer--mini .footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

/* Narzędzia (lewa strona) */
.footer-tools { flex: 0 1 auto; gap: 8px; }
.footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--footer-fs);
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1;
  user-select: none;
  transition: background .2s ease, color .2s ease, transform .1s ease, border-color .2s ease;
}
.footer-btn i { font-size: var(--footer-ico); line-height: 1; display: inline-grid; place-items: center; }
.footer-btn:hover,
.footer-btn:focus-visible { background: var(--glass-bg); border-color: var(--glass-border); }
.footer-btn[aria-pressed="true"] { color: var(--text-primary); background: rgba(148,163,184,0.18); border-color: var(--glass-border); }
.footer-btn em.auto-interval {
  font-style: normal;
  font-size: 10px;
  opacity: .85;
  background: var(--glass-bg);
  padding: 2px 6px;
  border-radius: 999px;
}

/* Skróty (mobile) */
.footer-nav {
  flex: 0 1 auto;
  gap: 8px;
}
.footer-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: var(--footer-fs);
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
  line-height: 1;
}
.footer-nav a:hover,
.footer-nav a:focus-visible { background: var(--glass-bg); border-color: var(--glass-border); color: var(--text-primary); }
.footer-nav a[aria-current="page"] { color: var(--text-primary); background: rgba(148,163,184,0.18); border-color: var(--glass-border); }
.footer-nav a i { font-size: var(--footer-ico); line-height: 1; display: inline-grid; place-items: center; }

/* Status */
.footer-status { flex: 1; justify-content: flex-end; gap: 8px; }
.net-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #10b981; /* online */
  box-shadow: 0 0 0 2px rgba(0,0,0,.08) inset;
}
.net-dot.offline { background: #ef4444; }
.net-dot.warn { background: #f59e0b; } /* ostatni błąd fetch */
.last-updated {
  font-size: calc(var(--footer-fs) - 1px);
  font-weight: 500;
  color: var(--text-secondary);
  opacity: .9;
  white-space: nowrap;
  line-height: 1;
  text-align: right;
}
.last-updated .stale { color: #ef4444; margin-left: 6px; font-size: 0.9em; }

/* Odśwież – stan busy (subtelny) */
.footer-refresh .footer-item.busy { opacity: .9; }
.footer-refresh .footer-item.busy i { animation: pulse2 1.2s ease-in-out infinite; }
@keyframes pulse2 {
  0% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: .9; }
}

/* Responsywność */
@media (min-width: 768px) {
  footer.footer--mini { justify-content: space-between; }
}
@media (max-width: 767px) {
  :root {
    --footer-h: 42px; --footer-fs: 11px; --footer-ico: 18px; --footer-gap: 4px; --footer-pad-x: 8px;
  }
  footer.footer--mini { justify-content: space-between; gap: 6px; }
  .footer-btn span { display: none; }            /* narzędzia – same ikony */
  .footer-nav a span { display: none; }          /* skróty – same ikony */
  .last-updated { white-space: normal; font-size: 10px; max-width: 55vw; }
}
@media (max-width: 480px) {
  .footer-btn em.auto-interval { display: none; } /* tylko ikona ⏱️ na ekstra wąskich */
}

/* =======================
Reports – dopasowania UI/UX
======================= */

/* Globalna wersja chipów (działa także poza .trade-filters – np. „Własny zakres”) */
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  text-decoration: none;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
  line-height: 1.15;
}
.chip:hover { background: rgba(0,0,0,0.05); }
[data-theme="dark"] .chip:hover { background: rgba(255,255,255,0.08); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip:focus, .chip:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

/* Mini-form w raportach – równy rytm, ładny wrap */
.mini-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}
.mini-form label { font-size: .92rem; color: var(--text-secondary); }
.mini-form .chip { justify-self: start; } /* „Własny zakres” przypina się po lewej */
@media (max-width: 480px) {
  .mini-form { grid-template-columns: 1fr; }
  .mini-form .chip { width: auto; }
}

/* KPI wewnątrz kafla raportu – lekkie karty, równe proporcje */
.tile .tile.kpi,
.tile .kpi-card {
  background: var(--bg-secondary);
  border: 1px dashed var(--glass-border);
  box-shadow: none;
  padding: 10px;
  border-radius: 12px;
}
.tile .kpi-card .label,
.tile .tile.kpi .label { color: var(--text-secondary); font-size: .92rem; }
.tile .kpi-card .value,
.tile .tile.kpi .value { font-weight: 700; font-size: 1.1rem; }

/* Jeśli KPI zrobione zwykłymi divami – uładnij siatkę (zadziała obok inline-style) */
.reports-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
@media (max-width: 360px) {
  .reports-kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* Tabele raportów – spójna typografia i stacking na mobile */
.tile table.report-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--chart-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tile table.report-table th,
.tile table.report-table td {
  padding: 8px 10px;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid var(--glass-border);
}
.tile table.report-table thead th {
  background: var(--glass-bg);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky; top: 0; z-index: 1;
  box-shadow: 0 1px 0 var(--glass-border);
}
.tile table.report-table tbody tr:nth-child(even) { background: rgba(148,163,184,0.08); }

/* Wyrównania liczb po prawej */
.tile table.report-table td[data-label="Transakcji"],
.tile table.report-table td[data-label="Wygrane"],
.tile table.report-table td[data-label="Winrate"],
.tile table.report-table td[data-label="PNL"],
.tile table.report-table td[data-label="PNL (suma)"],
.tile table.report-table td[data-label="PNL (średnio)"],
.tile table.report-table td[data-label="Best"],
.tile table.report-table td[data-label="Worst"] {
  text-align: right;
}

/* Kluczowe: raporty mają zawsze możliwość pełnego stackowania i zawijania */
.tile table.report-table {
  min-width: 0 !important;
  width: 100% !important;
  table-layout: fixed !important;
}
.tile table.report-table th,
.tile table.report-table td {
  white-space: normal; /* na mobile nie ucina treści */
}

/* Stacked rows dla raportów (<= 600px) – korzysta z data-label tak jak w trades.php */
@media (max-width: 600px) {
  .tile table.report-table,
  .tile table.report-table thead,
  .tile table.report-table tbody,
  .tile table.report-table th,
  .tile table.report-table td,
  .tile table.report-table tr {
    display: block; width: 100%;
  }
  .tile table.report-table thead { display: none; }
  .tile table.report-table tr {
    margin-bottom: .5rem; border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 8px;
    box-shadow: var(--shadow); background: var(--chart-bg);
  }
  .tile table.report-table td {
    white-space: normal !important;
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px;
    padding: 8px; border: none; border-bottom: 1px solid var(--glass-border);
    text-align: left; white-space: normal;
  }
  .tile table.report-table td:last-child { border-bottom: none; }
  .tile table.report-table td::before {
    content: attr(data-label) " "; font-weight: 600; color: var(--text-secondary);
  }
}

/* Wymuś “stacked” na bardzo wąskich ekranach (<= 480 px) dla report-table */
@media (max-width: 480px) {
  .tile table.report-table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed !important;
  }
  .tile table.report-table thead { display: none !important; }
  .tile table.report-table,
  .tile table.report-table tbody,
  .tile table.report-table tr,
  .tile table.report-table td,
  .tile table.report-table th {
    display: block !important;
    width: 100% !important;
  }
  .tile table.report-table tr {
    margin-bottom: .5rem !important;
  }
  .tile table.report-table td:last-child { border-bottom: 0 !important; }
}

/* Ultra‑small (<= 320px, pion) – label nad value dla raportowych tabel */
@media (max-width: 320px) and (orientation: portrait) {
  .tile table.report-table td {
    grid-template-columns: 1fr !important;
    align-items: start !important;
    gap: 4px !important;
    padding: 6px !important;
  }
  .tile table.report-table td::before {
    margin: 0 0 2px 0 !important;
    font-size: 12px !important;
    opacity: .9;
  }
}

/* Equity wykorzystywany w reports – tło + brak przycięcia na mobile */
#equityChart {
  background: var(--chart-bg);
  border-radius: 10px;
  overflow: hidden;
}
@media (pointer: coarse) {
  #equityChart { min-height: clamp(280px, 62vh, 820px); }
}

/* Drobne: pasek filtrów nad raportem – lepsze zawijanie i oddech */
.trade-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  margin: 6px 0;
}
.trade-filters .chips,
.trade-filters .filters-label { width: 100%; }

/* Badget liczby otwartych transakcji przy skrócie */
.footer-nav a { position: relative; }
.footer-nav__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  color: #fff;
  background: var(--accent-up);
  border: 1px solid rgba(0,0,0,0.15);
}
.footer-nav__badge.hidden { display: none; }

/* Auto – countdown (znaczy w em.auto-interval) */
.footer-btn em.auto-interval { letter-spacing: 0.2px; }

/* Tryb kompakt footera na desktopie – ukrywa skróty */
@media (min-width: 992px) {
  body.footer-compact footer.footer--mini .footer-nav { display: none !important; }
}

/* Footer – lepsza czytelność tła + poprawiony układ "Odśwież" */

/* 1) Mniej przezroczyste tło (czytelne w obu motywach) */
footer.footer--mini {
  background: var(--bg-secondary) !important; /* było: var(--glass-bg) */
  backdrop-filter: blur(8px); /* delikatnie mniejszy blur dla ostrzejszego tekstu */
}

/* 2) "Odśwież" – czytelne ułożenie ikony i napisu */
.footer-refresh .footer-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;                  /* większy odstęp ikona <-> tekst */
  padding: 6px 12px;         /* oddech */
  line-height: 1.05;         /* wyrównanie optyczne */
}
.footer-refresh .footer-item i {
  font-size: var(--footer-ico);
  line-height: 1;
  display: inline-grid;
  place-items: center;
  width: calc(var(--footer-ico) + 2px);
  height: calc(var(--footer-ico) + 2px);
}
.footer-refresh .footer-item span {
  transform: none;           /* usuwamy wcześniejsze przesunięcie */
  letter-spacing: 0.1px;
}

/* 3) Ultra‑wąskie ekrany: zostaje tylko ikona (jak wcześniej), ale z lepszym centrowaniem */
@media (max-width: 480px) {
  .footer-refresh .footer-item { padding: 6px 10px; }
  .footer-refresh .footer-item span { display: none; }
}

/* 4) Opcjonalne tryby (włączysz klasą na <body>):
      - body.footer-refresh-text-only → bez ikony, sam napis
      - body.footer-refresh-icon-only → bez napisu, sama ikona (tak jak mobile) */
body.footer-refresh-text-only .footer-refresh .footer-item i { display: none !important; }
body.footer-refresh-icon-only .footer-refresh .footer-item span { display: none !important; }

/* =======================
Header tools (extended)
======================= */

/* Akcje po prawej stronie nagłówka */
header { transition: transform .25s ease; }
header.header--hidden { transform: translateY(-100%); }

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}
.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 8px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .1s ease;
}
.header-btn:hover,
.header-btn:focus-visible { background: var(--glass-bg); border-color: var(--glass-border); color: var(--text-primary); }

/* Quick Search overlay */
#quickSearch.qs[hidden] { display: none !important; }
#quickSearch.qs {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  display: grid; place-items: start center;
  padding-top: max(12vh, 60px);
}
.qs__box {
  width: min(720px, 92vw);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.qs__input {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}
.qs__list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: min(48vh, 400px);
  overflow: auto;
}
.qs__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-primary);
}
.qs__item:hover,
.qs__item[aria-selected="true"] {
  background: rgba(148,163,184,0.18);
}
.qs__item i { font-style: normal; }

/* Responsywny układ nagłówka */
@media (max-width: 768px) {
  .header-actions { gap: 6px; }
  .header-btn { padding: 6px; }
}

/* Screenshot box + przycisk Usuń */
.shots .shot-box { position: relative; }
.shots .shot-del {
position: absolute;
top: 6px; right: 6px;
background: rgba(17,24,39,.85);
border: 1px solid rgba(255,255,255,.25);
color: #fff;
border-radius: 8px;
padding: 4px 8px;
font-size: 12px;
line-height: 1;
cursor: pointer;
}
.shots .shot-del:hover { background: #dc2626; }
@media (max-width: 360px) {
.shots .shot-del { padding: 4px 6px; font-size: 11px; }
}
/* Mobile performance: redukcja hover-efektów na ekranach dotykowych */
@media (pointer: coarse) {
  .tile:hover { transform: none !important; box-shadow: var(--shadow); }
}
/* Market closed – kafel szary */
.tile.market-closed {
filter: grayscale(0.6);
opacity: 0.78;
}
@media (pointer: coarse) {
.tile.market-closed:hover { transform: none; box-shadow: var(--shadow); }
}