/* Author-Styles (display:grid/flex) dürfen [hidden] nicht aushebeln */
[hidden] {
  display: none !important;
}

.portal-page {
  min-height: 100vh;
}

.portal-main {
  padding: 6.5rem clamp(1.25rem, 5vw, 3rem) 4rem;
  max-width: 72rem;
  margin: 0 auto;
}

/* Admin: mehr horizontale Breite für Kundenaktionen */
.portal-main--admin {
  max-width: 96rem;
  padding-left: clamp(1rem, 3vw, 2.25rem);
  padding-right: clamp(1rem, 3vw, 2.25rem);
}

.portal-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: clamp(1.35rem, 4vw, 2rem);
}

.portal-panel-wide {
  display: grid;
  gap: 1.25rem;
}

.portal-head {
  max-width: 36rem;
  margin-bottom: 1.5rem;
}

.portal-title {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.portal-lead {
  margin: 0;
  color: var(--ink-muted);
  max-width: 48ch;
}

.portal-form {
  display: grid;
  gap: 0.95rem;
  max-width: 26rem;
}

.portal-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.portal-form input[type="text"],
.portal-form input[type="password"],
.portal-form input[type="file"] {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
}

.portal-footer {
  margin-top: 2rem;
}

.portal-admin-link {
  opacity: 0.55;
  font-size: 0.85rem;
}

.portal-admin-link:hover {
  opacity: 1;
}

.portal-customer-pin {
  display: block;
  margin-top: 0.2rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--amber);
  word-break: break-all;
}

.portal-customer-pin.is-missing {
  font-family: inherit;
  color: #ffb4b4;
}

.portal-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.portal-toolbar-compact {
  margin-bottom: 0.85rem;
}

.portal-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.portal-admin-grid {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .portal-admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .portal-card-customers {
    grid-column: 1 / -1;
  }
}

.portal-card {
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.portal-card h3 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.portal-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.portal-customer-list {
  display: grid;
  gap: 0.55rem;
}

.admin-files-host {
  display: none;
}

.portal-customer-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.portal-customer-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.portal-customer-item.is-active,
.portal-customer-item.is-expanded {
  border-color: rgba(224, 160, 69, 0.55);
}

.portal-customer-expand:empty {
  display: none;
}

.portal-customer-manage {
  width: 100%;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.portal-customer-manage .portal-toolbar-compact {
  margin-bottom: 0.75rem;
}

.portal-customer-manage h3 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.portal-customer-manage .portal-lead {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.portal-customer-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.portal-customer-meta strong {
  display: block;
  font-family: var(--font-display);
}

.portal-customer-meta span {
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.portal-customer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  justify-content: flex-end;
}

.portal-customer-actions button {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  white-space: nowrap;
}

.portal-customer-actions button.is-danger {
  border-color: rgba(255, 120, 120, 0.35);
  color: #ffb4b4;
}

.portal-upload {
  margin-bottom: 1rem;
}

.portal-dropzone {
  position: relative;
  z-index: 1001; /* über .grain (z-index 1000), sonst schluckt das Overlay File-DnD */
  display: grid;
  gap: 0.65rem;
  justify-items: start;
  padding: 1.25rem 1.35rem;
  border: 1.5px dashed var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.18s ease, background 0.18s ease;
}

.portal-dropzone.is-dragover {
  border-color: var(--amber);
  background: rgba(232, 168, 56, 0.08);
}

.portal-dropzone-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.portal-dropzone-hint {
  margin: 0;
  max-width: 52ch;
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.portal-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.portal-upload-pick {
  cursor: pointer;
  margin: 0;
}

.portal-dropzone-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.portal-upload-progress {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  max-width: 36rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(224, 160, 69, 0.35);
  border-radius: 0.7rem;
  background: rgba(232, 168, 56, 0.06);
}

.portal-upload-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.portal-upload-progress-name {
  font-size: 0.88rem;
  color: var(--ink);
  word-break: break-all;
  line-height: 1.35;
}

.portal-upload-progress-count {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.portal-upload-progress-track {
  position: relative;
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.portal-upload-progress-track.is-file {
  height: 0.28rem;
}

.portal-upload-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c4842a, var(--amber));
  transition: width 0.12s ease-out;
}

.portal-upload-progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}

.portal-upload-progress-file-label {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.portal-upload-limit {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  max-width: 52rem;
  padding-top: 0.15rem;
}

.portal-upload-limit-current {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink);
}

.portal-upload-limit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
}

.portal-upload-limit-label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.portal-upload-limit-label select,
.portal-upload-limit-custom {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.35rem 0.5rem;
  min-width: 5.5rem;
}

.portal-upload-limit-custom {
  width: 5rem;
}

.portal-upload-label {
  display: grid;
  gap: 0.35rem;
  flex: 1 1 16rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.portal-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.portal-image-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.portal-media-hit {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #0a0a0a;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
  flex: 0 0 auto;
}

.portal-image-card img,
.portal-image-card .portal-media-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0a0a;
}

.portal-image-card .portal-media-video {
  object-fit: cover;
  pointer-events: none;
}

.portal-media-hit:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.portal-media-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.35));
}

