*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  background: #f5f6fa;
  color: #222;
}

.hidden { display: none !important; }

/* ── Login ────────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-box h1 { font-size: 28px; margin-bottom: 8px; }
.login-box p  { color: #666; margin-bottom: 32px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
}

.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }

nav { display: flex; gap: 4px; flex: 1; }

.nav-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.nav-btn:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.15); color: #fff; }

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  font-size: 14px;
  color: #ccc;
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.view-header h2 { font-size: 22px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}

.btn:hover             { opacity: .88; }
.btn:disabled          { cursor: not-allowed; }
.btn-primary           { background: #4f46e5; color: #fff; }
.btn-primary:disabled  { background: #9ca3af; }
.btn-secondary         { background: #e5e7eb; color: #374151; }
.btn-danger   { background: #ef4444; color: #fff; }
.btn-large    { padding: 12px 28px; font-size: 16px; }
.btn-small    { padding: 5px 12px; font-size: 13px; }
.rez-person-btn.active { background: #4f46e5; color: #fff; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  background: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.filter-bar input,
.filter-bar select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }

.filter-bar input[type="text"] { width: 220px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.data-table th {
  background: #f8f9fb;
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

/* ── Sites & Warehouses ───────────────────────────────────────────────────── */
.warehouse-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.warehouse-section h3 { font-size: 16px; margin-bottom: 12px; color: #374151; }

.site-block {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.site-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.site-block-header h3 { font-size: 16px; color: #374151; }

.warehouse-list { display: flex; flex-wrap: wrap; gap: 10px; }

.warehouse-chip {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.warehouse-chip .chip-name { font-weight: 500; }
.warehouse-chip .chip-default { font-size: 11px; color: #9ca3af; }

/* ── PZ items ─────────────────────────────────────────────────────────────── */
.pz-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pz-item-row select { flex: 2; min-width: 160px; }
.pz-item-row input  { flex: 1; min-width: 80px; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.modal-wide { width: 680px; }

.modal-box h3 { font-size: 18px; margin-bottom: 20px; }
.modal-box h4 { font-size: 15px; margin: 16px 0 10px; }

.modal-box label {
  display: inline-block;  /* iOS Safari: never flex on label */
  width: 100%;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 14px;
}

.modal-box input[type="text"],
.modal-box input[type="number"],
.modal-box input[type="date"],
.modal-box input[type="time"],
.modal-box input[type="email"],
.modal-box select,
.modal-box textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Player inline edit row ───────────────────────────────────────────────── */
.player-edit-row label {
  display: inline-block;
  width: 100%;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 14px;
}

.player-edit-row input[type="text"],
.player-edit-row input[type="email"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

/* ── Sale items ───────────────────────────────────────────────────────────── */
.sale-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.sale-item-row select { flex: 2; min-width: 160px; }
.sale-item-row input  { flex: 1; min-width: 80px; }

/* ── Reports ──────────────────────────────────────────────────────────────── */
#rep-daily-table td:nth-child(2),
#rep-daily-table td:nth-child(3),
#rep-vat-table td:nth-child(2),
#rep-vat-table td:nth-child(3),
#rep-vat-table td:nth-child(4) { text-align: right; }

/* ── Sortable table headers ──────────────────────────────────────────────── */
th[data-col] { cursor: pointer; user-select: none; }
th[data-col]:hover { background: #edf0f4; }
th.sort-asc::after  { content: ' ↑'; color: #4f46e5; font-weight: 700; }
th.sort-desc::after { content: ' ↓'; color: #4f46e5; font-weight: 700; }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: #9ca3af;
}
.empty-state p { font-size: 14px; margin-bottom: 12px; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.error { color: #ef4444; font-size: 13px; margin-top: 8px; }
.qty-invalid { border-color: #ef4444 !important; background: #fff5f5; }

.badge-active   { color: #16a34a; }
.badge-inactive { color: #9ca3af; }

/* ── Loading spinner ──────────────────────────────────────────────────────── */
@keyframes cs-spin { to { transform: rotate(360deg); } }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: cs-spin 0.7s linear infinite;
  margin: 48px auto;
}

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  color: #fff;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  pointer-events: all;
  animation: toast-in 0.2s ease;
}

.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #d97706; }

.toast-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 0 0 8px;
  margin-left: auto;
  flex-shrink: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Reservation grid container ──────────────────────────────────────────── */
#res-grid-container {
  overflow-x: auto;
  width: 100%;
}

/* ── Reservation slot legend ──────────────────────────────────────────────── */
.res-slot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #374151;
}

.res-slot-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.res-slot-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Player section cards (Nowa sprzedaż / reservation split) ─────────────── */
.rez-person-row {
  position: relative;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 12px 10px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.rez-person-row:focus-within {
  border-color: #6366f1;
}

/* ── Narrow-screen modal adjustments (tablet / phone) ─────────────────────── */
@media (max-width: 480px) {
  .modal-box { padding: 20px 16px; }
  .form-row { flex-direction: column; gap: 0; }
}
