:root {
  --teal: #0d4f4f;
  --orange: #ec6608;
  --bg: #f4f7f6;
  --card: #fff;
  --muted: #5a6a68;
  --border: #d8e3e1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #1a2e2c;
}

header {
  background: var(--teal);
  color: #fff;
  padding: 1.25rem 1.5rem;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

header h1 { margin: 0; font-size: 1.25rem; }
header p { margin: 0.25rem 0 0; opacity: 0.85; font-size: 0.9rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  background: #fff;
}

.info-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.info-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  opacity: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.12);
}

.lang-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 0;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  min-width: 2.25rem;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--teal);
}

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

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

main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }

.loading, .error { text-align: center; padding: 2rem; color: var(--muted); }
.error { color: #b42318; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 1rem;
}

.card h2 { margin: 0 0 0.4rem; color: var(--teal); font-size: 1.1rem; }
.stats { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.85rem; color: var(--muted); }
.stats span { background: #eef4f3; padding: 0.25rem 0.5rem; border-radius: 6px; }

.project-summary,
.wohnung-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
}

.project-summary::-webkit-details-marker,
.wohnung-summary::-webkit-details-marker,
.project-summary::marker,
.wohnung-summary::marker {
  display: none;
  content: "";
}

.project-summary {
  padding: 1rem 1.25rem;
  align-items: flex-start;
}

.wohnung-summary {
  padding: 0.75rem 0;
  flex-wrap: wrap;
}

.wohnung-summary h3 {
  flex: 1;
  min-width: 12rem;
}

.wohnung-summary .stats {
  margin-left: auto;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.project-summary > .chevron {
  margin-top: 0.55rem;
}

.project-summary-main {
  flex: 1;
  min-width: 0;
}

.project-summary-main h2 {
  margin: 0 0 0.35rem;
}

.project-export {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-left: auto;
}

.project-export .secondary {
  width: auto;
  min-width: 10.5rem;
  text-align: center;
}

.pdf-zip-hint {
  margin: -0.5rem 0 1rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}

.chevron {
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--teal);
  border-bottom: 2px solid var(--teal);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-top: -2px;
}

details[open] > summary > .chevron {
  transform: rotate(45deg);
  margin-top: 2px;
}

.project-body {
  padding: 0 1.25rem 1rem;
}

.zip-on-summary {
  flex-shrink: 0;
}

.wohnung {
  border-top: 1px solid var(--border);
  margin-top: 0;
  padding-top: 0;
}

.wohnung h3 { margin: 0; font-size: 0.95rem; }

.wohnung-body {
  padding: 0 0 0.75rem 1.2rem;
}

.assignment-block {
  margin-bottom: 0.5rem;
}

.no-uploads-yet,
.uploads.empty {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.15rem 0 0.35rem;
}

.tenant-info {
  background: #f8fbfa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}

.tenant-line {
  padding: 0.15rem 0;
  color: #2a3d3b;
}

.tenant-line strong {
  color: var(--teal);
  margin-right: 0.35rem;
}

.window-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-top: 0.5rem;
  background: #fafcfc;
}

.window-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--teal);
  margin-bottom: 0.25rem;
}

.window-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.photo-section h5 {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.photo-section:first-of-type h5 {
  margin-top: 0;
}

.assignment {
  font-size: 0.85rem;
  padding: 0.35rem 0;
  color: var(--muted);
}

button.toolbar-info {
  background: #fff;
  color: var(--teal);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 0.45rem 0.75rem;
}

button {
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover { opacity: 0.92; }

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

.thumbs img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #eee;
  cursor: zoom-in;
}

.thumbs img:hover {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

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

button.secondary {
  background: #fff;
  color: var(--teal);
  border: 1px solid var(--teal);
}

.uploads {
  margin-top: 8px;
}

.uploads-loader {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0.15rem 0 0.4rem;
}

.uploads-loader-track {
  position: relative;
  display: inline-block;
  overflow: hidden;
  color: var(--orange);
}

.uploads-loader-dots {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 7px;
  line-height: 1;
  letter-spacing: 0.28em;
  color: var(--orange);
  user-select: none;
}

.uploads-loader-slab {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1.7em;
  background: var(--orange);
  animation: uploads-slide 1.15s cubic-bezier(0.45, 0, 0.2, 1) infinite alternate;
}

.uploads-loader-label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

@keyframes uploads-slide {
  0% { left: 0; }
  100% { left: calc(100% - 1.7em); }
}

@media (prefers-reduced-motion: reduce) {
  .uploads-loader-slab {
    animation: none;
    left: 35%;
  }
}

.uploads h4 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.pdf-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pdf-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pdf-item.is-latest button:first-child {
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: min(960px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--teal);
}

.icon-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
}

#pdf-frame {
  width: 100%;
  height: min(70vh, 720px);
  border: none;
  background: #f0f0f0;
}

