:root {
  --bg0: #121820;
  --bg1: #1a2332;
  --bg2: #243044;
  --surface: #eef2f6;
  --ink: #142033;
  --ink-soft: #4a5a70;
  --muted: #5a6b80;
  --line: #d0dae6;
  --brand: #d62828;
  --brand-dark: #a81c1c;
  --accent: #0f766e;
  --accent-soft: #d9f3ef;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5b00;
  --ok-bg: #dcf5e7;
  --ok-ink: #14532d;
  --err-bg: #ffe1e1;
  --err-ink: #7f1d1d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(16, 28, 44, 0.12);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Space Grotesk", "DM Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #2a3b55 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #3a1f24 0%, transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, #dfe7f0 40%, var(--surface));
  background-attachment: fixed;
}

@media (display-mode: standalone) {
  body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
}

@media (max-width: 767px) {
  /* iOS auto-zoom elkerülése fókuszáláskor */
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* iPhone notch / Dynamic Island – constant() régebbi iOS-hez */
  padding-top: calc(0.85rem + constant(safe-area-inset-top));
  padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  padding-bottom: 0.85rem;
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  background: rgba(18, 24, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow: visible;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.45rem;
  border-radius: 3px;
  background: var(--brand);
  box-shadow: 0.35rem 0 0 #f4b942, 0.7rem 0 0 #2f9e44;
  vertical-align: 0.05em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #d7e0ea;
  font-size: 0.95rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  overflow: visible;
}

/* Mobil: BrickShelf egy sorban, menü alatta – ne takarja a Dynamic Island */
@media (max-width: 767px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding-top: calc(0.55rem + constant(safe-area-inset-top));
    padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
    padding-bottom: 0.7rem;
  }

  /* Ha a PWA mégsem ad safe-area-t, iPhone 14+ jellegű tartalék */
  @media (display-mode: standalone) {
    .topbar {
      padding-top: max(
        calc(0.55rem + env(safe-area-inset-top, 0px)),
        3.25rem
      );
    }
  }

  .brand {
    display: block;
    line-height: 1.2;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
    row-gap: 0.45rem;
    padding-top: 0.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.nav-menu {
  position: relative;
  display: block;
  flex: 0 0 auto;
  align-self: center;
}

.nav-menu > summary {
  list-style: none;
  cursor: pointer;
  color: #d7e0ea;
  user-select: none;
  line-height: 1.2;
  padding: 0.15rem 0;
}

.nav-menu > summary::-webkit-details-marker,
.nav-menu > summary::marker {
  display: none;
  content: "";
}

.nav-menu > summary::after {
  content: "▾";
  margin-left: 0.3rem;
  font-size: 0.7em;
  opacity: 0.8;
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  left: auto;
  width: max-content;
  min-width: 12.5rem;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: #243044;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 40;
}

.nav-menu-panel li {
  display: block;
  margin: 0;
  padding: 0;
}

.nav-menu-panel a {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: #f0f4f8;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.25;
}

.nav-menu-panel a:hover,
.nav-menu-panel a:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-user {
  color: #9eb0c5;
  font-size: 0.85rem;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-admin {
  background: #ffe8d6;
  color: #9a3412;
}

.admin-user-link {
  grid-template-columns: 1fr !important;
}

.login-page {
  background:
    radial-gradient(900px 420px at 15% -10%, #2a3b55 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #3a1f24 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1));
}

.main-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem 1.75rem;
  animation: rise 0.45s ease-out both;
}

.login-brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--brand);
  margin-bottom: 0.75rem;
}

.login-brand::before {
  content: "";
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.4rem;
  border-radius: 3px;
  background: var(--brand);
  box-shadow: 0.32rem 0 0 #f4b942, 0.64rem 0 0 #2f9e44;
  vertical-align: 0.05em;
}

.login-card h1 {
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.login-card .lede {
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
}

.login-form {
  display: grid;
  gap: 0.85rem;
}

.btn-block {
  width: 100%;
}

.check-field .check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 46px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.95rem;
}

.check-field .check-row input {
  width: auto;
  min-height: auto;
}

.main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 1.25rem 1rem 5rem;
}

.hero-stats,
.form-head {
  color: #f4f7fb;
  margin-bottom: 1.25rem;
  animation: rise 0.45s ease-out both;
}

h1 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: clamp(1.7rem, 5vw, 2.1rem);
  letter-spacing: -0.03em;
}

.lede {
  margin: 0;
  color: #b7c5d6;
  font-size: 0.98rem;
}

.filters,
.set-form,
.empty {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
  animation: rise 0.5s ease-out 0.05s both;
}

@media (min-width: 640px) {
  .filters {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    align-items: end;
  }
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.15rem;
}

.filter-actions .btn {
  flex: 0 0 auto;
  min-width: 7.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
}

.field.grow {
  flex: 1;
}

