:root {
  --primary: #d63384;
  --primary-hover: #b8256e;
  --primary-light: #fdf2f8;
  --primary-border: #fbcfe8;
  --accent: #7c3aed;
  --accent-light: #f5f3ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -12px rgba(214, 51, 132, 0.16);
  --radius: 16px;
}

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

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #fdf2f8 0%, #f8fafc 45%, #f5f3ff 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   GÓRNY PASEK NAWIGACJI (TOPBAR)
   ============================================================================ */
.topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(214, 51, 132, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Kroki kreatora */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.step-pill:hover {
  background: #e2e8f0;
}

.step-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
  box-shadow: 0 2px 8px rgba(214, 51, 132, 0.12);
}

.step-pill.completed {
  background: var(--success-light);
  color: #047857;
  border-color: #a7f3d0;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.step-pill.active .step-num {
  background: var(--primary);
  color: #fff;
}

.step-pill.completed .step-num {
  background: var(--success);
  color: #fff;
}

/* Pasek kredytów i konta */
.account-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #fff1f2, #f5f3ff);
  border: 1px solid var(--primary-border);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #831843;
}

.credits-count {
  font-size: 14px;
  font-weight: 900;
  color: var(--primary);
}

/* ============================================================================
   PRZYCISKI
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  color: #fff;
  box-shadow: 0 8px 20px -4px rgba(214, 51, 132, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -4px rgba(214, 51, 132, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 8px 20px -4px rgba(16, 185, 129, 0.35);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -4px rgba(16, 185, 129, 0.45);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 11px;
  border-radius: 9px;
}

.btn-lg {
  padding: 16px 28px;
  font-size: 16px;
  border-radius: 14px;
}

/* ============================================================================
   WIDOKI (VIEWS)
   ============================================================================ */
.view-section {
  display: none;
  flex: 1;
  width: 100%;
}

.view-section.active {
  display: block;
}

.container-narrow {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ============================================================================
   WIDOK 1: LOGOWANIE TOKENEM
   ============================================================================ */
.login-wrapper {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 44px 40px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--primary-border);
  text-align: center;
}

.login-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--text);
}

.login-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 26px;
}

.token-input {
  width: 100%;
  padding: 16px 18px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border: 2px solid var(--border);
  border-radius: 14px;
  outline: none;
  transition: all 0.2s;
  margin-bottom: 16px;
  font-family: inherit;
}

.token-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(214, 51, 132, 0.12);
}

.login-features {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.login-feature-item {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.4;
}

.login-feature-item strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 2px;
}

/* ============================================================================
   WIDOK 2: WGRANIE ZDJĘCIA I USTAWIENIA (KROK 1)
   ============================================================================ */
.section-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-step-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* Strefa wgrywania zdjęcia głównego */
.photo-upload-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: center;
}

.photo-preview-box {
  width: 240px;
  min-height: 240px;
  max-height: 320px;
  border-radius: 20px;
  border: 2px dashed var(--primary-border);
  background: #fdf2f8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  text-align: center;
  padding: 10px;
}

.photo-preview-box img {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  display: block;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.photo-tips {
  background: #f8fafc;
  border-radius: 14px;
  padding: 18px 20px;
  border: 1px solid var(--border);
}

.photo-tips h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
}

.photo-tips ul {
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

/* Siatka zdjęć dla poszczególnych miesięcy */
.month-photos-toggle {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.month-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.month-photo-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
}

.month-photo-card.has-custom {
  border-color: var(--primary);
  background: var(--primary-light);
}

.month-photo-card-title {
  font-weight: 800;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.month-photo-thumb {
  width: 100%;
  height: 90px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: 2px;
}

.month-photo-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Karty wyboru opcji (Sylwetka, Włosy, Okulary) */
.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.option-group {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.option-group label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.option-group p {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.select-input,
.text-input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  outline: none;
}

.select-input:focus,
.text-input:focus {
  border-color: var(--primary);
}

/* Własne święta */
.custom-dates-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.custom-dates-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: #831843;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.date-chip button {
  background: none;
  border: none;
  color: #be185d;
  font-weight: 900;
  cursor: pointer;
  font-size: 13px;
}

/* ============================================================================
   WIDOK 3: POSTĘP GENEROWANIA WSZYSTKICH STRON
   ============================================================================ */
.progress-bar-outer {
  width: 100%;
  height: 18px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0 10px;
}

.progress-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent), #10b981);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.batch-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.batch-card-item {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  transition: all 0.25s;
}

