*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-elevated: #0f0f0f;
  --bg-card: #121212;
  --bg-card-hover: #171717;
  --bg-input: #0f0f0f;
  --border: #262626;
  --border-strong: #363636;
  --border-subtle: #1a1a1a;
  --text: #ededed;
  --text-muted: #a1a1a1;
  --text-subtle: #6b6b6b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59,130,246,0.12);
  --accent-glow: rgba(59,130,246,0.06);
  /* aliasy starej palety — admin/landing dalej używają tych nazw */
  --green: var(--accent);
  --green-dim: var(--accent-soft);
  --green-glow: var(--accent-glow);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --amber: #fbbf24;
  --radius: 14px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
  letter-spacing: -0.006em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* Subtelny scrollbar w stylu tablicy */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
  background-clip: padding-box;
  border: 2px solid transparent;
}

button, input, textarea, select {
  font-family: inherit;
  letter-spacing: inherit;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 600px; height: 600px;
  background: var(--accent-glow);
  top: -260px; left: 50%;
  transform: translateX(-50%);
}
.glow-2 {
  width: 400px; height: 400px;
  background: rgba(59,130,246,0.03);
  bottom: -120px; right: -80px;
}

/* ===== Auth pages ===== */

.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-card .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg-input) inset;
  caret-color: var(--text);
}
.field input::placeholder {
  color: #555;
}

.btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #111;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.04);
  opacity: 1;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.45;
  margin-bottom: 16px;
  display: none;
}
.alert.visible { display: block; }
.alert-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}
.alert-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(59,130,246,0.3);
}

.auth-foot {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.auth-foot a {
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
}
.auth-foot a:hover { text-decoration: underline; }

.back-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--text); }

/* ===================================================== */
/* ============== NO-ACCESS PAGE ======================= */
/* ===================================================== */

.no-access-card {
  max-width: 480px;
  margin: 80px auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
}
.no-access-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--red);
  display: grid;
  place-items: center;
}
.no-access-icon svg {
  width: 36px;
  height: 36px;
}
.no-access-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.no-access-msg {
  font-size: 0.9375rem;
  line-height: 1.55;
  margin-bottom: 8px;
}
.no-access-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap;
}
.no-access-actions .btn {
  width: auto;
  min-width: 160px;
  padding: 10px 20px;
}

/* ===================================================== */
/* ============== LANDING PAGE ========================= */
/* ===================================================== */

.landing-wrap {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.landing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(26, 26, 26, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 40px;
}

.landing-brand {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.landing-brand span {
  color: var(--green);
  font-weight: 600;
}

.landing-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
}
.landing-admin-link {
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--green-dim);
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
  transition: opacity 0.15s ease;
}
.landing-admin-link:hover { opacity: 0.85; }
.landing-email {
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.landing-login-btn {
  width: auto;
  padding: 8px 18px;
  font-size: 0.8125rem;
}

.landing-content h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 28px;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.landing-card {
  position: relative;
  background: var(--bg-elevated);  /* ciemniejszy niż bg-card; hover staje się obecnym defaultem */
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.03) inset,
    0 8px 24px -12px rgba(0, 0, 0, 0.6);
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
  /* flex-column + body flex:1 → grid stretch wyrównuje wysokości kafli w row */
  display: flex;
  flex-direction: column;
}
/* Subtelny gradient na obramowaniu — odpowiednik panel-border z tablicy */
.landing-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(255, 255, 255, 0.02) 40%,
    rgba(255, 255, 255, 0) 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}
.landing-card:hover {
  background: var(--bg-card);  /* hover = poprzedni default */
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.landing-card.is-locked:hover {
  transform: none;
  background: var(--bg-elevated);
  border-color: var(--border);
}
.landing-card.is-hidden {
  opacity: 0.55;
  border-style: dashed;
}

.landing-card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.landing-card.is-locked .landing-card-link {
  cursor: not-allowed;
}

.landing-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-input);
}
.landing-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Fade USUNIĘTY — czyste, ostre odcięcie między obrazem a body (decyzja usera). */
.landing-card-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

.landing-card-hidden-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
  z-index: 3;
}

