:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e6ea;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --info: #6d28d9;
  --info-bg: #ede9fe;
  --radius: 10px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar-title { display: flex; flex-direction: column; }
.podtytul { color: var(--muted); font-size: 13px; margin-top: 2px; }

.zakladki {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.zakladka {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.zakladka:hover { color: var(--text); }
.zakladka.aktywna { color: var(--primary); border-bottom-color: var(--primary); }

.podsumowanie {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 20px 24px 0;
}
.karta {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.karta-etykieta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.karta-wartosc { font-size: 22px; font-weight: 600; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px 10px;
  flex-wrap: wrap;
}
.toolbar-spacer { flex: 1; }
.toolbar input[type="text"], .toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-size: 14px;
}
#szukaj { min-width: 260px; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2ff; color: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }

.import-label {
  padding: 9px 16px;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--primary-dark);
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.akcje-zaznaczenia {
  margin: 0 24px 10px;
  padding: 12px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
}

.tabela-wrapper {
  margin: 0 24px 40px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; cursor: pointer; user-select: none; }
.col-checkbox { width: 36px; }
.col-num { text-align: right; }
td.col-num { text-align: right; font-variant-numeric: tabular-nums; }
.col-akcje { text-align: right; }
tbody tr:hover { background: #f8fafc; }
tbody tr.niski-stan { background: #fef2f2; }
tbody tr.niski-stan:hover { background: #fee2e2; }
tbody tr.brak-stanu { background: #fecaca; }
tbody tr.brak-stanu:hover { background: #fca5a5; }
tbody tr.brak-stanu td.col-num { color: var(--danger); font-weight: 700; }
tbody tr.brak-stanu .dostepne-liczba { color: var(--danger); font-weight: 700; }

.badge-stan {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: #f1f5f9;
  color: #475569;
}

.link-akcja {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  padding: 4px 6px;
}
.link-akcja.usun { color: var(--danger); }

.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-status.zielony { background: var(--success-bg); color: var(--success); }
.badge-status.zolty { background: var(--warning-bg); color: var(--warning); }
.badge-status.czerwony { background: var(--danger-bg); color: var(--danger); }
.badge-status.niebieski { background: var(--info-bg); color: var(--info); }
.badge-status.szary { background: #f1f5f9; color: #64748b; }

.dostepne-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  padding: 2px 0;
}
.dostepne-liczba { font-size: 15px; font-weight: 600; line-height: 1.1; }
.dostepne-badge { font-size: 11px; padding: 2px 8px; white-space: nowrap; }

.sekcja-tytul { font-size: 14px; margin: 18px 0 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.pole-checkbox { display: flex; align-items: center; gap: 7px; font-size: 14px; margin-bottom: 12px; }
.pole-checkbox input { width: auto; }

.alert-panel {
  margin: 18px 24px 0;
  padding: 14px 18px;
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
}
.alert-tytul { font-weight: 600; color: var(--warning); margin-bottom: 8px; }
.alert-panel ul { margin: 0; padding-left: 20px; }
.alert-panel li { margin-bottom: 4px; font-size: 14px; }

.pusty-stan { padding: 60px 20px; text-align: center; color: var(--muted); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  padding: 24px 28px;
  width: 460px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: auto;
}
.modal-szeroki { width: 620px; }
.modal h2 { margin-top: 0; }

.pole { display: flex; flex-direction: column; margin-bottom: 14px; }
.pole label { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.pole input, .pole textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.pole-rzad { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.podpowiedz-brutto { font-size: 12px; color: var(--muted); margin-top: 4px; }

#tekstOferty { width: 100%; resize: vertical; }

.modal-akcje { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.sekcja-miesiac { margin: 0 24px 22px; }
.miesiac-naglowek {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 10px;
  font-weight: 600;
  font-size: 15px;
}
.miesiac-zysk { color: var(--success); font-weight: 700; }

.podglad-wyliczen {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 14px;
}
.podglad-wyliczen div { display: flex; justify-content: space-between; padding: 2px 0; }
.podglad-wyliczen .podglad-zysk {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