.pdf-status {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.pdf-status.hidden,
#pdf-frame.hidden {
  display: none;
}

.modal-panel-image {
  background: #121212;
  width: min(1100px, 100%);
}

.modal-panel-image .modal-header {
  border-bottom-color: #2a2a2a;
}

.modal-panel-image .modal-header h3 {
  color: #eee;
}

.modal-panel-image .icon-btn {
  color: #ccc;
}

.image-frame-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  background: #000;
  min-height: 40vh;
  position: relative;
}

#image-frame {
  max-width: calc(100% - 6rem);
  max-height: min(80vh, 900px);
  object-fit: contain;
  flex: 1;
}

.image-nav {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid #444;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.image-nav:hover {
  background: rgba(255, 255, 255, 0.28);
  opacity: 1;
}

.image-nav.hidden {
  visibility: hidden;
  pointer-events: none;
}

.image-counter {
  padding: 0.4rem 1rem 0.85rem;
  text-align: center;
  color: #bbb;
  font-size: 0.82rem;
}

.image-counter.hidden {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .chevron { transition: none; }
}

.modal-actions {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.modal-actions a {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
}

.modal-actions a:hover {
  text-decoration: underline;
}

.modal-panel-info {
  width: min(520px, 100%);
}

.info-modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  max-height: min(70vh, 520px);
  font-size: 0.9rem;
  line-height: 1.5;
  color: #2a3d3b;
}

.info-modal-body p {
  margin: 0 0 0.75rem;
}

.info-limits {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  font-size: 0.85rem;
}

.info-limits th,
.info-limits td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.info-limits th {
  background: #eef4f3;
  color: var(--teal);
  font-weight: 600;
}

.info-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.dl-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(247, 247, 247, 0.94);
  backdrop-filter: blur(6px);
}

.dl-overlay.hidden {
  display: none;
}

body:has(.dl-overlay:not(.hidden)) {
  overflow: hidden;
}

.dl-brick {
  width: 168px;
  height: 110px;
  overflow: visible;
}

.dl-brick polygon,
.dl-brick ellipse {
  fill: none;
  stroke: #9aa3a1;
  stroke-width: 1.35;
  stroke-linejoin: round;
}

.dl-cube {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: dl-construct 2.6s ease-in-out infinite;
}

.dl-cube-1 { animation-delay: 0s; }
.dl-cube-2 { animation-delay: 0.18s; }
.dl-cube-3 { animation-delay: 0.36s; }
.dl-cube-4 { animation-delay: 0.54s; }

@keyframes dl-construct {
  0%, 6% {
    opacity: 0;
    transform: translateY(10px);
  }
  18%, 68% {
    opacity: 1;
    transform: translateY(0);
  }
  86%, 100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.dl-overlay-label {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  background-image: linear-gradient(
    90deg,
    #8b9694 0%,
    #8b9694 38%,
    #eceeee 50%,
    #8b9694 62%,
    #8b9694 100%
  );
  background-size: 220% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: dl-shimmer 2.1s linear infinite;
}

@keyframes dl-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dl-cube {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .dl-overlay-label {
    animation: none;
    background: none;
    color: #8b9694;
    -webkit-text-fill-color: #8b9694;
  }
}
