.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.navbar .brand {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar .brand .dot { color: var(--accent); }
.navbar .brand .brand-logo {
  height: 19px;
  width: auto;
  display: block;
}
.navbar .brand .brand-sub {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.navbar .nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.navbar .nav-links a {
  padding: 8px 12px;
  color: var(--text-mid);
  border-radius: var(--radius);
  font-size: 13px;
}
.navbar .nav-links a:hover {
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--text);
}
.navbar .nav-links a.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
/* liczba przy „Notatki” = otwarte zadania przypisane do mnie (04.10) */
.navbar .nav-links .nav-n { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--accent); color: #fff; font-family: var(--font-mono); font-size: 11px; line-height: 18px; text-align: center; vertical-align: 1px; }
.navbar .nav-links .nav-n.is-warn { background: #dc2626; } /* „Etapy”: w toku po terminie */
.navbar .user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-mid);
}
.navbar .user-box .role {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  background: var(--bg-soft);
  border-radius: 4px;
}
.navbar .ggstock-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.navbar .ggstock-link:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  text-decoration: none;
}

.content {
  flex: 1;
  padding: 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .meta { color: var(--text-dim); font-size: 13px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 20px; margin-bottom: 16px; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  font-weight: 500;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-soft); }
.table td.mono { font-family: var(--font-mono); font-size: 12px; }
.table td .row-actions a {
  margin-right: 12px;
  font-size: 12px;
}

/* Forms */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.02em;
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="date"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-row .hint { font-size: 12px; color: var(--text-dim); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 24px;
}
.form-grid .full { grid-column: 1 / -1; }

.checkboxes {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mid);
  cursor: pointer;
}
.checkboxes input[type="checkbox"] {
  accent-color: var(--accent);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFF;
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFF; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #FFF; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-mid); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* Flash */
.flash {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid;
}
.flash.success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.flash.error   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--danger); }
.flash.info    { background: var(--info-soft);    border-color: var(--info);    color: var(--info); }

/* Login centered */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 32px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  font-size: 32px;
  margin-bottom: 4px;
}
.login-card h1 .dot { color: var(--accent); }
.login-card .sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.login-card .btn.primary { width: 100%; justify-content: center; }