.field span {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field-hint {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 400 !important;
  font-size: 0.82rem !important;
  color: var(--ink-soft);
}

input[type="file"] {
  padding: 0.55rem 0.4rem;
  background: #fbfcfe;
  cursor: pointer;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  background: #fbfcfe;
  color: var(--ink);
  min-height: 46px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--accent);
  background: #fff;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  text-align: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  min-height: 38px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: var(--bg2);
  color: #fff;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-danger {
  background: transparent;
  border-color: #f1a0a0;
  color: var(--brand);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: wait;
}

.set-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.set-row {
  animation: rise 0.4s ease-out both;
}

.set-row:nth-child(1) { animation-delay: 0.02s; }
.set-row:nth-child(2) { animation-delay: 0.04s; }
.set-row:nth-child(3) { animation-delay: 0.06s; }
.set-row:nth-child(4) { animation-delay: 0.08s; }
.set-row:nth-child(5) { animation-delay: 0.1s; }

.set-link {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.85rem;
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: 0 4px 14px rgba(16, 28, 44, 0.05);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.set-link:hover {
  border-color: #9eb0c5;
  transform: translateY(-1px);
}

.set-thumb-wrap {
  flex-shrink: 0;
}

.set-thumb {
  width: 88px;
  height: 66px;
  object-fit: contain;
  background: #f3f6fa;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}

.set-thumb-empty {
  background:
    linear-gradient(135deg, #e8eef5 25%, transparent 25%) -8px 0 / 16px 16px,
    linear-gradient(225deg, #e8eef5 25%, transparent 25%) -8px 0 / 16px 16px,
    #f3f6fa;
}

.set-body {
  min-width: 0;
}

.image-preview {
  text-align: center;
  margin-bottom: 0.25rem;
}

.image-preview-btn {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  border-radius: 12px;
}

.image-preview-btn:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 3px;
}

.image-preview img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f3f6fa;
  display: block;
  transition: transform 0.15s ease;
}

.image-preview-btn:hover img {
  transform: scale(1.02);
}

.image-preview-hint {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.lightbox {
  border: none;
  padding: 0;
  max-width: min(96vw, 920px);
  max-height: 92vh;
  background: transparent;
  overflow: visible;
}

.lightbox::backdrop {
  background: rgba(12, 18, 28, 0.82);
  backdrop-filter: blur(4px);
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: rise 0.2s ease-out both;
}

.lightbox img {
  max-width: min(96vw, 920px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.lightbox-close-form {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  margin: 0;
  z-index: 2;
}

.lightbox-close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.sync-box {
  margin-top: 1.25rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sync-box h2 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--ink);
}

.sync-panel .sync-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.sync-progress-wrap {
  height: 12px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.sync-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #1aa38f);
  transition: width 0.35s ease;
}

.sync-errors {
  margin-top: 1rem;
}

.sync-errors h2 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
}

.sync-errors ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--err-ink);
  font-size: 0.9rem;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.set-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.set-number {
  font-family: var(--display);
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.02em;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.set-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.set-meta,
.set-stats {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.set-stats {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--line);
  font-weight: 600;
}

.set-form {
  display: grid;
  gap: 0.85rem;
  animation: rise 0.45s ease-out both;
}

.fetch-bar {
  display: grid;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .fetch-bar {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

.grid-2 {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 520px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.hint {
  margin: -0.25rem 0 0;
  min-height: 1.2em;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.hint.is-loading {
  color: var(--accent);
}

.hint.is-ok {
  color: var(--ok-ink);
}

.hint.is-error {
  color: var(--err-ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.danger-zone {
  margin-top: 1.25rem;
  padding-top: 1rem;
}

.flash-wrap {
  width: min(720px, 100%);
  margin: 0.75rem auto 0;
  padding: 0 1rem;
  display: grid;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.92rem;
  animation: rise 0.3s ease-out both;
}

.flash-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.flash-error {
  background: var(--err-bg);
  color: var(--err-ink);
}

.flash-warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.readonly-banner {
  display: inline-block;
  margin: 0 0 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background: #eef3f8;
  color: #4a5d73;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.collector-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.collector-list > li {
  margin: 0;
}

.collector-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.collector-card:hover,
.collector-card:focus-visible {
  border-color: #9eb0c5;
  transform: translateY(-1px);
  color: var(--ink);
}

.collector-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--brand);
}

.collector-meta {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.view-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  margin: 0 0 1rem;
}

.view-grid dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.15rem;
}

.view-grid dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.view-notes {
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.view-notes h2 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.view-notes p {
  margin: 0;
  white-space: pre-wrap;
}

.barcode-panel {
  margin-bottom: 1rem;
}

.barcode-panel h2 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--ink);
}

.barcode-reader {
  width: 100%;
  max-width: 420px;
  margin: 0.75rem auto;
  overflow: hidden;
  border-radius: 12px;
  background: #0f1620;
}

.barcode-reader video {
  border-radius: 12px;
}

.barcode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}