.landing-card-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text);
  z-index: 2;
}
.lock-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  margin-bottom: 4px;
}
.lock-icon svg {
  width: 22px;
  height: 22px;
}
.lock-text {
  font-size: 0.8125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.lock-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* Body wypełnia resztę kafelka po image-wrap (flex: 1 + grid stretch
   = wszystkie kafle w row mają identyczną wysokość niezależnie od contentu). */
.landing-card-body {
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 132px;
}
.landing-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.landing-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.landing-card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}
.landing-card-date {
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-weight: 500;
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: auto;  /* push to bottom — flex-column body */
}
.landing-card.is-locked .landing-card-date {
  color: var(--text-muted);
}

.landing-card-arrow {
  position: absolute;
  bottom: 20px;
  right: 20px;
  color: #555;
  font-size: 20px;
  transition: color 0.2s ease, transform 0.2s ease;
}
.landing-card:hover .landing-card-arrow {
  color: var(--green);
  transform: translateX(3px);
}
.landing-card.is-locked .landing-card-arrow { display: none; }

/* Status badge (wspoldzielone z kolorami z admin/apps) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
  border: 1px solid;
}
.status-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-badge-green { background: var(--green-dim); color: var(--green); border-color: rgba(59,130,246,0.3); }
.status-badge-green .status-badge-dot { background: var(--green); }
.status-badge-amber { background: rgba(245,158,11,0.12); color: var(--amber); border-color: rgba(245,158,11,0.3); }
.status-badge-amber .status-badge-dot { background: var(--amber); }
.status-badge-blue { background: rgba(59,130,246,0.12); color: #3b82f6; border-color: rgba(59,130,246,0.3); }
.status-badge-blue .status-badge-dot { background: #3b82f6; }
.status-badge-red { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.3); }
.status-badge-red .status-badge-dot { background: var(--red); }
.status-badge-gray { background: rgba(107,114,128,0.12); color: #9ca3af; border-color: rgba(107,114,128,0.3); }
.status-badge-gray .status-badge-dot { background: #9ca3af; }

@media (max-width: 520px) {
  .landing-grid { grid-template-columns: 1fr; }
  .landing-content h1 { font-size: 1.35rem; }
  .landing-wrap { padding: 24px 16px 48px; }
  .landing-email { max-width: 120px; }
}

/* ===================================================== */
/* ============== ADMIN PANEL ========================== */
/* ===================================================== */

.admin-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px 28px;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  line-height: 1;
}
.admin-topbar a, .admin-topbar button, .admin-topbar span {
  line-height: 1;
}

