:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-alt: #f8faff;
  --border: #d9e3f2;
  --text: #1e2a3a;
  --muted: #5c6b82;
  --primary: #1c62d6;
  --primary-dark: #174eab;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, Helvetica, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 16px 30px rgba(24, 45, 74, 0.08); padding: 28px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.auth-title { margin: 0 0 8px; text-align: center; font-size: 24px; }
.auth-subtitle { margin: 0 0 20px; text-align: center; color: var(--muted); }
.form-row { margin-bottom: 14px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; }
.input, .textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 10px 12px; font-size: 14px; }
.textarea { min-height: 120px; resize: vertical; }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #ebf1fb; color: #123667; }
.alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #ffeaea; border: 1px solid #ffc3c3; color: #8a2424; }
.alert-ok { background: #eaf9ef; border: 1px solid #bde6ca; color: #1f6738; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo { max-width: 72px; height: auto; }
.topbar-brand .title { margin-left: 8px; line-height: 1; display: flex; align-items: center; }
.title { font-size: 20px; margin: 0; }
.user-badge { color: var(--muted); font-size: 14px; }
.logout { margin-left: 8px; }
.container { max-width: 1100px; margin: 20px auto; padding: 0 16px 32px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 14px; font-size: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab { display: inline-block; padding: 8px 12px; border-radius: 9px; background: #edf3ff; color: #1c4487; font-weight: 600; }
.tab.active { background: var(--primary); color: #fff; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 680px; }
table.grid th, table.grid td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.grid th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sort-link:hover { text-decoration: underline; }
.sort-icon {
  color: #93a1b9;
  font-size: 11px;
}
.sort-icon.active {
  color: #1c62d6;
}
.expiry-past {
  color: #c0392b;
  font-weight: 700;
}
.compact-input { width: 100%; min-width: 90px; }
.header-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.muted { color: var(--muted); }
table.grid td.col-kadencja { font-size: 11px; white-space: nowrap; }
table.grid td.col-opcje { white-space: nowrap; }
table.grid .btn-compact {
  display: inline-block;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  margin-right: 4px;
  line-height: 1.2;
  vertical-align: middle;
}
table.grid .btn-compact:last-child { margin-right: 0; }
.user-badges { margin-left: 6px; white-space: nowrap; }
.user-badges i { margin-left: 4px; font-size: 13px; vertical-align: middle; }
.user-badges i.icon-admin { color: #c0392b; }
.user-badges i.icon-perms { color: #1c62d6; }
.user-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 0 12px;
}
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 2px 12px;
}
.permissions-grid .form-row {
  margin-bottom: 8px;
}
.overview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.stat-card {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e6efff;
  color: #1c62d6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.stat-meta { min-width: 0; }
.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat-value {
  font-size: 15px;
  font-weight: 700;
}
.stat-value.ok { color: #1f8a49; }
.stat-value.warn { color: #b54708; }
.module-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.module-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #24436f;
  background: #edf3ff;
  border: 1px solid #d8e5ff;
  border-radius: 999px;
  padding: 5px 10px;
}
/* ---- Modal: zmiana hasla ---- */
.pwd-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 28, 54, 0.45);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pwd-modal-backdrop.open { display: flex; }
.pwd-modal-dialog {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 28, 54, 0.22);
  padding: 24px 28px 20px;
  width: 100%;
  max-width: 420px;
}
.pwd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.pwd-modal-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pwd-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 2px;
}
.pwd-modal-close:hover { color: var(--text); }
.pwd-modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 760px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .panel { padding: 14px; }
  .user-form-grid, .permissions-grid { grid-template-columns: 1fr; }
}
