:root {
  --primary: #5162F5;
  --primary-hover: #3d4bd1;
  --bg-body: #f3f5f9;
  --bg-card: #ffffff;
  --bg-input: #f9fafb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-focus: #5162F5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --danger: #ef4444;
  --success: #10b981;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body { font-family: var(--font-family); background-color: var(--bg-body); color: var(--text-main); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0 0 0.5rem; font-weight: 600; color: var(--text-main); }
button, input, select, textarea { font-family: inherit; font-size: 100%; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.topbar { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; padding: 12px 0; }
.topbar .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand-row { display: flex; align-items: center; gap: 12px; }

/* ZWIĘKSZONE LOGO */
.logo { height: 44px; width: auto; display: block; }
.logo.xl { height: 80px; }

.tabs { display: flex; gap: 4px; background: var(--bg-body); padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.tab { background: transparent; border: none; padding: 6px 16px; border-radius: 6px; color: var(--text-muted); font-weight: 500; font-size: 13px; cursor: pointer; transition: all 0.2s ease; }
.tab:hover { color: var(--text-main); }
.tab.active { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-sm); font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 500; font-size: 14px; cursor: pointer; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-main); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: var(--shadow-sm); text-decoration: none; height: 36px; white-space: nowrap; }
.btn:hover { border-color: #d1d5db; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary, .btn.cta { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover, .btn.cta:hover { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 4px 12px rgba(81, 98, 245, 0.3); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-muted); }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.04); color: var(--text-main); }
.btn.small { padding: 0 12px; font-size: 12px; height: 32px; }
.btn.block { width: 100%; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; transition: all 0.2s; flex-shrink: 0; }
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--primary); }
.icon-btn.white { background: var(--bg-card); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 16px; }
.card-h { padding: 12px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; justify-content: space-between; background: #fdfdfd; height: 60px; }
.card-h .row { display: flex; align-items: center; gap: 8px; height: 100%; }
.card-c { padding: 20px; }
.card.compact .card-c { padding: 16px; }

input, select, textarea { width: 100%; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-main); transition: all 0.2s; outline: none; }
input:focus, select:focus, textarea:focus { background: #fff; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(81, 98, 245, 0.15); }
input:disabled { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }

.search-wrap { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.search-btn, .clear { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; transition: all 0.2s; }
.search-btn:hover, .clear:hover { color: var(--primary); border-color: var(--primary); }

.table { display: grid; grid-template-columns: minmax(200px, 3fr) 1fr 1fr 1fr 0.8fr 140px; width: 100%; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.table .row { display: contents; }
.table .row > div { padding: 12px 16px; display: flex; align-items: center; font-size: 13px; color: var(--text-main); border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .row.head > div { background: #f9fafb; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }
.table .row:last-child > div { border-bottom: none; }
.table .row:hover:not(.head) > div { background: #f9fafb; }
.cell-main { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.table .row > div.right { justify-content: flex-end; overflow: visible; }

/* === POPRAWA APLIKACJI KLIENCKIEJ === */
.client-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  transition: all 0.2s;
  min-height: 56px;
}
.client-list-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.client-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.client-actions .icon-btn {
  background: #f3f5f9;
  border: 1px solid transparent;
}
.client-actions .icon-btn:hover {
  background: #fff;
  border-color: var(--border);
  color: var(--primary);
}

/* NOWA SIATKA DLA WIDOKU KLIENTA (RESPONSYWNA) */
.client-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
/* Mobile Fix */
@media (max-width: 900px) {
  .client-grid {
    grid-template-columns: 1fr; /* Jeden pod drugim na mobile */
  }
}

/* === MODAL & SWITCHES === */
dialog { background: var(--bg-card); border: none; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-lg); width: min(520px, 90vw); color: var(--text-main); animation: fadeIn 0.2s ease-out; }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(2px); }
.d-h { padding: 16px 24px; border-bottom: 1px solid var(--border); font-size: 18px; font-weight: 600; }
.d-c { padding: 24px; }
.actions.right { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* Nowoczesny Toggle Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #e5e7eb; transition: .3s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

.modal-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.modal-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.modal-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-label { font-weight: 500; font-size: 14px; }
.modal-desc { font-size: 12px; color: var(--text-muted); }

/* Inne */
.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #f3f4f6; color: var(--text-muted); border: 1px solid transparent; }
.pill.ok { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.progress { height: 6px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin: 4px 0; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s ease; }
.chk { display: inline-flex; align-items: center; cursor: pointer; position: relative; }
.chk input { appearance: none; width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; padding: 0; transition: all 0.2s; }
.chk input:checked { background-color: var(--primary); border-color: var(--primary); background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e"); }
.layout-admin { display: grid; grid-template-columns: 300px 1fr; gap: 24px; margin-top: 24px; margin-bottom: 40px; }
.stack { display: grid; gap: 16px; }
.stack.s8 { gap: 8px; }
.stack.s12 { gap: 12px; }
.grid-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; padding: 4px; }
.icon-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: all 0.2s; box-shadow: var(--shadow-sm); }
.icon-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.tile-thumb { aspect-ratio: 1; background: #f8fafc; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--primary); }
.tile-thumb svg { width: 48px; height: 48px; }
.tile-title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 12px; color: var(--text-muted); }
.tile-actions { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #f3f5f9 0%, #eef2ff 100%); }
.login-card { width: 100%; max-width: 400px; padding: 20px; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 24px; }
.footer, .app-footer { text-align: center; padding: 24px; color: var(--text-muted); font-size: 12px; }
.bulk-bar { background: #f0fdf4; border: 1px solid #bbf7d0; padding: 12px 20px; display: flex; align-items: center; gap: 16px; border-radius: var(--radius-sm); margin-bottom: 16px; color: #166534; }
.player { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; position: relative; box-shadow: var(--shadow-md); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.s { font-size: 12px; }
.kv { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1024px) { .layout-admin { grid-template-columns: 1fr; } .table { grid-template-columns: 1fr 1fr; } .table .row > div:not(.cell-main):not(.right) { display: none; } .table .head { display: none; } }
#lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
#lightbox .lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.8); }
#lightbox .lb-content { position: relative; z-index: 10; }
#lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.comments .group { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f9fafb; }
.comments .group h4 { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); margin: 0; }
.comments .item { padding: 10px 14px; background: #fff; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.comments .item:last-child { border-bottom: none; }
.comments .date { font-size: 11px; color: var(--text-muted); margin-top: 4px; }