.admin-brand {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.admin-brand span {
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 2px;
}

.admin-nav {
  display: flex;
  gap: 2px;
  flex: 1;
}
.admin-nav a {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.admin-nav a.is-active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.badge-count {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--amber);
  color: #111;
  font-size: 0.6875rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.8125rem;
}
.admin-email {
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-link-muted {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.admin-link-muted:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.btn-icon {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-icon:hover {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-logout {
  appearance: none;
  -webkit-appearance: none;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.btn-logout:hover {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.4);
  background: var(--red-dim);
}
.btn-logout.btn-logout-primary {
  background: var(--green);
  color: #111;
  border-color: var(--green);
}
.btn-logout.btn-logout-primary:hover {
  background: var(--green);
  color: #111;
  border-color: var(--green);
  opacity: 0.92;
}

/* Modifier dla Panel admina — zielony hover zamiast czerwonego (akcja
   nie-destrukcyjna, ekosystem statusów: success = zielony). */
.btn-logout.btn-logout-admin:hover {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.10);
}

.admin-main {
  flex: 1;
  padding: 32px 28px 64px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 24px;
}

/* ============== Table controls (search) ============== */

.table-controls {
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 11px 42px 11px 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.search-clear:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.no-results {
  text-align: center;
  padding: 32px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  background: linear-gradient(180deg, #ffffff 0%, #a1a1a1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.page-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.text-amber { color: var(--amber); }
.muted { color: var(--text-muted); }

/* ============== Data table ============== */

.data-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* overflow:hidden intentionally omitted so dropdown menus can escape
     the table bounds. Brzegowe wiersze dostają własny border-radius. */
}

.data-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 120px 80px 160px minmax(260px, 1fr);
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 0.875rem;
  position: relative;
}
.data-row > div {
  text-align: center;
  min-width: 0;
}
.data-row:last-child {
  border-bottom: none;
  border-bottom-left-radius: calc(var(--radius) - 1px);
  border-bottom-right-radius: calc(var(--radius) - 1px);
}
.data-row:not(.data-row-header):hover { background: rgba(255, 255, 255, 0.02); }

.data-row-header {
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 12px;
  padding-bottom: 12px;
  border-top-left-radius: calc(var(--radius) - 1px);
  border-top-right-radius: calc(var(--radius) - 1px);
}

.cell-email {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-admin {
  display: flex;
  justify-content: center;
}
.cell-status {
  display: flex;
  justify-content: center;
}

.cell-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

/* ============== Pills ============== */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pill-pending {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.pill-active {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(59,130,246, 0.3);
}
.pill-suspended {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.pill-you {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ============== Custom toggle ============== */

.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s ease, background 0.2s ease;
}
.toggle[data-on="true"] {
  background: var(--green-dim);
  border-color: rgba(59,130,246, 0.6);
}
.toggle[data-on="true"]::after {
  transform: translateX(16px);
  background: var(--green);
}

/* ============== Small buttons ============== */

.btn-sm {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm.btn-primary {
  background: var(--green);
  color: #111;
  border-color: var(--green);
}
.btn-sm.btn-primary:hover:not(:disabled) { opacity: 0.92; }

.btn-sm.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
}

.btn-sm.btn-danger {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.4);
}
.btn-sm.btn-danger:hover:not(:disabled) {
  background: var(--red-dim);
  border-color: rgba(239, 68, 68, 0.7);
}

/* Disabled state — overrides wszystkie warianty btn-sm.
   Neutralny szary bez zadnej reakcji na hover. */
.btn-sm:disabled,
.btn-sm:disabled:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 1;
  transform: none;
  box-shadow: none;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
}
.btn-danger:hover { opacity: 0.92; }

/* ============== Dropdown menu ============== */

.dropdown-wrap {
  position: relative;
  display: inline-block;
}
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dropdown-caret {
  font-size: 0.7rem;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.dropdown-toggle[aria-expanded="true"] .dropdown-caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #262626;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0,0,0,0.4);
  z-index: 50;
  display: none;
  text-align: left;
}
.dropdown-menu.is-open { display: block; }

.dropdown-item {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s ease;
}
.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.dropdown-item-danger {
  color: var(--red);
}
.dropdown-item-danger:hover {
  background: var(--red-dim);
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}

/* ============== Permission list inside modal ============== */

.perm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px;
  margin: 8px -2px 4px;
}
.perm-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.perm-item-info {
  flex: 1;
  min-width: 0;
}
.perm-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.perm-item-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============== Toast ============== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  max-width: 400px;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success {
  border-color: rgba(59,130,246, 0.4);
  color: var(--green);
}
.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--red);
}

/* ============== Modal ============== */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-wrap[hidden] { display: none; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid rgba(59,130,246, 0.25);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-card h3 {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.modal-card p {
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.modal-actions .btn {
  width: auto;
  min-width: 110px;
  padding: 10px 18px;
}

/* ============== Responsive ============== */

@media (max-width: 900px) {
  .admin-topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }
  .admin-nav { order: 3; width: 100%; overflow-x: auto; }
  .admin-main { padding: 24px 16px 48px; }
  .data-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .data-row-header { display: none; }
  .cell-actions { justify-content: flex-start; margin-top: 8px; }
}

/* ===================================================== */
/* ============== APPS PAGE ============================ */
/* ===================================================== */

.page-header-with-action {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.page-header-with-action .btn {
  width: auto;
  padding: 10px 18px;
}

.apps-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.app-card.is-hidden {
  opacity: 0.55;
  border-style: dashed;
}
.app-card:hover {
  border-color: rgba(59,130,246, 0.3);
}

.app-thumb {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}
.app-thumb:hover {
  border-color: var(--green);
}
.app-thumb:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}
.thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.7);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.app-thumb:hover .thumb-overlay { opacity: 1; }
.app-thumb.is-uploading .thumb-overlay {
  opacity: 1;
  background: rgba(59,130,246, 0.25);
}
.app-thumb.is-uploading .thumb-overlay::before {
  content: 'Wgrywanie…';
}

.app-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.app-slug-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.app-slug-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(59,130,246, 0.08);
  color: var(--green);
  border: 1px solid rgba(59,130,246, 0.25);
}

.btn-icon-danger {
  width: 28px;
  height: 28px;
  font-size: 0.875rem;
}

.inline-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: -4px;
}

.inline-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
  resize: none;
}
.inline-input:hover {
  border-color: var(--border);
}
.inline-input:focus {
  border-color: var(--green);
  background: var(--bg-input);
  box-shadow: 0 0 0 3px var(--green-dim);
}
.inline-textarea {
  min-height: 60px;
  font-family: inherit;
  line-height: 1.4;
}

.app-row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 4px;
}
.app-row-split .col { display: flex; flex-direction: column; gap: 6px; }
.app-row-split .col-narrow { max-width: 140px; }
.app-row-split .col-visible { flex-direction: column; align-items: flex-start; }