/* Notification badge + dropdown — globalne (navbar zalady na kazdej stronie) */
.notif-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.notif-badge .badge-dot {
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 4px;
}
.notif-dropdown {
  position: absolute;
  top: 30px;
  right: 0;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 100;
  max-height: 480px;
  display: none;
}
.notif-dropdown.open { display: flex; flex-direction: column; }
.notif-dropdown .nd-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notif-dropdown .nd-head form { margin: 0; }
.notif-dropdown .nd-list {
  max-height: 360px;
  overflow-y: auto;
}
.notif-dropdown .nd-item {
  display: block;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.notif-dropdown .nd-item:hover { background: var(--bg-soft); text-decoration: none; }
.notif-dropdown .nd-item:last-child { border-bottom: none; }
.notif-dropdown .nd-item .nd-title { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.notif-dropdown .nd-item .nd-meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
/* dzwonek (03.10): ikonka SVG, treść skrócona do 2 linii, tabela /notifications */
.nb-bell { display: inline-flex; align-items: center; gap: 4px; position: relative; }
.nb-bell .ico { width: 17px; height: 17px; }
.nb-bell.is-empty { opacity: 0.6; }
.notif-dropdown .nd-item .nd-body { font-size: 12px; color: var(--text-mid); margin-bottom: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-dropdown .nd-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
}
/* Grupy powiadomień w dzwonku (03.10): nagłówek grupy z licznikiem rozwija listę; strona /notifications — notifications.css */
.notif-dropdown { width: 360px; }
.notif-dropdown .nd-group { border-bottom: 1px solid var(--border); }
.notif-dropdown .nd-group:last-child { border-bottom: none; }
.notif-dropdown .nd-grow { display: flex; align-items: center; }
.notif-dropdown .nd-grow form { margin: 0; }
.notif-dropdown .nd-ghead {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 12px;
  background: none; border: 0; cursor: pointer; text-align: left; font: inherit; font-size: 13px; color: var(--text);
}
.notif-dropdown .nd-ghead:hover, .notif-dropdown .nd-gread:hover { background: var(--bg-soft); }
.notif-dropdown .nd-chev { width: 13px; height: 13px; color: var(--text-dim); transition: transform 0.15s; }
.notif-dropdown .nd-group.open .nd-chev { transform: rotate(90deg); }
.notif-dropdown .nd-glabel { flex: 1; min-width: 0; font-weight: 500; line-height: 1.3; }
.notif-dropdown .nd-gcount { font-family: var(--font-mono); font-size: 10px; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }
.notif-dropdown .nd-gread { background: none; border: 0; cursor: pointer; color: var(--text-dim); padding: 10px 12px; display: inline-flex; }
.notif-dropdown .nd-gread:hover { color: var(--accent); }
.notif-dropdown .nd-gitems { display: none; border-top: 1px solid var(--border); }
.notif-dropdown .nd-group.open .nd-gitems { display: block; }
.notif-dropdown .nd-gitems .nd-item { padding-left: 33px; }

/* Galeria zdjęć kolekcji */
/* Masonry (kolumny) — zdjęcia w naturalnych proporcjach, bez przycinania do kwadratu */
.collection-photo-grid {
  column-count: 4;
  column-gap: 10px;
}
@media (max-width: 1100px) { .collection-photo-grid { column-count: 3; } }
@media (max-width: 700px) { .collection-photo-grid { column-count: 2; } }
.collection-photo {
  position: relative;
  break-inside: avoid;
  margin: 0 0 10px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
}
.collection-photo img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.18s ease;
}
.collection-photo:hover img { transform: scale(1.03); }
.collection-photo[draggable="true"] { cursor: grab; }
.collection-photo.dragging { opacity: 0.4; outline: 2px dashed var(--accent); outline-offset: -2px; }

/* Lightbox podglądu */
dialog.lightbox {
  border: none;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
}
dialog.lightbox::backdrop { background: rgba(0,0,0,0.85); }
dialog.lightbox .lb-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
dialog.lightbox .lb-close,
dialog.lightbox .lb-nav {
  position: absolute;
  z-index: 2;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
dialog.lightbox .lb-close:hover,
dialog.lightbox .lb-nav:hover { background: rgba(0,0,0,0.8); }
dialog.lightbox .lb-close { top: 16px; right: 20px; width: 40px; height: 40px; font-size: 24px; }
dialog.lightbox .lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 30px; }
dialog.lightbox .lb-prev { left: 16px; }
dialog.lightbox .lb-next { right: 16px; }
dialog.lightbox .lb-caption {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.45);
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.collection-photo-del {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.collection-photo:hover .collection-photo-del { opacity: 1; }
.collection-photo-del button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.collection-photo-del button:hover { background: var(--danger); }

/* Galeria w okienku (gallery-modal.js): pełna strona galerii w iframe, bez podstrony */
dialog.gm-dialog {
  width: min(1180px, 94vw); height: min(820px, 90vh); max-width: none; max-height: none; padding: 0;
  border: none; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25); background: var(--bg, #fafafa);
}
dialog.gm-dialog:not([open]) { display: none; }
dialog.gm-dialog::backdrop { background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); }
.gm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 10px 22px; border-bottom: 1px solid var(--border); background: var(--bg-card); }
.gm-title { font-family: var(--font-serif); font-size: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-close { width: 32px; height: 32px; border: none; border-radius: 8px; background: transparent; color: var(--text-mid); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.gm-close:hover { background: var(--bg-soft); color: var(--text); }
.gm-close .ico { width: 18px; height: 18px; }
.gm-frame { flex: 1; width: 100%; border: none; background: var(--bg, #fafafa); }
/* strona osadzona w okienku: bez marginesów aplikacji */
body.is-embed .embed-content { padding: 14px 22px 22px; max-width: none; }
body.is-embed .page-header { margin-bottom: 10px; }

/* Podgląd pojedynczego zdjęcia / PDF-a (gallery-modal.js → ggViewer) */
dialog.mv-dialog {
  width: 94vw; height: 92vh; max-width: none; max-height: none; padding: 0; border: none; border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column; background: #111; color: #eee;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
dialog.mv-dialog:not([open]) { display: none; }
dialog.mv-dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog.mv-dialog:focus { outline: none; }
.mv-head { display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 18px; background: #1b1b1b; border-bottom: 1px solid #2a2a2a; }
.mv-count { font-family: var(--font-mono); font-size: 12px; color: #aaa; flex-shrink: 0; }
.mv-cap { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-open { font-size: 12px; color: #ccc; text-decoration: none; flex-shrink: 0; }
.mv-open:hover { color: #fff; text-decoration: underline; }
.mv-close { width: 32px; height: 32px; border: none; border-radius: 8px; background: transparent; color: #ccc; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mv-close:hover { background: #2a2a2a; color: #fff; }
.mv-close .ico { width: 18px; height: 18px; }
.mv-stage { flex: 1; min-height: 0; display: flex; align-items: stretch; position: relative; }
.mv-media { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 12px; }
.mv-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; }
.mv-pdf { width: 100%; height: 100%; border: none; background: #fff; border-radius: 4px; }
.mv-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 44px; height: 64px; border: none; border-radius: 10px;
  background: rgba(255,255,255,0.08); color: #fff; font-size: 34px; line-height: 1; cursor: pointer;
}
.mv-nav:hover { background: rgba(255,255,255,0.18); }
.mv-nav[hidden] { display: none; }
.mv-prev { left: 10px; }
.mv-next { right: 10px; }

/* Strona na całą szerokość okna (fullWidth w res.render) — kalendarz */
.content.content-full { max-width: none; padding: 24px 28px; }
/* link menu z licznikiem w jednej linii — licznik nie łamie się pod nazwą zakładki (Daniel 04.10: „rozpada mi się menu”) */
.navbar .nav-links a { white-space: nowrap; }
.navbar .nav-links { flex-wrap: nowrap; min-width: 0; }