.batch-card-item.generating {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(214, 51, 132, 0.15);
}

.batch-card-item.ready {
  border-color: var(--success);
  background: #f0fdf4;
}

.batch-card-item.failed {
  border-color: var(--danger);
  background: #fef2f2;
}

.batch-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.batch-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================================
   WIDOK 4: PODGLĄD TALII 13 KART, POPRAWKI I POBRANIE PDF A4
   ============================================================================ */
.deck-workspace {
  display: grid;
  grid-template-columns: 270px 1fr 340px;
  gap: 20px;
  padding: 20px 24px 40px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

.deck-sidebar {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 105px);
  overflow-y: auto;
  position: sticky;
  top: 82px;
}

.deck-sidebar h3 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.deck-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.deck-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.deck-item:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.deck-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.deck-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.deck-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.deck-item-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-status-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.status-ready {
  background: #dcfce7;
  color: #15803d;
}

.status-generating {
  background: #fce7f3;
  color: #be185d;
}

.status-empty {
  background: #f1f5f9;
  color: #64748b;
}

.status-failed {
  background: #fee2e2;
  color: #b91c1c;
}

/* Środkowa kolumna: Podgląd arkusza A4 */
.canvas-stage {
  background: #e2e8f0;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 760px;
  position: relative;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 640px;
  margin-bottom: 14px;
  background: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.a4-paper-wrapper {
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  border-radius: 4px;
  overflow: hidden;
  max-width: 640px;
  width: 100%;
  aspect-ratio: 2480 / 3508;
  position: relative;
}

#calendarCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#calendarCanvas:active {
  cursor: grabbing;
}

/* Prawa kolumna: Akcje dla strony oraz pobieranie PDF A4 */
.deck-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 82px;
}

.action-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.action-box h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.action-box p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.pdf-box {
  background: linear-gradient(155deg, #ffffff 0%, #fdf2f8 100%);
  border: 2px solid var(--primary-border);
  box-shadow: var(--shadow-lg);
}

/* ============================================================================
   MODAL NAKŁADKI (EKSPORT PDF / ALERT)
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
}

.toast-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  z-index: 1200;
  display: none;
  max-width: 420px;
}

.toast-banner.show {
  display: block;
}

/* ============================================================================
   WYBÓR JĘZYKA (7 JĘZYKÓW - PILLS & KAFELKI)
   ============================================================================ */
.lang-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lang-bar-login {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

.lang-pill:hover {
  border-color: var(--primary-border);
  color: var(--text);
  background: #fdf2f8;
}

.lang-pill.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(214, 51, 132, 0.16);
}

.lang-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  gap: 10px;
}

.lang-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  font-family: inherit;
}

.lang-tile:hover {
  border-color: var(--primary-border);
  background: #fff;
  transform: translateY(-1px);
}

.lang-tile.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 6px 16px rgba(214, 51, 132, 0.15);
}

.lang-tile-flag {
  font-size: 24px;
  line-height: 1;
}

.lang-tile-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.lang-tile.active .lang-tile-name {
  color: var(--primary);
}

.lang-tile-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Responsywność */
@media (max-width: 1180px) {
  .deck-workspace {
    grid-template-columns: 1fr;
  }
  .deck-sidebar,
  .deck-actions-panel {
    position: static;
    max-height: none;
  }
  .deck-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 768px) {
  .photo-upload-grid,
  .options-grid {
    grid-template-columns: 1fr;
  }
  .photo-preview-box {
    margin: 0 auto;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
}