.color-swatches {
  display: flex;
  gap: 8px;
  padding: 6px 0;
}
.swatch {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { border-color: var(--text); }
.swatch-green { background: var(--green); }
.swatch-amber { background: var(--amber); }
.swatch-blue  { background: #3b82f6; }
.swatch-red   { background: var(--red); }
.swatch-gray  { background: #6b7280; }

.save-indicator {
  position: absolute;
  top: -6px;
  right: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.save-indicator.visible { opacity: 1; }
.save-indicator.save-ok {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(59,130,246, 0.4);
}
.save-indicator.save-err {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.modal-card-wide {
  max-width: 520px;
}
.modal-card textarea,
.modal-card .field textarea {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  resize: vertical;
  min-height: 64px;
  transition: border-color 0.15s ease;
}
.modal-card textarea:focus {
  border-color: var(--green);
}

@media (max-width: 700px) {
  .app-card {
    grid-template-columns: 1fr;
  }
  .app-thumb {
    width: 100%;
    max-width: 240px;
    height: 180px;
  }
  .app-row-split {
    grid-template-columns: 1fr;
  }
}

/* ===================================================== */
/* ============== PERMISSIONS PAGE ===================== */
/* ===================================================== */

.perms-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  table-layout: fixed;
}

.perms-table thead th {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
}
.perms-table thead th:first-child {
  border-top-left-radius: calc(var(--radius) - 1px);
}
.perms-table thead th:last-child {
  border-top-right-radius: calc(var(--radius) - 1px);
}

.perms-user-col { width: 260px; }
.perms-apps-col { width: auto; }
.perms-bulk-col { width: 360px; }

.perms-table tbody td {
  padding: 16px 20px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.perms-table tbody tr:last-child td { border-bottom: none; }
.perms-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: calc(var(--radius) - 1px);
}
.perms-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: calc(var(--radius) - 1px);
}
.perms-table tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }

.perms-user-cell {
  border-right: 1px solid var(--border);
}
.perms-user-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.perms-email {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.perms-user-meta {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.perms-user-meta .pill {
  font-size: 0.625rem;
  padding: 2px 8px;
}

.perms-apps-cell {
  padding: 14px 20px;
  border-right: 1px solid var(--border);
}
.perms-apps-cell-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Pill-style toggle button dla aplikacji */
.perm-app-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.perm-app-btn:hover:not(:disabled) {
  border-color: rgba(59,130,246, 0.5);
  background: rgba(59,130,246, 0.04);
}
.perm-app-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.perm-app-btn.is-on {
  background: var(--green);
  border-color: var(--green);
  color: #111;
}
.perm-app-btn.is-on:hover:not(:disabled) {
  background: var(--green);
  opacity: 0.92;
}
.perm-app-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.perm-app-hidden {
  font-size: 0.7rem;
  opacity: 0.5;
  margin-left: 2px;
}

.perms-bulk-cell {
  text-align: center;
}
.perms-bulk-cell .btn-sm + .btn-sm {
  margin-left: 8px;
}

.perms-hint {
  margin-top: 14px;
  font-size: 0.75rem;
}

/* ============== Permission list inside modal (Users → Opcje → Nadaj uprawnienia) ============== */

.perm-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.perm-toggle:hover { border-color: var(--green); }
.perm-toggle:active { transform: scale(0.92); }
.perm-toggle.is-on {
  background: var(--green);
  border-color: var(--green);
  color: #111;
}
.perm-toggle:disabled { opacity: 0.6; cursor: wait; }
