:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-hover: #15803d;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

button {
  cursor: pointer;
  font: inherit;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  transition: all 0.2s;
}

input,
select,
textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  width: 100%;
  background: var(--surface);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.hidden {
  display: none !important;
}

/* ========================================
   AUTH SCREEN (LOGOWANIE)
   ======================================== */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.auth-wrapper {
  display: flex;
  width: 90vw;             /* 90% szerokości ekranu */
  max-width: 1650px;       /* ale nie szerszy niż 1650px */
  height: 80vh;            /* 80% wysokości ekranu */
  background: var(--surface);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.auth-card {
  width: 420px;            /* Stała, wygodna szerokość formularza */
  flex-shrink: 0;          /* Nie zwężaj formularza */
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--surface);
  position: relative;
  z-index: 2;
}

.auth-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.8rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.auth-banner {
  flex: 1;                 /* Banner zajmuje resztę miejsca */
  position: relative;
  background: #0f172a;
  overflow: hidden;
}

.auth-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;       /* Wypełnia obszar zachowując proporcje */
  display: block;
  transition: opacity 0.3s ease-in-out;
}

.auth-banner-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3rem;           /* Większy padding, żeby tekst nie uciekał */
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
  color: white;
  pointer-events: none;
}

.auth-banner-overlay h3 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.auth-banner-overlay p {
  font-size: 1.1rem;
  opacity: 0.95;
  max-width: 500px;
  line-height: 1.5;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Form elements */
.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.btn-full {
  width: 100%;
  background: var(--primary);
  color: white;
  font-weight: 600;
  padding: 0.8rem;
  font-size: 1rem;
}

.btn-full:hover {
  background: var(--primary-hover);
}

.btn-full:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.auth-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  #auth-screen {
    padding: 0.8rem;
  }
  
  .auth-wrapper {
    flex-direction: column;
    width: 94% !important;        /* Zajmuje 94% ekranu, zostawiając margines */
    max-width: 440px !important;  /* Ale nie szerszy niż 440px */
    height: auto !important;
    min-height: auto !important;
    border-radius: 16px;
    overflow: hidden;
  }
  
  .auth-card {
    width: 100% !important;
    padding: 1.5rem 1rem !important; /* Mniejszy padding = więcej miejsca na pola */
    box-shadow: none;
  }
  
  .auth-card h2 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
  }
  
  .form-group {
    margin-bottom: 0.9rem;
  }
  
  /* Blokuje auto-zoom na iOS przy focusie, który często "ucięcie" widok */
  input, select, textarea, .btn-full {
    font-size: 16px !important;
  }
  
  .auth-banner {
    display: none !important;
  }
  
  .task-board {
    grid-template-columns: 1fr !important; /* Jedna kolumna na mobile */
    gap: 1rem;
    padding: 1rem 0.5rem 6rem;
  }
  
  .task-column {
    width: 100%; /* Pełna szerokość */
    margin-bottom: 2rem; /* Odstęp między kolumnami */
  }
  
  .task-column h3 {
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
  }
  
  .task-actions {
  flex-direction: row !important;
  justify-content: flex-end !important; /* Przyciski od prawej */
  flex-wrap: nowrap; /* Nie zawijaj */
  gap: 0.3rem;
  width: 100%;
  }
  
  .task-actions .btn-done {
  width: 40% !important;
  flex: 0 0 40% !important;
  min-width: auto;
  }
  
  .task-actions .btn-edit {
  width: 20% !important;
  flex: 0 0 20% !important;
  min-width: auto;
  }
  
  .task-actions .btn-del {
  width: 20% !important;
  flex: 0 0 20% !important;
  min-width: auto;
  }
  
  .btn-sm {
  padding: 0.5rem;
  font-size: 0.75rem;
  }
}

/* ========================================
   HEADER
   ======================================== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.role-badge {
  background: var(--primary-light);
  color: #1e40af;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* ========================================
   TABS
   ======================================== */
.tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1rem 0;
  overflow-x: auto;
}

.tab {
  padding: 0.6rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  font-weight: 600;
}

/* ========================================
   TASK BOARD
   ======================================== */
.task-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  padding: 1rem 1rem 6rem;
  max-width: 1200px;
  margin: 0 auto;
}

.task-column h3 {
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-column h3 span {
  font-size: 0.8rem;
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* ========================================
   TASK CARDS
   ======================================== */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.2s, background 0.2s;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.task-card.done {
  opacity: 0.85;
  background: #f8fafc;
  border-style: dashed;
}

.task-card.overdue {
  background: var(--danger-light);
  border: 2px solid #fca5a5;
  border-left: 6px solid var(--danger);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.1);
}

.task-card.overdue:hover {
  background: #fee2e2;
  transform: translateY(-2px) scale(1.01);
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.task-title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.task-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.meta-item.overdue {
  color: var(--danger);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-recurring {
  background: #fef3c7;
  color: #92400e;
}

.badge-done {
  background: #dcfce7;
  color: #166534;
}

.badge-overdue {
  background: #fecaca;
  color: #7f1d1d;
  animation: pulseOverdue 1.5s infinite alternate;
}

@keyframes pulseOverdue {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.05); opacity: 1; }
}

.task-desc {
  margin-bottom: 0.8rem;
  white-space: pre-wrap;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.task-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-done { background: var(--success); color: white; }
.btn-done:hover { background: var(--success-hover); }
.btn-edit { background: #f59e0b; color: white; }
.btn-edit:hover { background: #d97706; }
.btn-del { background: var(--danger); color: white; }
.btn-del:hover { background: var(--danger-hover); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 1rem;
  font-size: 0.9rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* ========================================
   FAB
   ======================================== */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  transition: transform 0.2s;
  border: none;
}
.fab:hover { transform: scale(1.05); background: var(--primary-hover); }

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 1rem; }
.form-actions { display: flex; gap: 0.8rem; justify-content: flex-end; margin-top: 1rem; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

/* ========================================
   USER BANNERS
   ======================================== */
.user-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
}
.user-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.user-banner:hover { border-color: #cbd5e1; }
.user-banner.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.user-info { display: flex; flex-direction: column; }
.user-info span { font-size: 0.9rem; font-weight: 600; }
.user-info small { font-size: 0.7rem; color: var(--text-secondary); text-transform: capitalize; }
.user-check {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.1rem;
}
.user-banner.selected .user-check { opacity: 1; }

/* ========================================
   USERS TABLE
   ======================================== */
.users-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.users-table th {
  text-align: left;
  padding: 0.8rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.users-table td { padding: 0.8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: #f8fafc; }
.action-btns { display: flex; gap: 0.5rem; }
.link-btn { background: transparent; color: var(--primary); padding: 0.3rem; font-size: 0.9rem; width: auto; display: inline-block; }
.link-btn.danger { color: var(--danger); }
.link-btn:hover { background: var(--bg); border-radius: 4px; }
.loading { opacity: 0.6; pointer-events: none; }

/* ========================================
   ALERTS
   ======================================== */
.alert {
  padding: 15px 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: none;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.alert-error { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); color: white; }
.alert.show { display: block; animation: slideIn 0.3s ease; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Informacja o długim logowaniu */
.alert-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}