.portal-media-play span {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  padding-left: 0.15rem;
}

.portal-file-card {
  display: grid;
  gap: 0.35rem;
  align-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 1rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
}

.portal-file-card-name {
  font-size: 0.82rem;
  line-height: 1.35;
  word-break: break-word;
  color: var(--ink);
}

.portal-file-card-hint {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.portal-download-status {
  margin: 0;
  padding: 0.4rem 0.65rem 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-muted);
  flex: 1 1 auto;
}

.portal-download-status.is-done {
  color: #9ec89a;
}

.portal-download-status.is-pending {
  color: var(--ink-muted);
}

.portal-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0.55rem 0.6rem;
  margin-top: auto;
  min-width: 0;
}

.portal-image-actions a,
.portal-image-actions button {
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.42rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, filter 0.25s ease;
}

.portal-image-actions a.is-download,
.portal-image-actions button.is-download {
  background: var(--amber);
  border-color: transparent;
  color: #1a1208;
  font-weight: 500;
}

.portal-image-actions a.is-download:hover,
.portal-image-actions button.is-download:hover {
  background: #ebb05a;
  color: #1a1208;
}

.portal-image-actions button.is-danger {
  border-color: rgba(255, 120, 120, 0.35);
  color: #ffb4b4;
  background: rgba(255, 120, 120, 0.06);
}

.portal-image-actions button.is-danger:hover {
  border-color: rgba(255, 120, 120, 0.55);
  background: rgba(255, 120, 120, 0.12);
}

/* Kunden-Lightbox */
.portal-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(5, 6, 5, 0.94);
  backdrop-filter: blur(10px);
}

.portal-lightbox[hidden] {
  display: none !important;
}

.portal-lightbox-stage {
  margin: 0;
  max-height: 92vh;
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.portal-lightbox-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 72vh;
  max-width: min(94vw, 1100px);
  width: 100%;
  min-height: 12rem;
}

.portal-lightbox-media img,
.portal-lightbox-media video {
  display: block;
  max-height: 72vh;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #0a0a0a;
  border-radius: 0.35rem;
}

.portal-lightbox-media video {
  width: min(94vw, 1100px);
  max-height: 72vh;
}

.portal-lightbox-raw {
  display: grid;
  gap: 0.65rem;
  justify-items: center;
  text-align: center;
  padding: 2rem 1.25rem;
  max-width: 28rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.03);
}

.portal-lightbox-raw strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.portal-lightbox-raw p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.portal-lightbox-meta {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  max-width: min(40rem, 90vw);
}

.portal-lightbox-title {
  margin: 0;
  color: var(--ink-muted);
  text-align: center;
  font-size: 0.92rem;
  word-break: break-word;
}

.portal-lightbox-download,
.portal-lightbox-download.btn,
.portal-lightbox-download.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 9.5rem;
  min-height: 2.85rem;
  padding: 0.75rem 1.45rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  background: var(--amber);
  color: #1a1208;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(224, 160, 69, 0.28);
  transition: transform 0.25s var(--ease), background 0.25s ease, filter 0.25s ease, box-shadow 0.25s ease;
}

.portal-lightbox-download:hover,
.portal-lightbox-download.btn-primary:hover {
  background: #ebb05a;
  color: #1a1208;
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(224, 160, 69, 0.4);
}

.portal-lightbox-download:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.portal-lightbox-close,
.portal-lightbox-prev,
.portal-lightbox-next {
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  touch-action: manipulation;
}

.portal-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

@media (max-width: 720px) {
  .portal-lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    padding: 0.75rem;
    padding-bottom: 4.5rem;
  }

  .portal-lightbox-prev,
  .portal-lightbox-next {
    position: absolute;
    bottom: 1rem;
    width: 3.25rem;
    height: 3.25rem;
  }

  .portal-lightbox-prev {
    left: 1rem;
  }

  .portal-lightbox-next {
    right: 1rem;
  }

  .portal-lightbox-media {
    max-width: 100%;
    max-height: 62vh;
  }

  .portal-lightbox-media img,
  .portal-lightbox-media video {
    max-height: 62vh;
  }
}

.portal-error {
  margin: 0;
  color: #ffb4b4;
  font-size: 0.9rem;
}

.portal-success {
  margin: 0.75rem 0 0;
  color: var(--amber);
  font-size: 0.9rem;
}

.portal-lastname-hint {
  display: grid;
  gap: 0.55rem;
  margin: -0.35rem 0 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(255, 196, 120, 0.35);
  border-radius: 0.75rem;
  background: rgba(255, 196, 120, 0.08);
}

.portal-lastname-hint[hidden] {
  display: none;
}

.portal-lastname-hint-text {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.portal-lastname-hint .btn {
  justify-self: start;
}

.portal-empty {
  margin: 0;
  color: var(--ink-muted);
}

.portal-db-tables {
  margin: 0.4rem 0 1rem;
  padding-left: 1.1rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

@media (max-width: 720px) {
  .portal-toolbar {
    flex-direction: column;
  }

  .portal-customer-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .portal-customer-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .portal-customer-actions button {
    width: 100%;
    white-space: normal;
    text-align: left;
  }
}
